Simple Miner
Overview
|
GoalsThe goal of this project is to replicate the basic features of Minecraft. In this project, players modify and interact a generated world using blocks. The changes to the world are stored in real time and can be loaded back when needed. All of this is done while still maintaining 60 frames per second.
|
Features
Perlin Noise Generated Terrain
This project uses Perlin Noise algorithm to generate a smooth, continuous terrain. Since Perlin Noise provides a non-repeating, and reproducible result, we can easily reproduce the same terrain by using the same initial parameters. The parameters can be stored and used as a seed to generate the same terrain later.
|
Data Save / Load
To ensure that the ‘save and load’ functionality executes smoothly during gameplay without affecting the frame rate, the system has to prioritize the tasks based on distance from the player, and only handle one chunk of data per frame. Each chunk is stored in binary format, applying run-length encoding (RLE) compression technique. Since the characteristics of the order of blocks in a chunk create long series of blocks of the same type, RLE works well for compressing the chunks.
|
Vertex Lighting
The lighting uses vertex color of each surface based on its light value. There are 16 light levels in this project. When a block is exposed to the sky, its light level will be equal to the current skylight level. The light level is reduced for the blocks that are not directly under skylight. These blocks have a light value one less than that of the brightest air block immediately next to it.
|
Voxel Ray Tracing
Since this project take place in a voxel world, a fast ray trace algorithm can be used. This project adapts the algorithm explained in the paper - "A Fast Voxel Traversal Algorithm for Ray Tracing" by John Amanatides and Andrew Woo. The camera fires a ray trace every frame in the facing direction. This ray trace checks the edge of each block it passes through. When the next block is solid, an outline is drawn on the block to indicate that the player can interact with it.
|
Code Snaps [Github Link]
-
TheGame.hpp
-
TheGame.cpp
-
Chunk.hpp
-
Chunk.cpp
<
>
Video Trailer
|