Author: Glenn Olsson
This project aims to be a very minimal clone of the game Minecraft.
Simply put, the user can move around freely in the word, can place
blocks and remove blocks. The ground has collision detection and
going over the edge of the world or going through a hole created
by removing a ground block will make the player (the camera) move
downwards until it reaches a few blocks under the ground, when it
resets the camera above ground.
The collision detection in Y-plane is solved by using a 3D vector
with all the blocks in the world. At each render we check if there's
a block on (cam.x, cam.y - 1, cam.z)
. If not, we subtract
some height from the cameras y-value. When placing and removing blocks
the lookat_pt is used to determine where we want to remove/place a
block. A similar lookup is made in the 3D vector to determine which
block, if any, is at the location and update it/remove it.
There is a walking dummy in the scene who's fully green. The initial
intention was to make this a creeper but due to not finding a well
divided creeper .obj and with the limited time I had to work on the
project, I decided to use the dummy and make it fully green. The
dummy walks by both rotating the knee a bit, and the leg around the
bottom part of the dummy, and by pendeling its arms with the legs. It
moves in a simple bezier curve and I tried to have it face the way it
is walking in but was not able to make that fully functional. It has no
collision detection what so ever.
I used a custom data structure to keep track of all the blocks (called
Blocks
), including their position using the 3D vector.
Each block is also another data structure (called Block
)
which describes it material and handles each individual blocks texture.
A new block can easily be created by using Blocks
method
addBlock
which takes coordinates x, y, z
and
which material it is. This data structure also keeps provides methods
such as removeBlock
and drawBlocks
.
W - Move forward S - Move back D - Strafe right A - Strafe left SPACE - Place block Mouse click - Remove block Mouse scroll - Look around Q - Move light in +Z E - Move light in -Z