CSCI 1300, Section 100
Hints on Assignment 4
1. When doing the math to determine the iris coordinate, remember that
the computations must be done using floating point (i.e., double or
float variables). Because pixel coordinates are most sensibly
represented as integers, you will need to convert back and forth
between integer and floating point values. You will get strange
results from your program if some computations are being done as
integers (and fractional results are truncated) instead of as floating
point.
2. Click here to download Professor
Mozer's working program, as an illustration of what your program should
do. Sorry, it's the executable, not the source code!
Professor Mozer's program does one thing that is not in the
assignment: If the cursor is inside an eye, the iris tracks the
cursor. As the assignment is stated, the iris will always be
drawn on the edge of the eye. Professor Mozer thought his
solution was a bit nicer, and is only a couple extra lines of
code. Either solution is acceptable.
3. A sample program has been added to the examples web page which is a
very simple sort of "paint" program. When you hold down the left
mouse button and move the mouse, it will color pixels at the mouse
location blue; when you hold down the right mouse button, it will color
pixels red. Professor Mozer will go over this program in
class. This example shows you how to detect mouse clicks, just in
case the bgi documentation isn't clear.
4. The bgi shows how to compile your program using the graphics
library. In case you have difficulty finding this compile line in
the documentation, here it is: g++ program.cxx -lbgi -lgdi32 -luser32
-o program.exe
5. If you are having problems with flicker (where you see bits and
pieces of display appearing/disappearing, and/or the entire display
seems to flicker on and off), here's what you need to know:
The display on your monitor is redrawn about 60 times a second.
If the redraw occurs in the middle of updating your image, then it's
possible that part of the redraw will show the old image and part will
show the new image, leading to the flicker phenomenon. To avoid
flicker, redraw as little as
possible in your display. One thing you should do is
redraw only when something in the display has changed (i.e., when the
mouse moves or when the iris colors change). Another thing that might help--depending on how your
code is written--is to redraw smaller areas of the screen. For
example, if you want to erase an iris, you can either redraw the white
of the eye, or redraw the iris in white. The latter is preferable
because it redraws a smaller area of the screen.
6. On the handouts and assignments page, check out Professor Mozer's
"program design advice" if you are feeling stuck in general with the
assignment.