opengl game

Started by
18 comments, last by BlueSpud 10 years, 8 months ago

ok how are you FLeBlanc, do you have any input for me?

Advertisement

so I should use a vector? I am somewhat familiar with vectors.

It depends, you could make your own linked list, but only if it is absolutely necessary. The std::vector does have some overhead, but shouldn't be noticable for this game.

View my game dev blog here!

so I should use a vector? I am somewhat familiar with vectors.

It depends, you could make your own linked list, but only if it is absolutely necessary. The std::vector does have some overhead, but shouldn't be noticable for this game.

If he stored the textures outside the object, just not drawing them and still allocating the RAM for each invader wouldn't be a big deal, he could just clear the vector at the end of the level and it wouldn't be a huge performance problem.

thanks for all the help, any more opinions?

I am working on collision detection between the bullets and the aliens. I am unsure of how to proceed.

well I got the collision detection to work with the ufo at the top of the screen, but I also want the bullet to collide with the aliens, and then turn off the aliens.

well I got the collision detection to work with the ufo at the top of the screen, but I also want the bullet to collide with the aliens, and then turn off the aliens.

Because your not really shooting in diagonals, as far as I can tell, check into Axis aligned bounding box collisions, they're pretty easy ex:


struct box
{
float maxx,maxy,minx,miny;
};
bool collision(box* one, box* two)
if (one->maxx < two->minx || one->mazy < two->miny || one->minx > two->maxx || one->miny > two->maxy)
// no collision in any of these cases
return false;
//defaults to colliding
else return true

Of course, you would need to constantly update the boxes position, so you might want to add some kind of offset in there somewhere and add them onto the max,min,etc during the test. If you want something for oriented bounding boxes, boxes that aren't axis aligned, in other words, rotated, look into the separating axis theorem. Its a bit slower, but its fairly simple to implement and its almost pixel perfect.

ok so AABB is the way to go?

so how do I do multiple collision detection using AABB.

so how do I do multiple collision detection using AABB.

AABB being good is kind of ipso-facto, only if you want axis aligned boxes. If you want to test all the boxes against your bullet, you don't want to test all of them in say a loop, while your game is pretty simple and you probably wouldn't notice the difference, you should do at least 2 steps. There are a lot of approaches to the 2 step thing, for more complicated collision detection, there are even upwards of 3. By no means am I an expert, but this is what I would do:

1. loop through all the bounding boxes and check if the center of the bullet is within a relatively small distance to the center of each box. If it is, add it to the next step to be tested for the AABB collision.
2. loop through all the boxes that were passed down and as soon as you find a collision, stop the loop because there is no need to keep checking for possible collisions.

To reiterate, this isn't really necessary, but it is going to save you quite a bit of CPU time if you have 30 or 40 enemies, or you are testing multiple bullets per frame.

This topic is closed to new replies.

Advertisement