For this school project, I worked on expanding a minimalist C++ game engine, implementing core features such as 3D rendering, physics, gameplay mechanics, and procedural generation. The goal was to develop a voxel-based world—similar to Minecraft—while addressing challenges related to performance, scene management, and player interaction.
Key Features
Chunk Management & Optimization
Implemented chunk-based world rendering to optimize memory usage and performance.
Used Vertex Buffer Objects (VBOs) to efficiently render large voxel landscapes.
Developed a system to dynamically load and unload chunks based on player position.
for (int x = 0; x < MAT_SIZE_CUBES; x++) for (int y = 0; y < MAT_SIZE_CUBES; y++) for (int z = 0; z < MAT_HEIGHT_CUBES; z++) { Perlin.DoPenaltyMiddle = true; Perlin.setFreq(0.04f); float val = Perlin.sample((float)x, (float)y, (float)z); Perlin.DoPenaltyMiddle = false; Perlin.setFreq(0.2f); val -= (1.0f - max(val, Perlin.sample((float)x, (float)y, (float)z))) / 20.0f;
MCube* cube = getCube(x, y, z);
if (val > 0.5f) cube->setType(MCube::CUBE_HERBE); if (val > 0.51f) cube->setType(MCube::CUBE_TERRE); if (val > 0.55) cube->setType(MCube::CUBE_SABLE_01); if (val < 0.5 && z <= 0.1) cube->setType(MCube::CUBE_EAU); if (val > 0.48f && val < 0.5f && z <= 0.1) cube->setType(MCube::CUBE_SABLE_01); if (val > 0.56) cube->setType(MCube::CUBE_EAU); } }
Camera & Player Controls
Developed a first-person camera system with smooth movement and rotation.
Integrated player controls for seamless navigation through the voxel environment.
Implemented mouse look for intuitive camera control and keyboard input for movement.
if (avance) Force += camDirection * PlayerSpeed; // Move forward if (recule) Force -= camDirection * PlayerSpeed; // Move backward if (gauche) Force -= Cam->RightVec * PlayerSpeed; // Strafe left if (droite) Force += Cam->RightVec * PlayerSpeed; // Strafe right
if (Jump && Standing) { Jump = false; Force += YVec3f(0, 0, 5000); // Jump }
Created a day-night cycle, with sun and moon movement changing dynamically over time.
night-day-cycle
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17
voidupdateLights(float boostTime = 0){ // Calcul de la direction du soleil en fonction de l'heure bool nuit = getSunDirFromDayTime(SunDirection, 6.0f * 60.0f, 19.0f * 60.0f, boostTime); SunPosition = Renderer->Camera->Position + SunDirection * 500.0f;
// Définition des couleurs en fonction du jour ou de la nuit if (!nuit) { SunColor = YColor(1.0f, 1.0f, 0.8f, 1.0f); // Couleur du jour SkyColor = YColor(0.0f, 181.f / 255.f, 221.f / 255.f, 1.0f); // Ciel bleu } else { SunColor = YColor(1, 1, 1, 1); // Lune blanche SkyColor = YColor(0, 0, 0, 1); // Ciel noir }
// Application de la couleur de fond Renderer->setBackgroundColor(SkyColor); }