Driving Game (OpenGL4.0 & FMOD | C++)


Graphics

Task: Create a game that occurs on a non-linear path generated using splines.

The game is played using the arrow keys. Detailed controls in the Graphics Documentation linked below.

We were provided with 8 points that formed a circular line with the catmull-rom splines. I duplicated those, moved them to one side, and flipped them to create a "Figure-8" track commonly seen in many racing games.

To expand from just a single line, I duplicated the interpolated points and translated them along its TNB frame. Doing this many times resulted in the different textures and effects that happen when the vehicle reaches certain areas.

Instead of having the player follow the spline directly, I created a separate player class for a free moving player. This allows for a driving game instead of something similar to Crazy Taxi. If the vehicle gets on the grass, the max speed is reduced by 50%, and they "crash" when they hit the walls.

The tree positions were automatically generated. By checking its distance from the track, I can make sure it never goes onto the track itself.

I've used way too many lights for this game. Each lamp post has 2 spot lights, one pointing down and one up to illuminate the "bulb", totalling over 100 lights. These were passed to the shaders as an array using string manipulation a for loop.


Audio

Tasks:

  • Controllable FIR filter with circular buffer (Delay Line)
  • 3D Sound: Place a sound source in a 3D world that can be moved around, with distance roll-off and Doppler effect
  • Dynamic filter control

Detailed controls in the Audio Documentation linked below.

I created a circular buffer class that contains an array of floats, a "tail" value, and functions to insert and return values at "tail" position. Using this, I implemented a delay effect by having the adding the live value*0.7 to the delayed value*0.3, to make the delayed sound quieter than the live sound.

A song is played from the cube shown in the beginning. It can be moved around using the "IJKL" keys.

There is a base engine sound being played at a very low volume. As its pitch is shifted with speed, the volume gets increased with it. This is to compensate for the amplitude drop while pitch shifting upwards.