The player can walk around plane with trees and must defeat randomly spawning enemies by shooting at them. The trees spawn randomly and are newly generated as the user walks around. Trees that are too far away are unloaded.

Source Code on GitHub

Made in C++ with OpenGL using custom models and textures and a directional lighting system. I used GLFW for windowing and glad for openGL function loading, stb_image to import images, and assimp to deserialize wavefront models.

The game loads models and stores them in a model and mesh class. I first import the models with assimp then transfer the models and meshes into my classes.

I use a directional lighting system, where all models are lit from a single direction. This gives the textures more visiblity and looks a lot nicer than without lighting.

There is a skybox, which is a scaled sphere with a repeating cloud texture. To make the objects coming through the skybox look more natural I use a fog system, where colours are shifted towards the skybox blue colour depending on their distance from the camera.

The game generates chunks which contain a random number of trees with random offsets. The chunks generate as you move around the world. Chunks get deleted when you move too far away from them.

Enemies are spawned after a delay at a random direction from the player. They travel in the direction of the player, and when the enemy and player collide, the chunks are regenerated and all enemies and bullets are removed.

The player can shoot bullets which destroy enemies when they collide with them, the bullets are removed when they are too far away. When the bullets collide with the ground, their y-velocity is reflected.

ss1