Class SBSRModelControl

All Implemented Interfaces:
ActionListener, KeyListener, ImageObserver, MenuContainer, Serializable, EventListener, Accessible

public class SBSRModelControl extends JPanel implements ActionListener, KeyListener
See Also:
  • Field Details

    • strConnectionResult

      public String strConnectionResult
      Tells user things like host/client status and errors in the connection process when connect buton is pressed
    • strHostUsername

      public String strHostUsername
      The name the host enters in connection process
    • strClientUsername

      public String strClientUsername
      The name the client enters in connection process
    • strIp

      public String strIp
      The IP of the computer
    • strPort

      public String strPort
      Port of the computer
    • strUsername

      public String strUsername
      The entered username
    • strResult

      public String strResult
      The result of the connection method
    • blnHost

      public boolean blnHost
      Used to see who is host for extra privileges
    • blnjump

      public boolean blnjump
      Used to see if jumping or not
    • intNumPlayers

      public int intNumPlayers
      Used to count the number of players
    • intJumpCooldown

      public int intJumpCooldown
      Cooldown for jump
    • intHostCharacter

      public int intHostCharacter
      Sets which character the host is
    • intClientCharacter

      public int intClientCharacter
      Sets which character the client is
    • blnHostReady

      public boolean blnHostReady
      Checks to see if the host is ready
    • blnClientReady

      public boolean blnClientReady
      Checks to see if the client is ready
    • blnConnect

      public boolean blnConnect
      Checks to see if the user is connected to a server.
    • intPlayersReady

      public int intPlayersReady
      The number of players ready
    • intRaceTime

      public int intRaceTime
      Timer to count the seconds it takes for players to reach end of map
    • theTimer

      public Timer theTimer
      Timer that runs 60fps Animations
    • RaceTimer

      public Timer RaceTimer
      Timer that runs every second to count how long character takes to reach the end
    • dblCharacterDefX

      public double dblCharacterDefX
      Character displacement in X
    • dblCharacterDefY

      public double dblCharacterDefY
      Character displacement in Y
    • intEndY

      public int intEndY
      Integer value for the y-coordinate component denoting the bottom point of the pole
    • blnDemo

      public boolean blnDemo
      Communicates 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

      public String connect(String ipField, String portField, String UsernameField)
      Method used to host and connect client to host
    • playerDied

      public void playerDied(String strplayerUsername)
      Method to run when player dies
    • playerReachedEnd

      public void playerReachedEnd(String strplayerUsername)
      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

      public void keyPressed(KeyEvent evt)
      Checks which keys are pressed and excecutes code such as movement depending on which key is pressed
      Specified by:
      keyPressed in interface KeyListener
    • keyTyped

      public void keyTyped(KeyEvent evt)
      Checks which key is typed and focuses back to animation panel when enter is typed
      Specified by:
      keyTyped in interface KeyListener
    • keyReleased

      public void keyReleased(KeyEvent evt)
      Checks keys released and stops player movement
      Specified by:
      keyReleased in interface KeyListener
    • actionPerformed

      public void actionPerformed(ActionEvent evt)
      Overrides action listener and check things like button presses
      Specified by:
      actionPerformed in interface ActionListener
    • main

      public static void main(String[] args)
      Executing main program