-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgameScene.js
47 lines (37 loc) · 1.05 KB
/
gameScene.js
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
var g_gameScene = {};
// =================
// UPDATE SIMULATION
// =================
// We take a very layered approach here...
//
// The primary `update` routine handles generic stuff such as
// pausing, single-step, and time-handling.
//
// It then delegates the game-specific logic to `updateSimulation`
g_gameScene.init = function (firstInit = false) {
spatialManager.reset();
entityManager.reset();
}
// GAME-SPECIFIC UPDATE LOGIC
g_gameScene.updateSimulation = function (du) {
background.update(du);
entityManager.update(du);
hud.update(du);
// Prevent perpetual firing!
eatKey(Ship.prototype.KEY_FIRE);
}
// =================
// RENDER SIMULATION
// =================
// We take a very layered approach here...
//
// The primary `render` routine handles generic stuff such as
// the diagnostic toggles (including screen-clearing).
//
// It then delegates the game-specific logic to `gameRender`
// GAME-SPECIFIC RENDERING
g_gameScene.renderSimulation = function (ctx) {
background.render(ctx);
entityManager.render(ctx);
hud.render(ctx);
}