Changeset 223:527a5d4e3fa3


Ignore:
Timestamp:
Sep 4, 2009, 10:39:19 PM (11 years ago)
Author:
Simon Cross <hodgestar@…>
Branch:
default
Convert:
svn:b4e93282-eac8-4b8b-b765-0f5d36de2b68@224
Message:

Disable tools at night.

Location:
gamelib
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • gamelib/engine.py

    r222 r223  
    106106        """Add some chickens to the farm"""
    107107        sound.stop_background_music()
    108         self.game.gameboard.tv.sun(True)
     108        self.game.gameboard.start_day()
    109109
    110110        sound.play_sound("daybreak.ogg")
     
    148148        """Add some foxes to the farm"""
    149149        sound.stop_background_music()
    150         self.game.gameboard.tv.sun(False)
    151         self.game.gameboard.reset_states()
     150        self.game.gameboard.start_night()
    152151
    153152        sound.play_sound("nightfall.ogg")
  • gamelib/gameboard.py

    r221 r223  
    224224        self.killed_foxes = 0
    225225        self.add_cash(constants.STARTING_CASH)
     226        self.day, self.night = True, False
    226227
    227228        self.fix_buildings()
     
    249250
    250251    def set_selected_tool(self, tool, cursor):
     252        if not self.day:
     253            return
    251254        self.selected_tool = tool
    252255        if self.animal_to_place:
     
    277280        self.sprite_cursor.set_pos(tile_pos)
    278281
     282    def start_night(self):
     283        self.day, self.night = False, True
     284        self.tv.sun(False)
     285        self.reset_states()
     286
     287    def start_day(self):
     288        self.day, self.night = True, False
     289        self.tv.sun(True)
     290        self.reset_states()
     291
    279292    def in_bounds(self, pos):
    280293        """Check if a position is within the game boundaries"""
     
    287300
    288301    def use_tool(self, e):
     302        if not self.day:
     303            return
    289304        if e.button == 3: # Right button
    290305            self.selected_tool = None
Note: See TracChangeset for help on using the changeset viewer.