Added stones to indicate task completions.
This commit is contained in:
parent
40da292001
commit
c06afba6e1
|
@ -37,7 +37,8 @@ import loader
|
|||
class Game(object):
|
||||
"""Create an object to handle the game."""
|
||||
def __init__(self, window, directory, disable_music,
|
||||
running=False, speed=30, initial_goto_level=None):
|
||||
running=False, speed=30, initial_goto_level=None,
|
||||
level_num=0):
|
||||
self.__dict__.update(locals())
|
||||
|
||||
self.objs = []
|
||||
|
@ -85,6 +86,7 @@ class Game(object):
|
|||
|
||||
|
||||
def goto_level(self, level):
|
||||
self.level_num = level
|
||||
graphics_dir = os.path.join(self.directory, "resources", "graphics")
|
||||
|
||||
self.menu = game_menu.GameMenu(self, graphics_dir)
|
||||
|
@ -94,6 +96,9 @@ class Game(object):
|
|||
self.level = level(self, graphics_dir)
|
||||
self.objs.append(self.level)
|
||||
|
||||
def restart_level(self):
|
||||
self.goto_level(self.level_num)
|
||||
|
||||
|
||||
def update(self, t, dt):
|
||||
"""
|
||||
|
|
|
@ -64,7 +64,8 @@ class GameMenu(object):
|
|||
if self.active:
|
||||
if event.key in [pygame.K_SPACE, pygame.K_RETURN]:
|
||||
if self.menu[self.selection] == 'restart_level':
|
||||
self.game.level.restart()
|
||||
#self.game.level.restart()
|
||||
self.game.restart_level()
|
||||
self.toggle_menu()
|
||||
if self.menu[self.selection] == 'quit':
|
||||
self.game.stop()
|
||||
|
|
|
@ -53,7 +53,7 @@ class Level1(level.Level):
|
|||
self.solution = self.solution[:3]
|
||||
print self.solution
|
||||
|
||||
self.task_completions = []
|
||||
self.task_completions = [0, 0, 0]
|
||||
|
||||
self.dimensions = 50, 50
|
||||
|
||||
|
@ -503,6 +503,11 @@ class Level1(level.Level):
|
|||
self.imgs['indoor1'],
|
||||
[self.player]))
|
||||
|
||||
for i in range(3):
|
||||
self.objects.append(
|
||||
CompletionBlock(self, 64 * (door_x - 6 + i), 48 * 4,
|
||||
self.solution[i], i + 1))
|
||||
|
||||
# DRAW THE BACKGROUND
|
||||
|
||||
self.draw_background()
|
||||
|
@ -524,6 +529,19 @@ class Level1(level.Level):
|
|||
for obj in self.objects:
|
||||
obj.reset_pos()
|
||||
|
||||
class CompletionBlock(block.Block):
|
||||
def __init__(self, level, x, y, task, number):
|
||||
self.__dict__.update(locals())
|
||||
block.Block.__init__(self, level, x, y)
|
||||
|
||||
def update(self, e, t, dt):
|
||||
self.img = self.level.imgs['symbol%02d-0016' % (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)]
|
||||
break
|
||||
|
||||
class Wheel(block.Block):
|
||||
def __init__(self, level, x, y, immitate=None):
|
||||
self.__dict__.update(locals())
|
||||
|
|
|
@ -40,6 +40,13 @@ 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 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(1, 7):
|
||||
self.imgs['indoor%d' % o] = pygame.image.load(os.path.join(
|
||||
self.directory, 'tiles', 'indoor', 'ground%02d.png' % o))
|
||||
|
|
|
@ -123,6 +123,11 @@ 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