
If you are building a 2D game in AuraJS, keep the first version extremely small:
That is enough to prove your loop, input, rendering, and asset pipeline.
For a normal native 2D project, build around:
aura.setup for loading assetsaura.update(dt) for simulation and input handlingaura.draw() for aura.draw2d.*aura.storage for small save dataaura.audio for music and SFXKeep your first pass close to this:
assets/
player.png
jump.wav
ui/PressStart2P-Regular.ttf
src/
main.js
aura.config.json
let x = 240;
let y = 160;
let speed = 220;
let playerSprite = null;
let uiFont = null;
aura.setup = function () {
playerSprite = aura.assets.load('player.png');
aura.assets.load('jump.wav');
const fontResult = aura.assets.loadFont('ui/PressStart2P-Regular.ttf');
if (fontResult.ok) {
uiFont = fontResult.font;
}
};
aura.update = function (dt) {
if (aura.input.isKeyDown('arrowleft')) x -= speed * dt;
if (aura.input.isKeyDown('arrowright')) x += speed * dt;
if (aura.input.isKeyDown('arrowup')) y -= speed * dt;
if (aura.input.isKeyDown('arrowdown')) y += speed * dt;
if (aura.input.isKeyPressed('space')) {
aura.audio.play('jump.wav', { volume: 0.8, bus: 'sfx' });
}
};
aura.draw = function () {
aura.draw2d.clear(aura.rgba(0.08, 0.09, 0.12, 1));
aura.draw2d.sprite(playerSprite, x, y, { width: 48, height: 48 });
aura.draw2d.text('MOVE WITH ARROWS', 24, 24, {
size: 18,
color: aura.rgba(1, 1, 1, 1),
font: uiFont || undefined,
});
};
After the first screen works, the usual next layer is:
That maps well to the current runtime:
setup, not on first use during playdraw2d calls only from aura.draw()aura.assets.getFormatSupport(path) when you are unsure about a file typeupdate