Jump to content
  • Advertisement
Sign in to follow this  
Justindano

Need help with Shmup [ SDL ]

This topic is 2591 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

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!

Share this post


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

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

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

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!