when i display move function , the user will be prompted to move w, a, s, d given by the map and where the Hero = H position is at. I am told to use
#Initial player’s current row & current col [0,0]
#Adds 1 day to the time.
#Not allowed to move out of the map
But i am having difficulty knowing how to code it, this is my current coding.
def new_game():
day = 1
for i in range(day):
print("\nDay {}: You are in a town.".format(day))
town_text = ["1) View Character",\
"2) View Map",\
"3) Move",\
"4) Rest",\
"5) Save Game",\
"6) Exit Game"]
for t in range(len(town_text)):
print('{}'.format(town_text[t]))
option1 = int(input("Enter choice: "))
if option1 == 1:
view_char(Name, minDamage, maxDamage, Defence, HP)
elif option1 == 2:
view_map()
elif option1 == 3:
move(town_text)
day += 1
elif option1 == 4:
rest()
day += 1
day = day + 1
elif option1 == 5:
save()
elif option1 == 6:
exit()
else:
print("Error, Please try again")
return option1
#Display View Map
cord = [1,1]
def view_map():
world_map = [['H/T', ' ', ' ', ' ', ' ', ' ', ' ', ' '],\
[' ', ' ', ' ', 'T', ' ', ' ', ' ', ' '],\
[' ', ' ', ' ', ' ', ' ', 'T', ' ', ' '],\
[' ', 'T', ' ', ' ', ' ', ' ', ' ', ' '],\
[' ', ' ', ' ', ' ', ' ', ' ', ' ', ' '],\
[' ', ' ', ' ', ' ', ' ', ' ', ' ', ' '],\
[' ', ' ', ' ', ' ', 'T', ' ', ' ', ' '],\
[' ', ' ', ' ', ' ', ' ', ' ', ' ', 'K']]
for row in world_map:
print('\n' + '+---' *8+ '+')
for col in row:
print('|{:^3}'.format(col),end='')
print('|' + '\n' + '+---' *8+ '+')
#Display Move
def move(town_text):
view_map()
moving = print("W = up; A = left; S = down; D = right;")
option1 = str(input("Your move: "))
return option1