-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathgame.js
40 lines (33 loc) · 846 Bytes
/
game.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
"use strict";
var Splat = require("splatjs");
var canvas = document.getElementById("canvas");
var manifest = {
"images": {
},
"sounds": {
},
"fonts": {
},
"animations": {
}
};
var game = new Splat.Game(canvas, manifest);
function centerText(context, text, offsetX, offsetY) {
var w = context.measureText(text).width;
var x = offsetX + (canvas.width / 2) - (w / 2) | 0;
var y = offsetY | 0;
context.fillText(text, x, y);
}
game.scenes.add("title", new Splat.Scene(canvas, function() {
// initialization
}, function() {
// simulation
}, function(context) {
// draw
context.fillStyle = "#092227";
context.fillRect(0, 0, canvas.width, canvas.height);
context.fillStyle = "#fff";
context.font = "25px helvetica";
centerText(context, "Blank SplatJS Project", 0, canvas.height / 2 - 13);
}));
game.scenes.switchTo("loading");