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]
-
Field Summary
Fields Modifier and Type Field Description java.lang.StringaddressNetwork address of the Simulatorstatic intDEFAULT_PORTDefault 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 voidclose()Closes the Simulator.booleancomplete()Returns if the game has finished ("Complete").java.lang.Stringget(java.lang.String key)Returns the value of a Simulator variable.voidlocate(int x, int y)Relocates the Simulator window.static voidmain(java.lang.String[] args)Runs the Simulator (application!).doubleoption(java.lang.String key)Returns the value of a Hoverball option.voidset(java.lang.String key, double value)Sets a Simulator variable.voidset(java.lang.String key, java.lang.String value)Sets a Simulator variable.intstate()Returns the Simulator state.voidstate(int state)Changes the Simulator's state.doubletime()Returns the game time in the Simulator.
-
Field Details
-
DEFAULT_PORT
public static final int DEFAULT_PORTDefault port of the Simulator- See Also:
- Constant Field Values
-
address
public final java.lang.String addressNetwork address of the Simulator
-
-
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- portvisible- 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
valueequalsnullthe variable is deleted.- Parameters:
key- Simulator variablevalue- value
-
set
public void set(java.lang.String key, double value)Sets a Simulator variable.The
doublevalue is converted into astring.- Parameters:
key- Simulator variablevalue- 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
keyis 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 positiony- 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
-