Class SBSRModelControl
java.lang.Object
java.awt.Component
java.awt.Container
javax.swing.JComponent
javax.swing.JPanel
SBSRModelControl
- All Implemented Interfaces:
ActionListener,KeyListener,ImageObserver,MenuContainer,Serializable,EventListener,Accessible
- 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 TypeFieldDescriptionbooleanChecks to see if the client is readybooleanChecks to see if the user is connected to a server.booleanCommunicates to the code whether the player is in demo modebooleanUsed to see who is host for extra privilegesbooleanChecks to see if the host is readybooleanUsed to see if jumping or notdoubleCharacter displacement in XdoubleCharacter displacement in YintSets which character the client isintInteger value for the y-coordinate component denoting the bottom point of the poleintSets which character the host isintCooldown for jumpintUsed to count the number of playersintThe number of players readyintTimer to count the seconds it takes for players to reach end of mapTimer that runs every second to count how long character takes to reach the endThe name the client enters in connection processTells user things like host/client status and errors in the connection process when connect buton is pressedThe name the host enters in connection processThe IP of the computerPort of the computerThe result of the connection methodThe entered usernameTimer that runs 60fps AnimationsFields 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 TypeMethodDescriptionvoidOverrides action listener and check things like button pressesvoidUsed to check if both players are ready so game can beginMethod used to host and connect client to hostvoidkeyPressed(KeyEvent evt) Checks which keys are pressed and excecutes code such as movement depending on which key is pressedvoidkeyReleased(KeyEvent evt) Checks keys released and stops player movementvoidChecks which key is typed and focuses back to animation panel when enter is typedstatic voidExecuting main programvoidplayerDied(String strplayerUsername) Method to run when player diesvoidplayerReachedEnd(String strplayerUsername) Method to run when player reaches the endMethods 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, paintComponent, 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
-
strConnectionResult
Tells user things like host/client status and errors in the connection process when connect buton is pressed -
strHostUsername
The name the host enters in connection process -
strClientUsername
The name the client enters in connection process -
strIp
The IP of the computer -
strPort
Port of the computer -
strUsername
The entered username -
strResult
The result of the connection method -
blnHost
public boolean blnHostUsed to see who is host for extra privileges -
blnjump
public boolean blnjumpUsed to see if jumping or not -
intNumPlayers
public int intNumPlayersUsed to count the number of players -
intJumpCooldown
public int intJumpCooldownCooldown for jump -
intHostCharacter
public int intHostCharacterSets which character the host is -
intClientCharacter
public int intClientCharacterSets which character the client is -
blnHostReady
public boolean blnHostReadyChecks to see if the host is ready -
blnClientReady
public boolean blnClientReadyChecks to see if the client is ready -
blnConnect
public boolean blnConnectChecks to see if the user is connected to a server. -
intPlayersReady
public int intPlayersReadyThe number of players ready -
intRaceTime
public int intRaceTimeTimer to count the seconds it takes for players to reach end of map -
theTimer
Timer that runs 60fps Animations -
RaceTimer
Timer that runs every second to count how long character takes to reach the end -
dblCharacterDefX
public double dblCharacterDefXCharacter displacement in X -
dblCharacterDefY
public double dblCharacterDefYCharacter displacement in Y -
intEndY
public int intEndYInteger value for the y-coordinate component denoting the bottom point of the pole -
blnDemo
public boolean blnDemoCommunicates to the code whether the player is in demo mode
-
-
Constructor Details
-
SBSRModelControl
public SBSRModelControl(SBSRViewTest view) Adding action listeners from the view
-
-
Method Details
-
connect
Method used to host and connect client to host -
playerDied
Method to run when player dies -
playerReachedEnd
Method to run when player reaches the end -
checkPlay
public void checkPlay()Used to check if both players are ready so game can begin -
keyPressed
Checks which keys are pressed and excecutes code such as movement depending on which key is pressed- Specified by:
keyPressedin interfaceKeyListener
-
keyTyped
Checks which key is typed and focuses back to animation panel when enter is typed- Specified by:
keyTypedin interfaceKeyListener
-
keyReleased
Checks keys released and stops player movement- Specified by:
keyReleasedin interfaceKeyListener
-
actionPerformed
Overrides action listener and check things like button presses- Specified by:
actionPerformedin interfaceActionListener
-
main
Executing main program
-