Package hoverball

Class Simulator

java.lang.Object
hoverball.Simulator

public final class Simulator
extends java.lang.Object
The simulator is the core piece of the Hoverball program. It creates a virtual Hoverball world in which connected players can move - according to the laws of this world.

As the Simulator is entirely directed through the network, this class only offers a few elementary methods for its configuration.

Please refer to the Hoverball Manual for a detailed description of the Simulator.


The class Simulator can also be run as an application:

java hoverball.Simulator [:port]

  • (ohne) - Opens a Simulator at the default port.
  • :port - Opens a Simulator at the specified port.
    • Field Summary

      Fields 
      Modifier and Type Field Description
      java.lang.String address
      Network address of the Simulator
      static int DEFAULT_PORT
      Default port of the Simulator
    • Constructor Summary

      Constructors 
      Constructor Description
      Simulator()
      Opens a Simulator.
      Simulator​(boolean visible)
      Opens a Simulator visibly or invisibly ("headless").
      Simulator​(int port)
      Opens a Simulator at the specified port.
      Simulator​(int port, boolean visible)
      Opens a Simulator at the specified port visibly or invisibly.
    • Method Summary

      Modifier and Type Method Description
      void close()
      Closes the Simulator.
      boolean complete()
      Returns if the game has finished ("Complete").
      java.lang.String get​(java.lang.String key)
      Returns the value of a Simulator variable.
      void locate​(int x, int y)
      Relocates the Simulator window.
      static void main​(java.lang.String[] args)
      Runs the Simulator (application!).
      double option​(java.lang.String key)
      Returns the value of a Hoverball option.
      void set​(java.lang.String key, double value)
      Sets a Simulator variable.
      void set​(java.lang.String key, java.lang.String value)
      Sets a Simulator variable.
      int state()
      Returns the Simulator state.
      void state​(int state)
      Changes the Simulator's state.
      double time()
      Returns the game time in the Simulator.

      Methods inherited from class java.lang.Object

      clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Field Details

    • Constructor Details

      • Simulator

        public Simulator()
        Opens a Simulator.
      • Simulator

        public Simulator​(int port)
        Opens a Simulator at the specified port.
        Parameters:
        port - port
      • Simulator

        public Simulator​(boolean visible)
        Opens a Simulator visibly or invisibly ("headless").
        Parameters:
        visible - visible?
      • Simulator

        public Simulator​(int port, boolean visible)
        Opens a Simulator at the specified port visibly or invisibly.
        Parameters:
        port - port
        visible - visible?
    • Method Details

      • main

        public static void main​(java.lang.String[] args)
        Runs the Simulator (application!).
      • set

        public void set​(java.lang.String key, java.lang.String value)
        Sets a Simulator variable.

        If value equals null the variable is deleted.

        Parameters:
        key - Simulator variable
        value - value
      • set

        public void set​(java.lang.String key, double value)
        Sets a Simulator variable.

        The double value is converted into a string.

        Parameters:
        key - Simulator variable
        value - value
      • get

        public java.lang.String get​(java.lang.String key)
        Returns the value of a Simulator variable.
        Parameters:
        key - Simulator variable
        Returns:
        the value
      • option

        public double option​(java.lang.String key)
        Returns the value of a Hoverball option.

        If key is a Simulator variable but no option, it returns 0.

        Parameters:
        key - Hoverball option
        Returns:
        the value
      • state

        public void state​(int state)
        Changes the Simulator's state.
        Parameters:
        state - new state
      • close

        public void close()
        Closes the Simulator.
      • locate

        public void locate​(int x, int y)
        Relocates the Simulator window.
        Parameters:
        x - x-coordinate of the window position
        y - y-coordinate of the window position
      • state

        public int state()
        Returns the Simulator state.
        Returns:
        state
      • time

        public double time()
        Returns the game time in the Simulator.
        Returns:
        time
      • complete

        public boolean complete()
        Returns if the game has finished ("Complete").
        Returns:
        complete