OpenGL Endless Runner Game

Game

C++
OpenGL
OpenGL Endless Runner Game

About

This project is an endless runner game where the goal is to get as high of a score as possible while avoiding the vehicles on the road.

How was it built?

The game was built entirely using OpenGL and C++. Everything in the game is composed of either a cylinder, sphere, or cuboid, and each of these shapes are created using triangles.

Challenges faced

Since this project did not use a game engine, everything had to be coded by hand, and one of the challenges was figuring out collision detection. Without it, the main player's vehicle would go right through everything. My solution was to model each vehicle as a rectangle on the road, and that simplifies the problem from being 3D to being 2D. Then, to check if a collision has occurred, I would check if two rectanges from two vehicles overlap with each other.

Another challenge I had was figuring out how to display everything. Trying to instantiate one long road is impractical since the program would have to render all the objects, even if they are very far away. Instead, I use a finite number of road segments, including the fence, grass, and trees. Segments that go behind the camera respawn to the back of the viewable road.

One more challenge I faced was with keyboard inputs. While OpenGL include callback functions to handle them, they were not able to be integrated with the game. Instead, I created my own callback function to handle key presses.