-
Notifications
You must be signed in to change notification settings - Fork 0
/
tama.js
76 lines (67 loc) · 2.09 KB
/
tama.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
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
class Tama {
constructor(){
this.x = 200;
this.y = 200;
this.vy = 0;
this.width = canvas.width / 30;
this.height = canvas.height / 20;
this.weight = .5;
this.radius = 7;
// if(level > 1){
// this.radius = 20
// }
}
update(){
let curve = Math.sin(angle) * 20
if (this.y > canvas.height - (this.height * 3) + curve){
this.y = canvas.height - (this.height * 3) + curve;
this. vy = 1;
} else {
this.vy += this.weight;
this.vy *= .8;
this.y += this.vy;
}
// stops from going over top
// if (this.y < 0 + this.height){
// this.y = 0 + this.height;
// this.vy = 0;
// }
if(spacePressed && this.y > this.height - 100)
this.boost();
}
draw(){
// hitbox
// ctx.fillStyle = 'white ';
// ctx.beginPath();
// ctx.arc(this.x, this.y, this.radius, 0, Math.PI * 2)
// ctx.fill();
const tama = new Image();
if (level < 2) {
//hitbox
// ctx.fillStyle = 'white ';
// ctx.beginPath();
// ctx.arc(this.x, this.y, this.radius, 0, Math.PI * 2)
// ctx.fill();
tama.src = '/src/images/TAMA.png';
ctx.drawImage(tama, this.x - 10, this.y - 11, canvas.height / 20, 20);
}
if (level >= 2){
//hitbox
this.radius = 18;
// ctx.fillStyle = 'white ';
// ctx.beginPath();
// ctx.arc(this.x, this.y, this.radius, 0, Math.PI * 2)
// ctx.fill();
tama.src = '/src/images/ASTRONAUT.png';
ctx.drawImage(tama, this.x - 50, this.y - 50, canvas.height / 5, canvas.width / 5);
}
}
boost(){
this.vy -= 3;
// handleExhaust();
// const tama = new Image();
// tama.src = 'ASTRONAUT.png';
// ctx.drawImage(tama, this.x, this.y + 50, 70, 125);
}
}
const tama = new Tama();