Added tiles.
This commit is contained in:
@@ -24,15 +24,43 @@
|
||||
The first level.
|
||||
"""
|
||||
|
||||
import os
|
||||
import pygame
|
||||
|
||||
import level
|
||||
import player
|
||||
import tile
|
||||
|
||||
class Level1(level.Level):
|
||||
def __init__(self):
|
||||
def __init__(self, graphics_dir):
|
||||
self.__dict__.update(locals())
|
||||
|
||||
self.player = player.Player(200, 200)
|
||||
|
||||
self.tiles = []
|
||||
self.imgs = {}
|
||||
|
||||
self.load()
|
||||
|
||||
for i in range(0, 10):
|
||||
for j in range(0, 10):
|
||||
self.tiles.append(
|
||||
tile.Tile(i*64, j*48,
|
||||
self.imgs['ground%d' % (((i + j) % 2) + 1)]))
|
||||
|
||||
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))
|
||||
|
||||
def update(self, e, t, dt):
|
||||
self.player.update(e, t, dt)
|
||||
|
||||
def draw(self, window):
|
||||
for tile in self.tiles:
|
||||
tile.draw(window)
|
||||
|
||||
self.player.draw(window)
|
||||
|
||||
Reference in New Issue
Block a user