Class ParkourTimer
java.lang.Object
net.vincent.parkourwarrior.ParkourTimer
Timer class for Parkour Warrior.
This class manages the in-game timer, tracking elapsed time during gameplay, rendering the timer on screen, and saving record times when a map is completed.
- Since:
- 1.1
-
Field Summary
FieldsModifier and TypeFieldDescriptionintThe end time milliseconds when a map is completed.Formatted string for the end time milliseconds.intThe end time minutes when a map is completed.Formatted string for the end time minutes.intThe end time seconds when a map is completed.Formatted string for the end time seconds.longThe current timer milliseconds.Formatted string for the current timer milliseconds.longThe current timer minutes.Formatted string for the current timer minutes.longThe current timer seconds.Formatted string for the current timer seconds. -
Constructor Summary
ConstructorsConstructorDescriptionParkourTimer(ParkourMain parkourMain) Constructs a newParkourTimerwith a reference to the main game panel. -
Method Summary
Modifier and TypeMethodDescriptionvoiddrawTimer(Graphics2D graphics2D) Draws the timer on the screen.voidrunTimer(long startTime, double FPS) Runs the timer by calculating elapsed time since the start.voidsaveTime()Saves the current timer as the end time and updates the record time if it is faster than the previous record.
-
Field Details
-
endTimeMilis
public int endTimeMilisThe end time milliseconds when a map is completed.- Since:
- 1.1
-
endTimeSeconds
public int endTimeSecondsThe end time seconds when a map is completed.- Since:
- 1.1
-
endTimeMinutes
public int endTimeMinutesThe end time minutes when a map is completed.- Since:
- 1.1
-
endTimeMinutesStr
-
endTimeSecondsStr
-
endTimeMilisecondsStr
-
timerTimeMinutes
public long timerTimeMinutesThe current timer minutes.- Since:
- 1.1
-
timerTimeSeconds
public long timerTimeSecondsThe current timer seconds.- Since:
- 1.1
-
timerTimeMiliseconds
public long timerTimeMilisecondsThe current timer milliseconds.- Since:
- 1.1
-
timerTimeMinutesStr
-
timerTimeSecondsStr
-
timerTimeMilisecondsStr
Formatted string for the current timer milliseconds.- Since:
- 1.1
-
-
Constructor Details
-
ParkourTimer
Constructs a newParkourTimerwith a reference to the main game panel.- Parameters:
parkourMain- the main game panel instance- Since:
- 1.1
-
-
Method Details
-
runTimer
public void runTimer(long startTime, double FPS) Runs the timer by calculating elapsed time since the start.Computes minutes, seconds, and milliseconds from the elapsed nanoseconds and formats them into display strings.
- Parameters:
startTime- the start time in nanosecondsFPS- the current frames per second- Since:
- 1.1
-
drawTimer
Draws the timer on the screen.- Parameters:
graphics2D- theGraphics2Dcontext to draw on- Since:
- 1.1
-
saveTime
public void saveTime()Saves the current timer as the end time and updates the record time if it is faster than the previous record.- Since:
- 1.1
-