Jump to content
  • Advertisement


This topic is now archived and is closed to further replies.


Space invaders Collision detection

This topic is 7007 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

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?

Share this post

Link to post
Share on other sites
Guest Anonymous Poster

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


Share this post

Link to post
Share on other sites
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.

Share this post

Link to post
Share on other sites
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,

Share this post

Link to post
Share on other sites
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.

Share this post

Link to post
Share on other sites

  • Advertisement

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!