I tried coding Minecraft from scratch
Here's my attempt at programming a Minecraft clone from scratch with C and OpenGL in 1 week after studying game dev for a few months. During the creation of this video, my SSD died and some of the footage was lost. :( Link to the source code: https://github.com/c6dy/minecraft-c I started off by creating a simple window. I didn't feel like using the X11 API to make one, so I ended up just using the GLFW library. The library not only handles window creation, but makes input handling really easy too. After writing all of the necessary OpenGL code for dealing with shaders, buffer objects, and creating a 3D camera, I was able to render a single cube. I tried and failed to create my own pixel art for textures, so, in a galaxy-brain move, I decided to just pixelate images of grass and dirt that I found online. The result wasn't perfect, but it was definitely better than anything I could come up with on my own. While trying to render chunks by drawing each cube individually, my computer nearly exploded, so I needed to come up with a better solution. I decided to try using OpenGL's instanced rendering function, but in the end, that didn't perform well either and I was limited to ~650,000 cubes. After doing a little research, I found out that the faces that can't be seen by the player shouldn't be drawn. After I had that implemented, I was running at a smooth 60 FPS. I used a popular library called FastNoiseLite to generate perlin noise. I didn't really know what I was doing and I just messed around with configuration values until I got something that looked decent. If I had done some more research on this, perhaps I could have gotten something that looks a lot more like the real Minecraft. Infinite world generation was pretty easy to implement, but the way I implemented it does have one major flaw. While the world is technically infinite, the memory used by the chunks that get "removed" when you move further away from them isn't handled correctly, so basically the world is only infinite until you run out of memory. oops. This is my first attempt at creating a voxel engine and I ended up using some weird hashmap implementation that I found on GitHub that really hindered performance with larger worlds. If I were to spend more time on this, I could probably create something that's much more performant. I also would have liked to add things like clouds, lighting, and transparent water, but I ended up running out of time. #gamedev #programming #coding
Download
0 formatsNo download links available.