Jump to content

  • Log In with Google      Sign In   
  • Create Account

We're offering banner ads on our site from just $5!

1. Details HERE. 2. GDNet+ Subscriptions HERE. 3. Ad upload HERE.


Space invaders Collision detection


Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

  • You cannot reply to this topic
5 replies to this topic

#1 horvak   Members   -  Reputation: 122

Like
Likes
Like

Posted 13 September 1999 - 12:37 PM

Hi,
I've put together a space invaders clone in java, I have an array of 55 invaders, doing their invader thing, with a ship at the bottom doing it's thing.
Now what is the best way to detect that a players' shot has hit an invader ? Is to check for the colour at specific points, ie check what colour is just in front of the missile and if it's an invader colour then I've hit something ? or is to cehck the x,y co-oords of the invader array against the x,y of the player shot ?
I thought of colouring each invader in a specific color and then mapping that colour to each invader in the array, so that when a missile hits a specific colour you find which invader it is mapped to and score a hit and blank the invader.. the mapping contains the array element number of the zapped alien... am I on the right track ?

Thanks in advance,
Karl.


Sponsor:

#2 Psepha   Members   -  Reputation: 122

Like
Likes
Like

Posted 01 September 1999 - 07:45 AM

Coooo - Fancy trying this when finished (*wipes a nostalgic tear from corner of eye*)Fraid I was around when they first appeared. Hell, I was programming around then!

OK - My tuppenceworth.
Depends on how shiny and eye candy it is. Plain background (as in the olde game) just check the pixels you are about to blit to are zero or background colour. Allows the baddies to move sideways onto a missile and get blown rather than just checking the forward point of the missile.

Should be able to check the x,y of the missile against the xy of baddies to work out which one shot (don't need to make each one a different colour).
There were a couple of tutorials around on collision routines (at least at sweet.oblivion) so I assume they should have been moved here?


#3 Anonymous Poster_Anonymous Poster_*   Guests   -  Reputation:

Likes

Posted 02 September 1999 - 08:41 AM

Hi

I'm also writing a Space Invaders game. My collision detection is simply using bounding rectangles. Works great!!!

Depends on how accurate you want to be, the above method is "good enough".

My game is in VC++, but the principle should be the same.

Let me know how you get on

Cya


#4 bosjoh   Members   -  Reputation: 122

Like
Likes
Like

Posted 03 September 1999 - 08:28 AM

One really good method:
Draw a border around the enemy's with a specific color. If that color is hit you can do your colission routines.

With this method you can use backgrounds too.


#5 Anonymous Poster_Anonymous Poster_*   Guests   -  Reputation:

Likes

Posted 03 September 1999 - 09:38 AM

Probably the best method for accurate sprite collision detection I've seen is described in an article at http://www.chesworth.com/pv/vault/game/vcol_1.htm . It only uses a few binary operations.

#6 Pseudo   Members   -  Reputation: 100

Like
Likes
Like

Posted 13 September 1999 - 12:37 PM

The other methods mentioned work just fine, but an alternative method would be to have a radius for each baddy, and then check the missle point around that like this:

find the difference in the x,and y between the missle, and the center of the baddy. Then say if(xdiff*xdiff + ydiff*ydiff > radius*radius) DoStuff();

This would be more computationally expensive than bounding boxes, but if the enemies are not rectangular, it tends to be much more acurate.


I used this method is a little astroids game I created, and it worked very well.





Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.



PARTNERS