|
||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
| SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||
java.lang.Object | +--fi.utu.cs.asteroids.Game
Parameter handling and auxiliary methods for the game.
The initial parameters include:
asteroidDensity- The density of the asteroids. The radius of an asteroid is determined by dividing its mass with the density.
asteroidInitialVelocity- The initial velocity of an asteroid.
asteroidInitialAcceleration- The initial acceleration of an asteroid.
asteroidMinimumMass- The minimum mass for the asteroids.
asteroidMaximumMass- The maximum mass for the asteroids.
asteroidMinFractionOnSplit- The minimum size of the asteroid fraction on a split with respect to the original asteroid in the interval (0.0,1.0].
asteroidMaxFractionOnSplit- The maximum size of the asteroid fraction on a split with respect to the original asteroid in the interval (0.0,1.0].
asteroidSumOfFractionsOnSplit- The total sum of fractions created on a split (should be < 1.0).
projectileMass- The mass of the projectiles.
projectileRadius- The radius of the projectiles.
projectileLifetime- The lifetime of the projectiles in seconds.
projectileInitialVelocity- The initial velocity of the projectiles.
projectileInitialAcceleration- The initial acceleration of the projectiles
shipMass- The mass of the ships.
shipRadius- The radius of the ships.
shipShotsPerSecond- The amount of shots that the ship is capable of firing in one second.
shipSteeringRotationPerSecond- The angle (in radians) that the ship is capable of rotating in one second.
shipThrusterForce- The force created by the ship's thruster in one second. The acceleration of the ship depends on this force and the ship's mass.
sparkRadius- The radius of the sparks.
sparkLifetime- The lifetime of the sparks in seconds.
sparkMaxVelocity- The maximum velocity of the sparks on an explosion cloud.
sparksOnCloud- The amount of sparks used in an explosion cloud.
debrisRadius- The radius of a piece of debris.
debrisLifetime- The lifetime of a piece of debris in seconds.
debrisMaxVelocity- The maximum velocity of the debris on a cloud.
debrisOnCloud- The amount of debris in a cloud.
collisionAsteroidAsteroid- A Boolean value indicating whether the asteroids can collide with each other.
collisionProjectileProjectile- A Boolean value indicating whether the projectiles can collide with each other.
collisionProjectileShip- A Boolean value indicating whether the projectiles can collide with the ships.
collisionShipShip- A Boolean value indicating whether the ships can collide with each other.
playgroundWidth- The width of the universe used in the game.
playgroundHeight- The height of the universe used in the game.
playgroundBorder- The size of the border that surrounds the visible area.
decorations- A Boolean value indicating whether the decorations (i.e., sparks and debris) are included in the game.
| Method Summary | |
static Asteroid |
createAsteroidOnBorder(Universe u)
Creates and inserts an Asteroid object to the
the universe u. |
static Universe |
createPlayground()
Creates and returns a toroid universe. |
static Universe |
createPlayground(double w,
double h)
Creates and returns a toroid universe with the width w and height h. |
static Ship |
createShipOnCenter(Universe u)
Creates and inserts a Ship object to the center
of the universe u. |
static Ship |
createShipOnRandomPosition(Universe u)
Creates and inserts a Ship object to a random position
in the universe u. |
static ShapeView |
createView(Universe u,
double z)
Creates and returns a ShapeView Swing component.
|
static ShapeView |
createView(Universe u,
double z,
double b)
Creates and returns a ShapeView Swing component.
|
static boolean |
getBooleanParameter(java.lang.String n)
Returns the Boolean value of the parameter n. |
static double |
getDoubleParameter(java.lang.String n)
Returns the double-precision floating point value of the parameter n. |
static int |
getIntegerParameter(java.lang.String n)
Returns the integer value of the parameter n. |
static java.lang.String |
getStringParameter(java.lang.String n)
Returns the String object of the
parameter n. |
static void |
initialize()
Sets the built-in default values to the parameters. |
static void |
load(java.io.InputStream is)
Reads a parameter list (type, name and value triplets) from the input stream is. |
static java.util.Iterator |
parameterNames()
Returns an iterator to the names of all the parameters. |
static void |
save(java.io.OutputStream os)
Writes the parameter list (type, key and element triplets) to the output stream os. |
static void |
setParameter(java.lang.String n,
boolean v)
Sets the parameter n to the Boolean value
v. |
static void |
setParameter(java.lang.String n,
double v)
Sets the parameter n to the double-precision
floating point value v. |
static void |
setParameter(java.lang.String n,
int v)
Sets the parameter n to the integer value
v. |
static void |
setParameter(java.lang.String n,
java.lang.String s)
Sets the parameter n to the String
object s. |
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Method Detail |
public static Universe createPlayground()
playgroundWidth and the
height by the parameter playgroundHeight.
public static Universe createPlayground(double w,
double h)
w and height h.
public static ShapeView createView(Universe u,
double z)
ShapeView Swing component.
The width of the border is defined by the parameter
playgroundBorder.u - The universe of the game.z - The zoom factor.createView(Universe,double,double)
public static ShapeView createView(Universe u,
double z,
double b)
ShapeView Swing component.
The view shows the rectangle ((u.getMinimumCorner().getX()
+ b, u.getMinimumCorner().getY() + b),
(u.getMaximumCorner().getX() - b,
u.getMaximumCorner().getY() - b)).u - The universe of the game.z - The zoom factor.b - The width of the border.public static Asteroid createAsteroidOnBorder(Universe u)
Asteroid object to the
the universe u. The asteroid, heading a random
direction, is placed on a random position in the border.Asteroidpublic static Ship createShipOnCenter(Universe u)
Ship object to the center
of the universe u.Shippublic static Ship createShipOnRandomPosition(Universe u)
Ship object to a random position
in the universe u.Shippublic static void initialize()
public static double getDoubleParameter(java.lang.String n)
n. The method throws
ClassCastException if the parameter is of a
different type.public static int getIntegerParameter(java.lang.String n)
n. The method throws
ClassCastException if the parameter is of a
different type.public static boolean getBooleanParameter(java.lang.String n)
n. The method throws
ClassCastException if the parameter is of a
different type.public static java.lang.String getStringParameter(java.lang.String n)
String object of the
parameter n. The method throws
ClassCastException if the parameter is of a
different type.
public static void setParameter(java.lang.String n,
double v)
n to the double-precision
floating point value v.
public static void setParameter(java.lang.String n,
int v)
n to the integer value
v.
public static void setParameter(java.lang.String n,
boolean v)
n to the Boolean value
v.
public static void setParameter(java.lang.String n,
java.lang.String s)
n to the String
object s.public static java.util.Iterator parameterNames()
public static void load(java.io.InputStream is)
throws java.io.IOException
is. The stream is assumed to be
using ISO 8859-1 character encoding.
Every parameter occupies one line of the input stream. Lines from
the input stream are processed until end of file is reached on the
input stream.
A line that begins with a type token DOUBLE,
INTEGER, BOOLEAN or STRING
is interpreted to contain the name and the value of a parameter.
For example,
DOUBLE pi 3.14 INTEGER meaningOfLife 42 BOOLEAN existence false STRING employees "Dilbert, Alice, Wally"
java.io.IOException - An error occurred when reading the input stream.save(OutputStream)
public static void save(java.io.OutputStream os)
throws java.io.IOException
os.java.io.IOException - An error occurred when writing the output stream.load(InputStream)
|
||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
| SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||