Getting Started
Requirements
Create a project
The easiest start is the Bare Template.
Option 1: use the template on GitHub
- On the template page, click Use this template and create your repo.
- 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 devOption 2: download the ZIP
- On the template page, click Code → Download ZIP and unzip it.
- Open a terminal in the unzipped folder.
- Run
npm install, thennpm 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 withGameas the first scene. It takes options as a second argument, like a background color or a fixed resolution. See Configuration.- Passing
settingsData.jsontosupergives 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.
bareis a global supplied by the engine. It's a shorthand forthis.scenehere. See The bare Object.
Example: this is src/game.ts in the template.
Scripts
| Command | What it does |
|---|---|
npm run dev | Start the dev server with hot reload |
npm run build | Production build into dist/ |
npm run build-zip | Build and zip dist/ into dist.zip |
npm run analyze | Inspect what ends up in the bundle |
Next steps
- Follow Build Your First Game to move a character, swap its image, and test a production build.
- Install the Chrome extension to inspect and edit your game while it runs.
- Read Project Structure to learn where things go.
- Explore the Showcase and the example games: Platformer, Shmup.