- commit
- 3a3c6655970c9f2f1cd51deecf895e105551dca1
- parent
- dd2c11768f94a09f078c5456e8a648dce1cd5eb5
- Author
- Tobias Bengfort <tobias.bengfort@posteo.de>
- Date
- 2021-05-09 08:27
do not respawn on abyss
Diffstat
| M | tighogg.py | 24 | ++++++++++++++---------- |
1 files changed, 14 insertions, 10 deletions
diff --git a/tighogg.py b/tighogg.py
@@ -62,6 +62,7 @@ class Player: 62 62 self.cycle_duration = 3 63 63 self.cycle_frame = 0 64 64 self.cooldown = -1 -1 65 self.alive = True 65 66 66 67 @property 67 68 def floor(self): @@ -92,6 +93,9 @@ class Player: 92 93 self.cycle_frame = (self.cycle_frame + 1) % (self.cycle_duration * 4) 93 94 94 95 def die(self): -1 96 if not self.alive: -1 97 return -1 98 self.alive = False 95 99 self.cooldown = 30 96 100 self.direction = self.base_direction 97 101 self.running = False @@ -205,7 +209,7 @@ class Game: 205 209 self.cols, self.rows = shutil.get_terminal_size() 206 210 sys.stdout.write(boon.get_cap('clear')) 207 211208 -1 if self.straggler.cooldown > 1:-1 212 if not self.straggler.alive: 209 213 camera = self.leader.x - self.cols / 2 210 214 else: 211 215 camera = (self.leader.x + self.straggler.x) / 2 - self.cols / 2 @@ -214,7 +218,7 @@ class Game: 214 218 self.render_hud() 215 219 216 220 for player in self.players:217 -1 if player.cooldown < 0:-1 221 if player.alive: 218 222 player.render(camera, self.cols, self.rows) 219 223 220 224 sys.stdout.flush() @@ -260,23 +264,23 @@ class Game: 260 264 player.cooldown -= 1 261 265 262 266 # die on out-of-screen263 -1 if (264 -1 self.straggler.cooldown < 0265 -1 and abs(self.straggler.x - self.leader.x) > self.cols266 -1 ):-1 267 if abs(self.straggler.x - self.leader.x) > self.cols: 267 268 self.straggler.die() 268 269 269 270 # die on abyss 270 271 for player in self.players:271 -1 if player.cooldown < 0 and player.y > 2 * BLOCK_HEIGHT:-1 272 if player.y > 2 * BLOCK_HEIGHT: 272 273 player.die() 273 274 274 275 # respawn on edge of screen275 -1 if self.straggler.cooldown == 0:-1 276 if not self.straggler.alive and self.straggler.cooldown <= 0: 276 277 if self.direction == RIGHT:277 -1 self.straggler.x = self.leader.x + self.cols / 2-1 278 x = self.leader.x + self.cols / 2 278 279 else:279 -1 self.straggler.x = self.leader.x - self.cols / 2-1 280 x = self.leader.x - self.cols / 2 -1 281 if self.map.get_floor(x) is not math.inf: -1 282 self.straggler.x = x -1 283 self.straggler.alive = True 280 284 281 285 self.render() 282 286 time.sleep(1 / 30 - (time.time() - last))