a-robots-conundrum/robotgame/level2.py

51 lines
1.2 KiB
Python

import os
import pygame
import random
import re
import level
import player
import tile
import block
import boulder
import lever
import level_bonus
import fadeout
class Level2(level.Level):
def __init__(self, game, graphics_dir, paused=False):
level.Level.__init__(self, game, graphics_dir, size=(64*5, 48*5),
paused=paused)
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)]))
self.draw_background()
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)
self.objects.append(
lever.Lever(
self, 64 * 2, 48 * 3,
[lambda setting: f()],
toggling=False,
anim='lever_updown'))
def restart(self):
for obj in self.objects:
obj.reset_pos()