Homework 4

Short Description:

Write a program that allows you to wonder about a fixed size plane.

This assignment is worth 30 points.

Goals

When you finish this homework, you should

Formal Description

This program will be modified and extended, we will be adding features, and functionality, so make sure that you keep your design and implementation as open as possible. In the future I plan to add:

Write a program which allows you to move about a two dimensional plane.

For now, the plane should be a grid, with lines every 5 units. Intersection points where booth coordinates are multiples of ten should be labeled, with the label centered at the intersection point (See the diagram below). Please do not label any point on the outside edge of the grid. I did a sign change for my labels to orient the plane the way I expected it to be (left hand system vs right hand system). Such a change will require a reflection, of some sort, for objects you place in the plane.

The size of the gird is limited, but should be easy to change. The gird should be centered on the origin. In my case my gird was 200x200, so it extended from (-100,-100) to (100,100). We will replace this with a terrain object in the next iteration of this program. However, the replacement will be a modified grid as well.

You should provide a mechanism to allow your user to wander around in the plane. They should begin near the origin, looking at the origin. Using the four arrow keys, they should be able to move. Required movements are forward, backwards. In addition, the user should be able to turn to the left and to the right. The position the user is looking at is fixed, Look_Ahead units in front of the user. The user should have the ability to change Look_Ahead within a selected range (I used 3 to 20). As the user moves. the look at position should move. For example, if you are on (0,5) looking at (0,0), and you move one step forward, you should be at (0,-4) and looking at (0,-1).

To do this, I kept track of two positions, and an angle. I allowed my user to turn 5 degrees at a time in any direction. You should never allow your user to step off the end of the world. Each time my user moved, I added .5 to their position and to the look at position. I never let the user pass the edge. If they tried, I just ignored the keypress. I did allow them to look over the edge of the grid, but there is nothing there!

Please use the following keypresses
Key Action
Up ArrowMove forward a single step along the current vector
Down ArrowMove backward a single step along the current vector
Right ArrowTurn to the right
Left ArrowTurn to the left
AIncrease look ahead distance
aDecrease look ahead distance
rReset to the default position
qExit the program

You may add other keypress operations as well, but please:

Discussion

I would consider building a camera object. Build methods to:

I sprinkled a few teapots about the plane for something to look at. In the future we will add some additional objects.

I would use the font routines/objects developed in the previous assignment.

Submission

You should email tar file as an attachment to a message to danbennett360@gmail.com. This tar file should contain all of the source code required to generate your project, a Makefile, and the README file.