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.String
address
Network address of the Simulatorstatic 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.
-
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
value
equalsnull
the variable is deleted.- Parameters:
key
- Simulator variablevalue
- value
-
set
public void set(java.lang.String key, double value)Sets a Simulator variable.The
double
value 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
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 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
-