-
Notifications
You must be signed in to change notification settings - Fork 1
/
levels.js
50 lines (47 loc) · 1 KB
/
levels.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
48
49
50
module.exports = Levels;
function Levels() {
this.levels = [];
}
Levels.prototype = {
title: "Level",
separator: ": ",
levels: null,
generic: function(){},
current_level: -1,
starter: function(){},
add_level: function(level) {
this.levels.push(level);
},
add_starter: function(starter) {
this.starter = starter;
},
add_generic_level: function(level) {
this.generic = level;
},
start: function() {
this.starter(this.current_level);
},
run_level: function(index) {
this.clean_level();
this.current_level = index;
if(this.levels[index] == null) {
this.generic(index);
} else {
this.levels[index](index);
}
this.start();
},
next_level: function() {
this.run_level(this.current_level + 1);
},
restart_level: function() {
this.run_level(this.current_level);
},
clean_level: function() {
this.screen.clear();
},
retangle_definition: function(){},
draw: function(screen) {
screen.ctx.fillText(this.title + this.separator + this.current_level, 0, 0);
}
};