Files
m4kc/README.md
T

85 lines
3.8 KiB
Markdown
Raw Normal View History

2021-05-07 23:34:55 -04:00
# M4KC
2021-05-07 23:44:27 -04:00
![Grass block icon](icons/icon.png)
2021-05-07 23:44:27 -04:00
2021-05-07 23:38:47 -04:00
*Minecraft 4K - C Rewrite*
2021-05-07 23:34:55 -04:00
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](https://en.wikipedia.org/wiki/Java_4K_Game_Programming_Contest), where each submission had to be under 4 kilobytes in size. Its wiki page can be found [here](https://minecraft.fandom.com/wiki/Minecraft_4k).
Being so small, the game proved somewhat easy to de-compile and edit. [Multiple people have given this a go, including me](https://www.minecraftforum.net/forums/mapping-and-modding-java-edition/minecraft-mods/1290821-minecraft-4k-improved-by-crunchycat-download-now).
This project is an attempt to translate the game into C in order to increase its performance, and to provide a platform upon which to add new features.
2021-05-12 15:27:15 -04:00
## Some goals for this project
2021-05-07 23:34:55 -04:00
2021-05-12 15:27:15 -04:00
* Maintaining the original look and feel as closely as possible. ✅️
* Keeping the final executable under 20 KB (on Linux, with the system I have set up in `build.sh`) ✅️
2021-05-12 15:27:15 -04:00
* More blocks 🏗️
* Perlin noise terrain generation ✅️
* Water ✅️
* Biomes 🏗️
* Caves ✅️
* Infinite worlds, horizontally and vertically too 🏗️
2021-05-12 15:27:15 -04:00
* Mobs and multiplayer (this would require changing the rendering engine to some degree) 🏗️
* Day/night ✅️
*✅️ - got that!*
*🏗️ - not yet...*
2021-05-07 23:34:55 -04:00
2021-05-07 23:48:22 -04:00
## Dependencies
2021-05-07 23:34:55 -04:00
2021-05-07 23:38:47 -04:00
### Bare minimum to make this code run
2025-03-24 09:40:41 +01:00
* KolibriOS [GCC Toolchain](https://git.kolibrios.org/Egor00f/kolibrios-gcc-toolchain)
* KolibriOS [SDK Folder](https://git.kolibrios.org/KolibriOS/kolibrios/src/branch/main/contrib)
* KolibriOS [SDL2 Library](https://git.kolibrios.org/KolibriOS/SDL2)
## Build instructions
2025-03-24 09:40:41 +01:00
1. Put SDL2 soruce code inside your SDK folder, like this:
```text
/contrib/sdk/sources/SDL2
```
2025-03-24 09:40:41 +01:00
2. Run `make` inside this folder, to build SDL2 for KolibriOS
3. Put M4KC source code into your SDK folder, like this:
2025-03-24 09:40:41 +01:00
```text
/contrib/sdk/sources/m4kc
```
2025-03-24 09:40:41 +01:00
4. Build it using provided xmake.lua:
2021-05-07 23:34:55 -04:00
2025-03-24 09:40:41 +01:00
```text
xmake build m4kc-kolibri
```
Or use your preferred build system.
2021-05-12 15:27:15 -04:00
## FAQ
I've either been asked these, or I expect to be at some point.
> What's with the cryptic variable names like `f22` and `i6`?
2022-07-17 19:17:18 -04:00
A lot of this code is decompiled from the original java version, and those are names the decompiler assigned to the variables. Much of the code is extremely obfuscated due to what are probably compiler optimizations, and some variables have not been deciphered and renamed yet. This is why they mostly appear in the `gameLoop` function.
2021-05-12 15:27:15 -04:00
> Why is it so slow?
The game uses a 3D voxel raycaster to render things, which is a lot slower than more traditional methods of rendering. Luckily, C provides more powerful ways to optimize something like this than Java - and optimizations will keep coming.
2022-04-14 01:03:46 -04:00
2022-05-08 01:42:46 -04:00
> Will you add in \_\_\_\_\_ from Minecraft?
I plan to port over a lot of user interface features, controls, and gameplay mechanics from the official game. However, this game will be taken in its own direction content-wise. For example, crafting will be a part of the game eventually, but creepers will not. New features will be added if they fit with the aesthetic and feel of the game, and make sense from a technichal and gameplay perspective.
2025-03-24 09:40:41 +01:00
> Where does it put saves in KolibriOS
Game will save it's data into same folder as executable, if placed on disk with write support. Otherwise, all data will be saved into `/tmp0/1/m4kc`.
2022-04-14 01:03:46 -04:00
## Screenshots
What this actually looks like.
2025-03-24 09:40:41 +01:00
<img alt="Main menu" src="screenshots/0.png" width="49.8%"> <img alt="Cool house" src="screenshots/1.bmp" width="49.8%">
<img alt="World selection" src="screenshots/2.png" width="49.8%"> <img alt="Rolling hills" src="screenshots/3.bmp" width="49.8%">
<img alt="A beach" src="screenshots/4.bmp" width="49.8%">