run to cursor <\kbd>
You should never change ApiEnd in today's lab.
Positions
This week we are using the EzWindows Position class
to represent points within the window. Here's one instance
of constructing a position called NosePos
- Position NosePos(6.0f, 9.0f) ;
We didn't need Positions
stonehenge lab because we
were only displaying rectangles. However, this week we're going to
suggest you display ellipses and triangles and these EzWindows
objects do require Positions.
You'll find Positions to be useful when you are
defining several objects centered on the same point, such
as the pupil and iris of an eye.
You describe the point once as a Position and then
use the Position several times. Saves typing.
Rectangles
You met the RectangleShape object in the stonehenge lab.
This week we're going to suggest that you use Positions
when you define RectangleShapes as in:
- RectangleShape Nose(MyWin, NosePos, Red, 2.0f, 3.0f) ;
Remember that the last two parameters to the RectangleShape
constructor are the width and height of the rectangle.
Once you've defined a shape, you use the Draw method to
display it in the window.
Ellipses
The ellipse is the first of this week's two new shapes.
The definitions for rectangles and ellipses are very similar:
- EllipseShape LIris (MyWin, LEyePos, Blue, 0.8f, 0.8f) ;
Again, the last two arguments are the width and height of
the ellipse. In this case, the two arguments are the same
so we actually get a circle.
Remember to Draw your ellipse after you've defined it.
Triangle
This week's second new shape is a triangle. EzWindows triangles
are a tad boring. They are all equilateral triangles which point
upwards. An example definition follows:
- TriangleShape Nose(MyWin, NosePos, Red, 2.0f) ;
Note that the TriangleShape constructor only has
one size argument. It is the last argument and gives the
length of a side of the triangle (remember, it's a equilateral
triangle so all sides have the same length).
Lab Checkoff
This lab has more indefinite goals than the previous ones.
However, it has two definite rules:
- You must work with a partner.
- You can not leave for at least one hour.
Your job is to improve the face. At the minimum you must add hair and
eyes. To provide some inspiration, here are some of the faces that students created last
semester.
If you finish that early, you should try something else like a beauty mark, eyebrows, or even facial hair. By
the way, the monocle is a challenge. You have to draw two ellipses,
an initial ellipse of black to be the rim of the monocle and then a
smaller ellipse of yellow to repaint the background inside the
monocle.
What to turn in
If you are proud of your efforts, provide
your lab instructor with a floppy containing your C++ source file.
We'd like to add your creation to the gallery of faces started last
year.
What's in store for the future
Download the EzWindows executable ultimate.exe and run it. Notice
that the teeth appear three seconds after the face is first displayed.
Also, try pressing on the face with your mouse. This draws beauty
marks.
Return to CSCI 201 page
Return to the UNCA Computer Science home page