I am making a python curses program and I need to know how to make collisions. It is an open world game.
`import curses
stdscr = curses.initscr()
curses.initscr()
curses.noecho()
curses.cbreak()
stdscr.keypad(True)
key = stdscr.getkey()
player = "@"
x, y = [55, 14]
x2, y2 = [53, 14]
while True:
try:
key = stdscr.getkey()
except:
key = None
if key == "KEY_LEFT":
x -= 1
elif key == "KEY_RIGHT":
x += 1
elif key == "KEY_UP":
y -= 1
elif key == "KEY_DOWN":
y += 1
if x == 55 and y == 14:
y -= 1
stdscr.clear()
stdscr.addstr(y2, x2, "###########")
stdscr.addstr(y, x, player)
stdscr.refresh()'
I only have a few months of coding experience so maybe it looks nooby.
I tried this:
if x == 53 and y == 14:
But it would be tedious.