Skip to content

Getting Started ​

Requirements ​

Install Node.js and Git.

Create a project ​

The easiest start is the Bare Template.

Option 1: use the template on GitHub

  1. On the template page, click Use this template and create your repo.
  2. Clone it and start the dev server:
sh
git clone https://github.com/YOUR-NAME/YOUR-REPO.git bare-game
cd bare-game
npm install
npm run dev

Option 2: download the ZIP

  1. On the template page, click Code → Download ZIP and unzip it.
  2. Open a terminal in the unzipped folder.
  3. Run npm install, then npm run dev.

Ctrl-click the localhost URL shown in the terminal to open your game.

You should see a rotating gear. Keep the terminal running while you edit; saving src/game.ts restarts the game through Vite's hot reload.

Your first scene ​

The template's src/game.ts looks like this:

ts
import { GameObject, Scene, StartBare } from 'bare-engine';
import settingsDataJson from '../public/data/settingsData.json';

export class Game extends Scene
{
    obj: GameObject;

    constructor()
    {
        super(settingsDataJson);
    }

    OnStart()
    {
        this.obj = this.AddGameObject('⚙')
            .SetPosition(bare.width * .5, bare.height * .5)
            .CenterPivot();
    }

    OnFixedUpdate()
    {
        this.obj.rotation++;
    }
}

StartBare(Game);
  • StartBare(Game) boots the engine with Game as the first scene. It takes options as a second argument, like a background color or a fixed resolution. See Configuration.
  • Passing settingsData.json to super gives the scene your prefabs and other game data.
  • AddGameObject('⚙') resolves '⚙' to a prefab or image and adds a GameObject to the scene.
  • Rotation is in degrees, so the gear turns one degree per fixed update.
  • bare is a global supplied by the engine. It's a shorthand for this.scene here. See The bare Object.

Example: this is src/game.ts in the template.

Scripts ​

CommandWhat it does
npm run devStart the dev server with hot reload
npm run buildProduction build into dist/
npm run build-zipBuild and zip dist/ into dist.zip
npm run analyzeInspect what ends up in the bundle

Next steps ​

Bare Engine is open source under the MIT license.