Changeset 209:189f7f8ef714


Ignore:
Timestamp:
04/06/11 21:41:53 (12 years ago)
Author:
Jeremy Thurgood <firxen@…>
Branch:
default
Phase:
public
Message:

Basic item interaction.

Location:
skaapsteker/sprites
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • skaapsteker/sprites/base.py

    r208 r209  
    7373
    7474
     75    def collided_player(self, player):
     76        print "%s is ignoring player" % self
     77
     78
    7579class Projectile(GameSprite):
    7680    gravitates = False
     
    9296
    9397    def setup(self, name, world):
    94         pass
     98        self.name = name
     99        self.world = world
    95100
    96101
     
    101106
    102107
    103     def collided_player(self):
     108    def collided_player(self, player):
    104109        print "Player touched %s" % self
     110        player.take_item(self)
     111
    105112
    106113
  • skaapsteker/sprites/player.py

    r208 r209  
    148148            print 'Health', self.the_world.fox.health
    149149
     150
    150151    def damage(self, damage):
    151152        self.the_world.fox.health -= damage
     
    224225                            image = pygame.transform.flip(image, True, False)
    225226                        self._image_dict[key].append(image)
     227
     228
     229    def take_item(self, item):
     230        my_item = self.the_world.fox.item
     231        if my_item is not None:
     232            print "I already have", my_item
     233            return
     234        getattr(self.the_world.items, item.name).level = "gone"
     235        self.the_world.fox.item = item.name
     236        item.kill()
     237        print "took", item
Note: See TracChangeset for help on using the changeset viewer.