El código deja de funcionar en la línea 25 por el siguiente error y ya he intentado muchas cosas, lo siento si es muy básico.
if map_objects[POS_X] == cordinate_x and map_objects[POS_Y] == cordinate_y:
TypeError: 'int' object is not subscriptable
import readchar
import os
POS_X = 0
POS_Y = 1
MAP_WIDTH = 20
MAP_HEIGHT = 15
player_pos = [12, 5]
map_objects = [[2, 8], [9, 11], [2, 6], [5, 7]]
while True:
print("+" + "-" * MAP_WIDTH * 3 + "+")
for cordinate_y in range(MAP_HEIGHT):
print("|", end="")
for cordinate_x in range(MAP_WIDTH):
char_to_draw = " "
for map_objects in map_objects:
if map_objects[POS_X] == cordinate_x and map_objects[POS_Y] == cordinate_y:
char_to_draw = "+"
if player_pos[POS_X] == cordinate_x and player_pos[POS_Y] == cordinate_y:
char_to_draw = "@"
print("{}".format(char_to_draw), end="")
print("|")
print("+" + "-" * MAP_WIDTH * 3 + "+")
print("[W] Up [S] Down [A] Left [D] Right")
# Ask to user where he want to move
# player_move_ask = (input("Where do you want to move? [W]Up [S]Down [A]Left [D]Right"))
# if player_move_ask == "W":
direction = readchar.readchar().decode()
if direction == "w":
player_pos[POS_Y] -= 1
player_pos[POS_Y] %= MAP_HEIGHT
elif direction == "s":
player_pos[POS_Y] += 1
player_pos[POS_Y] %= MAP_HEIGHT
elif direction == "a":
player_pos[POS_X] -= 1
player_pos[POS_X] %= MAP_WIDTH
elif direction == "d":
player_pos[POS_X] += 1
player_pos[POS_X] %= MAP_WIDTH
elif direction == "q":
break
os.system("cls")