eahil

My Python Game Thus Far

May 12th, 2013
100
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.62 KB | None | 0 0
  1. from os import system
  2. from sys import exit
  3.  
  4. #All functions
  5.  
  6. x_pos = 0
  7. y_pos = 0
  8.  
  9. def mov():
  10.     global x_pos, y_pos
  11.     moving = True
  12.     while moving == True:
  13.         print("Type d for directions or type \"stay\" to stay.")
  14.         a = input("\n(moving)> ")
  15.         if a == "d" or a == "D":
  16.             print("\nYou can move (n)orth, (s)outh, (e)ast, or (w)est.\n")
  17.             print("You are at (%d, %d)\n" % (x_pos, y_pos))
  18.         elif a == "w" or a == "W":
  19.             x_pos += 1
  20.         elif a == "e" or a == "E":
  21.             x_pos += -1
  22.         elif a == "N" or a == "n":
  23.             y_pos += 1
  24.         elif a == "S" or a == "s":
  25.             y_pos += -1
  26.         elif a == "stay":
  27.             moving = False
  28.             print("You remain where you were.")
  29.         else:
  30.             print("You haven't moved.")
  31.    
  32.  
  33. def parser(a):
  34.     places = []
  35.     places.append(a)
  36.     try:
  37.         if places[0] == "h":
  38.             print("\nuse, check, items, clear, q or exit")
  39.         elif places[0] == "use":
  40.             places[1].use
  41.         elif places[0] == "check":
  42.             pass
  43.         elif places[0] == "items":
  44.             pass
  45.         elif places[0] == "move":
  46.             mov()
  47.         elif places[0] == "q" or places[0] == "exit" or places[0] == "quit":
  48.             exit("Quitting...")
  49.         elif places[0] == "clear":
  50.             system("clear")
  51.         else:
  52.             print("I don't understand that command.")
  53.     except IOError:
  54.        print("Please use these commands correctly!")
  55. # Main Game
  56.  
  57. run = True
  58. while run == True:
  59.     print("For help, press h.")
  60.     parser(input("\n> "))
Advertisement
Add Comment
Please, Sign In to add comment