For those who don't know, Minecraft 4K was a stripped down version of Minecraft submitted by Notch to the Java 4K Game Programming Contest, where each submission had to be under 4 kilobytes in size. Its wiki page can be found here.
Some things I realized while working with the game's cryptic code:
It uses a 3D voxel raycaster
Textures are generated with an algorithm
Due to the 4 KB size constraint, the code is very inefficient.
I thought I could improve the performance of the code, and create a platform for improving upon it if I rewrote it in C, using SDL as a graphics library. C offers far more low level capabilities than java does, which lends itself to far better performance and efficiency. Fortunately, Java has very similar syntax to C and I was able to straight up copy and paste large chunks of code (albeit with heavy edits and debugging).
Some things I've managed to improve:
Movement controls now work properly.
Less system resource usage.
Some bugs I'm still trying to work out:
"Sticky" block collision - this behavior is present in the original version and I have been trying to work out ways to fix it for a while.
Block outline cuts off at mouse x position.
Goals for this project:
Maintaining the original look and feel as closely as possible.
Keeping the final executable under 10 KB (on Linux, with the system I have set up in the makefile)
Mobs and multiplayer (this would require changing the rendering engine to some degree)
Day/night??? I don't know whether or not this would change the look or feel too much.
This program has been successfully compiled many times on my Pop OS machine with gcc, strip, gzexe, and SDL2. I may look into producing windows specific binaries in the future, but for now the code should compile on windows as is as long as you have SDL2 installed.
Version 0.2 posted, download links have been updated.
Changes:
Placing and breaking blocks now works
Classic style terrain generation has been fixed
The game can now generate either the original terrain, or new perlin noise terrain using an algorithm I found here. It is possible to get the old terrain by changing line 53 to be genMap(SEED, 0, world);
I am eventually going to make some sort of in game option to pick which terrain style to generate.
This is quite impressive and glad to see libSDL getting some love. Use to code for that way back in the early 00's. If one really wants to get some decent performance then look into using opengl with SDL.
I made some caves by reusing the perlin noise function with an offset seed. The generation function places a 3 block tall pillar of air on a 2D plane at around y=60 wherever the perlin noise function returns a number from 0.47 to 0.53. The perlin noise function is again run with another offset seed to determine the height offset of each pillar. If the cave generates above ground, exposed dirt is replaced by grass. The result is some nice looking caves:
For those who don't know, Minecraft 4K was a stripped down version of Minecraft submitted by Notch to the Java 4K Game Programming Contest, where each submission had to be under 4 kilobytes in size. Its wiki page can be found here.
Being so small, the game proved somewhat easy to de-compile and edit. Multiple people have given this a go, including me.
Some things I realized while working with the game's cryptic code:
I thought I could improve the performance of the code, and create a platform for improving upon it if I rewrote it in C, using SDL as a graphics library. C offers far more low level capabilities than java does, which lends itself to far better performance and efficiency. Fortunately, Java has very similar syntax to C and I was able to straight up copy and paste large chunks of code (albeit with heavy edits and debugging).
Some things I've managed to improve:
Some bugs I'm still trying to work out:
Goals for this project:
This program has been successfully compiled many times on my Pop OS machine with gcc, strip, gzexe, and SDL2. I may look into producing windows specific binaries in the future, but for now the code should compile on windows as is as long as you have SDL2 installed.
I'm open to suggestions, tips, etc.
Currently at version 0.2
Downloads:
You can run make run to run the program, or make install to install it.
I've also made a Github repo
Version 0.2 posted, download links have been updated.
Changes:
The game can now generate either the original terrain, or new perlin noise terrain using an algorithm I found here. It is possible to get the old terrain by changing line 53 to be genMap(SEED, 0, world);
I am eventually going to make some sort of in game option to pick which terrain style to generate.
Attached below is a screenshot of new terrain.
Made a repo on github:
https://github.com/sashakoshka/m4kc
Version 0.3 posted, download links have been updated.
Changes:
...while still being under 10 kilobytes!
Nice
very excited with this thread
This is quite impressive and glad to see libSDL getting some love. Use to code for that way back in the early 00's. If one really wants to get some decent performance then look into using opengl with SDL.
https://www.libsdl.org/release/SDL-1.2.15/docs/html/guidevideoopengl.html
Semester has ended so i can work on this again. I'm refactoring the codebase because as of right now its a complete mess.
I made some caves by reusing the perlin noise function with an offset seed. The generation function places a 3 block tall pillar of air on a 2D plane at around y=60 wherever the perlin noise function returns a number from 0.47 to 0.53. The perlin noise function is again run with another offset seed to determine the height offset of each pillar. If the cave generates above ground, exposed dirt is replaced by grass. The result is some nice looking caves:
What amount of memory does this take up? Is it still close to 4 kilobytes?
Also anybody ever made a discord for this project would make updates and communication for it easier?