changeset 203:653da96db572

Fixed dangling cursor sprite and did some TODO list maintenance.
author Jeremy Thurgood <firxen@gmail.com>
date Fri, 04 Sep 2009 20:25:32 +0000
parents 3074784c93f4
children 636c3fafa32d
files TODO gamelib/engine.py gamelib/gameboard.py
diffstat 3 files changed, 17 insertions(+), 15 deletions(-) [+]
line wrap: on
line diff
--- a/TODO	Fri Sep 04 20:23:30 2009 +0000
+++ b/TODO	Fri Sep 04 20:25:32 2009 +0000
@@ -1,5 +1,9 @@
 == TODO ==
 
+* Fix cursor sprite layering
+
+* Add invalid cursor sprite
+
 * <Hodgestar> A BuildingFullError can be raised when attempting to hatch eggs in buildings.
 
 * <confluence> Muzzle flashes!
@@ -8,8 +12,6 @@
 
 * Add the demolition fox
 
-* Finish egg selling 
-
 * <jerith> Our menu isn't friendly and buildings don't show their contents.
   * <Hodgestar> And we need to add a numerical overlay to show how many chickens are in a building.
 
@@ -46,7 +48,3 @@
 
 * <tzhau> simchicken! so are there gonna to be chicken processing plants? escaping chickens?
   * <Hodgestar> tzhau: We could add some sort of self-managing henhouse that sells chickens automatically to make space for hatching eggs.
-
-* <Nitwit> Hodgestar: I see the ninja fox screenshot shows we have a chicken counting bug somewhere
-  * <Hodgestar> Nitwit: Is the chicken perhaps inside? Or is the number too low?
-  * <Nitwit> Hodgestar: the number's too low - there are 5 chickens visible, but a count of only 4
--- a/gamelib/engine.py	Fri Sep 04 20:23:30 2009 +0000
+++ b/gamelib/engine.py	Fri Sep 04 20:25:32 2009 +0000
@@ -120,7 +120,7 @@
         if events_equal(e, START_NIGHT):
             return NightState(self.game)
         elif e.type is KEYDOWN and e.key == K_ESCAPE:
-            self.game.gameboard.reset_cursor()
+            self.game.gameboard.set_cursor()
             return GameOver(self.game)
         elif e.type is ANIM_ID:
             self.game.gameboard.run_animations()
@@ -148,7 +148,7 @@
         """Add some foxes to the farm"""
         sound.stop_background_music()
         self.game.gameboard.tv.sun(False)
-        self.game.gameboard.reset_cursor()
+        self.game.gameboard.set_cursor()
 
         sound.play_sound("nightfall.ogg")
         # Add a timer to the event queue
@@ -168,7 +168,7 @@
         elif e.type is KEYDOWN and e.key == K_d:
             return pygame.event.post(START_DAY)
         elif e.type is KEYDOWN and e.key == K_ESCAPE:
-            self.game.gameboard.reset_cursor()
+            self.game.gameboard.set_cursor()
             return GameOver(self.game)
         elif e.type is ANIM_ID:
             self.game.gameboard.run_animations()
--- a/gamelib/gameboard.py	Fri Sep 04 20:23:30 2009 +0000
+++ b/gamelib/gameboard.py	Fri Sep 04 20:25:32 2009 +0000
@@ -249,6 +249,12 @@
     def set_selected_tool(self, tool, cursor):
         self.selected_tool = tool
         self.select_animal_to_place(None)
+        sprite_curs = None
+        if buildings.is_building(tool):
+            sprite_curs = sprite_cursor.SpriteCursor(tool.IMAGE, self.tv)
+        self.set_cursor(cursor, sprite_curs)
+
+    def set_cursor(self, cursor=None, sprite_curs=None):
         if cursor:
             pygame.mouse.set_cursor(*cursor)
         else:
@@ -256,12 +262,10 @@
         if self.sprite_cursor:
             self.tv.sprites.remove(self.sprite_cursor)
             self.sprite_cursor = None
-        if buildings.is_building(tool):
-            self.sprite_cursor = sprite_cursor.SpriteCursor(tool.IMAGE, self.tv)
+        if sprite_curs:
+            self.sprite_cursor = sprite_curs
             self.tv.sprites.append(self.sprite_cursor)
-
-    def reset_cursor(self):
-        pygame.mouse.set_cursor(*cursors.cursors['arrow'])
+            
 
     def update_sprite_cursor(self, e):
         tile_pos = self.tv.screen_to_tile(e.pos)
@@ -279,7 +283,7 @@
     def use_tool(self, e):
         if e.button == 3: # Right button
             self.selected_tool = None
-            self.reset_cursor()
+            self.set_cursor()
         elif e.button != 1: # Left button
             return
         if self.selected_tool == constants.TOOL_SELL_CHICKEN: