+ 3

Can anyone help me if red box hits orange one game over 😭😭

https://code.sololearn.com/WCUCQirB3zzc/?ref=app

23rd Aug 2020, 4:19 AM
Papa Penguin
8 ответов
+ 6
Nice practice. Instead of using getComputedStyle, you could simplify by using a JavaScript variable to store the position of red rectangle and orange rectangle. There are two ways of collision testing, distance approach versus edge approach, as your items are rectangular, you can check four conditions: left edge of red compared with right edge of orange right edge of red compared with left edge of orange top edge of red compared with bottom edge of orange bottom edge of red compared with top edge of orange you can also use corner position to check collision. Explaining Rectangular Collision Testing Visually: https://code.sololearn.com/WOSkh92TwAYI/ If the above does not help, here is my video tutorial about collision testing: https://youtu.be/JkfxEXUXGzY The video is based on a code of another sololearner who asked for help last time. But the mathematics are the same.
23rd Aug 2020, 8:31 AM
Gordon
Gordon - avatar
23rd Aug 2020, 5:17 AM
Namit Jain
Namit Jain - avatar
+ 2
Namit Jain i don't understand
23rd Aug 2020, 5:28 AM
Papa Penguin
23rd Aug 2020, 5:58 AM
Papa Penguin
+ 1
You know the vertices of the two rectangles. From that you can find out their sides and their co-ordinates. And just apply this formula on each side
23rd Aug 2020, 5:50 AM
Namit Jain
Namit Jain - avatar
+ 1
Namit Jain bro group me Hindi me samjhado 😅😅
23rd Aug 2020, 5:51 AM
Papa Penguin
+ 1
Aad Hoogenboom please help
23rd Aug 2020, 6:48 AM
Papa Penguin