Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- from os import system
- from sys import exit
- #All functions
- x_pos = 0
- y_pos = 0
- def mov():
- global x_pos, y_pos
- moving = True
- while moving == True:
- print("Type d for directions or type \"stay\" to stay.")
- a = input("\n(moving)> ")
- if a == "d" or a == "D":
- print("\nYou can move (n)orth, (s)outh, (e)ast, or (w)est.\n")
- print("You are at (%d, %d)\n" % (x_pos, y_pos))
- elif a == "w" or a == "W":
- x_pos += 1
- elif a == "e" or a == "E":
- x_pos += -1
- elif a == "N" or a == "n":
- y_pos += 1
- elif a == "S" or a == "s":
- y_pos += -1
- elif a == "stay":
- moving = False
- print("You remain where you were.")
- else:
- print("You haven't moved.")
- def parser(a):
- places = []
- places.append(a)
- try:
- if places[0] == "h":
- print("\nuse, check, items, clear, q or exit")
- elif places[0] == "use":
- places[1].use
- elif places[0] == "check":
- pass
- elif places[0] == "items":
- pass
- elif places[0] == "move":
- mov()
- elif places[0] == "q" or places[0] == "exit" or places[0] == "quit":
- exit("Quitting...")
- elif places[0] == "clear":
- system("clear")
- else:
- print("I don't understand that command.")
- except IOError:
- print("Please use these commands correctly!")
- # Main Game
- run = True
- while run == True:
- print("For help, press h.")
- parser(input("\n> "))
Advertisement
Add Comment
Please, Sign In to add comment