-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathclassPlatformTile.js
More file actions
54 lines (23 loc) · 986 Bytes
/
classPlatformTile.js
File metadata and controls
54 lines (23 loc) · 986 Bytes
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
class PlatformTile extends Tile
{
constructor(x, y, width, height, speedX){
super(x, y, width, height, speedX);
this.moe = 0.3;
this.sprite = new Image;
}
start(){
this.sprite.src = 'imgs/tiles/PlatformTile.jpg';
//Create top collider with father's width and 10% of it's height
this.colliders.push(new RectCollider(this.x,this.y,this.width,(this.height*this.moe),this.speedX,this.speedY));
this.colliders.push(new RectCollider(this.x,this.y+(this.height*(1-this.moe)),this.width,(this.height*this.moe),this.speedX,this.speedY));
this.colliders.push(new RectCollider(this.x, this.y+(this.height*this.moe), this.width, this.height*(1-2*this.moe), this.speedX, this.speedY));
}
update(){
this.speedControl();
this.draw();
}
draw(){
if(this.x > -100 && this.x < Global.canvas.width + 100)
Global.ctx.drawImage(this.sprite,this.x,this.y, this.width, this.height);
}
}