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()