-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.js
More file actions
31 lines (25 loc) · 779 Bytes
/
main.js
File metadata and controls
31 lines (25 loc) · 779 Bytes
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
var gamejs = require('gramework').gamejs,
Game = require('./game').Game,
Dispatcher = require('gramework').Dispatcher,
gramework = require('gramework'),
conf = require('./conf');
var main = function() {
var dispatch = new Dispatcher();
var game = new Game();
dispatch.push(game);
// Play area.
var mainSurface = gamejs.display.setMode([800, 600], gamejs.display.DISABLE_SMOOTHING);
gamejs.onTick(function(dt) {
dispatch.update(dt);
dispatch.draw(mainSurface);
}, this, conf.globals.fps);
gamejs.onEvent(function(ev) {
dispatch.event(ev);
});
};
var images = Object.keys(conf.Images).map(function(img) {
return conf.Images[img];
});
gramework.init();
gamejs.preload(images);
gamejs.ready(main);