DEV Community

gagecantrelle
gagecantrelle

Posted on • Edited on

MINECRAFT-How does it work? (part 1)

As you know Minecraft is a popular sandbox game created by Markus Notch, a Swedish game programmer. It was created in 2009. Markus worked on this game until 2014, that's when the game was sold to Microsoft. Since then, Minecraft’s popularity grew over the years. Everyone who played this game wondered if there could be more. Later on, people began making mods for the game to make Minecraft more fun and interesting to play. You may be interested in making a mod for the game or even making a game similar to Minecraft. You might be wondering how does the code for Minecraft work? Let’s take a look at how you might code a fake version of Minecraft.

Before we start you should know the following

  1. This will not teach you how to make your own Minecraft game. It will help you figure out what you might need to do if you are planning to make a game like Minecraft.

  2. Know how to code on at least one low-level language. It’s possible to code in a higher-level language, it but won't perform good and may be difficult to code some concepts. Use C, C++, C#, Java, Rust, or some other low-level language

  3. Should be familiar with memory management.

First, we need to decide on what graphic API we will use, but you need to learn what is a graphic API? As you know an API acts like a key that can access data from other software’s. A graphic API dose the same but will render 3D models. If you want to learn how to use a graphic, I recommend OpenGL since it is a basic graphic API. Now let talk about making a window. You will need a window library and a function loader. To access OpenGL functions, you will also need a function loader to help your code know where to find these functions.

Image description

There is a function loader library to help with this process, for example the Glad library. After you pick your library, you would need to link it to your folder. Depending on if your using C or C++ you would need to compile a Glad source code manually. If your using java or C# you can just use a library to do it for you.

Once you have a window to use to render a game, you then need to set up a buffer to change our 2D world into the window to a 3D world. The buffer will help with mathematical calculations that will create a 3D game space. You can use some linear algebra to transform an object into a 2D image. This process is also known as rasterization. It then goes through a graphic pipeline process. There are six stages with two being optional, vector inputs, tessellation, geometry shader, primitive assembly, rasterization, and fragment shading.

Image description

Vertex Input
.Vertex data is data about 3D points that create a 3D object .contains metadata
.which texture is applied
.what color this point should be
.and other data you want to attach

.It then goes to a vertex shader
.mathematical calculations that change the vertices from world
space to 2D space

Image description

.The transformation is known as matrix math that take in 4
parameters
.vertex data
.transformation matrix
.transforms an objects local coordinate to world coordinates.
.It contains where our 3D object locations, rotations and
scale
.projection matrix
.how you would like to view the world on a 2D screen.
Image description

.view matrix
. what the camera is viewing in you game world
Image description

Tessellation (optional)
.Vertex data will break that data and make more vertices
.the new vertices will be located inside the origin vertices
Image description

Geometry shader (optional)
.dynamically add or remove primitives
.completely new geometry on the gpu.

.This is not typically used in real time application.
Image description

Primitive assembly
.Has three simplest objects or primitives that can be rasterize
.points, lines, and triangles

Image description
.Due to certain mathematical properties to make them easier to
work with
.used to make any other shape imaginable.
Image description
Image description

Rasterization
.Converts all the clipped primitives into fragments
.basically a pixel
.Fragments can contain more or less than one pixel
.You can think of this as adding texture

Fragment shading
.Coloring in every single fragment on the screen

For a lot of these processes you would need some help from a math library, to make it a bit easier to run your code. Here are some examples: Java JOML, C++ GLM, and C# OpenTK.

All information gathered for this blog are down below all images used for this blog are screen shot from the videos:
https://www.youtube.com/watch?v=HhH_9DnMBgw https://www.youtube.com/watch?v=ppGasKJ_-Wk https://www.ign.com/articles/the-history-and-evolution-of-minecraft https://www.youtube.com/watch?v=N7kyXkK2E5s

Also this was created for an assignment.

Top comments (1)

Collapse
 
tomhard84 profile image
tomhard84

Thank you for sharing this information with us MCPECUBE