Py学习  »  Python

我想做一个迷你游戏。在python中,运动是在-5到5(包括-5)之间的X和Y坐标中进行的。我该如何将其放入循环中

beginner_geek07 • 3 年前 • 1292 次点击  
#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.

我能得到帮助吗? 这个游戏类似于Zork 命令和我想做的事情已经列出了,我认为剩下的唯一一件事就是尝试适应范围为[-5,5]的循环。

Python社区是高质量的Python/Django开发社区
本文地址:http://www.python88.com/topic/128113
 
1292 次点击  
文章 [ 1 ]  |  最新文章 3 年前