Skip to content

fivekoi/SaltyGameEngine

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

429 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Salty Game Engine

A lightweight 2D C++ game engine, developed for the creation of browser games.

SaltyDemo Scene Demo above uses assets from:

Sample Games

  • 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

Features

  • 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.

Scripting Example

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.

script

Installation Guide

Follow these steps to get a local copy of the engine up and running on Windows.

Prerequisites

  • 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\bin to PATH
      • The following should now work in a new cmd
      g++ --version
      
  • Emscripten
    # 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:\emsdk and C:\emsdk\upstream\emscripten to PATH
    • The following should now work in a new cmd
    em++ --version
    

Installation

TODO: create a releases page, the build folder contains everything needed to run the engine.

Style Guide

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.

About

Lightweight 2D C++ game engine, created for browser game development.

Resources

Stars

Watchers

Forks

Contributors

Languages