OpenGL FPS


Overview:

The project is a basic first-person shooter game developed as a final project for my Graphics Libraries course. Set in a procedurally generated city, the player must defend itself against cactuses. The game was developed using C++, OpenGL, and a top-down/manager style architecture.

  • Team of 2
  • SDL2/OpenGL
  • Procedural Generation
  • UV Mapping
  • Cube collision
  • Top-Down architecture
  • Manager architecture
  • CMake

Completion: March 2023

Duration: 1 week

Platform: C++/SDL2/OpenGL

See project on Github

Contribution:

first-person camera

I worked on implementing the first-person camera system for our game using OpenGL and SDL. This involved setting up the camera's position and movement based on player input. Additionally, I was responsible for implementing the player's movement and input systems to ensure a smooth and immersive player experience.

game mechanics

I developed many core mechanics of the game. I implemented a life system in the game, giving lives to the player, when he is out of lives the game is over. I developed a score system to calculate the points made by killing cactuses. I also developed the scope allowing the player to aim.

Text Generation Tool & HUD

As we were using SDL2 in conjunction with OpenGL, we faced an issue with displaying text because SDL and OpenGL render textures in different directions. To solve this problem, I developed a simple text printing tool that involved loading an image containing all the characters with equal spacing. I created a function that takes in a string of text to display and returns an array of the required character images for that text. We used this system to display the score in the game's UI. This allowed us to efficiently display text without any issues arising from the different rendering directions of SDL and OpenGL.

Using the text tool, I implemented some world space UI for our game for the player to be informed about his stats. The number of lives and score of the player is show on screen. The UI is placed in the world and position in the camera's side using matrix transformations

uv mapping tool & procedurally generated city

In order to expedite the process of creating new objects for our game, I implemented a UV mapping system that automatically generates cubes and applies textures to them. This proved to be a highly efficient method for creating various elements in our game, such as grass, buildings, fences, and the skybox.

To provide a unique experience for players in each game, we implemented procedural generation for the city in our game. The system takes in parameters such as the size of the city and the number of buildings and cactuses to place within it. It generates the grass and walls, and then procedurally places the buildings and cactuses to ensure they do not overlap. This allows for a different layout of the city each time the game is played, adding to the game's replayability.

Cube collision detection

I worked on implementing cube collision detection using the AABB method to prevent the player from exiting the map or going through buildings. This involved the bounding boxes of the player and objects in the game world, and checking for intersections between them. I also applied this collision detection system to the bullets in the game, to detect when they hit the player or cactuses. This helped to ensure a smoother and more realistic gameplay experience, as well as preventing any unintended actions from occurring.


closing thougths:

In conclusion, the development of this first-person shooter game project was a challenging yet rewarding experience. By utilizing C++, OpenGL, and a top-down/manager style architecture, we were able to create a dynamic and immersive gameplay environment set in a procedurally generated city. The implementation of features such as the first-person camera, UV mapping tool, text generation tool, game mechanics, in-game UI, and cube collision detection added depth and functionality to the game. The one-week development duration pushed us to work efficiently and make the most of our resources. Overall, it was a valuable opportunity to apply our knowledge of graphics libraries and showcase our programming skills, resulting in an engaging and enjoyable game project.