-
Notifications
You must be signed in to change notification settings - Fork 0
/
player.js
36 lines (28 loc) · 904 Bytes
/
player.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
class Player{
constructor(x,y,width,height){
this.body = Bodies.rectangle(x, y, width, height);
this.width = width;
this.height = height;
this.img1 = loadImage("user.png","user2.png","user3.png");
/*this.img1 = loadImage("user.png");
this.img2 = loadImage("user2.png");
this.img3 = loadImage("user3.png");
this.img4 = loadImage("userjump.png");
this.img5 = loadImage("userleft.png");*/
World.add(world, this.body);
}
display(){
push();
translate(this.body.position.x, this.body.position.y);
// rotate(angle);
// fill("yellow");
imageMode(CENTER);
image(this.img1,0,0,25,25);
pop();
}
jump(){
if(keyCode === 32){
player.velocityY = -5;
}
}
}