Added the robot with animations to the game. Also made the game pause when using the menu.

This commit is contained in:
Sakse Dalum
2012-08-08 13:26:55 +02:00
parent 28a19d5493
commit ea181b40c0
9 changed files with 92 additions and 32 deletions

View File

@@ -34,12 +34,12 @@ import tile
import block
class Level1(level.Level):
def __init__(self, graphics_dir):
self.__dict__.update(locals())
def __init__(self, graphics_dir, paused=False):
level.Level.__init__(self, graphics_dir, paused)
self.player = player.Player(self, 5*64, 5*48)
self.dimensions = 20, 20
self.dimensions = 10, 10
self.tiles = []
self.objects = []
@@ -54,9 +54,9 @@ class Level1(level.Level):
tile.Tile(self, i*64, j*48, self.imgs['ground1']))
self.objects.append(self.player)
for i in range(100):
self.objects.append(block.Block(self, random.randint(0, 20)*64,
random.randint(0, 20)*48,
for i in range(10):
self.objects.append(block.Block(self, random.randint(0, 10)*64,
random.randint(0, 10)*48,
self.imgs['block1'],
movable=True))
@@ -73,13 +73,7 @@ class Level1(level.Level):
self.imgs[block] = pygame.image.load(os.path.join(
self.graphics_dir, 'blocks', '%s.png' % block))
def update(self, e, t, dt):
for obj in self.objects:
obj.update(e, t, dt)
def draw(self, window):
for tile in self.tiles:
tile.draw(window)
for obj in sorted(self.objects, key=lambda obj: (obj.y + obj.z)):
obj.draw(window)
def restart(self):
self.objects.remove(self.player)
self.player = player.Player(self, 5*64, 5*48)
self.objects.append(self.player)