Merge branch 'master' of hongabar.org:a-robots-conundrum
This commit is contained in:
commit
e7745a6f60
Binary file not shown.
After Width: | Height: | Size: 210 B |
Binary file not shown.
After Width: | Height: | Size: 203 B |
|
@ -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):
|
||||
|
|
|
@ -66,18 +66,23 @@ class Laser(worldobject.WorldObject):
|
|||
|
||||
self.start_dark = 0
|
||||
|
||||
self.surf = pygame.Surface(self.level.game.window.get_size(),
|
||||
pygame.SRCALPHA)
|
||||
|
||||
def update(self, e, t, dt):
|
||||
self.start_dark = (t % 200) / 100
|
||||
worldobject.WorldObject.update(self, e, t, dt)
|
||||
|
||||
def draw(self, window):
|
||||
self.surf.fill((0, 0, 0, 0))
|
||||
|
||||
colors = [(155, 0, 0), (255, 0, 0)]
|
||||
c = self.start_dark
|
||||
if self.x0d != self.x1d:
|
||||
length = self.x1d - self.x0d
|
||||
for i in range(0, length, 8):
|
||||
x0d = self.x0d + i
|
||||
pygame.draw.line(window, colors[c],
|
||||
pygame.draw.line(self.surf, colors[c],
|
||||
(x0d - self.level.camera_x,
|
||||
self.y0d - self.level.camera_y),
|
||||
(x0d + min(8, length - i) - self.level.camera_x,
|
||||
|
@ -87,10 +92,11 @@ class Laser(worldobject.WorldObject):
|
|||
length = self.y1d - self.y0d
|
||||
for i in range(0, length, 8):
|
||||
y0d = self.y0d + i
|
||||
pygame.draw.line(window, colors[c],
|
||||
pygame.draw.line(self.surf, colors[c],
|
||||
(self.x0d - self.level.camera_x,
|
||||
y0d - self.level.camera_y),
|
||||
(self.x0d - self.level.camera_x,
|
||||
y0d + min(8, length - i) - self.level.camera_y), 2)
|
||||
c ^= 1
|
||||
|
||||
|
||||
window.blit(self.surf, (0, 0))
|
||||
|
|
|
@ -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))
|
||||
|
@ -141,12 +148,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')),
|
||||
|
@ -192,8 +205,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