-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgame.js
42 lines (34 loc) · 939 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
41
42
/**
* @author john
*/
Game = {
canvas : undefined,
ctx : undefined,
module : undefined,
Modules : {},
interval : undefined,
start : function() {
this.canvas = document.getElementById('GameCanvas');
this.ctx = this.canvas.getContext('2d');
this.ctx.canvas.width = 400;
this.ctx.canvas.height = 400;
this.module = new this.Modules.Title(this);
this.module.init();
this.interval = setInterval(this.loop.bind(this), 100);
},
loop : function() {
this.module.update();
this.ctx.clearRect(0,0,400,400);
this.module.paint(this.ctx);
},
title2running : function() {
this.module.destroy();
this.module = new this.Modules.Running(this);
this.module.init();
},
running2title : function() {
this.module.destroy();
this.module = new this.Modules.Title(this);
this.module.init();
}
}