Play in your browser, here!
I made a custom engine on SDL2 for mostly 2d rendering (though 3d is supported, it just doesn't have much work put into it yet). This is a test of a few different systems:
- scenes
- menus
- text rendering
- general mesh rendering
- shader pipeline
- very simple serde
- sound effects
- sprite sheets/simple animation (working, not currently in use)
Features:
- rewind!
- replay files
- dynamic window scaling (native)
TODO:
- set replay filename (native)
- replay file safety checks
- replay format compression
Known issues:
- some rotational issues with tight spaces
- web scale canvas with window size
- web sound effects
- stb_image
- stb_truetype
- shader based on https://www.shadertoy.com/view/Ms3XWH
- DejaVuSansMono and Ubuntu fonts
- SDL2 / SDL_mixer
C++ (11) compiler, and:
pacman -Sy glew mesa sdl2
apt install libsdl2-dev libglew-dev
dnf install glew-devel SDL2-devel
make
build/main
# or
make run
depends on emscripten/emsdk
make wasm
# output in build/js/
-
Why do this?
Implementing an existing game is a great way to isolate the technical/mechanical details. The core creative side - game rules, etc., is already handled. Tetris has simple mechanics, but hides a lot of depth and nuance.
-
Why does your C++ look like this?
I really like C, and I'm not very experienced with C++. Mainly I end up writing C with some slight syntax adjustments, default parameters, and function overloading.
-
Why are you including
.cpp
files directly / using one big header file?I'm aware that this isn't the traditional structure of a C++ program. I chose to avoid creating many individual compilation units because a) it's less complex, and b) it compiles from scratch significantly faster - the best-case performance is probably slightly worse, but any potential build caching issues are off the table.
-
Why write engine code when you could be using ____ ?
I like making the tools that make the product. Being realistic with expectations, this functions as a great learning exercise!
-
Why can you rewind?! You can't rewind in tetris...
Why not! I wanted a simple replay system and as a side effect, game states can be played in reverse.
-
What is that sound that plays when you rewind?
That's the sound of your going-back-in-time potion
-
... can I turn it off?
If you must.