A lightweight 2D C++ game engine, developed for the creation of browser games.
Scene Demo above uses assets from:
- Feedback Loop - a game made for the 2025 GMTK Game Jam with the theme "Loop"
- Dino Run - a simple 2D sidescroller where you collect coins
- Browser Support: Compile and run your games on Windows and the Web.
- Modular Architecture: Easily extend or replace components (and renderer/asset manager) without modifying the core engine.
- Native Scripting System: Write game logic in C++ with custom scripting API.
- Memory-Efficient Audio: Supports multiple streaming sources with dynamic loading and unloading of audio to optimize memory usage.
Salty Engine has native C++ scripting, allowing for serialized (SF_) variables for convenient in-engine editing. An example script is shown below.
#pragma once
#include "SaltyEngine.h"
class PlayerMovement : public IScript {
private:
SF_ float speed;
SF_ Rigidbody* rb;
float jumpTimer = 0.0f;
SF_ Sound jumpSound;
public:
// Initialization will be handled by engine (including that of SF_ variables)
PlayerMovement(Entity* entity, Transform* transform, std::vector<SaltyType>& serializedVars);
void Start() override;
void Update(float dt) override;
};#include "PlayerMovement.h"
// Called before the first frame of Update()
void PlayerMovement::Start(){
Audio::Load(sound);
Camera::position = transform->position;
}
// Called every frame before Render()
void PlayerMovement::Update(float dt){
if(Input::KeyHeld[KEY_A]){
transform->position.x -= dt * speed;
}
if(Input::KeyHeld[KEY_D]){
transform->position.x += dt * speed;
}
Camera::position.x = transform->position.x;
jumpTimer -= dt;
if(Input::KeyDown[KEY_W] && jumpTimer <= 0){
jumpTimer = 1.0f;
rb->velocity.y = 3.0f;
Audio::Play(jumpSound);
}
}In-engine editing for example script above.
Follow these steps to get a local copy of the engine up and running on Windows.
- MinGW
- I use the MSYS2 distribution
- Make sure you run this command in the MSYS2 terminal to install gcc
pacman -S mingw-w64-ucrt-x86_64-gcc- And add
C:\msys64\ucrt64\binto PATH - The following should now work in a new cmd
g++ --version
- I use the MSYS2 distribution
- Emscripten
- Run the following commands (taken from emscripten.org)
# Get the emsdk repo git clone https://github.com/emscripten-core/emsdk.git # Enter that directory cd emsdk # Download and install the latest SDK tools. emsdk.bat install latest # Make the "latest" SDK "active" for the current user. (writes .emscripten file) emsdk.bat activate latest- Add
C:\emsdkandC:\emsdk\upstream\emscriptento PATH - The following should now work in a new cmd
em++ --version
TODO: create a releases page, the build folder contains everything needed to run the engine.
The style of Salty Game Engine mostly follows the Google C++ Style Guide with a few small additions (e.g. enums being prefixed by E).
You may find the (partially) full Salty Style Guide here.
