This lab is Lab 5 but with arrays.
If a directory called C:\FILES\Lab13 presently exists on your computer, delete it.
You get one project to start this lab. Download a ZIP'ed copy of the Lab 13 project and store it in the C:\FILES directory.
Build and the project and run the project. You should see a familar face. However, notice that this time the face has a nose that isn't an equalateral triangle and the eye has six points. Something exciting is happending.
Position FaceShape[4] = {
Position( 1.0f, 1.0f) ,
Position(11.0f, 1.0f) ,
Position(11.0f, 15.0f) ,
Position( 1.0f, 15.0f)
} ;
declares and then initializes an array of four Position
s.
These four Position
s are a polygon outlining the head of the face.
The next line of code:
MyWin.RenderPolygon(FaceShape, 4, Yellow, true);
draws the four point polygon and fills it with yellow.
The final argument (true
) to RenderPolygon
specifies that a black border should be trace around the edge
of the polygon.
If you look a big further through the code, you'll see where the 3-point nose, the 4-point mouth, and the 6-point eye are drawn.
FaceShape
array to have six points.
NoseShape
with the statement
NoseShape[2] = Position( 6.0f, 10.9f) ;
and then redraw the polygon in black.
EyeShape
array
to the right position with the statement
EyeShape[i].SetXDistance(EyeShape[i].GetXDistance()+4.0f) ;
All you need to do is write a for
loop around the
above to execute the statement for all values of i
from 0 to 5.