Skip to content

Commit

Permalink
Tell the player about the game crashing.
Browse files Browse the repository at this point in the history
Infinite splash screens are frustrating.
  • Loading branch information
Francis Herne committed Nov 22, 2014
1 parent 9b6109b commit 65de1c9
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 2 deletions.
7 changes: 6 additions & 1 deletion Player.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,12 @@ def setworld(self, name, position=None, blocking=False):
if self.geplayer is not None:
self.geplayer.world.removegeplayer(self.geplayer)
def lworld():
geplayer = GEPlayer(self, worlds.getworld(name), position)
try:
geplayer = GEPlayer(self, worlds.getworld(name), position)
except Exception, e:
with self.statelock:
self.state = 'crashed'
raise e; return
with self.statelock:
self.geplayer = geplayer
self.state = 'normal'
Expand Down
2 changes: 2 additions & 0 deletions WorldView.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,8 @@ def splash(message, fontsize=40, icon=None):
splash("You won!")
elif state == 'loading':
splash("Loading "+mapdef['name'], 25, HourGlass)
elif state == 'crashed':
splash("Game crashed!")
return self.scrollpos
if geplayer is not self.geplayer:
self.geplayer = geplayer
Expand Down
2 changes: 1 addition & 1 deletion main.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ def handleevents(player):
if event.key == FUSEREEL:
player.action('ignitefuse')
if event.type == pygame.KEYDOWN:
if player.state in ['lost', 'won']:
if player.state in ['lost', 'won', 'crashed']:
time.sleep(2)
sys.exit()
if event.key in MOVEDIRS:
Expand Down

0 comments on commit 65de1c9

Please sign in to comment.