Repository navigation
Expand file tree
/
Copy pathPlayer2.java
More file actions
65 lines (54 loc) · 1.66 KB
/
Copy pathPlayer2.java
File metadata and controls
65 lines (54 loc) · 1.66 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
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
import city.cs.engine.*;
public class Player2 extends Walker {
private static final Shape messiShape = new BoxShape(2, 2.1f);
private static final BodyImage image =
new BodyImage("data/players/messi.png", 5);
private static final BodyImage RightImage =
new BodyImage("data/players/messiRight.png", 5);
private int player2Score;
private int walkingSpeed;
private int jumpSpeed;
/**
* - Default stats (at the start of each level):
* - Walk speed of 5
* - Jump speed of 11
* - Score of 0
* */
public Player2(World world) {
super(world, messiShape);
addImage(image);
player2Score = 0;
walkingSpeed = 5;
jumpSpeed = 11;
}
public int getPlayer2Score() {
return player2Score;
}
public void setPlayer2Score(int player2Score) {
this.player2Score = player2Score;
}
// will flip the image depending on where the player is facing
@Override
public void startWalking(float speed) {
super.startWalking(speed);
if(speed < 0) {
this.removeAllImages();
this.addImage(image);
} else {
this.removeAllImages();
this.addImage(RightImage);
}
}
public int getWalkingSpeed() {
return walkingSpeed;
}
public void setWalkingSpeed(int walkingSpeed) {
this.walkingSpeed = walkingSpeed;
}
public int getJumpSpeed() {
return jumpSpeed;
}
public void setJumpSpeed(int jumpSpeed) {
this.jumpSpeed = jumpSpeed;
}
}