Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- running = True
- path = ""
- x = 10 #min 0 max 20
- y = 10 #min 0 max 20
- yd = 0
- xd = 0
- class room1010:
- blocked = False
- description = "Room is 0 and 0"
- class room1011:
- blocked = False
- description = "Room is 0 and 1"
- class room109:
- blocked = False
- description = "Room is 0 and -1"
- def action():
- global x
- global y
- global xd
- global yd
- path = input("What do you want to do? >")
- #Movements
- if path == "n" or path == "North" or path == "north" or path == "go north" or path == "Go North":
- yd = 1
- if pathfree():
- y = y + 1
- print("You go North")
- else:
- print("Path is blocked")
- elif path == "s" or path == "South" or path == "south" or path == "go south" or path == "Go South":
- yd = -1
- if pathfree():
- y = y - 1
- print("You go South")
- else:
- print("Path is blocked")
- elif path == "w" or path == "East" or path == "west" or path == "go west" or path == "Go West":
- xd = -1
- if pathfree():
- x = x - 1
- print("You go West")
- else:
- print("Path is blocked")
- elif path == "e" or path == "West" or path == "east" or path == "go east" or path == "Go East":
- xd = 1
- if pathfree():
- x = x + 1
- print("You go East")
- else:
- print("Path is blocked")
- #actions
- #incorrect output
- else:
- print("'" + path + "' is not an accepted command.")
- def pathfree():
- global x
- global y
- global xd
- global yd
- blocked = False
- pathtest = "blocked = room" + str(x + xd) + str(y + yd) + ".blocked"
- exec(pathtest)
- return blocked
- def areainfo():
- global x
- global y
- #print("Position: %s, %s" % (x, y))
- printarea = "print(room" + str(x) + str(y) + ".description)"
- exec(printarea)
- def main():
- action()
- areainfo()
- print(" ")
- while running:
- main()
- input()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement