Changeset 47:215e2e74c244


Ignore:
Timestamp:
Apr 3, 2011, 7:01:45 PM (9 years ago)
Author:
Jeremy Thurgood <firxen@…>
Branch:
default
Message:

Better dummy monster.

Location:
skaapsteker
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • skaapsteker/level.py

    r42 r47  
    3434    def __init__(self, leveldef):
    3535        self.level_data = json.loads(data.load('levels/' + leveldef + '.json').read())
     36        self.sprites = Group()
    3637        self.build_background()
    3738        self.build_tiles()
    3839        self.setup_enemies()
    39         self.setup_sprites()
    4040
    4141
     
    5757                if tile:
    5858                    self.tiles.add(tile)
     59                    self.sprites.add(tile)
    5960        print "level:", self.tile_size, self.pixel_size
    6061
    6162
    6263    def setup_enemies(self):
    63         self.enemies = []
    64         for enemy in self.level_data['enemies']:
    65             self.enemies.append(enemies.get_enemy(enemy))
     64        self.enemies = Group()
     65        for enemy_def in self.level_data['enemies']:
     66            enemy = enemies.get_enemy(enemy_def)
     67            self.enemies.add(enemy)
     68            self.sprites.add(enemy)
    6669
    67     def setup_sprites(self):
    68         self.sprites = []
    69         for sprite_desc in self.level_data['sprites']:
    70             self.sprites.append(find_sprite(sprite_desc))
    71         print self.sprites
     70
     71    # def setup_sprites(self):
     72    #     self.sprites = []
     73    #     for sprite_desc in self.level_data['sprites']:
     74    #         self.sprites.append(find_sprite(sprite_desc))
     75    #     print self.sprites
     76
    7277
    7378    def get_surface(self):
  • skaapsteker/sprites/base.py

    r35 r47  
    44
    55from skaapsteker.physics import Sprite
     6from skaapsteker import data
    67
    78
     
    1011
    1112class Monster(Sprite):
     13    image_file = None
     14
    1215    def __init__(self, pos, **opts):
    1316        Sprite.__init__(self)
     17        self.image = data.load_image('sprites/' + self.image_file)
    1418        self.starting_tile_pos = pos
     19        self.rect = self.image.get_rect(topleft=(pos[0]*TILE_SIZE[0], pos[1]*TILE_SIZE[1]))
    1520        self.setup(**opts)
    1621
  • skaapsteker/sprites/enemies.py

    r25 r47  
    1010
    1111class Dummy(Monster):
     12    image_file = 'dummy.png'
     13
    1214    def setup(self, direction):
    1315        print "Dummy monster at %r, facing %s" % (self.starting_tile_pos, direction)
Note: See TracChangeset for help on using the changeset viewer.