space invaders
hello i am attempting to make my first game using direct x
although i am not having many problem with the basics of it i would just like to know if anyone has any tips on how to do collision detection on a space invaders type game.
Just a simple algorithm would do im just trying to learn the basics with this so im not worried about accurate hits.
thanks
A basic algorithm is just do a bounding box test against objects that matter. If I remember space invaders right, then just the ship against shots and enemies and the ship''s shots against enemies.
I think the original Space Invaders actually used color keys for checking if a hit was scored (since the background was all black). However, I would recommend bounding boxes (this leads to an interesting question on how to handle the shields, but that''s half the fun of game programming :
)
-Chris
---<<>>---
Chris Rouillard
Software Engineer
crouilla@hotmail.com
)
-Chris
---<<>>---
Chris Rouillard
Software Engineer
crouilla@hotmail.com
---<<>>--- Chris Rouillard Software Engineercrouilla@hotmail.com
If you go to my site (http://www.crosswinds.net/~uselessknowledge) you can download my source code for a space invaders game, which uses the bounding boxes method for collision detection.
------------------------------
Jonathan Little
invader@hushmail.com
http://www.crosswinds.net/~uselessknowledge
------------------------------
Jonathan Little
invader@hushmail.com
http://www.crosswinds.net/~uselessknowledge
You might do something along the lines of:
if (missilex < alienright //
missilex > alienleft //
missiley < alienbottom //
missiley > alientop) {
DO STUFF FOR GETTING HIT
}
Hope that helps.
- Daniel
http://sw.mtx.net/daniel/
if (missilex < alienright //
missilex > alienleft //
missiley < alienbottom //
missiley > alientop) {
DO STUFF FOR GETTING HIT
}
Hope that helps.
- Daniel
http://sw.mtx.net/daniel/
- DanielMy homepage
thanks to everyone for the replies I appreciate it Qoy i took a look at your game it''s pretty cool. Just one question though how long did it take you?
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement