diff gamelib/buildings.py @ 170:92d11e0544bc

Switch building to selected image when building is selected.
author Simon Cross <hodgestar@gmail.com>
date Thu, 03 Sep 2009 22:59:30 +0000
parents a9b800b4175e
children b400991ccce1
line wrap: on
line diff
--- a/gamelib/buildings.py	Thu Sep 03 22:44:20 2009 +0000
+++ b/gamelib/buildings.py	Thu Sep 03 22:59:30 2009 +0000
@@ -56,11 +56,13 @@
         """Initial image, tile vid position, size and tile number for building."""
         self.day_image = imagecache.load_image(self.IMAGE)
         self.night_image = imagecache.load_image(self.IMAGE, ('night',))
+        self.selected_image = imagecache.load_image(self.SELECTED_IMAGE)
         self.pos = pos
         self.size = self.SIZE
         self.tile_no = self.TILE_NO
         self._buy_price = self.BUY_PRICE
         self._sell_price = self.SELL_PRICE
+        self._sun_on = True
 
         self._floors = []
         for f in range(self.FLOORS):
@@ -131,7 +133,14 @@
     def sell_price(self):
         return self._sell_price
 
+    def selected(self, selected):
+        if selected:
+            self.setimage(self.selected_image)
+        else:
+            self.sun(self._sun_on)
+
     def sun(self, sun_on):
+        self._sun_on = sun_on
         if sun_on:
             self.setimage(self.day_image)
         else:
@@ -172,6 +181,7 @@
     SELL_PRICE = 90
     SIZE = (3, 2)
     IMAGE = 'sprites/henhouse.png'
+    SELECTED_IMAGE = 'sprites/select_henhouse.png'
     NAME = 'Hen House'
     FLOORS = 1
 
@@ -182,6 +192,7 @@
     SELL_PRICE = 150
     SIZE = (2, 3)
     IMAGE = 'sprites/hendominium.png'
+    SELECTED_IMAGE = 'sprites/select_hendominium.png'
     NAME = 'Hendominium'
     FLOORS = 2
 
@@ -193,6 +204,7 @@
     SELL_PRICE = 150
     SIZE = (2, 2)
     IMAGE = 'sprites/watchtower.png'
+    SELECTED_IMAGE = 'sprites/select_watchtower.png'
     NAME = 'Watch Tower'
     FLOORS = 1