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)
|
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
SpaceObject
SpaceObject(Game theGame,
double xP,
double yP,
double xV,
double yV)
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)