This assignment is worth 30 points.
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 Arrow | Move forward a single step along the current vector |
Down Arrow | Move backward a single step along the current vector |
Right Arrow | Turn to the right |
Left Arrow | Turn to the left |
A | Increase look ahead distance |
a | Decrease look ahead distance |
r | Reset to the default position |
q | Exit the program |
You may add other keypress operations as well, but please:
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.