123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051 |
- import error
- from common import Directions
- from game import *
- import sys
- import graphics
- def game_loop():
- '''Reads user input, parses it and performs it'''
- gameState = game()
- print gameState
- while 1:
- graphics.graphicsloop(gameState)
-
- def up(gameState):
- gameState.move(Directions.UP)
-
- def down(gameState):
- gameState.move(Directions.DOWN)
-
- def left(gameState):
- gameState.move(Directions.LEFT)
-
- def right(gameState):
- gameState.move(Directions.RIGHT)
-
- def iact(gameState):
- gameState.interact()
-
- def errorCommand(gameState):
- print "Not a valid command!"
-
- def quit(gameState):
- print "End!"
- sys.exit()
- def parse_command(raw):
- if raw in command_lookup:
- return command_lookup[raw]
- else:
- return errorCommand
- command_lookup = {'w': up,
- 'a': left,
- 's': down,
- 'd': right,
- 'f': iact,
- 'q': quit}
- if __name__ == "__main__":
- print "Beginning!"
- game_loop()
|