Hmmmm not the approach I would have gone with, but not a bad solution. I'm unfamiliar with the abbreviation UDT, though, so some explanation would be nice. It is a good solution to the given problem, though it would be a bear to adjust (having to scale everything properly in the array and such). Only point I would make here is:
Rather than have a variable for the state of each asteroid, put it into the asteroid data array, like so:
AsteroidData#(Number,0)=1
Where that 0 spot will have a 1 (alive) or 0 (dead).
This will cut down on how many variables deal with the same thing (in this case, asteroid information).
Here is how I would solve the situation:
Control the spawning based on how many "points" in the asteroids are out. That is to say that a Large asteroid is worth 3, a medium is worth 2, and a small is worth 1. As the asteroids are spawning, it will only spawn up to 50 points. That way, if a large asteroid explodes into 3 small ones, the total number of points remains constant and there are available data slots.
I would expand the "alive or dead" system to contain hit points instead (so instead of AsteroidData#(Number,0) containing 0 or 1, it will have 0,1,2,3 depending on the size of the asteroid). When spawning, I would set up a function that would scan through the array to see if there is an open/dead asteroid slot available, then check my total asteroid budget, and if one can be made, I would do it.
What you get from this is:
-Easy to expand (simply change the total budget and the array size and you can scale up or down all you want)
-Easy to control/monitor(if things stop working you can check the variables easily to see what's happening)
-Easy to adjust on the fly (you could easily just start the budget small and increase it up to its maximum limit to increase difficulty).
-You can have almost 20 large asteroids on the screen at any time (a little overkill, but still)
Make sense?
Great Quote:
"Time...LINE??? Time isn't made out of lines...it is made out of circles. That is why clocks are round!" -Caboose