Package org.vyang.parkourwarrior
Class ParkourMain
java.lang.Object
java.awt.Component
java.awt.Container
javax.swing.JComponent
javax.swing.JPanel
org.vyang.parkourwarrior.ParkourMain
- All Implemented Interfaces:
ImageObserver,MenuContainer,Serializable,Runnable,Accessible
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:
-
Nested Class Summary
Nested classes/interfaces inherited from class javax.swing.JPanel
JPanel.AccessibleJPanelNested classes/interfaces inherited from class javax.swing.JComponent
JComponent.AccessibleJComponentNested classes/interfaces inherited from class java.awt.Container
Container.AccessibleAWTContainerNested classes/interfaces inherited from class java.awt.Component
Component.AccessibleAWTComponent, Component.BaselineResizeBehavior, Component.BltBufferStrategy, Component.FlipBufferStrategy -
Field Summary
FieldsModifier and TypeFieldDescriptionintTo determine which map is the player currently playing.intTo indicate the current map state.final intThe number for custom maps.final intThe number for the default maps, which is inside the JAR.Instance declaration forDialogScreenfinal intThe number for the finish screen.final doubleThe FPS of the game, currently 60.The {ImageIcon} for the game.The instance declaration forKeyHandler, used by all.Instance declaration forMapManager, used by all.final intThis is the maximum amount of tiles allowed in a column.final intThis is the maximum amount of tiles allowed in a row.final intThis is the maximum columns of ties that can be in a world.final intThis is the maximum rows of tiles that can be in a world.Instance declaration forMenuBarbooleanTo determine if the program needs to play music.Instance declaration forParkourTimeclass, used by all.The font used by the game.final intThe number for playing map state.Instance declaration forPlayerclass, used by all.final intThis is the screen maximum height in pixels, which ismaxHeightTiles * tileSizefinal intThis is the maximum screen width in pixels, which ismaxWidthTiles * tileSizeInstance declaration forTileManagerclass, used by all.final intThis is mentioned atfinal int scale, and it is the final tile size for this game.longThe time when the timer is started, for time calculation.final intThe number for title map state.Instance declaration forTitleScreenclass, used by all.Fields inherited from class javax.swing.JComponent
listenerList, TOOL_TIP_TEXT_KEY, ui, UNDEFINED_CONDITION, WHEN_ANCESTOR_OF_FOCUSED_COMPONENT, WHEN_FOCUSED, WHEN_IN_FOCUSED_WINDOWFields inherited from class java.awt.Component
accessibleContext, BOTTOM_ALIGNMENT, CENTER_ALIGNMENT, LEFT_ALIGNMENT, RIGHT_ALIGNMENT, TOP_ALIGNMENTFields inherited from interface java.awt.image.ImageObserver
ABORT, ALLBITS, ERROR, FRAMEBITS, HEIGHT, PROPERTIES, SOMEBITS, WIDTH -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidgetPixelFont(String path) The method to get the font file inresand create aFontfor the program to use.voidThe method to get the sound file fromresand puts the audio into aClip.voidThe method for calling paint methods in each state for each class.voidquit(int code) The global quit method that handles the uninitialization.voidrun()The method fromRunnableinterface, to control what would be done each frame.voidupdate()The method to call updates on updates on values of the game, like the player position.Methods inherited from class javax.swing.JPanel
getAccessibleContext, getUI, getUIClassID, paramString, setUI, updateUIMethods inherited from class javax.swing.JComponent
addAncestorListener, addNotify, addVetoableChangeListener, computeVisibleRect, contains, createToolTip, disable, enable, firePropertyChange, firePropertyChange, firePropertyChange, fireVetoableChange, getActionForKeyStroke, getActionMap, getAlignmentX, getAlignmentY, getAncestorListeners, getAutoscrolls, getBaseline, getBaselineResizeBehavior, getBorder, getBounds, getClientProperty, getComponentGraphics, getComponentPopupMenu, getConditionForKeyStroke, getDebugGraphicsOptions, getDefaultLocale, getFontMetrics, getGraphics, getHeight, getInheritsPopupMenu, getInputMap, getInputMap, getInputVerifier, getInsets, getInsets, getListeners, getLocation, getMaximumSize, getMinimumSize, getNextFocusableComponent, getPopupLocation, getPreferredSize, getRegisteredKeyStrokes, getRootPane, getSize, getToolTipLocation, getToolTipText, getToolTipText, getTopLevelAncestor, getTransferHandler, getVerifyInputWhenFocusTarget, getVetoableChangeListeners, getVisibleRect, getWidth, getX, getY, grabFocus, hide, isDoubleBuffered, isLightweightComponent, isManagingFocus, isOpaque, isOptimizedDrawingEnabled, isPaintingForPrint, isPaintingOrigin, isPaintingTile, isRequestFocusEnabled, isValidateRoot, paint, paintBorder, paintChildren, paintImmediately, paintImmediately, print, printAll, printBorder, printChildren, printComponent, processComponentKeyEvent, processKeyBinding, processKeyEvent, processMouseEvent, processMouseMotionEvent, putClientProperty, registerKeyboardAction, registerKeyboardAction, removeAncestorListener, removeNotify, removeVetoableChangeListener, repaint, repaint, requestDefaultFocus, requestFocus, requestFocus, requestFocusInWindow, requestFocusInWindow, resetKeyboardActions, reshape, revalidate, scrollRectToVisible, setActionMap, setAlignmentX, setAlignmentY, setAutoscrolls, setBackground, setBorder, setComponentPopupMenu, setDebugGraphicsOptions, setDefaultLocale, setDoubleBuffered, setEnabled, setFocusTraversalKeys, setFont, setForeground, setInheritsPopupMenu, setInputMap, setInputVerifier, setMaximumSize, setMinimumSize, setNextFocusableComponent, setOpaque, setPreferredSize, setRequestFocusEnabled, setToolTipText, setTransferHandler, setUI, setVerifyInputWhenFocusTarget, setVisible, unregisterKeyboardAction, updateMethods inherited from class java.awt.Container
add, add, add, add, add, addContainerListener, addImpl, addPropertyChangeListener, addPropertyChangeListener, applyComponentOrientation, areFocusTraversalKeysSet, countComponents, deliverEvent, doLayout, findComponentAt, findComponentAt, getComponent, getComponentAt, getComponentAt, getComponentCount, getComponents, getComponentZOrder, getContainerListeners, getFocusTraversalKeys, getFocusTraversalPolicy, getLayout, getMousePosition, insets, invalidate, isAncestorOf, isFocusCycleRoot, isFocusCycleRoot, isFocusTraversalPolicyProvider, isFocusTraversalPolicySet, layout, list, list, locate, minimumSize, paintComponents, preferredSize, printComponents, processContainerEvent, processEvent, remove, remove, removeAll, removeContainerListener, setComponentZOrder, setFocusCycleRoot, setFocusTraversalPolicy, setFocusTraversalPolicyProvider, setLayout, transferFocusDownCycle, validate, validateTreeMethods inherited from class java.awt.Component
action, add, addComponentListener, addFocusListener, addHierarchyBoundsListener, addHierarchyListener, addInputMethodListener, addKeyListener, addMouseListener, addMouseMotionListener, addMouseWheelListener, bounds, checkImage, checkImage, coalesceEvents, contains, createImage, createImage, createVolatileImage, createVolatileImage, disableEvents, dispatchEvent, enable, enableEvents, enableInputMethods, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, getBackground, getBounds, getColorModel, getComponentListeners, getComponentOrientation, getCursor, getDropTarget, getFocusCycleRootAncestor, getFocusListeners, getFocusTraversalKeysEnabled, getFont, getForeground, getGraphicsConfiguration, getHierarchyBoundsListeners, getHierarchyListeners, getIgnoreRepaint, getInputContext, getInputMethodListeners, getInputMethodRequests, getKeyListeners, getLocale, getLocation, getLocationOnScreen, getMouseListeners, getMouseMotionListeners, getMousePosition, getMouseWheelListeners, getName, getParent, getPropertyChangeListeners, getPropertyChangeListeners, getSize, getToolkit, getTreeLock, gotFocus, handleEvent, hasFocus, imageUpdate, inside, isBackgroundSet, isCursorSet, isDisplayable, isEnabled, isFocusable, isFocusOwner, isFocusTraversable, isFontSet, isForegroundSet, isLightweight, isMaximumSizeSet, isMinimumSizeSet, isPreferredSizeSet, isShowing, isValid, isVisible, keyDown, keyUp, list, list, list, location, lostFocus, mouseDown, mouseDrag, mouseEnter, mouseExit, mouseMove, mouseUp, move, nextFocus, paintAll, postEvent, prepareImage, prepareImage, processComponentEvent, processFocusEvent, processHierarchyBoundsEvent, processHierarchyEvent, processInputMethodEvent, processMouseWheelEvent, remove, removeComponentListener, removeFocusListener, removeHierarchyBoundsListener, removeHierarchyListener, removeInputMethodListener, removeKeyListener, removeMouseListener, removeMouseMotionListener, removeMouseWheelListener, removePropertyChangeListener, removePropertyChangeListener, repaint, repaint, repaint, requestFocus, requestFocus, requestFocusInWindow, resize, resize, setBounds, setBounds, setComponentOrientation, setCursor, setDropTarget, setFocusable, setFocusTraversalKeysEnabled, setIgnoreRepaint, setLocale, setLocation, setLocation, setMixingCutoutShape, setName, setSize, setSize, show, show, size, toString, transferFocus, transferFocusBackward, transferFocusUpCycle
-
Field Details
-
tileSize
public final int tileSizeThis is mentioned atfinal int scale, and it is the final tile size for this game.- Since:
- 1.0
- See Also:
-
maxWidthTiles
public final int maxWidthTilesThis is the maximum amount of tiles allowed in a row.- Since:
- 1.0
- See Also:
-
maxHeightTiles
public final int maxHeightTilesThis is the maximum amount of tiles allowed in a column.- Since:
- 1.0
- See Also:
-
screenWidth
public final int screenWidthThis is the maximum screen width in pixels, which ismaxWidthTiles * tileSize- Since:
- 1.0
- See Also:
-
screenHeight
public final int screenHeightThis is the screen maximum height in pixels, which ismaxHeightTiles * tileSize- Since:
- 1.0
- See Also:
-
maxWorldColumn
public final int maxWorldColumnThis is the maximum columns of ties that can be in a world.- Since:
- 1.1
- See Also:
-
maxWorldRow
public final int maxWorldRowThis is the maximum rows of tiles that can be in a world.- Since:
- 1.1
- See Also:
-
musicOn
public boolean musicOnTo determine if the program needs to play music.- Since:
- 1.0
-
currentMapState
public int currentMapStateTo 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 currentMapTo determine which map is the player currently playing.- Since:
- 1.1
-
title
public final int titleThe number for title map state.- Since:
- 1.1
- See Also:
-
play
public final int playThe number for playing map state.- Since:
- 1.1
- See Also:
-
dialogue
public final int dialogueThe number for the finish screen.- Since:
- 1.1
- See Also:
-
defaultPlayMap
public final int defaultPlayMapThe number for the default maps, which is inside the JAR.- Since:
- 1.1
- See Also:
-
customPlayMap
public final int customPlayMapThe 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 timerStartTimeThe time when the timer is started, for time calculation.- Since:
- 1.2
-
FPS
public final double FPSThe FPS of the game, currently 60.- Since:
- 1.0
- See Also:
-
ico
The {ImageIcon} for the game.- Since:
- 1.0
-
player
Instance declaration forPlayerclass, used by all.- Since:
- 1.0
-
tileManager
Instance declaration forTileManagerclass, used by all.- Since:
- 1.0
-
mapManager
Instance declaration forMapManager, used by all.- Since:
- 1.1
-
titleScreen
Instance declaration forTitleScreenclass, used by all.- Since:
- 1.2
-
parkourTimer
Instance declaration forParkourTimeclass, used by all.- Since:
- 1.1
-
keyHandler
The instance declaration forKeyHandler, used by all.- Since:
- 1.0
-
dialogScreen
Instance declaration forDialogScreen- Since:
- 1.4
-
pixelFont
The font used by the game.- Since:
- 1.2
-
-
Constructor Details
-
ParkourMain
public ParkourMain()The constructor for classParkourMain.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
JFrameis created, for example the game's mainThread.- Since:
- 1.0
-
-
Method Details
-
run
public void run()The method fromRunnableinterface, to control what would be done each frame. -
update
public void update()The method to call updates on updates on values of the game, like the player position.- Since:
- 1.0
-
paintComponent
The method for calling paint methods in each state for each class.- Overrides:
paintComponentin classJComponent- Parameters:
g- theGraphicsobject to protect- Since:
- 1.0
-
getSound
The method to get the sound file fromresand puts the audio into aClip.- Parameters:
path- Path to the audio inside the JAR.- Since:
- 1.1
-
getPixelFont
The method to get the font file inresand create aFontfor the program to use.- Parameters:
path- The path to the font file.- Since:
- 1.2
-
quit
public void quit(int code) The global quit method that handles the uninitialization.- Parameters:
code- Exit code.- Since:
- 1.5
-