Implemented the logic to generate a rolling boulder map.
This commit is contained in:
parent
7666891baa
commit
9e286508ca
|
@ -30,9 +30,10 @@ import worldobject
|
|||
import block
|
||||
|
||||
class Boulder(worldobject.WorldObject):
|
||||
def __init__(self, level, x, y, movable=True, rolling=False):
|
||||
def __init__(self, level, x, y, direction=(1, 0),
|
||||
movable=True, rolling=False):
|
||||
self.__dict__.update(locals())
|
||||
worldobject.WorldObject.__init__(self, level, x, y,
|
||||
worldobject.WorldObject.__init__(self, level, x, y, direction=direction,
|
||||
movable=movable, speed=4)
|
||||
|
||||
self.anim = 'boulder_right'
|
||||
|
|
|
@ -36,11 +36,13 @@ import block
|
|||
import boulder
|
||||
import lever
|
||||
|
||||
import logic.rollingstone
|
||||
|
||||
class Level1(level.Level):
|
||||
def __init__(self, game, graphics_dir, paused=False):
|
||||
level.Level.__init__(self, game, graphics_dir, paused)
|
||||
|
||||
self.dimensions = 10, 10
|
||||
self.dimensions = 50, 50
|
||||
|
||||
for i in range(self.dimensions[0]):
|
||||
for j in range(self.dimensions[1]):
|
||||
|
@ -53,23 +55,37 @@ class Level1(level.Level):
|
|||
# self.imgs['block1'],
|
||||
# movable=True))
|
||||
|
||||
b = boulder.Boulder(self, 64, 48)
|
||||
b = boulder.Boulder(self, 64, 0, direction=(0, 1))
|
||||
self.objects.append(b)
|
||||
self.objects.append(lever.Lever(self, 64*5, 48*7, [b.activate]))
|
||||
self.objects.append(lever.Lever(self, 64*2, 0, [b.activate]))
|
||||
|
||||
arrow_blocks = [block.ArrowBlock(self, 64*4, 48, (1, 0)),
|
||||
block.ArrowBlock(self, 64*4, 48*2, (-1, 0)),
|
||||
block.ArrowBlock(self, 64*5, 48*2, (0, 1)),
|
||||
block.ArrowBlock(self, 64*5, 48, (0, -1))]
|
||||
arrow_blocks = [block.ArrowBlock(self, 0, 48, (1, 0)),
|
||||
block.ArrowBlock(self, 0, 48*2, (-1, 0)),
|
||||
block.ArrowBlock(self, 0, 48*3, (0, 1)),
|
||||
block.ArrowBlock(self, 0, 48*4, (0, -1))]
|
||||
|
||||
self.objects.extend(arrow_blocks)
|
||||
self.objects.append(lever.Lever(self,
|
||||
128,
|
||||
48*2,
|
||||
self.objects.append(lever.Lever(self, 64*3, 0,
|
||||
[arrow_block.activate
|
||||
for arrow_block in arrow_blocks],
|
||||
toggling=True))
|
||||
|
||||
playfield_pos = (64*2, 48*2)
|
||||
|
||||
playfield, nsteps = (
|
||||
logic.rollingstone.generate_simple_playfield(10, 10, 7, 50))
|
||||
|
||||
for i in range(10):
|
||||
for j in range(10):
|
||||
if (i, j) in playfield:
|
||||
if playfield[(i, j)] is logic.rollingstone.Blocker:
|
||||
self.objects.append(
|
||||
block.Block(self,
|
||||
playfield_pos[0] + 64 * i,
|
||||
playfield_pos[1] + 48 * j,
|
||||
self.imgs['block1'],
|
||||
movable=True))
|
||||
|
||||
def load(self):
|
||||
"""Load all resources used in the level."""
|
||||
tile_list = ['ground1', 'ground2']
|
||||
|
|
Loading…
Reference in New Issue