48 lines
1.2 KiB
Python
48 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
|
|
|
|
|
|
class Level2(level.Level):
|
|
def __init__(self, game, graphics_dir, paused=False):
|
|
level.Level.__init__(self, game, graphics_dir, size=(64*20, 48*20),
|
|
paused=paused)
|
|
|
|
self.dimensions = 20, 20
|
|
|
|
for i in range(self.dimensions[0]):
|
|
for j in range(self.dimensions[1]):
|
|
self.tiles.append(
|
|
tile.Tile(self, i*64, j*48, self.imgs['ground1']))
|
|
|
|
self.draw_background()
|
|
|
|
blocks = [block.Block(self, 64*4, 48, self.imgs['block1'])]
|
|
|
|
self.objects.extend(blocks)
|
|
|
|
def load(self):
|
|
"""Load all resources used in the level."""
|
|
tile_list = ['ground1', 'ground2']
|
|
|
|
for tile in tile_list:
|
|
self.imgs[tile] = pygame.image.load(os.path.join(
|
|
self.graphics_dir, 'tiles', '%s.png' % tile))
|
|
|
|
block_list = ['block1']
|
|
for block in block_list:
|
|
self.imgs[block] = pygame.image.load(os.path.join(
|
|
self.graphics_dir, 'blocks', '%s.png' % block))
|
|
|
|
def restart(self):
|
|
for obj in self.objects:
|
|
obj.reset_pos()
|