Skip to content

Instantly share code, notes, and snippets.

@pathunstrom
Created April 30, 2018 18:38
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save pathunstrom/2106289a2378e3958cde62de7ced7f01 to your computer and use it in GitHub Desktop.
Save pathunstrom/2106289a2378e3958cde62de7ced7f01 to your computer and use it in GitHub Desktop.
Ways to count player lives.
class Game:
def __init__(self):
self.player = Player()
self.extra_lives = 3
self.running = False
def run(self):
self.running = True
while self.running
if not self.player.alive:
self.extra_lives += -1
if self.extra_lives <= 0:
self.running = False
game = Game()
game.run()
running = True
lives = 3
while running:
run_simulation()
if is_player_dead():
lives += -1
if lives <= 0:
running = False
running = True
player = Player()
assert player.lives == 3
while running:
run_simulation()
if players.lives <= 0:
running = False
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment