For players who can move, how can they tell if they touch an obstacle when they move?

suppose the black square is the player and the white background is the wall. How to tell the black square touches the wall and tell him to stop moving.

clipboard.png

Dec.14,2021

every time it is inefficient to judge traversal, especially when there are many walls
save the data of each location of the map into a two-dimensional array in advance
for example

map[0][0] = 'blank'
map[2][1] = 'wall'
map[7][6] = 'red'
When

moves, you can directly judge whether map [x] [y] is wall or something else

.

each square is a coordinate, and when the square moves, determine whether the coordinates are equal

.
MySQL Query : SELECT * FROM `codeshelper`.`v9_news` WHERE status=99 AND catid='6' ORDER BY rand() LIMIT 5
MySQL Error : Disk full (/tmp/#sql-temptable-64f5-1b3c7b4-4d9b6.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
MySQL Errno : 1021
Message : Disk full (/tmp/#sql-temptable-64f5-1b3c7b4-4d9b6.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?