Added trigger pads/holes and implemented them into level1.

This commit is contained in:
Sakse Dalum
2012-08-09 16:00:27 +02:00
parent a63a4034c5
commit 1d838ef5d1
2 changed files with 107 additions and 18 deletions

View File

@@ -35,6 +35,7 @@ import tile
import block
import boulder
import lever
import trigger
import logic.rollingstone
@@ -44,6 +45,8 @@ class Level1(level.Level):
48 * 100),
paused=paused)
self.task_completions = []
self.dimensions = 50, 50
for i in range(self.dimensions[0]):
@@ -179,6 +182,13 @@ class Level1(level.Level):
task2_pos[1] + 48 * (task2_size[1]),
'moat_end_horizontal_flip')
self.objects.append(
trigger.Trigger(self, task2_pos[0] + 64 * (task2_size[0]),
task2_pos[1] + 48 * (task2_size[1] - 1),
[self.complete_task],
self.imgs['hole'], [b],
signal=[0, 2]))
### Task 4: Inverted bits
task4_pos = (64 * 13, 48 * 13)
@@ -231,6 +241,12 @@ class Level1(level.Level):
risingblocks[i].set_init_pos()
risingblocks[n].set_init_pos()
self.objects.append(trigger.Trigger(self, task4_pos[0] + 64 * 8,
task4_pos[1] - 48 * 3,
[self.complete_task],
self.imgs['hole'], [b],
signal=[0, 4]))
# Moat
self.add_moat(task4_pos[0] - 64 * 2, task4_pos[1] - 48 * 4,
'moat_corner_north')
@@ -260,27 +276,31 @@ class Level1(level.Level):
def load(self):
"""Load all resources used in the level."""
tile_list = ['ground1', 'ground2']
l = ['ground1', 'ground2']
for o in l:
self.imgs[o] = pygame.image.load(os.path.join(
self.graphics_dir, 'tiles', '%s.png' % o))
for tile in tile_list:
self.imgs[tile] = pygame.image.load(os.path.join(
self.graphics_dir, 'tiles', '%s.png' % tile))
l = ['block1']
for o in l:
self.imgs[o] = pygame.image.load(os.path.join(
self.graphics_dir, 'blocks', '%s.png' % o))
block_list = ['block1']
for block in block_list:
self.imgs[block] = pygame.image.load(os.path.join(
self.graphics_dir, 'blocks', '%s.png' % block))
l = ['hole']
for o in l:
self.imgs[o] = pygame.image.load(os.path.join(
self.graphics_dir, '%s.png' % o))
moat_list = ['moat_corner_north',
'moat_corner_south',
'moat_corner_north_flip',
'moat_corner_south_flip',
'moat_end_horizontal',
'moat_horizontal',
'moat_vertical']
for moat in moat_list:
self.imgs[moat] = pygame.image.load(os.path.join(
self.graphics_dir, 'moat', '%s.png' % moat))
l = ['moat_corner_north',
'moat_corner_south',
'moat_corner_north_flip',
'moat_corner_south_flip',
'moat_end_horizontal',
'moat_horizontal',
'moat_vertical']
for o in l:
self.imgs[o] = pygame.image.load(os.path.join(
self.graphics_dir, 'moat', '%s.png' % o))
# Special treatment
self.imgs['moat_end_horizontal_flip'] = pygame.transform.flip(
@@ -322,6 +342,14 @@ class Level1(level.Level):
self.imgs[anim].append(img)
def complete_task(self, task):
if task == 0:
return
self.task_completions.append(task)
if len(self.task_completions) > 3:
self.task_completions.remove(self.task_completions[0])
print(self.task_completions)
def restart(self):
for obj in self.objects:
obj.reset_pos()