+ 3

Collision detection?

Anyone know a way to check collision between any two objects? (squares, circles, etc. On the JavaScript canvas)

2nd Mar 2017, 7:09 PM
Noah Wise
Noah Wise - avatar
3 odpowiedzi
+ 7
a simple but approximate method would be to define a radius so that every object is contained in its circular safezone. check the distance between every object and another. if the distance is less than the sum of the radiuses means the two circular safe zones are overlapping and there fore a collision is happening. you can check this pixel overlapping example by Peter Lager https://www.openprocessing.org/sketch/149174 this is a nice library for p5js https://p5js.org https://github.com/bmoren/p5.collide2D For complex game frameworks with physics engine: http://phaser.io/ http://createjs.com/
2nd Mar 2017, 7:27 PM
seamiki
seamiki - avatar
+ 5
good question 🔵🔴⚪ 💥💥💥
11th Sep 2018, 4:39 AM
NimWing Yuan
NimWing Yuan - avatar
+ 3
Thanks a lot seamiki!
2nd Mar 2017, 7:42 PM
Noah Wise
Noah Wise - avatar