a-robots-conundrum/robotgame/level2.py

51 lines
1.2 KiB
Python
Raw Normal View History

import os
import pygame
import random
import re
import level
import player
import tile
import block
import boulder
import lever
2012-08-09 15:51:59 +02:00
import level_bonus
import fadeout
2012-08-08 20:22:13 +02:00
class Level2(level.Level):
def __init__(self, game, graphics_dir, paused=False):
2012-08-09 15:51:59 +02:00
level.Level.__init__(self, game, graphics_dir, size=(64*5, 48*5),
2012-08-08 20:22:13 +02:00
paused=paused)
2012-08-09 15:51:59 +02:00
self.dimensions = 5, 5
for i in range(self.dimensions[0]):
for j in range(self.dimensions[1]):
self.tiles.append(
tile.Tile(self, i*64, (j + 1)*48, self.imgs['indoor%d' % random.randint(1, 6)]))
2012-08-08 20:22:13 +02:00
self.draw_background()
2012-08-09 15:51:59 +02:00
bonus = level_bonus.Level(self.game, self.graphics_dir)
def f():
self._update = self.update
self.update = lambda *args: None
def g():
self.update = self._update
bonus.enter(self)
fadeout.Fadeout(self.game, g)
2012-08-09 15:51:59 +02:00
self.objects.append(
lever.Lever(
self, 64 * 2, 48 * 3,
[lambda setting: f()],
2012-08-09 15:51:59 +02:00
toggling=False,
anim='lever_updown'))
def restart(self):
for obj in self.objects:
obj.reset_pos()