Figuring out the geometry
The CCDrawNode
class provides just three functions. These functions are drawDot
, drawSegment
, and drawPolygon
, which enable you to draw a color-filled circle, a color-filled segment, and a color-filled polygon with a separate border, respectively. We will write a simple yet extremely resourceful function to help us with the generation of vertices for our game elements. However, before we write this utilitarian function, let's take a closer look at each element and the vertices they contain:
Game element |
Visual |
Visual with vertices |
---|---|---|
Player | ||
Enemy | ||
Shield | ||
Bomb | ||
Missile launcher |
I have highlighted the vertices on each of these shapes to underline a basic geometrical object that we will use to our advantage in this game—the regular polygon. As most of you may know, a regular polygon is a polygon that is equiangular and equilateral. The interesting thing about a regular polygon is that we can use the parametric equation of a circle to get its vertices...