I have a 2d, top-down game, where there are 2 players; one is controlled by the arrow keys, and the other one is controlled by the WASD keys. I want to make it to where when the 2 players overlap, I can make it to where it stops the program, or I can print something in the console, something like
Tag: collision-detection
detect collision between two circles and sliding them on each other
I’m trying to detect collision between two circles like this: Now when collision is detected I want to slide the circle1 from on the circle2 (circle1 is moving) like this: –circle1———————————circle2—————…
Collision in canvas javascript game
I added collision to my game but I have a problem. But first I´ll give you some background. I have this: On update(); function I have this: That is used here: Note: wPlayer and hPlayer are the width and height of the player, as the animation is done through a spritesheet. xPlayer and yPlayer are the positions…
Test if two lines intersect – JavaScript function
I’ve tried searching for a javascript function that will detect if two lines intersect each other. The function will take the x,y values of both the start end points for each line (we’ll call them line A and line B). Is to return true if they intersect, otherwise false. Example of the function. I&…