Added the spacecraft to level 1, fixed some bugs when lifting arrow blocks.
This commit is contained in:
parent
a627c4f2bb
commit
00bfc53b7b
|
@ -33,11 +33,12 @@ import copy
|
|||
class Block(worldobject.WorldObject):
|
||||
def __init__(self, level, x, y, img_str='block1',
|
||||
movable=False, visible=True,
|
||||
width=1, height=1, blit_area=None):
|
||||
width=1, height=1, blit_area=None,
|
||||
blocking=True, z=0):
|
||||
self.__dict__.update(locals())
|
||||
worldobject.WorldObject.__init__(self, level, x, y,
|
||||
worldobject.WorldObject.__init__(self, level, x, y, z=z,
|
||||
movable=movable, visible=visible,
|
||||
blit_area=blit_area)
|
||||
blit_area=blit_area, blocking=blocking)
|
||||
|
||||
for i in range(width):
|
||||
for j in range(height):
|
||||
|
@ -119,6 +120,7 @@ class ArrowBlock(Block):
|
|||
self.anim = 'arrow_up'
|
||||
if direction == (0, 1):
|
||||
self.anim = 'arrow_down'
|
||||
self.img_str = self.anim
|
||||
|
||||
def activate(self, setting):
|
||||
self.movable = True
|
||||
|
@ -148,7 +150,8 @@ class ArrowBlock(Block):
|
|||
worldobject.WorldObject.update(self, e, t, dt)
|
||||
|
||||
def draw(self, window):
|
||||
self.img = self.level.imgs[self.anim][int(self.frame)]
|
||||
if not self.holder:
|
||||
self.img = self.level.imgs[self.anim][int(self.frame)]
|
||||
Block.draw(self, window)
|
||||
|
||||
class RisingBlock(Block):
|
||||
|
|
|
@ -62,9 +62,28 @@ class Level1(level.Level):
|
|||
self.tiles.append(
|
||||
tile.Tile(self, i*64, j*48, self.imgs['ground1']))
|
||||
|
||||
self.player.set_pos(64 * 15, 48 * 30)
|
||||
start_pos = 7 * 64, 34 * 48
|
||||
|
||||
self.player.set_pos(*start_pos)
|
||||
self.player.set_init_pos()
|
||||
|
||||
self.objects.append(block.Block(self, start_pos[0] - 2 * 64,
|
||||
start_pos[1] + 48,
|
||||
self.imgs['spacecraft'], z=16))
|
||||
self.objects.append(block.InvisBlock(self, start_pos[0] - 2 * 64,
|
||||
start_pos[1]))
|
||||
self.objects.append(block.InvisBlock(self, start_pos[0] - 64,
|
||||
start_pos[1]))
|
||||
self.objects.append(block.InvisBlock(self, start_pos[0] - 64,
|
||||
start_pos[1] + 48))
|
||||
self.objects.append(block.InvisBlock(self, start_pos[0],
|
||||
start_pos[1] + 48))
|
||||
|
||||
self.add_tile(start_pos[0] + 4 * 64, start_pos[1] - 3 * 48,
|
||||
'indoor%d' % random.randint(1, 6), blocking=False)
|
||||
self.add_tile(start_pos[0] + 2 * 64, start_pos[1] - 7 * 48,
|
||||
'indoor%d' % random.randint(1, 6), blocking=False)
|
||||
|
||||
for i in range(self.size[0] / 64):
|
||||
if not i % 3:
|
||||
self.objects.append(block.Block(self, i * 64,
|
||||
|
@ -536,14 +555,14 @@ class Level1(level.Level):
|
|||
class CompletionBlock(block.Block):
|
||||
def __init__(self, level, x, y, task, number):
|
||||
self.__dict__.update(locals())
|
||||
block.Block.__init__(self, level, x, y)
|
||||
block.Block.__init__(self, level, x, y, blocking=False)
|
||||
|
||||
def update(self, e, t, dt):
|
||||
self.img = self.level.imgs['symbol%02d-0016' % (self.task + 12)]
|
||||
self.img = self.level.imgs['symbol%02d-0018' % (self.task + 12)]
|
||||
for t in range(1, 4):
|
||||
if (self.level.task_completions[-t:] == self.level.solution[:t]
|
||||
and t >= self.number):
|
||||
self.img = self.level.imgs['symbol%02d-0018' % (self.task + 12)]
|
||||
self.img = self.level.imgs['symbol%02d-0019' % (self.task + 12)]
|
||||
break
|
||||
|
||||
class Wheel(block.Block):
|
||||
|
|
|
@ -40,12 +40,18 @@ class Loader(object):
|
|||
self.imgs[o] = pygame.image.load(os.path.join(
|
||||
self.directory, 'tiles', '%s.png' % o))
|
||||
|
||||
for o in range(1, 18):
|
||||
for o in range(1, 13):
|
||||
for i in range(16, 19):
|
||||
self.imgs['symbol%02d-%04d' % (o, i)] = (
|
||||
pygame.image.load(os.path.join(
|
||||
self.directory, 'symbols', 'blocks',
|
||||
'block%02d-%04d.png' % (o, i))))
|
||||
for o in range(13, 18):
|
||||
for i in range(16, 20):
|
||||
self.imgs['symbol%02d-%04d' % (o, i)] = (
|
||||
pygame.image.load(os.path.join(
|
||||
self.directory, 'symbols', 'blocks',
|
||||
'block%02d-%04d.png' % (o, i))))
|
||||
|
||||
for o in range(1, 7):
|
||||
self.imgs['indoor%d' % o] = pygame.image.load(os.path.join(
|
||||
|
@ -59,8 +65,9 @@ class Loader(object):
|
|||
self.directory, 'blocks', '%s.png' % o))
|
||||
self.imgs['lasersource_left'] = pygame.transform.flip(
|
||||
self.imgs['lasersource_right'], 1, 0)
|
||||
|
||||
l = ['hole', 'well', 'wall', 'wall_outside', 'intro-screen']
|
||||
|
||||
l = ['hole', 'well', 'wall', 'wall_outside', 'intro-screen',
|
||||
'spacecraft']
|
||||
for o in l:
|
||||
self.imgs[o] = pygame.image.load(os.path.join(
|
||||
self.directory, '%s.png' % o))
|
||||
|
@ -136,12 +143,18 @@ class Loader(object):
|
|||
if anim in ('arrow_left',):
|
||||
img = pygame.transform.flip(img, 1, 0)
|
||||
|
||||
if (anim in ('arrow_left', 'arrow_right',
|
||||
'arrow_up', 'arrow_down')
|
||||
and len(self.imgs[anim]) >= 16):
|
||||
self.imgs[anim + '_lifted'] = img
|
||||
continue
|
||||
|
||||
self.imgs[anim].append(img)
|
||||
|
||||
####### PLAYER #######
|
||||
|
||||
for anim, directory in (
|
||||
[('idle_up', os.path.join('robot_idle', 'up')),
|
||||
(('idle_up', os.path.join('robot_idle', 'up')),
|
||||
('idle_down', os.path.join('robot_idle', 'down')),
|
||||
('idle_right', os.path.join('robot_idle', 'right')),
|
||||
('idle_left', os.path.join('robot_idle', 'right')),
|
||||
|
@ -187,8 +200,7 @@ class Loader(object):
|
|||
'left_up')),
|
||||
('lever_left_down', os.path.join('robot_lever', 'vertical',
|
||||
'right_down'))
|
||||
]
|
||||
):
|
||||
)):
|
||||
|
||||
self.imgs['robot_' + anim] = []
|
||||
|
||||
|
|
Loading…
Reference in New Issue