Ejemplo n.º 1
0
    def __init__(self, mower):
        self.over = False
        self.color = (0.78, 0.78, 1.0)
        self.hsv_color = [240/360.0, 60/100.0, 0]

        self.weather = 'cloudy'

        self.sun = Sun()
        self.moon = Moon()
        self.rain = Rain()
        self.lawn = Lawn(mower)
        self.heart_attack = HeartAttack()

        self.clouds = Clouds(self.hsv_color)
        self.garbage_can = GarbageCan()

        self.weather_time = 20
        self.counter = self.weather_time

        events.AddListener(self)
Ejemplo n.º 2
0
class Background:
    def __init__(self, mower):
        self.over = False
        self.color = (0.78, 0.78, 1.0)
        self.hsv_color = [240/360.0, 60/100.0, 0]

        self.weather = 'cloudy'

        self.sun = Sun()
        self.moon = Moon()
        self.rain = Rain()
        self.lawn = Lawn(mower)
        self.heart_attack = HeartAttack()

        self.clouds = Clouds(self.hsv_color)
        self.garbage_can = GarbageCan()

        self.weather_time = 20
        self.counter = self.weather_time

        events.AddListener(self)

    def update(self, tick):
        if self.over:
            return self.update_dead(tick)

        self.heart_attack.update(tick)

        global CURRENT_CLOUD_COVERAGE

        self.counter -= tick

        if self.counter <= 0:
            CURRENT_CLOUD_COVERAGE = random.choice(CLOUD_COVERAGE.keys())
            if 'cloudy' in CURRENT_CLOUD_COVERAGE or \
               'overcast' in CURRENT_CLOUD_COVERAGE:
                self.rain.active = random.choice([True, False])
            else:
                self.rain.active = False

#            print "It's now %s" % CURRENT_CLOUD_COVERAGE
#            if self.rain.active:
#                print "It's raining"
#            else:
#                print "It's not raining"

            self.counter = self.weather_time

        elements = [self.sun, self.moon, self.rain, self.clouds, self.lawn]

        for element in elements:
            if element:
                element.update(tick)

        if self.sun.deg < 180 and self.sun.deg > 150:
            self.hsv_color[2] = (180 - self.sun.deg) / 30
        elif self.sun.deg < 30 and self.sun.deg > 0:
            self.hsv_color[2] = self.sun.deg / 30

        self.color = colorsys.hsv_to_rgb(*self.hsv_color)

    def draw(self):
        elements = [self.sun, self.moon, self.clouds, self.lawn,
                    self.rain, self.garbage_can]

        for element in elements:
            if element:
                element.draw()

        self.heart_attack.draw()

    def update_dead(self, tick):
        return

    def On_NarrativeOver(self):
        self.over = True