Tasks now in correct order.
This commit is contained in:
parent
fbd699356c
commit
5fe049f585
|
@ -51,7 +51,6 @@ class Level1(level.Level):
|
|||
self.solution = range(1, 6)
|
||||
random.shuffle(self.solution)
|
||||
self.solution = self.solution[:3]
|
||||
print self.solution
|
||||
|
||||
self.task_completions = [0, 0, 0]
|
||||
|
||||
|
@ -81,59 +80,69 @@ class Level1(level.Level):
|
|||
self.objects.append(block.InvisBlock(self, self.dimensions[0] * 64,
|
||||
i * 48))
|
||||
|
||||
### Task 1: Wheels of fortune
|
||||
task1_pos = (64 * 15, 48 * 13)
|
||||
|
||||
ws = []
|
||||
|
||||
for i in range(5):
|
||||
w1 = Wheel(self, task1_pos[0] + 64 * i, task1_pos[1] - 48 * 2)
|
||||
w2 = Wheel(self, task1_pos[0] + 64 * i, task1_pos[1],
|
||||
immitate=w1)
|
||||
self.objects.extend([w1, w2])
|
||||
self.objects.append(lever.Lever(self,
|
||||
task1_pos[0] + 64 * i,
|
||||
task1_pos[1] + 48 * 1,
|
||||
[w2.activate],
|
||||
anim='lever_updown'))
|
||||
ws.append(w2)
|
||||
self.add_tile(task1_pos[0] + 64 * i,
|
||||
task1_pos[1] - 48 * 3,
|
||||
### Task 1: Teleporters
|
||||
|
||||
task5_size = 5, 8 # y, x -- Note, inverted.
|
||||
task5_pos = (64 * 12, 48 * 19)
|
||||
|
||||
task5_nturns = random.randint(2, 4) * 2 - 1
|
||||
|
||||
playfield, nsteps, directions = (
|
||||
logic.rollingstone.generate_simple_unsolved_solvable_extra(
|
||||
task5_size[0], task5_size[1], task5_nturns,
|
||||
task5_size[0]*task5_size[1]))
|
||||
|
||||
for x in range(task5_size[1]):
|
||||
for y in range(task5_size[0]):
|
||||
self.add_tile(task5_pos[0] - 64 * (x - 1),
|
||||
task5_pos[1] - 48 * y,
|
||||
'indoor%d' % random.randint(1, 6), blocking=False)
|
||||
|
||||
|
||||
for i, j in playfield:
|
||||
self.objects.append(
|
||||
trigger.Trigger(self,
|
||||
task5_pos[0] - 64 * (j - 1),
|
||||
task5_pos[1] - 48 * i,
|
||||
[lambda x: self.player.set_pos(
|
||||
task5_pos[0] + 2 * 64,
|
||||
(task5_pos[1]
|
||||
- random.randint(0, task5_size[0] - 1) * 48))],
|
||||
self.imgs['hole'],
|
||||
[self.player],
|
||||
visible=False))
|
||||
|
||||
for i in range(task5_size[1] + 1):
|
||||
self.add_tile(task5_pos[0] - 64 * i,
|
||||
task5_pos[1] + 48,
|
||||
'moat_horizontal')
|
||||
self.add_tile(task5_pos[0] - 64 * i,
|
||||
task5_pos[1] - task5_size[0] * 48,
|
||||
'moat_horizontal')
|
||||
self.add_tile(task5_pos[0] + 64,
|
||||
task5_pos[1] + 48,
|
||||
'moat_end_horizontal_flip')
|
||||
# self.add_tile(task5_pos[0] + 64,
|
||||
# task5_pos[1] - task5_size[0] * 48,
|
||||
# 'moat_end_horizontal_flip')
|
||||
self.add_tile(task5_pos[0] - 64 * (task5_size[1] + 1),
|
||||
task5_pos[1] + 48,
|
||||
'moat_corner_south')
|
||||
self.add_tile(task5_pos[0] - 64 * (task5_size[1] + 1),
|
||||
task5_pos[1] - task5_size[0] * 48,
|
||||
'moat_corner_north')
|
||||
for i in range(task5_size[0]):
|
||||
self.add_tile(task5_pos[0] - 64 * (task5_size[1] + 1),
|
||||
task5_pos[1] - 48 * i,
|
||||
'moat_vertical')
|
||||
|
||||
self.objects.append(
|
||||
lever.Lever(self,
|
||||
task1_pos[0] + 64 * 5,
|
||||
task1_pos[1] + 48 * 2,
|
||||
[lambda *xs: self.complete_task(1)
|
||||
if len(ws) == len([w for w in ws if w.on])
|
||||
else lambda: None]))
|
||||
|
||||
self.add_tile(task1_pos[0] - 64,
|
||||
task1_pos[1] - 48 * 3,
|
||||
'moat_corner_north')
|
||||
self.add_tile(task1_pos[0] + 64 * 5,
|
||||
task1_pos[1] - 48 * 3,
|
||||
'moat_corner_north_flip')
|
||||
for i in range(3):
|
||||
self.add_tile(task1_pos[0] - 64,
|
||||
task1_pos[1] + 48 * (i - 2),
|
||||
'moat_vertical')
|
||||
self.add_tile(task1_pos[0] + 64 * 5,
|
||||
task1_pos[1] + 48 * (i - 2),
|
||||
'moat_vertical')
|
||||
self.add_tile(task1_pos[0] - 64,
|
||||
task1_pos[1] + 48,
|
||||
'moat_corner_south_flip')
|
||||
self.add_tile(task1_pos[0] + 64 * 5,
|
||||
task1_pos[1] + 48,
|
||||
'moat_corner_south')
|
||||
self.add_tile(task1_pos[0] - 64 * 2,
|
||||
task1_pos[1] + 48,
|
||||
'moat_horizontal')
|
||||
self.add_tile(task1_pos[0] + 64 * 6,
|
||||
task1_pos[1] + 48,
|
||||
'moat_end_horizontal_flip')
|
||||
task5_pos[0] - 64 * (task5_size[1]),
|
||||
task5_pos[1] - (task5_size[0] / 2) * 48,
|
||||
[lambda *x: self.complete_task(1)]))
|
||||
|
||||
### Task 2: Rolling stone
|
||||
|
||||
|
@ -272,68 +281,11 @@ class Level1(level.Level):
|
|||
task2_pos[1] + 48 * (task2_size[1] - 1),
|
||||
[self.complete_task, b.fall],
|
||||
self.imgs['hole'], [b],
|
||||
signal=[0, 2]))
|
||||
signal=[0, 2],
|
||||
toggling=True))
|
||||
|
||||
|
||||
### Task 3: Colour blocks
|
||||
|
||||
task3_pos = (64 * 15, 48 * 20)
|
||||
|
||||
# Abstract "boxes", actually colour fields
|
||||
boxes = logic.colourboxes.generate_colour_boxes(1, 3)
|
||||
boxes += boxes
|
||||
boxes += [logic.colourboxes.generate_random_box(1) for _ in range(3)]
|
||||
random.shuffle(boxes)
|
||||
|
||||
pos_colour = {}
|
||||
for box, (x, y) in zip(boxes, itertools.product(range(3), range(3))):
|
||||
# self.tiles.append(tile.Tile(self, x * 64 + task3_pos[0],
|
||||
# y * 48 + task3_pos[1],
|
||||
# self.imgs['ground1']))
|
||||
pos_colour[(x, y)] = box
|
||||
self.add_tile(task3_pos[0] + 64 * x, task3_pos[1] + 48 * (y + 1),
|
||||
'indoor%d' % random.randint(1, 6), blocking=False)
|
||||
|
||||
action_blocks = [block.ActionBlock(self, 64 * i + task3_pos[0],
|
||||
task3_pos[1], movable=True)
|
||||
for i in range(3)]
|
||||
self.objects.extend(action_blocks)
|
||||
|
||||
wells = [block.ColorWell(self, task3_pos[0] + 64,
|
||||
task3_pos[1] + 48 * 5)]
|
||||
self.objects.extend(wells)
|
||||
|
||||
def update_wells(block):
|
||||
cur_boxes = []
|
||||
for block in action_blocks:
|
||||
box = pos_colour.get(((block.x - task3_pos[0]) / 64,
|
||||
(block.y - task3_pos[1] - 48) / 48))
|
||||
if box:
|
||||
cur_boxes.append(box)
|
||||
|
||||
if not cur_boxes:
|
||||
well_colours = [(0, 0, 0)] * len(wells)
|
||||
else:
|
||||
well_colours = logic.colourboxes.get_colours(cur_boxes)
|
||||
for i in range(len(wells)):
|
||||
wells[i].set_colour(*well_colours[i])
|
||||
|
||||
for b in action_blocks:
|
||||
b.action = update_wells
|
||||
|
||||
self.objects.append(
|
||||
lever.Lever(self,
|
||||
task3_pos[0] + 64,
|
||||
task3_pos[1] + 48 * 4,
|
||||
[lambda *x: (self.complete_task(3)
|
||||
if (len([w for w in wells
|
||||
if (w.well_colour
|
||||
== (255, 255, 255))
|
||||
])
|
||||
== len(wells))
|
||||
else lambda: None)]))
|
||||
|
||||
### Task 4: Inverted bits
|
||||
### Task 3: Inverted bits
|
||||
|
||||
task4_pos = (64 * 26, 48 * 18)
|
||||
|
||||
|
@ -389,7 +341,7 @@ class Level1(level.Level):
|
|||
task4_pos[1] - 48 * 3,
|
||||
[self.complete_task, b.fall],
|
||||
self.imgs['hole'], [b],
|
||||
signal=[0, 4]))
|
||||
signal=[0, 3]))
|
||||
|
||||
# Moat
|
||||
self.add_tile(task4_pos[0] - 64 * 2, task4_pos[1] - 48 * 4,
|
||||
|
@ -413,67 +365,117 @@ class Level1(level.Level):
|
|||
'moat_end_horizontal')
|
||||
|
||||
|
||||
### Task 5: Teleporters
|
||||
### Task 4: Colour blocks
|
||||
|
||||
task5_size = 5, 8 # y, x -- Note, inverted.
|
||||
task5_pos = (64 * 12, 48 * 19)
|
||||
task3_pos = (64 * 15, 48 * 20)
|
||||
|
||||
task5_nturns = random.randint(2, 4) * 2 - 1
|
||||
# Abstract "boxes", actually colour fields
|
||||
boxes = logic.colourboxes.generate_colour_boxes(1, 3)
|
||||
boxes += boxes
|
||||
boxes += [logic.colourboxes.generate_random_box(1) for _ in range(3)]
|
||||
random.shuffle(boxes)
|
||||
|
||||
playfield, nsteps, directions = (
|
||||
logic.rollingstone.generate_simple_unsolved_solvable_extra(
|
||||
task5_size[0], task5_size[1], task5_nturns,
|
||||
task5_size[0]*task5_size[1]))
|
||||
pos_colour = {}
|
||||
for box, (x, y) in zip(boxes, itertools.product(range(3), range(3))):
|
||||
# self.tiles.append(tile.Tile(self, x * 64 + task3_pos[0],
|
||||
# y * 48 + task3_pos[1],
|
||||
# self.imgs['ground1']))
|
||||
pos_colour[(x, y)] = box
|
||||
self.add_tile(task3_pos[0] + 64 * x, task3_pos[1] + 48 * (y + 1),
|
||||
'indoor%d' % random.randint(1, 6), blocking=False)
|
||||
|
||||
for x in range(task5_size[1]):
|
||||
for y in range(task5_size[0]):
|
||||
self.add_tile(task5_pos[0] - 64 * (x - 1),
|
||||
task5_pos[1] - 48 * y,
|
||||
'indoor%d' % random.randint(1, 6), blocking=False)
|
||||
action_blocks = [block.ActionBlock(self, 64 * i + task3_pos[0],
|
||||
task3_pos[1], movable=True)
|
||||
for i in range(3)]
|
||||
self.objects.extend(action_blocks)
|
||||
|
||||
wells = [block.ColorWell(self, task3_pos[0] + 64,
|
||||
task3_pos[1] + 48 * 5)]
|
||||
self.objects.extend(wells)
|
||||
|
||||
for i, j in playfield:
|
||||
self.objects.append(
|
||||
trigger.Trigger(self,
|
||||
task5_pos[0] - 64 * (j - 1),
|
||||
task5_pos[1] - 48 * i,
|
||||
[lambda x: self.player.set_pos(
|
||||
task5_pos[0] + 2 * 64,
|
||||
(task5_pos[1]
|
||||
- random.randint(0, task5_size[0] - 1) * 48))],
|
||||
self.imgs['hole'],
|
||||
[self.player],
|
||||
visible=False))
|
||||
def update_wells(block):
|
||||
cur_boxes = []
|
||||
for block in action_blocks:
|
||||
box = pos_colour.get(((block.x - task3_pos[0]) / 64,
|
||||
(block.y - task3_pos[1] - 48) / 48))
|
||||
if box:
|
||||
cur_boxes.append(box)
|
||||
|
||||
for i in range(task5_size[1] + 1):
|
||||
self.add_tile(task5_pos[0] - 64 * i,
|
||||
task5_pos[1] + 48,
|
||||
'moat_horizontal')
|
||||
self.add_tile(task5_pos[0] - 64 * i,
|
||||
task5_pos[1] - task5_size[0] * 48,
|
||||
'moat_horizontal')
|
||||
self.add_tile(task5_pos[0] + 64,
|
||||
task5_pos[1] + 48,
|
||||
'moat_end_horizontal_flip')
|
||||
# self.add_tile(task5_pos[0] + 64,
|
||||
# task5_pos[1] - task5_size[0] * 48,
|
||||
# 'moat_end_horizontal_flip')
|
||||
self.add_tile(task5_pos[0] - 64 * (task5_size[1] + 1),
|
||||
task5_pos[1] + 48,
|
||||
'moat_corner_south')
|
||||
self.add_tile(task5_pos[0] - 64 * (task5_size[1] + 1),
|
||||
task5_pos[1] - task5_size[0] * 48,
|
||||
'moat_corner_north')
|
||||
for i in range(task5_size[0]):
|
||||
self.add_tile(task5_pos[0] - 64 * (task5_size[1] + 1),
|
||||
task5_pos[1] - 48 * i,
|
||||
'moat_vertical')
|
||||
if not cur_boxes:
|
||||
well_colours = [(0, 0, 0)] * len(wells)
|
||||
else:
|
||||
well_colours = logic.colourboxes.get_colours(cur_boxes)
|
||||
for i in range(len(wells)):
|
||||
wells[i].set_colour(*well_colours[i])
|
||||
|
||||
for b in action_blocks:
|
||||
b.action = update_wells
|
||||
|
||||
self.objects.append(
|
||||
lever.Lever(self,
|
||||
task5_pos[0] - 64 * (task5_size[1]),
|
||||
task5_pos[1] - (task5_size[0] / 2) * 48,
|
||||
[lambda *x: self.complete_task(5)]))
|
||||
task3_pos[0] + 64,
|
||||
task3_pos[1] + 48 * 4,
|
||||
[lambda *x: (self.complete_task(4)
|
||||
if (len([w for w in wells
|
||||
if (w.well_colour
|
||||
== (255, 255, 255))
|
||||
])
|
||||
== len(wells))
|
||||
else lambda: None)]))
|
||||
|
||||
### Task 5: Rising columns
|
||||
task1_pos = (64 * 15, 48 * 13)
|
||||
|
||||
ws = []
|
||||
|
||||
for i in range(5):
|
||||
w1 = Wheel(self, task1_pos[0] + 64 * i, task1_pos[1] - 48 * 2)
|
||||
w2 = Wheel(self, task1_pos[0] + 64 * i, task1_pos[1],
|
||||
immitate=w1)
|
||||
self.objects.extend([w1, w2])
|
||||
self.objects.append(lever.Lever(self,
|
||||
task1_pos[0] + 64 * i,
|
||||
task1_pos[1] + 48 * 1,
|
||||
[w2.activate],
|
||||
anim='lever_updown'))
|
||||
ws.append(w2)
|
||||
self.add_tile(task1_pos[0] + 64 * i,
|
||||
task1_pos[1] - 48 * 3,
|
||||
'moat_horizontal')
|
||||
|
||||
self.objects.append(
|
||||
lever.Lever(self,
|
||||
task1_pos[0] + 64 * 5,
|
||||
task1_pos[1] + 48 * 2,
|
||||
[lambda *xs: self.complete_task(5)
|
||||
if len(ws) == len([w for w in ws if w.on])
|
||||
else lambda: None]))
|
||||
|
||||
self.add_tile(task1_pos[0] - 64,
|
||||
task1_pos[1] - 48 * 3,
|
||||
'moat_corner_north')
|
||||
self.add_tile(task1_pos[0] + 64 * 5,
|
||||
task1_pos[1] - 48 * 3,
|
||||
'moat_corner_north_flip')
|
||||
for i in range(3):
|
||||
self.add_tile(task1_pos[0] - 64,
|
||||
task1_pos[1] + 48 * (i - 2),
|
||||
'moat_vertical')
|
||||
self.add_tile(task1_pos[0] + 64 * 5,
|
||||
task1_pos[1] + 48 * (i - 2),
|
||||
'moat_vertical')
|
||||
self.add_tile(task1_pos[0] - 64,
|
||||
task1_pos[1] + 48,
|
||||
'moat_corner_south_flip')
|
||||
self.add_tile(task1_pos[0] + 64 * 5,
|
||||
task1_pos[1] + 48,
|
||||
'moat_corner_south')
|
||||
self.add_tile(task1_pos[0] - 64 * 2,
|
||||
task1_pos[1] + 48,
|
||||
'moat_horizontal')
|
||||
self.add_tile(task1_pos[0] + 64 * 6,
|
||||
task1_pos[1] + 48,
|
||||
'moat_end_horizontal_flip')
|
||||
|
||||
### Final: The door
|
||||
|
||||
|
@ -523,7 +525,6 @@ class Level1(level.Level):
|
|||
self.task_completions.append(task)
|
||||
if len(self.task_completions) > 3:
|
||||
self.task_completions = self.task_completions[-3:]
|
||||
print(self.task_completions)
|
||||
|
||||
def restart(self):
|
||||
for obj in self.objects:
|
||||
|
|
|
@ -123,11 +123,6 @@ class Player(worldobject.WorldObject):
|
|||
if event.key == pygame.K_SPACE:
|
||||
self.touch(*self.direction)
|
||||
|
||||
for i in range(1, 6):
|
||||
if event.key == getattr(pygame, 'K_%d' % i):
|
||||
self.level.complete_task(i)
|
||||
|
||||
|
||||
else:
|
||||
self.working = not (self.frame == len(
|
||||
self.imgs[self.anim_root + '_' + self.anim]) - 1)
|
||||
|
|
Loading…
Reference in New Issue