-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathHouse.js
43 lines (34 loc) · 1.02 KB
/
House.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
class House{
xHousePos=0;
lineWidth=10;
lineCap="round";
constructor(){
this.lineDrawer=new LineDrawer();
this.smokes=new Smokes();
}
update(canvasWidth){
this.xHousePos+=2;
if(this.xHousePos-100-canvasWidth*2===0){
this.xHousePos=0;
this.smokes.reset();
}
}
draw(ctx){
ctx.lineWidth=this.lineWidth;
ctx.lineCap=this.lineCap;
ctx.save();
ctx.scale(0.5,0.5);
ctx.translate(-200,200)
ctx.translate(this.xHousePos,200)
this.smokes.update();
this.smokes.draw(ctx);
this.lineDrawer.draw(ctx,100,100,150,50);
this.lineDrawer.draw(ctx,110,70,110,80);
this.lineDrawer.draw(ctx,150,50,200,100);
this.lineDrawer.draw(ctx,100,100,200,100);
this.lineDrawer.draw(ctx,100,100,100,200);
this.lineDrawer.draw(ctx,100,200,200,200);
this.lineDrawer.draw(ctx,200,200,200,100);
ctx.restore();
}
}