From 6631a25df226bea8e633b37ed4732d93c6dccfe9 Mon Sep 17 00:00:00 2001 From: Daniel Drake Date: Sun, 31 Aug 2008 19:38:30 +0000 Subject: add restart functionality --- diff --git a/bridge.py b/bridge.py index 6b0cf28..ead0878 100644 --- a/bridge.py +++ b/bridge.py @@ -15,6 +15,12 @@ class Bridge: self.level_completed = False self.sounds = {"wooo":loadSound("sounds/wooo.wav"), "death":loadSound("sounds/death.wav"), "startup":loadSound("sounds/startup.wav")} + def restart(self): + self.world.run_physics = False + self.train_off_screen = False + self.level_completed = False + self.train_was_created = False + def create_world(self): self.world.set_color((100,150,50)) rect = pygame.Rect((-400,800), (750, -250)) diff --git a/tools.py b/tools.py index 60676fe..086aa80 100644 --- a/tools.py +++ b/tools.py @@ -36,6 +36,8 @@ class Tool(object): #space pauses self.game.bridge.create_train() self.game.world.run_physics = not self.game.world.run_physics + elif event.key == K_r: + self.game.bridge.restart() elif event.key == K_t: self.game.bridge.create_train(force=True) elif event.key == K_b: -- cgit v0.9.1