Space invaders Collision detection

Started by
4 comments, last by horvak 24 years, 7 months ago
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?

Advertisement
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

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.

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

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.

This topic is closed to new replies.

Advertisement