Class Units

java.lang.Object
  |
  +--Units

class Units
extends java.lang.Object

The Units clas is a catch-all for holding a lot of the spatial size, temporal duration, and speed constants used in the Asteroids program. These statics could just as well live in the individual classes, but since they interact with each other, it's more perspicacious to have them in one spot. All the times are specified in seconds. The size units are arbitrary, we generally state them in terms of SIZE_WORLD, which is the diameter of the world where the asteroids live. A speed of k * SIZE_WORLD means that the object travels k* SIZE_WORLD in one second, and that the object takes 1/k seconds to travel all the way across the world. Thus a speed of 0.25 * SIZE_WORLD means the object travels a quarter wau across in one second, and takes four seconds to travel all the way across.


Field Summary
(package private) static double ACCELERATION_ASTEROID_DART
          Acceleration used by asteroid to avoid the nearest bullet.
(package private) static double ACCELERATION_ASTEROID_TOSHIP
          Acceleration towards the ship.
(package private) static double ACCELERATION_THRUST
          Acceleration in world widths per second per second.
(package private) static double DARTING_SPEEDUP
          Factor by which a darting asteroid is allowed to exceed its normal maxspeed.
(package private) static double FIRE_WAIT_SHIP
          Seconds between bullet shots, so the bullets aren't too close together.
(package private) static double FIRE_WAIT_UFO
          Seconds between missile shots, so the missles aren't too often.
(package private) static double HEIGHT_WORLD
          The height of the unchanging real world in which the Asteroids move, the document size, rather than the view size.
(package private) static double HYPER_WAIT_SHIP
          Number of seconds that a ship is immune while doing a hyperjump.
(package private) static double LIFETIME_BULLET
          life in seconds.
(package private) static double LIFETIME_EXPLOSION
          Number of seconds that explosion lines live.
(package private) static double LIFETIME_MISSILE
          Missile lives long enough to cross the screen once.
(package private) static double LIFETIME_UFO
          Seconds that a UFO lives
(package private) static double MAX_SIZE_ASTEROID
          Max size of asteroid side in world units.
(package private) static double MAX_SPEED_ASTEROID
           
(package private) static double MAX_SPEED_BULLET
          Let Bullet go faster than the ship can go.
(package private) static double MAX_SPEED_SHIP
          Ship's maximum speed.
(package private) static double MAX_SPEED_SPRITE
          Default Sprite maxspeed, crosses world in 1.2 seconds.
(package private) static double MAX_TURN_SPEED_ASTEROID
          Max speed of asteroid rotation, in radians per second.
(package private) static double MAX_TURN_SPEED_EXPLOSION
          Max speed of explosion rotation.
(package private) static double MIN_SIZE_ASTEROID
           
(package private) static double MIN_SPEED_ASTEROID
          Min speed of asteroid motion in world units per update.
(package private) static double MIN_SPEED_UFO
          Min speed of Ufo motion in units per update.
(package private) static double RADIUS_WORLD
          Useful for disk wrap.
(package private) static double SIZE_WORLD
          The minimum cross diameter of the world.
(package private) static double SPEED_BULLET
          Bullet speed in worlds per second.
(package private) static double SPEED_INCREMENT_ASTEROIDS
          Increment to the maxspeed (short of MAX_SPEED_ASTEROID) to be used when starting a new board.
(package private) static double SPEED_MISSILE
          Speed the missile uses to pursue a ship.
(package private) static double SPEED_MULTIPLIER_EXPLOSION
          Multiply this times a shape vertex's distance from the origin to get the outward speed of an explosion fragment.
(package private) static double START_MAX_SPEED_UFO
          Speed in world units per second.
(package private) static double STORM_PAUSE
          Number of updates to pause after an old wave of asteroids before a new one.
(package private) static double TIMEUNIT
          Seconds between screen updates.
(package private) static double TURN_STEP_FAST_SHIP
          See TURN_STEP_SLOW.
(package private) static double TURN_STEP_SLOW_SHIP
          Size of ship's rotation speed when you hold down the arrow key.
(package private) static double WIDTH_WORLD
          The width of the unchanging real world in which the Asteroids move, the document size, rather than the view size.
 
Constructor Summary
(package private) Units()
           
 
Methods inherited from class java.lang.Object
, clone, equals, finalize, getClass, hashCode, notify, notifyAll, registerNatives, toString, wait, wait, wait
 

Field Detail

TIMEUNIT

static final double TIMEUNIT
Seconds between screen updates. Used in the Asteroids main function's update as part of an argument to a wait call. We have 0.04, which means we try for 25 updates a second. I still need to look into exactly how to handle the case when the processor can't go this fast.

WIDTH_WORLD

