C481 B581 Computer Graphics
Dana Vrajitoru
Homework 5

Due date: Thursday, February 17.

Ex. 1 Download the following files in a separate folder (you don't want to mix the main.cc and the Makefile with those of another program). The name of the executable is "maze":
Makefile
interface.h
interface.cc
bus.h
bus.cc
maze.h
maze.cc
main.cc

Compile and run the program. When you run the program, you should get a window that looks like this. The arrow keys can move the bus around through the empty spaces in the maze only.

a. When the bus is moving east, it looks like it's upside down (see this reference image). Implement a change to make the bus appear with the wheel down (like when it's going west), but with the arrangement of the windows the same as it is now. Basically you need to apply a mirror over Ox transformation to it. You can either use a scale of factor -1 for y and 1 for x and z, or a rotation over the Ox axis of angle 180.

b. The maze is in fact bigger that the view area shown on screen. The position of the camera can be controlled by the variables viewoffx and viewoffy defined in the interface. These define a translation that is applied to the whole scene. Figure out a scheme of adapting these values when the bus gets close to the borders of the window. The goal is for the camera to follow the bus (but not all the time) and reveal a new portion of the maze in the direction in which the bus is moving.

c. Add a resource to the maze that the bus can collect while going around - grass, soccer balls, apples. It can be whatever object you want, as long as it fits in a 1x1 square.

Add a few of these resources to the maze, with the number 2. There is already a Cell_type value for it in maze.h. Create a new display list containing this object in maze.cc, and then modify the maze draw function to call this display list for every resource in the maze. You will have to call a translation to place each resource in its final position in the window, and don't forget to call push and pop matrix before and after. When the but is moved around, make it check for the cell it moves into containing food, and if it does, remove it from the maze. Add a global counter in the interface that counts the resources collected. Print that number out with a message when the program is exited with the "q" key.

Send me: the source file(s) that you modify, individual attachments by email. You don't need to send me the Makefile.