How to Make a Box Collision in JavaScript | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 4

How to Make a Box Collision in JavaScript

24th Jun 2018, 11:53 AM
Amar Dahake
2 Answers
+ 4
You need to calculate the offset for both elements. if(($(pipeTop).offset().left <= player.offset().left + player.width()) && (player.offset().left <= $(pipeTop).offset().left + $(pipeTop).width())) { https://code.sololearn.com/WftFhf1E9UQI
24th Jun 2018, 12:44 PM
Toni Isotalo
Toni Isotalo - avatar
+ 2
http://lmgtfy.com/?q=JavaScript+box+collision
24th Jun 2018, 12:19 PM
Janningā­
Janningā­ - avatar