Changeset 88:bf4adb40ca3c


Ignore:
Timestamp:
Apr 4, 2011, 2:45:11 PM (9 years ago)
Author:
Neil Muller <drnlmuller@…>
Branch:
default
Message:

Rough outline of a player object, completely with statuesque flying fox

Location:
skaapsteker
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • skaapsteker/data.py

    r58 r88  
    3333
    3434
     35def get_files(filepath):
     36    """Return a sorted list of files in the given directory, with the directory stripped"""
     37    return sorted(os.listdir(os.path.join(data_dir, filepath)))
     38
     39
    3540IMAGES = {}
    3641
  • skaapsteker/level.py

    r75 r88  
    5252
    5353class Level(object):
    54     def __init__(self, leveldef):
     54    def __init__(self, leveldef, player):
    5555        self.level_data = json.loads(data.load('levels/' + leveldef + '.json').read())
    5656        self.sprites = LayeredUpdates()
     
    5858        self.build_tiles()
    5959        self.setup_enemies()
     60        self.setup_player(player)
    6061
    6162
     
    8788            self.sprites.add(enemy)
    8889
     90    def setup_player(self, player):
     91        player_data = self.level_data['player']
     92        player.set_facing(player_data.pop('direction'))
     93        player.set_image()
     94        player.set_pos(player_data.pop('pos'))
     95        self.sprites.add(player)
    8996
    9097    # def setup_sprites(self):
  • skaapsteker/levelscene.py

    r50 r88  
    44import level
    55import physics
     6import sprites.player
    67import pygame
    78
    89class LevelScene(engine.Scene):
    910
    10     def __init__(self, leveldef):
    11         self._level = level.Level(leveldef)
     11    def __init__(self, leveldef, player=None):
     12        if not player:
     13            self._player = sprites.player.Player()
     14        else:
     15            self._player = player
     16        self._level = level.Level(leveldef, self._player)
    1217        self._level_surface = self._level.get_surface()
    1318        self._pos = (0, 0)
     
    1924        for sprite in self._level.tiles:
    2025            self._world.add(sprite)
     26
     27        self._world.add(self._player)
    2128
    2229    def draw(self, screen_surface):
     
    3340    def dispatch(self, ev):
    3441        # handle events here!
     42        self._player.dispatch(ev)
    3543        pass
  • skaapsteker/sprites/base.py

    r59 r88  
    2828
    2929class NPC(Sprite):
    30     pass
    31 
    32 
    33 class Player(Sprite):
    3430    pass
    3531
Note: See TracChangeset for help on using the changeset viewer.