- WASD for movement
- E to open Inventory
- ESC to close
- Hold left click to break block
- Right click to interact/place block
- Everything else like Minecraft
- Cross-Platorm π»π±: MacOS, Linux, Windows, Web, Android and IOS all supported!
- Performant π: Uses C++, the game runs smoothly even on browsers. (700+ FPS on a 11 year old laptop!)
- Multilingual π: Unicode and Locale support build in. (No more οΏ½!)
- Modern β¨: Uses Modern C++23 features and follows best practices. SDL3 used!
- Extendable π§©: The Game Engine uses the ECS arcitecture. Extend easily by adding stuff to
src/registers.cpp
! - Debuggable π: Custom asserts and Debug menu helps you identify any bugs π!
- Custom Saves π: Easily save any data on any platform you want in a json file, the game engine will manage it for you!
- Crafting UI: UI for any type of menu you want!
- Audio π’: Easily integrate audio into the game
- Minimal dependencies: Only SDL3 Needed!
Minecraft Features:
- Walking
- Breaking
- Inventory
- Placing
- Crafting
- Smelting
- Break levels
- Loot table
- Audio
This game engine uses the Entity-Component-System architecture, implemented using Scenes
and sparse_sets
.
Entities are just UUIDs.
Components are just plain old structs.
The systems manage all the logic and changes the components.
Dependencies:
- SDL3
Compile SDL3:
$ git clone --depth 1 https://github.com/libsdl-org/SDL.git
$ cd SDL
$ mkdir build && cd build
$ cmake ..
$ cmake --build .
$ sudo cmake --install .
Compile project:
$ git clone --depth 1 https://github.com/cheyao/2d-minecraft.git
$ cd 2d-minecraft
$ mkdir build && cd build
$ cmake ..
$ cmake --build .
For Linux:
$ ./OpenGL
For MacOS:
$ mv OpenGL.app /Applications/
$ open /Applications/OpenGL.app # Or just openg the app
Same, use cmake to build project
MacOS Dependencies:
$ brew install --cask android-platform-tools android-ndk temurin@17
$ brew install cmake
Add these to your .zshrc
(Change it to the appropriate folders on linux):
$ export ANDROID_NDK_HOME="/usr/local/share/android-ndk"
$ export JAVA_HOME=`/usr/libexec/java_home -v 17` # Yes, you __must__ use java 17, blame android
$ export ANDROID_HOME="/usr/local/share/android-commandlinetools/"
Configure your gradlew's credentials (I'm not gonna let you use mine duh)
File: ~/.gradle/gradle.properties
RELEASE_STORE_FILE=[KEYSTORE PATH RELATIVE FROM ./android]
RELEASE_STORE_PASSWORD=[KEYSTORE PASSWORD]
RELEASE_KEY_ALIAS=[KEY NAME]
RELEASE_KEY_PASSWORD=[KEY PASSWORD]
Now build the project:
$ git clone --depth 1 https://github.com/cheyao/2d-minecraft.git
$ cd 2d-minecraft
$ git submodule update --init --recursive
$ mkdir build && cd build
$ cmake -DCMAKE_BUILD_TYPE=Release \
-DANDROID=ON \
..
$ cmake --build .
Now there is the apk in the folder
Install emsdk to ~/emsdk
On arch just run sudo pacman -S emscripten
Build SDL3:
$ source ~/emsdk/emsdk_env.sh # Only on MacOS
$ git clone --depth 1 https://github.com/libsdl-org/SDL.git
$ cd SDL
$ mkdir build && cd build
$ emcmake cmake ..
$ cmake --build .
$ cmake --install .
Build the project:
$ git clone --depth 1 https://github.com/cheyao/2d-minecraft.git
$ cd 2d-minecraft
$ mkdir build && cd build
$ emcmake cmake -DCMAKE_BUILD_TYPE=Release ..
$ emcmake cmake --build .
$ python3 -m http.server
If you get the error emcc: error: unable to create cache directory "{cachdir}"
run the build command with sudo
Currently the web build fetches the resources on demand
There are scripts in the cmake folder:
cmake
βββ distribute-linux.sh
βββ getdll32.sh
βββ getdll64.sh
βββ index.html.in
βββ info.plist.in
βββ mac-patch-dylib.sh
βββ sign-apk.sh
./cmake/distribute-linux.sh
For patching the executable then copying the dlibs intolibs
folder, should be enough to patch for linux release./cmake/mac-patch-dylib.sh
Same but for mac, only works for bundled macos app./cmake/index.html.in
Is the Emscripten idex./cmake/sign-apk.sh
Is to sign the android apk
The assets should be bundled automatically with android and macos, on other platforms you must distribute with the assets (that are copied into the project folder)
assets
βββ fonts
βββ models
βββ shaders
βββ textures
βββ ui
./assets/fonts/
Fonts./assets/models/
3D models./assets/shaders/
shaders./assets/textures/
Textures, the models will look here for the corresponding textures./assets/textures/ui
Textures for the UI./assets/strings.csv
Source loc csv file (See here for language codes)./assets/strings.json
Output loc file (to be generated)
The linux save directory is ~/.local/share/cyao/opengl/
-
In-game metrics & ms count
- ImGUI Menu
-
Live edit shaders in-game
-
Fix MacOS bundle process https://github.com/libsdl-org/SDL/blob/main/docs/README-macos.md
-
Game pause + resume things
-
Debug menu with ImGUI and item names
-
Better component and actors
-
UI Scaling
-
Multitouch
-
Collision resolver
-
Scaling
-
Save state
-
Android build
- Android controls
-
Debug menu
- Collision area editor
- Signal list
- Velocity arrows
- Component and entity list
- Real time component and entity addition
-
UI
- Embed text in buttons
-
Pause menu etc
- Text
- Settings
-
Localization
- Fallback fonts.
-
Emscripten build
- Progress bar
- Text with contrast
-
TTF
- Button auto scale + text
- Generate texturemap
- Signed distance field fonts https://steamcdn-a.akamaihd.net/apps/valve/2007/SIGGRAPH2007_AlphaTestedMagnification.pdf
-
Windows build
-
Level map
- Level generator
- Thing
- Binary json (MessagePack)
- Move scenes to
src/scenes
-
Grid map
-
Add functional hot reload
-
Entity name saved
-
Combine localemanager and textmanager
-
Shadows
-
Multithreading
- Preload
-
Read books (By priority)
No AI used, the prs from https://github.com/cheyao/opengl/pulls?q=is%3Apr+is%3Aclosed included some, but they included some fucking bugs and I had to rewrite everything.
Plus I'm smarter then AI! My implementation of sparse set caching shaved out 700000ns of runtime while the ai version shaved only 400000ns!
NOT AN OFFICIAL MINECRAFT SPINOFF. NOT APPROVED BY OR ASSOCIATED WITH MOJANG OR MICROSOFT