I have this project wherein I have to make a basic text-based maze/adventure game. This is my code so far but it's weird. I want it to be able to quit anytime and for it to display 'Please choose an available direction' when the input is not among the choices. I know my code is wrong but I don't know what to do about it. Can someone help me out? Thanks!
btw, I used this link as a guide http://ift.tt/2xTcbHx
maze_list = []
maze = ['Available Directions: East', None, 1, None, None]
maze_list.append(maze)
maze = ['Available Directions: East, South', None, 2, 3, 0]
maze_list.append(maze)
maze = ['Available Directions: West', None, None, None, 1]
maze_list.append(maze)
maze = ['Available Directions: North, East', 1, 4, None, None]
maze_list.append(maze)
maze = ['Available Directions West, South', None, None, 5, 3]
maze_list.append(maze)
current_tile = 0
print(maze_list[0])
done = False
while done != True:
print('')
print(maze_list[current_tile][0]) # available directions
move = raw_input('Which direction will you take?' )
if move == 'East' or 'east' or 'EAST':
next_tile = maze_list[current_tile][2]
current_tile = next_tile
print('')
print(maze_list[current_tile][0])
move = raw_input('Which direction will you take? ')
if move == 'South' or 'south' or 'SOUTH':
next_tile = maze_list[current_tile][3]
current_tile = next_tile
print('')
print(maze_list[current_tile][0])
move = raw_input('Which direction will you take? ')
if move == 'East' or 'east' or 'EAST':
next_tile = maze_list[current_tile][2]
current_tile = next_tile
print('')
print(maze_list[current_tile][0])
move = raw_input('Which direction will you take? ')
if move == 'South' or 'south' or 'SOUTH':
next_tile = maze_list[current_tile][3]
current_tile = next_tile
print('Nice')
if move == 'Quit' or 'quit' or 'QUIT':
print('Better luck next time. \nGoodbye.')
elif move == 'West' or 'west' or 'WEST':
next_tile = maze_list[4]
current_tile = next_tile
else:
print('Please choose an available direction')
elif move == 'Quit' or 'quit' or 'QUIT':
print('Better luck next time. \nGoodbye.')
elif move == 'North' or 'north' or 'NORTH':
next_tile = maze_list[1]
current_tile = next_tile
else:
print('Please choose an available direction')
elif move == 'Quit' or 'quit' or 'QUIT':
print('Better luck next time. \nGoodbye.')
elif move == 'East' or 'east' or 'EAST':
next_tile = maze_list[current_tile][2]
current_tile = next_tile
else:
print('Please choose an available direction')
elif move == 'Quit' or 'quit' or 'QUIT':
print('Better luck next time. \nGoodbye.')
else:
print('Please choose an available direction.')
Aucun commentaire:
Enregistrer un commentaire