Hey I’m trying to create a collision detection function for a simple planet obstacle game. The spaceship should detect the planets. The planets are overlayed with invisible boxes with id’s 1-9 in order of distance from the sun. I have already created the function to move the spaceship. Thanks in advance.
Demo: https://dl.dropboxusercontent.com/spa/24cqjowiq0m2v2a/Exports/planets/planets.html
Project:
planets.hype.zip (594.7 KB)
Hi,
What are you asking here?
I need a JavaScript function for my spaceship to detect when it is hit by the planets
I’m asking for a collision detection function
A few questions and suggestions
-
What purpose do the invisible boxes have?
-
What is supposed to happen if you detect a collision?
-
It's considered bad practice to name elements with a number
-
The spin is set pretty fast, it's hard to see what is happening on the webpage - maybe you can stretch the timelines to slow it down a bit.
Here's a sample of an action started from a collision, I'm not sure it will work from a keyboard action (arrow keys)
offset_action.hype.zip (13.0 KB)
The bounding boxes on the planets are larger than the actual planet so I made the boxes to fit the planet. If you detect a collision a simple warning will work