-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdino.js
38 lines (32 loc) · 854 Bytes
/
dino.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
// Dino 클래스를 따로 분리한 파일
let groundY = canvas.height - 25;
var cow1 = new Image();
cow1.src = 'src/cow.png';
var cow2 = new Image();
cow2.src = 'src/cow2.png'
var cow3 = new Image();
cow3.src = 'src/cow3.png'
class Dino {
constructor(){
this.x = 50;
this.y = canvas.height - 75;
this.width = 50;
this.height = 50;
this.speedX = 5;
this.isJumping = false;
this.jumpingEnd = true;
this.jumpCount = 0;
this.jumpMaxHeight = 20;
this.jumpSpeed = 10;
}
draw(){
ctx.drawImage(cow1,this.x, this.y, this.width, this.height);
}
draw2(){
ctx.drawImage(cow2,this.x, this.y, this.width, this.height);
}
draw3(){
ctx.drawImage(cow3,this.x, this.y, this.width, this.height);
}
}
var dino = new Dino();