Take the 2-minute tour ×
Game Development Stack Exchange is a question and answer site for professional and independent game developers. It's 100% free, no registration required.

What would the algorithm be for generating/drawing the asteroid shapes from the original Asteroids game? Is it even an algorithm? Or would they be hard coded shapes?

Here is a screenshot to jog your memory.

Screenshot from Asteroids game

EDIT - Also found this:

alt text

from the article Edge - The Making of Asteroids. Interesting read, but does not mention any specifics.

share|improve this question

6 Answers 6

up vote 8 down vote accepted

I can't say I have any inside information, but given the finite number of shapes (note how even in your screenshot two of the large-asteroid shapes are repeated), I always assumed it was hard-coded. You could certainly reproduce it that way if you were going to build it today.

share|improve this answer

Asteroids was a vector based game, so shapes were most likely described as 'turn left 30 degrees and move 10 forward'. As in the Logo programming language. So you draw your shape as in the sketch, convert it to a series of vector commands, set a scale, position and rotation and start the drawlist. I guess you can reproduce it pretty much like that by drawing line-lists. Oh yeah, I assume they're hard-coded, as, like others noted, the ones in the game match the ones on the sketches.

share|improve this answer

I also expect them to be hard-coded as a list of points. The machines back then were not powerful enough to waste any CPU time and memory on dynamically generating asteroid shapes.

If you want to generate Asteroids dynamically, here's what I would do:

  • Choose a random angle (higher than the previous, up to 360°
  • Add a point at a random distance from the center

In other words, imagine drawing several circles from around the center of the image with various radii. Then pick a random angle (direction) and a random circle, the intersection of the line and the circle is going to be one of the shape points. Repeat until you made a full 360 sweep. You'll end up with a list of points that connected create an asteroid shape.

share|improve this answer

My algorithm was: For each of 8 equally spaced angles around a circle, choose a random distance and draw a point at that angle and distance from the center connected to the previous point.

share|improve this answer

It appears that the four asteroid types you have posted drawings of do match the asteroids in your screen shot (if you look at the red lines of the drawings as the correct lines).

It also appears that the lower-left "medium-sized" asteroid is an example of asteroid drawing #2, and that drawing also appears as the two left-most large asteroids.

So it looks as if there are four asteroid images which can appear at 3 (?) scalings. Nice sleuthing.

share|improve this answer

Another possibility to generate asteroids dynamically would be to take a predetermined form from a set, and modify a random number of times the edges: you take an edge, choose a point on this edge (near the middle), and move it along the perpendicular direction, towards the outside or the inside. You replace your initial edge with the two edges resulting of the use of the point:

A---------B become

A--     --B     
   --C--

You can do this a number of times, on initial or resulting edges. This is a simple fractal/recursive modification of the edges. (As with all recursive modification, the size of variation should go down with the depth.)

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.