littlejsengine
Version:
LittleJS - Tiny and Fast HTML5 Game Engine
51 lines (43 loc) • 1.56 kB
JavaScript
/*
Little JS Hello World Demo
- Just prints 'Hello World!'
- A good starting point for new projects
*/
;
// import LittleJS module
import * as LJS from '../../dist/littlejs.esm.js';
const {vec2, rgb} = LJS;
///////////////////////////////////////////////////////////////////////////////
function gameInit()
{
// called once after the engine starts up
// setup the game
}
///////////////////////////////////////////////////////////////////////////////
function gameUpdate()
{
// called every frame at 60 frames per second
// handle input and update the game state
}
///////////////////////////////////////////////////////////////////////////////
function gameUpdatePost()
{
// called after physics and objects are updated
// setup camera and prepare for render
}
///////////////////////////////////////////////////////////////////////////////
function gameRender()
{
// called before objects are rendered
// draw any background effects that appear behind objects
}
///////////////////////////////////////////////////////////////////////////////
function gameRenderPost()
{
// called after objects are rendered
// draw effects or hud that appear above all objects
LJS.drawTextScreen('Hello World!', LJS.mainCanvasSize.scale(.5), 80);
}
///////////////////////////////////////////////////////////////////////////////
// Startup LittleJS Engine
LJS.engineInit(gameInit, gameUpdate, gameUpdatePost, gameRender, gameRenderPost, ['tiles.png']);