Class ParkourTimer

java.lang.Object
net.vincent.parkourwarrior.ParkourTimer

public class ParkourTimer extends Object
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 Details

    • endTimeMilis

      public int endTimeMilis
      The end time milliseconds when a map is completed.
      Since:
      1.1
    • endTimeSeconds

      public int endTimeSeconds
      The end time seconds when a map is completed.
      Since:
      1.1
    • endTimeMinutes

      public int endTimeMinutes
      The end time minutes when a map is completed.
      Since:
      1.1
    • endTimeMinutesStr

      public String endTimeMinutesStr
      Formatted string for the end time minutes.
      Since:
      1.1
    • endTimeSecondsStr

      public String endTimeSecondsStr
      Formatted string for the end time seconds.
      Since:
      1.1
    • endTimeMilisecondsStr

      public String endTimeMilisecondsStr
      Formatted string for the end time milliseconds.
      Since:
      1.1
    • timerTimeMinutes

      public long timerTimeMinutes
      The current timer minutes.
      Since:
      1.1
    • timerTimeSeconds

      public long timerTimeSeconds
      The current timer seconds.
      Since:
      1.1
    • timerTimeMiliseconds

      public long timerTimeMiliseconds
      The current timer milliseconds.
      Since:
      1.1
    • timerTimeMinutesStr

      public String timerTimeMinutesStr
      Formatted string for the current timer minutes.
      Since:
      1.1
    • timerTimeSecondsStr

      public String timerTimeSecondsStr
      Formatted string for the current timer seconds.
      Since:
      1.1
    • timerTimeMilisecondsStr

      public String timerTimeMilisecondsStr
      Formatted string for the current timer milliseconds.
      Since:
      1.1
  • Constructor Details

    • ParkourTimer

      public ParkourTimer(ParkourMain parkourMain)
      Constructs a new ParkourTimer with 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 nanoseconds
      FPS - the current frames per second
      Since:
      1.1
    • drawTimer

      public void drawTimer(Graphics2D graphics2D)
      Draws the timer on the screen.
      Parameters:
      graphics2D - the Graphics2D context 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