-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathLevel.js
56 lines (50 loc) · 1.51 KB
/
Level.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
51
52
53
54
55
56
var levelLayout = [
"#######################",
"#.....................#",
"#.....................#",
"#.....................#",
"#.....................#",
"#.....................#",
"#.....................#",
"#.....................#",
"#.....................#",
"#.....................#",
"#.....................#",
"#.....................#",
"#######################"
]
function Level(currLevel) {
powerupjs.GameObjectList.call(this);
for (var x=0; x < 12; x++) {
for (var y=0; y < 9; y++) {
this.add(new BackgroundTile(new powerupjs.Vector2(x * 128, y * 128 - 256), sprites.backgroundTiles['purple']))
}
}
var tiles = new TileField(currLevel);
var fruits = new FruitFeild(currLevel);
var traps = new TrapFeild(currLevel);
var boxes = new BoxFeild(currLevel);
var enemies = new EnemyField(currLevel)
var player = new Player(currLevel);
player.origin = new powerupjs.Vector2(player.width / 2, player.height)
this.add(fruits)
this.add(traps);
this.add(tiles)
this.add(enemies)
this.add(boxes);
this.add(player)
this.alternateInt = 1;
this.alternateDate = Date.now();
}
Level.prototype = Object.create(powerupjs.GameObjectList.prototype);
Level.prototype.reset = function() {
this.find(ID.fruits).reset();
this.find(ID.traps).reset();
}
Level.prototype.update = function(delta) {
powerupjs.GameObjectList.prototype.update.call(this, delta);
if (Date.now() > this.alternateDate + 8000) {
this.alternateInt *= -1
this.alternateDate = Date.now()
}
}