CS314 Project 4, by Wai-Hin Wayne Ngan SharpShooter (for Windows) In a few minutes, you will be inside a target range. You can walk around and challenge different stages by stepping into the blue circle in front of each stage. When you step into the circle, you'll receive a brief description of what you are given and your objective. As soon as you understand the objective, start shooting! Controls to walk around: mouse - look w - walk forward s - walk backward a - move left (strafe) d - move right (strafe) ESC - quit Controls to shoot: mouse - aim left click - shoot right click - exit stage r - reload How to play: For each stage, the general objective is to shoot down all the targets before running out of ammo (also with a time constraint in the "hard" level). How to beat the game: You... can't. You're free to shoot until you get bored. Still, you pretty much beat the game if you can finish "hard", since the other levels would be pretty meaningless if you manage to finish "hard". Advacned functionalities implemented: -First person navigation (forward/backward/strafe/pitch/yaw) -First person collision detection against walls, with tangential movements upon collision -Simulated dynamics: Target fragments fly off in parabolic trajectories. Each fragment rotates about a random axis and bounces against floors and walls. Known Issues: -If you shoot too fast, sometimes you might end up in the ceiling or stuck in some weird place. Please refrain from doing that. You won't win just by wasting all your ammo ;) ------------------------------------------------------------------------------------- Objects Hierarchy: Stage -Gun -Targets[] -TargetFragments[] StageEasy : Stage StageMedium : Stage StageHard : Stage Arrays: -Textures -Bounds of current area -Number of Targets in each stage -4 fragments in each Target Enumerated variables: -Current stage (WALK, EASY, MEDIUM, HARD) -Status of current stage (INTRO, BEGAN, CLEARED, FAILED) ------------------------------------------------------------------------------------- Low Level Mechanics: Keyboard Movements: Each a/s/w/d key has a boolean variable associated with it. When a key is pressed, the variable is flipped to true (when released, it's flipped to false). The idle function monitors each variable to see whether the camera should move. Collision Detection: The entire environment is sliced up into 8 areas. Each area has its own set of bounds (stored in an array of size 8). After deciding which area we are currently in, we can use the area information to access, in O(1) time, the set of bounds in the array that surrounds the current area. This is much more efficient than simply checking against the player's position against every single wall. Navigation: Relative transformation is done similar to that in Projects 2 and 3. All translation and rotations are done prior to applying the viewing transformation. SetCursorPos() is used to lock the mouse position so that you can turn your head in any direction by any amount. (Since SetCursorPos a Windows API, the game is Windows only.) Shooting (Picking): I used OpenGL's built-in implementation to implement picking. When you left click, the scene will be drawn in a small window centered on the screen (since your cursor is locked at the center of the screen). As the program deciphers what's being hit, it uses the depth information to decide what's closest, either a target or an obstacle. If an obstacle and a target are both being hit, and if the target is deeper than an obstacle, then the target is not hit. Timing in "Hard" level: We keep track of when we started, and how much time is elapsed since we began playing this stage. This can be done by clock(), which returns how much time elapsed since the program has been running, in the time.h library. If the time elapsed exceeds the time limit and there are still targets left, you lose. ------------------------------------------------------------------------------------- Sources: Tutorials: http://nehe.gamedev.net/data/lessons/lesson.asp?lesson=06 http://nehe.gamedev.net/data/lessons/lesson.asp?lesson=08 http://nehe.gamedev.net/data/lessons/lesson.asp?lesson=32 http://www.lighthouse3d.com/opengl/picking/ http://www.lighthouse3d.com/opengl/glut/index.php?strokefont The idea of a first person shooter (FPS) game, along with this particular set of controls, is inspired by an overwhelming amount of FPS games over the history. But the idea of a target range is inspired by a mission in Grand Theft Auto Vice City by Rockstar Games. Sound effects are from Half Life: Counter-Strike Special Thanks: Jackson Wong, for coming up with the name "SharpShooter"! Jonathan Lee, for committing numerous attempts to find bugs (by screwing my game up)