-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathblocks.js
More file actions
146 lines (131 loc) · 4.09 KB
/
blocks.js
File metadata and controls
146 lines (131 loc) · 4.09 KB
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
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
class Ground {
// holds common collective functionality for ground / platforms.
constructor(game, x, y, w) {
Object.assign(this, { game, x, y, w });
this.spritesheet = ASSET_MANAGER.getAsset("./assets/Environmental_Blocks.png");
this.BB = new BoundingBox(this.game,this.x, this.y, 32 * w, 32, "orange");
};
update() {
this.BB = new BoundingBox(this.game,this.x ,this.y, 32 * this.w, 32, "orange");
};
draw(ctx) {
for (var i = 0; i < this.w; i++) {
ctx.drawImage(this.spritesheet,
this.spritex, this.spritey, 16, 16,
this.x + i * 32 - this.game.camera.x, this.y-this.game.camera.y,
16 * 2, 16 * 2);
}
this.BB.draw(ctx);
};
}
class GrassGround extends Ground {
constructor(game, x, y, w) {
super(game, x, y, w);
Object.assign(this, {spritex:0, spritey:32});
}
}
class UnderGround extends Ground {
constructor(game, x, y, w) {
super(game, x, y, w)
Object.assign(this, {spritex:32, spritey:96});
};
}
class IceGround extends Ground {
constructor(game, x, y, w) {
super(game, x, y, w);
Object.assign(this, {spritex:112, spritey:224});
};
}
class HellGround extends Ground {
constructor(game, x, y, w) {
super(game, x, y, w);
Object.assign(this, {spritex:368, spritey:192});
};
}
class Wall {
// Holds common collective functionality for Walls.
// Walls are build from top down IE (x:0 y:0 size: 10)
// This starts top right corner and goes 10 blocks down
constructor(game, x, y, w) {
Object.assign(this, { game, x, y, w });
this.spritesheet = ASSET_MANAGER.getAsset("./assets/Environmental_Blocks.png");
this.BB = new BoundingBox(this.game,this.x, this.y, 32, 32*w, "orange");
};
update() {
this.BB = new BoundingBox(this.game,this.x ,this.y, 32 , 32*this.w, "orange");
};
draw(ctx) {
for (var i = 0; i < this.w; i++) {
ctx.drawImage(this.spritesheet,
this.spritex, this.spritey, 16, 16,
this.x- this.game.camera.x, this.y + i*32 - this.game.camera.y,
16 * 2, 16 * 2);
}
this.BB.draw(ctx);
};
}
class GrassWall extends Wall {
constructor(game, x, y, w) {
super(game, x, y, w);
Object.assign(this, {spritex:0, spritey:32});
}
}
class UnderWall extends Wall {
constructor(game, x, y, w) {
super(game, x, y, w)
Object.assign(this, {spritex:32, spritey:96});
};
}
class IceWall extends Wall {
constructor(game, x, y, w) {
super(game, x, y, w);
Object.assign(this, {spritex:112, spritey:224});
};
}
class HellWall extends Wall {
constructor(game, x, y, w) {
super(game, x, y, w);
Object.assign(this, {spritex:368, spritey:192});
};
}
class Arrow {
// Holds common collective functionality for Walls.
// Walls are build from top down IE (x:0 y:0 size: 10)
// This starts top right corner and goes 10 blocks down
constructor(game, x, y) {
Object.assign(this, { game, x, y });
this.spritesheet = ASSET_MANAGER.getAsset("./assets/arrows.png");
};
update(){
}
draw(ctx) {
ctx.drawImage(this.spritesheet,
this.spritex, this.spritey, 175, 175,
this.x- this.game.camera.x, this.y - this.game.camera.y,
200, 200);
}
}
class LeftArrow extends Arrow{
constructor(game,x,y){
super(game,x,y);
Object.assign(this,{spritex:220,spritey:210})
}
}
class RightArrow extends Arrow{
constructor(game,x,y){
super(game,x,y);
Object.assign(this,{spritex:220,spritey:0})
}
}
class UpArrow extends Arrow{
constructor(game,x,y){
super(game,x,y);
Object.assign(this,{spritex:430,spritey:400})
}
}
class DownArrow extends Arrow{
constructor(game,x,y){
super(game,x,y);
Object.assign(this,{spritex:430,spritey:210})
}
}