CSCI 201 Lab 8 -- Making faces with EzWindows
In this lab you'll use the EzWindows interface to
make a face.
If you need a review, go back to Lab 4 now.
Create a project of type Win32 Application
(not type Win32 Console Application)
in C:/FILES called Face.
Add the EzWindows library to the project and modify the
compiler options to use the EzWindows include directory.
Add a new C++ Source called face.cpp to your project.
Use cut-and-paste to copy an initial version of
face.cpp into your program.
Build and run your program. You should see a rather abstract
face with only a nose and mouth.
First note the use of the two routines ApiMain and
ApiEnd. You saw them both before, but we didn't talk much about
ApiMain is called when your application begins execution.
Its sibling routine, ApiEnd, is called just
before your application is terminated. ApiMain replaces
main when you are using the EzWindows library. In last week's
lab you saw part of Apimain in assembly language when you ran the
overlap program in the debugger and didn't use run to cursor
You should never change ApiEnd in today's lab.
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.
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:
Remember that the last two parameters to the RectangleShape
constructor are the width and height of the rectangle.
- RectangleShape Nose(MyWin, NosePos, Red, 2.0f, 3.0f) ;
Once you've defined a shape, you use the Draw method to
display it in the window.
The ellipse is the first of this week's two new shapes.
The definitions for rectangles and ellipses are very similar:
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.
- EllipseShape LIris (MyWin, LEyePos, Blue, 0.8f, 0.8f) ;
Remember to Draw your ellipse after you've defined it.
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:
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).
- TriangleShape Nose(MyWin, NosePos, Red, 2.0f) ;
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
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
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
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
Return to CSCI 201 page
Return to the UNCA Computer Science home page