You are not allowed to do AttachFile on this page. Login and try again.

    AdamCohen/Assignment 1 Writeup

Describe AdamCohen/Assignment 1 Writeup here.

PROGRAM NOTES:

This program is a homeless man's PacMan. When you run the program, pacman will start moving upwards along the path. You can control his movement with the arrow keys. It's a solid 8 seconds of fun. Enjoy.

IMPL NOTES:

Pacman is drawn with an open_circle function which draws a circle with a variable width 'slice' chopped out in an arbitrary direction. Pacman has a static _direction field associated with it. With every clock tick, he moves a bit in that direction. When he is drawn, the open slice also faces in that direction. The size of the slice is also a static member and changes with every tick to make his mouth go open and shut. The path is just a few rectangles.

User input is very simple. glutSpecialFunc(arrows) defines that the action of the arrow keys is to simply change pacman's direction field to 0, 90, 180, or 270, depending on the button.

1) There are a number of events which trigger event functions that are

  • specified by the programmer at compile-time. For instance, we define the display() function, which is supposed to run every time a display event occurs (when the screen must be redrawn). This is defined with a call to glutDisplayFunc( display ); during initialization.

2) In this case, it specifies that we are in RGBA mode as well

  • as double buffering mode. RGB is a particular way of representing color on the screen. Double buffering is a technique where the drawing buffer is different from the onscreen buffer, and it makes animated updates look much smoothers. There are a number of other flags that can be or'd together.

3) glOrtho(), according to man, multiplies the coordinate system

  • by an orthoganal matrix defined in the parameters. Since the default matrix is from -1 to 1 on both axes, the net effect is that the new coordinate system (below) goes from 0 to 100 instaed. glViewport() changes the reference point for the coordinate system. As I have it below, (0, 0) in the coordinate system corresponds to (0,0) in pixels (by first two parameters) and the 'end' of the coordinate system - in this case (100, 100) is given by (w, h) in pixels. Put another way, the viewport rectangle spans the entire window with coordinate (0,0) at the bottom left.
Recent