Sign in to follow this  
Side Winder

(SOLVED) Adding shrapnel to my Asteroids game

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
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

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this