Changeset 30:2eec29085060


Ignore:
Timestamp:
Aug 30, 2009, 6:51:28 PM (11 years ago)
Author:
Simon Cross <hodgestar@…>
Branch:
default
Convert:
svn:b4e93282-eac8-4b8b-b765-0f5d36de2b68@31
Message:

Color night and day.

Location:
gamelib
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • gamelib/engine.py

    r29 r30  
    4444    def init(self):
    4545        """Add some chickens to the farm"""
     46        self.game.gameboard.tv.sun(True)
     47
    4648        # disable timer
    4749        pygame.time.set_timer(MOVE_FOX_ID, 0)
     
    111113    def init(self):
    112114        """Add some foxes to the farm"""
     115        self.game.gameboard.tv.sun(False)
     116
    113117        # Add a timer to the event queue
    114118        self.cycle_count = 0
  • gamelib/tiles.py

    r24 r30  
    33from pgu import tilevid, vid
    44import pygame
     5from pygame.locals import BLEND_RGBA_MULT
    56import os
    67
     
    3435                    self.tiles[n] = FarmTile(img)
    3536
     37    def sun(self, sun_on):
     38        """Make it night."""
     39        for tile in self.tiles:
     40            if hasattr(tile, "sun"):
     41                tile.sun(sun_on)
     42        for sprite in self.sprites:
     43            if hasattr(sprite, "sun"):
     44                sprite.sun(sun_on)
     45
    3646class FarmTile(vid.Tile):
    37     pass
     47
     48    NIGHT_COLOUR = (100.0, 100.0, 200.0, 255.0)
     49
     50    def __init__(self, image):
     51        self.day_image = image
     52        self.night_image = image.copy()
     53        self.night_image.fill(self.NIGHT_COLOUR, None, BLEND_RGBA_MULT)
     54        self.image = self.day_image
     55
     56    def sun(self, sun_on):
     57        if sun_on:
     58            self.image = self.day_image
     59        else:
     60            self.image = self.night_image
Note: See TracChangeset for help on using the changeset viewer.