-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCreativeHuman.java
More file actions
28 lines (21 loc) · 886 Bytes
/
CreativeHuman.java
File metadata and controls
28 lines (21 loc) · 886 Bytes
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
public class CreativeHuman extends HumanPaddle {
public static final double MIN_PADDLE_LENGTH = 10;
public static final double DECREASE_IN_LENGTH = 5;
public CreativeHuman(){
super(HUMAN_PADDLE_LENGTH, HUMAN_PADDLE_SPEED, HUMAN_PADDLE_COLOR);
}
//override ballVolleyed to decrease paddle length every time it collides with a ball
public void ballVolleyed(){
this.volleys += 1;
if (getPaddleLength() > MIN_PADDLE_LENGTH + DECREASE_IN_LENGTH)
setLength(getPaddleLength() - DECREASE_IN_LENGTH);
}
// override pointscored function to reset paddle length after a point is scored
public void pointScored(boolean didHumanScore){
if (didHumanScore){
this.score++;
}
this.volleys = 0;
setLength(HUMAN_PADDLE_LENGTH);
}
}