-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMediumSlider.java
59 lines (49 loc) · 2.41 KB
/
MediumSlider.java
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
/**
* Subclass of slider that has overload constructor to set values and run methods in parent class depending
* on whether it is a slider on the starting tower or a moving slider
* Child sliders can control their own difficulty by changing the starting duration of slider, its fastest duration
* and how quickly the duration increases
*
* this is for a medium difficulty slider
*
*
* @author (Huy Nguyen)
* @version (January 14th 2024)
*/
public class MediumSlider extends Slider
{
//SET SLIDER CUSTOM VARIABLES
private static final short STARTING_DURATION = 2000; //how long it takes the slider to move across the first time it's placed. K
private static final short FASTEST_DURATION = 800; //the fastest it can take the slider to move across the screen on it's placed
private static final short INCREMENT_DURATION = 300; //how much the duration will go down by each time a slider is placed to incrementally increase difficulty by increasing and increasing the speed
//set child duration to be that of the starting duration by default
private static short shtChildDuration = STARTING_DURATION;
//constructor used to simply add a slider when building the initial tower
public MediumSlider(byte b)
{
super(b); //call super constructor
//call addrectangletoscreen to put rectangle in the middle of the screen
super.addRectangleToScreen();
}
//constructor used to simply add a moving slider
public MediumSlider(byte b, boolean bolSide)
{
super(b); //call super constructor
//set duration of slider
super.setDuration(shtChildDuration);
//if lowering duration maintains that the duration does not exceed fasted duration
if ((shtChildDuration - INCREMENT_DURATION) >= FASTEST_DURATION)
{
shtChildDuration -= INCREMENT_DURATION; //make duration quicker using increment
}
//addrectangletoscreen to screen by calling overloaded method with bolSide
///because I want the version that puts the rectangle on the side of a screen and starts its animation
super.addRectangleToScreen(bolSide);
}
public static void resetDuration()
{
//reset child duration to be that of the starting duration by default
//add increment duration because the second constructor will take it away
shtChildDuration = STARTING_DURATION;
}
}