diff options
author | Daniel Drake <dsd@laptop.org> | 2008-08-31 19:16:46 (GMT) |
---|---|---|
committer | Daniel Drake <dsd@laptop.org> | 2008-08-31 19:19:55 (GMT) |
commit | e96abf6926e8ccae5fbab81edddd2b4e9aec7b34 (patch) | |
tree | 145e129fc4b3748785df9ef627f58d2ddd1ce459 | |
parent | 621ffa66628afe5543ce6dff3d7e676e6d92ede8 (diff) |
detect when level is complete
-rw-r--r-- | bridge.py | 9 | ||||
-rw-r--r-- | physics.py | 6 |
2 files changed, 11 insertions, 4 deletions
@@ -12,6 +12,7 @@ class Bridge: self.first_train = None self.train_off_screen = False self.train_was_created = False + self.level_completed = False def create_world(self): self.world.set_color((100,150,50)) @@ -20,7 +21,7 @@ class Bridge: pygame.draw.rect(self.screen, (100,180,255), rect, 3) self.world.add.rect(rect.center, rect.width / 2, rect.height / 2, dynamic=False) - rect = pygame.Rect((1200,800), (-350, -250)) + rect = pygame.Rect((1600,800), (-750, -250)) rect.normalize() pygame.draw.rect(self.screen, (100,180,255), rect, 3) self.world.add.rect(rect.center, rect.width / 2, rect.height / 2, @@ -57,8 +58,10 @@ class Bridge: pygame.draw.circle(self.screen, (int(force/2),255-int(force/2),0), coord, 4) pos = self.first_train.GetPosition() - if pos.y < 0: - print "TRAIN FELL OFF!" + if pos.x > 14.0: + self.level_completed = True + elif pos.y < 0.0: + print "TRAIN FELL OFF!", pos.x self.train_off_screen = True def create_train(self, worldpoint = (-100,490), train = (100, 50), wheelrad = 20, cars = 3, force = False): @@ -91,7 +91,11 @@ class PhysicsGame: text = self.font.render("Train fell off the screen, try again!", True, (0,0,0)) textpos = text.get_rect(left=700,top=43) self.screen.blit(text,textpos) - + elif self.bridge.level_completed: + text = self.font.render("Level completed, well done!!", True, (0,0,0)) + textpos = text.get_rect(left=700,top=43) + self.screen.blit(text,textpos) + # Flip Display pygame.display.flip() |