All assignments use the graphics framework. Look at the lecture slides on http://pclx.com/itcc for more information on how to complete these assignments. Use HW3's code and the slides as a guide. Our goal with these assignments is not to be strict or exact, but to allow each student to experiment and come up with his own solution to a rather flexible question.
PLEASE SUBMIT A SINGLE .cpp FILE TO ITCC_TEACHERS@PCLX.COM WITH YOUR SOLUTION WITH A COMMENT AS THE FIRST LINE OF YOUR FILE IDENTIFYING YOURSELF. PLEASE DO NOT RESUBMIT YOUR SOLUTION, EVEN IF IT IS INCORRECT THE FIRST TIME. SEND TWO .cpp FILES -- THE SCREEN SAVER AND THE LIBRARY. YOU DO NOT HAVE TO WRITE ANSWERS TO THE QUESTIONS.
Challenge #1. With this assignment, we're going to build a library of graphics functions to enable us to write more complicated games. This library is called the 'Primitive' library since we'll be drawing graphical primitives (lines, circles, etc.) using it. You also now have the skills to write your own Clear and SetPixel functions, so I have removed these from the framework. (The latest Framework must be downloaded for direct access to the video buffer!) You are encouraged to write EVERY function using Primitive_SetPixel and to author the functions in the order they are given for difficulty. Function prototypes have been provided for you in the supplemental files, but feel free to add as many primitives as you'd like!
One thing to note is that this project contains THREE files -- the normal HW3 file in addition to one .cpp file to hold the function bodies (ITCC_Primitive.cpp) and one header file to declare what will be found in the library (ITCC_Primitive.h). You should only have to edit the two .cpp files. Use the Driver file to test your Primitive functions as you write them. Note that the ONLY Main function is located in the Driver cpp file.
How would you draw a line or circle? Take a look at Bresenham's Line Algorithm and Bresenham's Circle Algorithm (explained in-depth in the links below and in the slides). We hope you understand its derivation (or at least that of the DDA), but if it is still confusing you can find the source code on-line.
Challenge #2. Let's put your new library to use by making a screen saver (well, as close to one as we can get without installing it)! One of the most popular screen savers that comes with the Windows OS is Mystify. Let's try to emulate this by using our line functions and our knowledge of arrays, except let's make it a little less complicated by only making each quadrilateral consist of ONE line instead of four. Some things to note:
srand(GetTickCount()); // seeds the generator with the ms since Windows started
int rndNum = rand()%640; // generates a random number from 0-639, inclusive.
Most importantly, have fun with this one, as always :-)