spacewar
Class SpaceObject

java.lang.Object
  |
  +--spacewar.SpaceObject
Direct Known Subclasses:
Bullet, EnergyPacket, Ship

abstract class SpaceObject
extends java.lang.Object

SpaceObjects are objects that float around in space. They support the minimal SpaceObject protocol, having to do with position, velocity, size and liveness. They are constructed with game, position, velocity and size. When constructed, a spaceobject adds itself to the registry. When it dies, a spaceobject removes itself from the registry. But note that it doesn't decide when to die, subclasses do that. SpaceObjects also support the paint()/getSize() protocol. The display aspect actually implements these methods. They draw the space object on the screen and say how much space it takes up there.


Constructor Summary
(package private) SpaceObject(Game theGame, double xP, double yP, double xV, double yV)
          
 
Method Summary
(package private)  void ()
          
(package private)  void accelerate(double dXVel, double dYVel)
          
(package private)  void clockTick()
           Move 1 unit of time's worth of distance.
(package private)  void die()
          
Advised by: spacewar.Display1.SpaceObjectDA, spacewar.Display2.SpaceObjectDA
(package private)  Game getGame()
          
(package private)  double getOldXPos()
          
(package private)  double getOldYPos()
          
(package private) abstract  int getSize()
          
(package private)  double getXPos()
          
(package private)  double getXVel()
          
(package private)  double getYPos()
          
(package private)  double getYVel()
          
(package private) abstract  void handleCollision(SpaceObject obj)
          
(package private)  boolean isAlive()
          
(package private)  void setIsAlive(boolean n)
          
(package private)  void setXVel(double n)
          
(package private)  void setYVel(double n)
          
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

SpaceObject

SpaceObject(Game theGame,
            double xP,
            double yP,
            double xV,
            double yV)
Method Detail

void ()
Overrides:
in class java.lang.Object

getGame

Game getGame()

getXPos

double getXPos()

getYPos

double getYPos()

getOldXPos

double getOldXPos()

getOldYPos

double getOldYPos()

getXVel

double getXVel()

getYVel

double getYVel()

setXVel

void setXVel(double n)

setYVel

void setYVel(double n)

isAlive

boolean isAlive()

setIsAlive

void setIsAlive(boolean n)

clockTick

void clockTick()
Move 1 unit of time's worth of distance. I.e. increment xPos by xVel and yPos by yVel. If we move off an edge of the screen move us back in the opposite edge.

accelerate

void accelerate(double dXVel,
                double dYVel)

die

void die()

Advised by: spacewar.Display1.SpaceObjectDA, spacewar.Display2.SpaceObjectDA

getSize

abstract int getSize()

handleCollision

abstract void handleCollision(SpaceObject obj)