This demo shows how to draw basic stuff.
The following code shows how to draw basic stuff with sprites batch.
// init shaku
await Shaku.init();
// add shaku's canvas to document and set resolution to 800x600
document.body.appendChild(Shaku.gfx.canvas);
Shaku.gfx.setResolution(800, 600, true);
// load sprite's texture asset
let texture = await Shaku.assets.loadTexture('assets/sprite.png');
// create a SpriteBatch
let spritesBatch = new Shaku.gfx.SpriteBatch();
// main loop
function step()
{
// start new frame and clear screen
Shaku.startFrame();
Shaku.gfx.clear(Shaku.utils.Color.cornflowerblue);
// draw a sprite using the spritebatch
spritesBatch.begin();
let position = new Shaku.utils.Vector2(400, 300);
let size = new Shaku.utils.Vector2(100, 100);
spritesBatch.drawQuad(texture, position, size);
spritesBatch.end();
// end frame and request next frame
Shaku.endFrame();
Shaku.requestAnimationFrame(step);
}
// start main loop
step();