Asteroids, like ships, can be approximated to a circle for the purposes of collision detection. However, they should be irregular shapes, and each one should be unique. To achieve this we’ll make extensive use of the Math.random method to define the shape of our asteroids.
Drawing Basic Shapes
As a first stab, we’ll divide our circle into segments and draw a straight line from each segment to the next. We can do that by rotating the canvas in steps and drawing a line at each step before closing the path. We’ll want some randomness in the distance of the ...