Changeset 206:e2acf4663065


Ignore:
Timestamp:
04/06/11 21:19:08 (12 years ago)
Author:
Neil Muller <drnlmuller@…>
Branch:
default
Phase:
public
Message:

Move fox properties to the world

Files:
4 edited

Legend:

Unmodified
Added
Removed
  • data/game.json

    r194 r206  
    11{
    22    "fox": {
    3         "item": null
     3        "item": null,
     4        "tails" : [],
     5        "health" : 80
    46    },
    57    "missions": {
  • skaapsteker/levelscene.py

    r189 r206  
    1717        super(LevelScene, self).__init__(game_state)
    1818
    19         self._player = sprites.player.Player()
     19        self._player = sprites.player.Player(game_state.world)
    2020        self._level = level.Level(leveldef, self._player)
    2121
  • skaapsteker/sprites/base.py

    r203 r206  
    4545        self.floor_rect = Rect(self.collide_rect.topleft, (self.collide_rect.width, 2))
    4646        self._layer = Layers.PLAYER
    47         self.health = 1
     47        self.health = 10
    4848        self.setup(**opts)
    4949
  • skaapsteker/sprites/player.py

    r204 r206  
    22
    33import pygame.transform
    4 import os
    54import time
    65
     
    1716    wants_updates = True
    1817
    19     def __init__(self):
     18    def __init__(self, the_world):
    2019        Sprite.__init__(self)
    2120        self.image = None
     
    3130        self._load_images()
    3231        # We muck with these in load for convience, so ensure they're right
    33         self.tails = 0
     32        self.the_world = the_world
     33        self.health = the_world.fox.health
    3434        self.set_facing('left')
    3535        self.set_image()
     
    3838        self._last_collide = []
    3939        self._layer = Layers.PLAYER
    40         self.health = 4
    4140
    4241    def set_image(self):
    43         key = self._make_key()
     42        key = self._make_key(len(self.the_world.fox.tails))
    4443        images = self._image_dict[key]
    4544        if self._animation_frame >= len(images):
     
    175174
    176175    def action_fire1(self):
    177         if self.tails < 2:
     176        # FIXME: Use the correct tail properties for this
     177        if len(self.the_world.fox.tails) < 2:
    178178            # Only have a bite attack
    179179            print 'attacking'
     
    193193        return 'standing'
    194194
    195     def _make_key(self, action=None):
     195    def _make_key(self, tails, action=None):
    196196        if action is None:
    197197            action = self._get_action()
    198         tails = self.tails
    199         if self.tails >= 4:
     198        if tails >= 4:
    200199            tails = 4
    201         elif self.tails >= 2:
     200        elif tails >= 2:
    202201            tails = 2
    203202        return '%s %s %d' % (action, self.facing, tails)
     
    206205        for action in ['standing', 'running', 'jumping', 'attacking']:
    207206            for tails in [0, 1, 2, 4]:
    208                 self.tails = tails
    209                 directory = os.path.join('sprites',
    210                         'kitsune_%s' % action,
    211                         'kitsune_%s_%dtail' % (action, tails))
     207                directory = 'sprites/kitsune_%s/kitsune_%s_%dtail' % (action, action, tails)
    212208                for facing in ['left', 'right']:
    213209                    self.facing = facing
    214                     key = self._make_key(action)
     210                    key = self._make_key(tails, action)
    215211                    self._image_dict[key] = []
    216212                    for image_file in get_files(directory):
     
    218214                            # Skip extra junk for now
    219215                            continue
    220                         image = load_image(os.path.join(directory, image_file))
     216                        image = load_image('%s/%s' % (directory, image_file))
    221217                        if facing == 'right':
    222218                            image = pygame.transform.flip(image, True, False)
Note: See TracChangeset for help on using the changeset viewer.