+ 3
Collision detection?
Anyone know a way to check collision between any two objects? (squares, circles, etc. On the JavaScript canvas)
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/
+ 5
good question 🔵🔴⚪ 💥💥💥
+ 3
Thanks a lot seamiki!