Assignment 2
CIS 410/510 Game Development
Spring, 2008
-
This assignment will build upon the code you wrote for assignment 1.
-
Make TerrainDemo into a simple game by making the following changes (100 points total):
-
Create three (3) OGRE terrain script files to access new height maps and textures (see terrain.cfg from assignment 1 as an example) (10 points). You may use these height maps and textures. You may also create your own height maps, if you would like, using any image editing software. Images should be 513x513, grayscale, 8 bits per channel. You can also use a texture generator such as Terra Tex Gen (PC) to make nice looking terrain textures with shadow maps.
-
Create a Level class. The constructor should take an unsigned integer as an argument; values of 0, 1, and 2 should each load a unique terrain, sky box (you can use these), and fog settings. Llevel 1 should be created when the program is first run. Map the "F1" key such that the current level will be destroyed and the next Level created (i.e., level 1 deleted and level 2 created or level 3 deleted and level 1 created). Loading a Level should return the camera to a common starting location on the terrain. Make sure to include a destructor for the Level class that destroys all objects allocated from within the class (10 points).
-
Create an Enemy class. When created, each Enemy should create an Ogre SceneNode and Ogre Entity to add a sphere mesh to the scene at a random location on the terrain. When destroyed, the Enemy class should remove the sphere mesh from the scene and properly delete it (hint: the Ogre SceneManager handles creating and deleting of Ogre objects) (10 points). The Enemy class should have two private methods:
bool inRange(const Ogre::Vector3& position, float r) const : Returns true iff position is within r meters of the center of the sphere. This method can and should be written without using a square root operation (10 points).
void moveTowards(const Ogre::Vector3& position, float velocity, float elapsedTime) : Moves the center of the sphere along the terrain towards the position by an amount depending on velocity and elapsedTime (10 points).
-
Add a public method to the Enemy class to control behavior:
bool update(float elapsedTime) : Updates the Enemy's behavior each frame. Initially, the Enemy should check to see if it is within ACTIVATION_RADIUS meters of the camera (using the inRange method). If it is, it enters a chasing state and begins to follow the camera (using the moveTowards method) based on a CHASE_VELOCITY. The Enemy should change colors (i.e., change materials) when it changes state. While chasing, if an Enemy gets within KILL_RADIUS meters of the camera, this method will return false to indicate that the game has ended. After RELAX_TIME seconds of unsuccessfully chasing the camera, an Enemy will return to its initial state (unless the Enemy is within ACTIVATION_RADIUS of the camera at this time, in which case the Enemy will implicitly begin chasing the camera again). Adjust the ACTIVATION_RADIUS, CHASE_VELOCITY, KILL_RADIUS, and RELAX_TIME parameters to make the game enjoyable (30 points). It is not necessary for the 410 students to implement the State Pattern for this assignment, but think about how it would be applied. 510 students will implement the State Pattern.
-
Set up the Level class to create 100 Enemy objects for each level. The Level class should call each Enemy's update method each frame (you'll need to add update methods to Level and TerrainDemo as well). When an Enemy indicates that the game has ended, disable movement of the camera and enemies on the terrain, change the fog and/or background color, and wait for the user to press the "F1" key to start a new level (20 points).
-
This is an individual assignment; collaboration is allowed, but each student must type and submit their own code.
-
Zip your assignment2 directory and email it to "eric <at> cs <dot> uoregon <dot> edu" by 5 PM on Wednesday, 4/23. Please remove any intermediate files not necessary for compiling and running the application (i.e., a "Clean Solution" operation). Please include all source and header files.
copyright 2008, Eric David Wills, University of Oregon
back to main