Need help with Shmup [ SDL ]

Started by
0 comments, last by BeerNutts 12 years, 5 months ago
Hey guys!
Thanks for coming by to this thread.
Anyways, my problem is, i am developing a shoot em up game, and i have already got the bullets, spaceship etc moving around.
My problem is with the enemies, I can draw many onto the screen, but i don't want a lot of enemies popping around
I use vector container to store the enemies.

while(running)
{
PastFrames = SDL_GetTicks() - beginTime;
beginTime = SDL_GetTicks();
if( PastFrames < PerFrames )
{
SDL_Delay( PerFrames - PastFrames );
int myrand = rand()%30+1;
if( myrand == 1 )
{
Asteroid myAsteroid;
Asteroids.push_back(myAsteroid);
}
}
}

This works a bit, But is there any other efficient way to do this, I cant figure it out, Any possible way is suitable for me.
Thanks in advance!
Advertisement
Yes. You should have external configuration files that setup when and what enemies are released into the game.

I would suggest using a file that has a list of lines that contains this information:
a time (in seconds or milliseconds), an enemy name, and a location (and maybe a starting velocity)

Then, in your game, you load the file, and put all the info in a EnemiesToBeReleased vector, and each game loop check if it's time to release an enemy, and, if so, put the enemy into your enemy vector.

You could do this via xml, or just a simple text file that you read out, which ever you feel works better. See my 2d Game Making blog (in my sig, go to the earlier posts) for some examples on parsing xml with tinyxml.

Good Luck.

My Gamedev Journal: 2D Game Making, the Easy Way

---(Old Blog, still has good info): 2dGameMaking
-----
"No one ever posts on that message board; it's too crowded." - Yoga Berra (sorta)

This topic is closed to new replies.

Advertisement