forked from yubhav/pandemic-endgame
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathavenger.js
More file actions
49 lines (44 loc) · 1.07 KB
/
Copy pathavenger.js
File metadata and controls
49 lines (44 loc) · 1.07 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
class Avenger {
constructor () {
this.size = 100;
this.x = 50;
this.y = height - this.size;
this.yVelocity = 0;
this.gravity = 2;
}
selectAvenger() {
if (selectSkin.value() === "america") {
this.character = captamerica;
}
if (selectSkin.value() === "ironman") {
this.character = ironman;
}
if (selectSkin.value() === "thor") {
this.character = thor;
}
if (selectSkin.value() === "hulk") {
this.character = hulk;
}
if (selectSkin.value() === "widow") {
this.character = widow;
}
// console.log(this.character);
}
move() {
this.y += this.yVelocity;
this.yVelocity += this.gravity;
this.y = constrain(this.y, 0, height - this.size);
}
jump() {
if (this.y == height - this.size) {
this.yVelocity = -35;
}
}
hits(virus){
return collideRectRect(this.x+40, this.y, this.size-40, this.size,
virus.x, virus.y, virus.size, virus.size);
}
draw() {
image(this.character, this.x, this.y, this.size, this.size);
}
}