Created
April 30, 2018 18:38
-
-
Save pathunstrom/2106289a2378e3958cde62de7ced7f01 to your computer and use it in GitHub Desktop.
Ways to count player lives.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
running = True | |
lives = 3 | |
while running: | |
run_simulation() | |
if is_player_dead(): | |
lives += -1 | |
if lives <= 0: | |
running = False |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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