diff options
author | Daniel Drake <dsd@laptop.org> | 2008-08-31 18:54:58 (GMT) |
---|---|---|
committer | Daniel Drake <dsd@laptop.org> | 2008-08-31 18:54:58 (GMT) |
commit | 0a3af3cc2b517e940045b780d84b120918495a70 (patch) | |
tree | 354f95b5daa9345b4ca6e3861c257a71d892b715 | |
parent | 67729dc5eba7dfe9f386530e877f5d0f0cfd5e89 (diff) |
make space only create one train
-rw-r--r-- | bridge.py | 6 | ||||
-rw-r--r-- | tools.py | 2 |
2 files changed, 6 insertions, 2 deletions
@@ -11,6 +11,7 @@ class Bridge: self.capacity = 1 self.first_train = None self.train_off_screen = False + self.train_was_created = False def create_world(self): self.world.set_color((100,150,50)) @@ -60,7 +61,10 @@ class Bridge: print "TRAIN FELL OFF!" self.train_off_screen = True - def create_train(self, worldpoint = (-100,490), train = (100, 50), wheelrad = 20, cars = 3): + def create_train(self, worldpoint = (-100,490), train = (100, 50), wheelrad = 20, cars = 3, force = False): + if not force and self.train_was_created: + return + self.train_was_created = True points = [] self.train_off_screen = False for i in range(0,cars): @@ -37,7 +37,7 @@ class Tool(object): self.game.bridge.create_train() self.game.world.run_physics = not self.game.world.run_physics elif event.key == K_t: - self.game.bridge.create_train() + self.game.bridge.create_train(force=True) elif event.key == K_b: self.game.setTool("box") elif event.key == K_c: |