Collision Detection | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 1

Collision Detection

I'm working on a project and I make collision detection right now. It works. It can check for rectangles overlapping each other but I don't know what to do when player collide a wall. any idea? I want him just to stop walking to walls directions

12th Jul 2018, 12:51 AM
Ilias
Ilias - avatar
2 Answers
+ 1
if(player.xpos > screen.width - player.width){ player.xpos = screen.width - player.width }
12th Jul 2018, 3:05 AM
Dlite
Dlite - avatar
0
https://github.com/borislavvv00 Check my github acount to see how i do it.
12th Jul 2018, 8:17 PM
B K