-
-
Notifications
You must be signed in to change notification settings - Fork 215
Expand file tree
/
Copy pathgame.js
More file actions
51 lines (43 loc) · 1.48 KB
/
game.js
File metadata and controls
51 lines (43 loc) · 1.48 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
/*
Little JS Hello World Demo
- Just prints 'Hello World!'
- A good starting point for new projects
*/
'use strict';
// 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']);