-
Notifications
You must be signed in to change notification settings - Fork 0
/
Player.pde
53 lines (45 loc) · 870 Bytes
/
Player.pde
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
class Player{
int speed = 5;
int hp = 100;
int shield = 0;
float x = width/2;
float y = height/2;
int xVelocity = 0;
int yVelocity = 0;
float angle=0;
Guns gun = new Guns();
void move(){
x += xVelocity * speed;
y += yVelocity * speed;
}
void show(){
rotating();
pushMatrix();
translate(x, y);
rotate(angle);
rectMode(CENTER);
rect(0, 0, 40, 40);
popMatrix();
}
void setXVelocity(int vel){
this.xVelocity = vel;
}
void setYVelocity(int vel){
this.yVelocity = vel;
}
void rotating(){
if(mouseX != x){
angle = (mouseY - y)/( mouseX - x);
angle = atan(angle);
}
}
float getX(){
return this.x;
}
float getY(){
return this.y;
}
float getAngle(){
return this.angle;
}
}