Class ParkourMain

All Implemented Interfaces:
ImageObserver, MenuContainer, Serializable, Runnable, Accessible

public class ParkourMain extends JPanel implements Runnable
The central class of Parkour Warrior.

This class initialized the JPanel and Graphics2D for the game's drawer and frame to draw. This class also defines global fields for the use of the other classes, and create instances of other classes of this game in order to make the initialization not stuck in an infinite loop.

Since:
1.0
See Also:
  • Field Details

    • tileSize

      public final int tileSize
      This is mentioned at final int scale, and it is the final tile size for this game.
      Since:
      1.0
      See Also:
    • maxWidthTiles

      public final int maxWidthTiles
      This is the maximum amount of tiles allowed in a row.
      Since:
      1.0
      See Also:
    • maxHeightTiles

      public final int maxHeightTiles
      This is the maximum amount of tiles allowed in a column.
      Since:
      1.0
      See Also:
    • screenWidth

      public final int screenWidth
      This is the maximum screen width in pixels, which is maxWidthTiles * tileSize
      Since:
      1.0
      See Also:
    • screenHeight

      public final int screenHeight
      This is the screen maximum height in pixels, which is maxHeightTiles * tileSize
      Since:
      1.0
      See Also:
    • maxWorldColumn

      public final int maxWorldColumn
      This is the maximum columns of ties that can be in a world.
      Since:
      1.1
      See Also:
    • maxWorldRow

      public final int maxWorldRow
      This is the maximum rows of tiles that can be in a world.
      Since:
      1.1
      See Also:
    • mapNumber

      public ArrayList<Integer> mapNumber
      This is the map number for the program to load the maps, defined for PropertiesData and TileManager.
      Since:
      1.1
    • mapPath

      public ArrayList<String> mapPath
      This is the path to maps in the system, defined for PropertiesData and TileManager.
      Since:
      1.1
    • mapType

      public ArrayList<Integer> mapType
      This is the type of map, defined for PropertiesData and TileManager, currently unused.
      Since:
      1.1
    • isDefaultMap

      public ArrayList<Boolean> isDefaultMap
      This is the type of map (e.g. default), defined for PropertiesData and TileManager.
      Since:
      1.1
    • haveFinishedMap

      public ArrayList<Boolean> haveFinishedMap
      This is for Graphics2D to see if the it need to print time next to the map, defined for PropertiesData and TileManager.
      Since:
      1.1
    • recordTimeMinutes

      public ArrayList<Integer> recordTimeMinutes
      The shortest minutes used to finish a map, defined for PropertiesData and TileManager.
      Since:
      1.1
    • recordTimeSeconds

      public ArrayList<Integer> recordTimeSeconds
      The shortest seconds used to finish a map, defined for PropertiesData and TileManager.
      Since:
      1.1
    • recordTimeMiliseconds

      public ArrayList<Integer> recordTimeMiliseconds
      The shortest milliseconds used to finish a map, defined for PropertiesData and TileManager.
      Since:
      1.1
    • endIndex

      public ArrayList<Integer> endIndex
      The end index, defined for PropertiesData and TileManager.
      Since:
      1.1
    • musicOn

      public boolean musicOn
      To determine if the program needs to play music.
      Since:
      1.0
    • currentMapState

      public int currentMapState
      To indicate the current map state.

      For loop to determine call which draw method (e.g. title screen, playing, finish screen).

      Since:
      1.1
    • currentMap

      public int currentMap
      To determine which map is the player currently playing.
      Since:
      1.1
    • title

      public final int title
      The number for title map state.
      Since:
      1.1
      See Also:
    • play

      public final int play
      The number for playing map state.
      Since:
      1.1
      See Also:
    • finish

      public final int finish
      The number for the finish screen.
      Since:
      1.1
      See Also:
    • defaultPlayMap

      public final int defaultPlayMap
      The number for the default maps, which is inside the JAR.
      Since:
      1.1
      See Also:
    • customPlayMap

      public final int customPlayMap
      The number for custom maps.

      The map can be anywhere in the system that the program have permission for.

      Since:
      1.1
      See Also:
    • timerStartTime

      public long timerStartTime
      The time when the timer is started, for time calculation.
      Since:
      1.2
    • FPS

      public final double FPS
      The FPS of the game, currently 60.
      Since:
      1.0
      See Also:
    • ico

      public ImageIcon ico
      The {ImageIcon} for the game.
      Since:
      1.0
    • player

      public Player player
      Instance declaration for Player class, used by all.
      Since:
      1.0
    • tileManager

      public TileManager tileManager
      Instance declaration for TileManager class, used by all.
      Since:
      1.0
    • propertiesData

      public PropertiesData propertiesData
      Instance declaration for PropertiesData, used by all.
      Since:
      1.1
    • titleScreen

      public TitleScreen titleScreen
      Instance declaration for TitleScreen class, used by all.
      Since:
      1.2
    • parkourTimer

      public ParkourTimer parkourTimer
      Instance declaration for ParkourTime class, used by all.
      Since:
      1.1
    • finishScreen

      public FinishScreen finishScreen
      Instance declaration for FinishScreen class, used by all.
      Since:
      1.2
    • keyHandler

      public KeyHandler keyHandler
      The instance declaration for KeyHandler, used by all.
      Since:
      1.0
    • pixelFont

      public Font pixelFont
      The font used by the game.
      Since:
      1.2
  • Constructor Details

    • ParkourMain

      public ParkourMain()
      The constructor for class ParkourMain.

      This constructor defines instances of each class for all classes to use, for preventing loops and conserving memory. This constructor also calls startup methods since this runs only after the JFrame is created, for example the game's main Thread.

      Since:
      1.0
  • Method Details

    • run

      public void run()
      The method from Runnable interface, to control what would be done each frame.
      Specified by:
      run in interface Runnable
      Since:
      1.0
    • update

      public void update()
      The method to call updates on updates on values of the game, like the player position.
      Since:
      1.0
    • paintComponent

      public void paintComponent(Graphics g)
      The method for calling paint methods in each state for each class.
      Overrides:
      paintComponent in class JComponent
      Parameters:
      g - the Graphics object to protect
      Since:
      1.0
    • getSound

      public void getSound(String path)
      The method to get the sound file from res and puts the audio into a Clip.
      Parameters:
      path - Path to the audio inside the JAR.
      Since:
      1.1
    • getPixelFont

      public void getPixelFont(String path)
      The method to get the font file in res and create a Font for the program to use.
      Parameters:
      path - The path to the font file.
      Since:
      1.2