static final double WIDTH_WORLD
The width of the unchanging real world in which the Asteroids move, the document size, rather than the view size. Used in Asteroids.

HEIGHT_WORLD

static final double HEIGHT_WORLD
The height of the unchanging real world in which the Asteroids move, the document size, rather than the view size. Used in Asteroids.

SIZE_WORLD

static final double SIZE_WORLD
The minimum cross diameter of the world. Used for the rest of the Unit definitions.

RADIUS_WORLD

static final double RADIUS_WORLD
Useful for disk wrap.

STORM_PAUSE

static final double STORM_PAUSE
Number of updates to pause after an old wave of asteroids before a new one. Was 30.

MAX_SPEED_SPRITE

static final double MAX_SPEED_SPRITE
Default Sprite maxspeed, crosses world in 1.2 seconds.

MIN_SPEED_ASTEROID

static final double MIN_SPEED_ASTEROID
Min speed of asteroid motion in world units per update. 0.1

MAX_SPEED_ASTEROID

static final double MAX_SPEED_ASTEROID

SPEED_INCREMENT_ASTEROIDS

static final double SPEED_INCREMENT_ASTEROIDS
Increment to the maxspeed (short of MAX_SPEED_ASTEROID) to be used when starting a new board.

MIN_SIZE_ASTEROID

static final double MIN_SIZE_ASTEROID

MAX_SIZE_ASTEROID

static final double MAX_SIZE_ASTEROID
Max size of asteroid side in world units.

MAX_TURN_SPEED_ASTEROID

static final double MAX_TURN_SPEED_ASTEROID
Max speed of asteroid rotation, in radians per second.

ACCELERATION_ASTEROID_DART

static final double ACCELERATION_ASTEROID_DART
Acceleration used by asteroid to avoid the nearest bullet.

DARTING_SPEEDUP

static final double DARTING_SPEEDUP
Factor by which a darting asteroid is allowed to exceed its normal maxspeed.

ACCELERATION_ASTEROID_TOSHIP

static final double ACCELERATION_ASTEROID_TOSHIP
Acceleration towards the ship.

MIN_SPEED_UFO

static final double MIN_SPEED_UFO
Min speed of Ufo motion in units per update. Was 3.

START_MAX_SPEED_UFO

static final double START_MAX_SPEED_UFO
Speed in world units per second.

LIFETIME_UFO

static final double LIFETIME_UFO
Seconds that a UFO lives

FIRE_WAIT_UFO

static final double FIRE_WAIT_UFO
Seconds between missile shots, so the missles aren't too often.

MAX_SPEED_SHIP

static final double MAX_SPEED_SHIP
Ship's maximum speed.

HYPER_WAIT_SHIP

static final double HYPER_WAIT_SHIP
Number of seconds that a ship is immune while doing a hyperjump.

FIRE_WAIT_SHIP

static final double FIRE_WAIT_SHIP
Seconds between bullet shots, so the bullets aren't too close together.

TURN_STEP_SLOW_SHIP

static final double TURN_STEP_SLOW_SHIP
Size of ship's rotation speed when you hold down the arrow key. Needs to be small so you can aim accurately enough to hit a missile, on the other hand it needs to be large so you can spin and fire off a big sweep of bullets. So we have two kinds of TURN_STEP. Speed is radians per second. 0.6

TURN_STEP_FAST_SHIP

static final double TURN_STEP_FAST_SHIP
See TURN_STEP_SLOW. Radians per second. 1.2

ACCELERATION_THRUST

static final double ACCELERATION_THRUST
Acceleration in world widths per second per second. 1.0

SPEED_MISSILE

static final double SPEED_MISSILE
Speed the missile uses to pursue a ship. Worlds per second. 0.27.

LIFETIME_MISSILE

static final double LIFETIME_MISSILE
Missile lives long enough to cross the screen once.

SPEED_MULTIPLIER_EXPLOSION

static final double SPEED_MULTIPLIER_EXPLOSION
Multiply this times a shape vertex's distance from the origin to get the outward speed of an explosion fragment. 4.0

MAX_TURN_SPEED_EXPLOSION

static final double MAX_TURN_SPEED_EXPLOSION
Max speed of explosion rotation. Radians per second. 1.3

LIFETIME_EXPLOSION

static final double LIFETIME_EXPLOSION
Number of seconds that explosion lines live. 1.5

MAX_SPEED_BULLET

static final double MAX_SPEED_BULLET
Let Bullet go faster than the ship can go.

SPEED_BULLET

static final double SPEED_BULLET
Bullet speed in worlds per second. 0.8

LIFETIME_BULLET

static final double LIFETIME_BULLET
life in seconds. Make sure it lives long enough to reach the edge of the screen. 2.0
Constructor Detail

Units

Units()