help me with 8 directional movement with map cols
h
You simply check if the x and y position you are moving towards is free. See the table below to know which direction needs to be free.
x and y reference to the position of your player. d is a placeholder for the distance you want to check. This can be anything, depending on your usecase.
| Direction | Collision Check |
|---|---|
| Left | x - d |
| Up | y + d |
| Right | x + d |
| Down | y - d |
| Left & Up | x - d & y + d |
| Right & Up | x + d & y + d |
| Left & Down | x - d & y - d |
| Right & Down | x + d & y - d |
thx