+ 2
How can we make collosion between two objects by using js?
Please anybody explain
4 Respuestas
+ 4
There is a MDN tutorial dedicated for that.
https://developer.mozilla.org/en-US/docs/Games/Tutorials/2D_Breakout_game_pure_JavaScript/Collision_detection
Basically, this is the logic (from MDN) 👇
If the center of the ball is inside the coordinates of one of our bricks, we'll change the direction of the ball. For the center of the ball to be inside the brick, all four of the following statements need to be true:
The x position of the ball is greater than the x position of the brick.
The x position of the ball is less than the x position of the brick plus its width.
The y position of the ball is greater than the y position of the brick.
The y position of the ball is less than the y position of the brick plus its height.
+ 2
@Little Coder
Without what?
+ 1
Is there is no easy way without it?
@Ore
0
Without the code. Which you given in the link