Jump to content
  • Advertisement
Sign in to follow this  
LightningRobbie

Spawning enemies

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

I'm working on a spawner class that spawns my game's enemy objects. The spawn time was based on a random number in Spawner.Update() method that would be constantly called throughout the game. As long as current enemies are not greater than int TotalEnemies.

However, the rusted wheel in my head started to crank, and I realized, wouldn't this be bad idea? Wouldn't my enemies spawn slow on a slow pc, and fast on a fast PC? I'm guessing I need to spawn them based on elapsed time rather than Update cycles.

Please let me know if I'm right or wrong, and feel free to share your silly mistakes. smile.png

Share this post


Link to post
Share on other sites
Advertisement
If your spawn update method is not limited by the game loop (which it should), then that problem will occur. All your update/process functions should ideally be limited by time, so that they don't perform differently on different machines unlike render functions which are not limited and make use of better machines for better framerates.

Share this post


Link to post
Share on other sites
Just use seconds or milliseconds to determine how often to release enemies. That's standard across all platforms...unless they are travelling near the speed of light ;)

Share this post


Link to post
Share on other sites

Just use seconds or milliseconds to determine how often to release enemies. That's standard across all platforms...unless they are travelling near the speed of light ;)

In other words, limiting in the game loop. Limiting can be done in 2 ways - time-based and frame-based. Time based is obviously the better method as its not dependent on the machine speed.


De-coupling the update process and the render process is a good idea.

Truly!

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!