Changeset 218:5cb0e0b9cd16


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

Make sprite cursors stay on top by fudging the sprite list. :/

Location:
gamelib
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • gamelib/gameboard.py

    r217 r218  
    264264        else:
    265265            pygame.mouse.set_cursor(*cursors.cursors['arrow'])
    266         if self.sprite_cursor:
    267             self.tv.sprites.remove(self.sprite_cursor)
    268             self.sprite_cursor = None
    269         if sprite_curs:
    270             self.sprite_cursor = sprite_curs
    271             self.tv.sprites.append(self.sprite_cursor)
     266        self.sprite_cursor = sprite_curs
     267        self.tv.sprites.set_cursor(sprite_curs)
    272268
    273269    def reset_states(self):
  • gamelib/tiles.py

    r175 r218  
    4242REVERSE_TILE_MAP = TILE_MAP._reverse_map
    4343
     44class FarmSprites(list):
     45    def __init__(self):
     46        list.__init__(self)
     47        self.removed = []
     48        self._cursor = None
     49
     50    def append(self, sprite):
     51        if self._cursor is not None:
     52            # pop cursor
     53            assert(self._cursor is self.pop())
     54            list.append(self, sprite)
     55            list.append(self, self._cursor)
     56        else:
     57            list.append(self, sprite)
     58        sprite.updated = 1
     59
     60    def remove(self, sprite):
     61        list.remove(self, sprite)
     62        sprite.updated = 1
     63        self.removed.append(sprite)
     64
     65    def set_cursor(self, cursor):
     66        if self._cursor is not None:
     67            self.remove(self._cursor)
     68        self._cursor = cursor
     69        if cursor is not None:
     70            list.append(self, cursor)
     71
    4472
    4573class FarmVid(tilevid.Tilevid):
     
    4977    def __init__(self):
    5078        tilevid.Tilevid.__init__(self)
     79        self.sprites = FarmSprites()
    5180
    5281    def png_folder_load_tiles(self, path):
Note: See TracChangeset for help on using the changeset viewer.