Collision Detection function

collision

#1

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)


(Mark Hunte) #2

Hi,

What are you asking here?


#3

I need a JavaScript function for my spaceship to detect when it is hit by the planets


#4

I’m asking for a collision detection function


(Greg) #5

A few questions and suggestions

  1. What purpose do the invisible boxes have?

  2. What is supposed to happen if you detect a collision?

  3. It’s considered bad practice to name elements with a number

  4. 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)


#6

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