Jump to content
  • Advertisement
Sign in to follow this  
Side Winder

(SOLVED) Adding shrapnel to my Asteroids game

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

So I'm writing an Asteroids game and I want some shrapnel. However, the problem I'm having is, I guess, with the random generator. I'm seeding the random generator with time() but if I'm doing a for loop, the time won't change throughout the loop. So basically, what I'm asking is.. without the need to manually assign the velocity's for each individual piece of shrapnel, how can I assign the values? Also, I've done an array of 100 for shrapnel. Because the loop is looping so fast, all 100 of that array is being used when one asteroid is hit. How can I make it so only.. lets say.. 20 of those would actually be visible from one hit? That way, if two asteroids were hit in quick succession, the second asteroid would still have shrapnel. Thanks for any help. [Edited by - Side Winder on March 18, 2007 10:19:38 AM]

Share this post


Link to post
Share on other sites
Advertisement
Sorry I'm so tired haha. I was doing the rand() function outside the loop!

What to do about the 2nd problem? I had an idea of making a loop for the collision on each type of asteroid (large, medium, small) which would work but that's 3x as much code... So would really help if I could shorten it down.

Share this post


Link to post
Share on other sites
For your second problem, there are two things you should do.

First, only create a fixed number of shrapnel bits whenever an asteroid is hit, and you can make this number depend on the size of the asteroid.

Second, don't restrict your shrapnel bits — why only 100, instead of an arbitrarily large number? Use a resizable container.

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.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!