CPE 471 Final Project, Spring 2009

By: Canh Sy

Description

This project is a 3D platform game where the user controls a character to move around the world and to collect coins scattered throughout the world. The camera will follow the character around and acts like a third person view. Any camera movement or rotation would be centered around the character.

Design

The user can control the character in the world by pressing the 'w', 'a', 's', and 'd' buttons. The character can move forward and backward and rotate itself. The character also have an ability to jump by pressing SPACEBAR.

The camera is always looking at the character to make it look like a third person view. The camera is controlled by the mouse buttons, where a left-click rotates and right-click zooms.

The world consists of hierarchal models of trees and houses, with each model texture mapped. Inside the world, there are ghosts flying around the world to slowdown the character. When the ghost touches the character, the character would slowdown and the movement speed will gradually increase to its normal speed. Coins are also scattered around the world. Once a coin is collected, a message will appear in the terminal to keep track of coins collected and remaining.

The character is made up of opengl and glu primitives in a hierarchal design. Animation is incorporated as the character walk and jump.

Collision detection is incorporated in the game. The idea of the collision detection is based on the sphere to plane collision. Planes are set up in the beginning of the game for the walls and the houses. As the game runs, collision is tested everytime the display function is called. Once a collision to the plane occurs, another function is called to detect if the collision is between the boundaries of the walls and houses. This is accomplished by setting up a bounding box with the min and max of the x, y, and z coordinates. When a collision of the wall or house occurs, the character would not be able to move in the direction of the collision.

When all the coins are collected, the user will be free to roam around the world. A message will appear in the terminal to inform the user if they would like to play the game again. If the user decides to play again, the coins will appear at their same location again, only this time the character will remain at its place.

Keyboard Controls

  • 'w' or 'W' : move character forward
  • 's' or 'S' : move character backward
  • 'a' or 'A' : rotate character left
  • 'd' or 'D' : rotate character right
  • SPACEBAR : jump
  • 'p' or 'P' : play game again (only available after completion of game)
  • 'q' or 'Q' : quit game
  • Mouse Controls

  • left click : rotates camera around the character
  • right click : zoom in or out
  • ScreenShots

    Beginning of game:

    Visiting the temple:

    Jumping:

    In the back alley:

    References

    CG Textures

    Mayang's Free Texture Library

    Basic Collision Detection

    Collision Boxes

    Swiftless' Game Programming Site

    NeHe Productions