laneya

multiplayer roguelike game
git clone https://git.ce9e.org/laneya.git

commit
0bdf745115d7383e28fcc0f2fb00ad6314e471c8
parent
b8879d299a1d6868216f6aa923a13756109b2f23
Author
Tobias Bengfort <tobias.bengfort@gmx.net>
Date
2014-10-06 20:24
dirtywords: cleanup on exception

Diffstat

M laneya/dirtywords/example.py 40 ++++++++++++++++++++++------------------

1 files changed, 22 insertions, 18 deletions


diff --git a/laneya/dirtywords/example.py b/laneya/dirtywords/example.py

@@ -34,21 +34,25 @@ class Player(object):
   34    34 if __name__ == '__main__':
   35    35     scr = Screen(32, 100)
   36    36 
   37    -1     scr.border()
   38    -1 
   39    -1     player = Player(scr)
   40    -1     player.move('down')  # initial refresh
   41    -1 
   42    -1     while 1:
   43    -1         ch = scr.getch()
   44    -1         if ch == ord('h'):
   45    -1             player.move('left')
   46    -1         elif ch == ord('j'):
   47    -1             player.move('down')
   48    -1         elif ch == ord('k'):
   49    -1             player.move('up')
   50    -1         elif ch == ord('l'):
   51    -1             player.move('right')
   52    -1         elif ch == ord('q'):
   53    -1             scr.cleanup()
   54    -1             sys.exit()
   -1    37     try:
   -1    38         scr.border()
   -1    39 
   -1    40         player = Player(scr)
   -1    41         player.move('down')  # initial refresh
   -1    42 
   -1    43         while 1:
   -1    44             ch = scr.getch()
   -1    45             if ch == ord('h'):
   -1    46                 player.move('left')
   -1    47             elif ch == ord('j'):
   -1    48                 player.move('down')
   -1    49             elif ch == ord('k'):
   -1    50                 player.move('up')
   -1    51             elif ch == ord('l'):
   -1    52                 player.move('right')
   -1    53             elif ch == ord('q'):
   -1    54                 scr.cleanup()
   -1    55                 sys.exit()
   -1    56     except:
   -1    57         scr.cleanup()
   -1    58         raise