Repository navigation
Expand file tree
/
Copy pathPlayer1.java
More file actions
64 lines (54 loc) · 1.66 KB
/
Copy pathPlayer1.java
File metadata and controls
64 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
import city.cs.engine.*;
public class Player1 extends Walker {
private static final Shape ronaldoShape = new BoxShape(2f, 2.1f);
private static final BodyImage image =
new BodyImage("data/players/ronaldo.png", 5);
private static final BodyImage leftImage =
new BodyImage("data/players/ronaldoLeft.png", 5);
private int player1Score;
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 Player1(World world) {
super(world, ronaldoShape);
walkingSpeed = 5;
jumpSpeed = 11;
addImage(image);
player1Score = 0;
}
public int getPlayer1Score() {
return player1Score;
}
public void setPlayer1Score(int player1Score) {
this.player1Score = player1Score;
}
// 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(leftImage);
} else {
this.removeAllImages();
this.addImage(image);
}
}
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;
}
}