'I am trying to make a mini game. The movement is in X and Y coordinates that range between -5 and 5 inclusively in python. How do I fit this in a loop
#The Commands are going North and South in the Y - variable and East and West in the X - variable and X - to exit the game
x = 0
y = 0
print("Welcome to sloth quest!")
print("________________________________________")
print()
print("You're currently at position (0, 0) in the world.")
print("Available commands:
N - go north, S - go south, E - go east, W - go west, X - exit game)
command = input("Enter a command: ")
if command == ("N"):
y = y + 1
elif command == ("E"):
x = x + 1
elif command == ("S"):
y = y -1
elif command == ("W"):
x = x -1
#I want to make a loop so that these commands can be input together so that the goal or hazard is reached.
Can I get help on this? The game is similar to Zork The commands and what I want to do are already listed , and I think that the only thing that is left is trying to fit in into a loop with the ranges [-5, 5] inclusively.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
