5
\$\begingroup\$

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 http://www.heinzwerner.de/emu_asteroids.jpg

EDIT - Also found this:

alt text http://www.next-gen.biz/files/images/feature_article/2009/05/asteroids4.jpg

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

\$\endgroup\$

6 Answers 6

8
\$\begingroup\$

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.

\$\endgroup\$
6
\$\begingroup\$

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.

\$\endgroup\$
4
\$\begingroup\$

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.

\$\endgroup\$
4
\$\begingroup\$

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.

\$\endgroup\$
2
\$\begingroup\$

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.

\$\endgroup\$
1
\$\begingroup\$

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

\$\endgroup\$

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .