|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--java.lang.Thread | +--gecco.util.SignalThread | +--gecco.server.clock.Clock
This is a virtual game clock. It keeps track of the game time and its relation to real time. At any moment, the relationship is linear, but seen over the course of a whole game, the function will be pieced together of many such linear functions.
Field Summary |
Fields inherited from class java.lang.Thread |
MAX_PRIORITY, MIN_PRIORITY, NORM_PRIORITY |
Fields inherited from interface gecco.util.SignalRunnable |
SIGKILL, SIGNONE, SIGPAUSE, SIGQUIT, SIGRESUME |
Constructor Summary | |
Clock(double startTime,
double speed,
double normalSpeed,
boolean isFrozen)
Create a game clock. |
Method Summary | |
void |
freeze(boolean freeze)
Freezes or unfreezes the game. |
void |
gameSleep(double time)
Sleep for the specified amount of game time. |
double |
gameTime(double realTime)
Converts real time to game time. |
double |
gameTimeNow()
Returns the current game time, in seconds. |
void |
gameWait(Object obj,
double time)
Wait on an object for (at most) the specified amount of game time. |
double |
getNormalSpeed()
Returns the normal speed of the game time. |
double |
getSpeed()
Gets the Speed attribute of the Clock object |
boolean |
isFrozen()
Gets the Frozen attribute of the Clock object |
void |
realSleep(double time)
Sleep for the specified amount of real time. |
double |
realTime(double gameTime)
Converts game time to real time. |
double |
realTimeNow()
Returns the current value of the real-time clock, in seconds. |
void |
realWait(Object obj,
double time)
Wait on the specified object for (at most) the specified amount of real time. |
void |
run()
Wake up sleeping threads at the times they asked for. |
void |
setNormalSpeed()
Sets the speed of the game to its default value. |
void |
setSpeed(double speed)
Sets the speed of the game. |
Methods inherited from class gecco.util.SignalThread |
clearSignal, current, pauseHandler, sendSignal, signalPending |
Methods inherited from class java.lang.Thread |
activeCount, checkAccess, countStackFrames, currentThread, destroy, dumpStack, enumerate, getContextClassLoader, getName, getPriority, getThreadGroup, holdsLock, interrupt, interrupted, isAlive, isDaemon, isInterrupted, join, join, join, resume, setContextClassLoader, setDaemon, setName, setPriority, sleep, sleep, start, stop, stop, suspend, toString, yield |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Constructor Detail |
public Clock(double startTime, double speed, double normalSpeed, boolean isFrozen)
speed
- The speed of the game time.normalSpeed
- The normal speed of the game time.startTime
- The game time should start at this value.isFrozen
- true
if the game time is initially
frozen, false
otherwise.Method Detail |
public void setNormalSpeed()
public void setSpeed(double speed)
speed
- The new speed of the game time.public double getSpeed()
public double getNormalSpeed()
public boolean isFrozen()
public double realTime(double gameTime)
gameTime
- A point in game time.
public double realTimeNow()
public double gameTime(double realTime)
realTime
- A point in real time.
public double gameTimeNow()
public void realSleep(double time) throws InterruptedException
time
- The number of real seconds to sleep.
InterruptedException
- If the thread is interrupted.public void realWait(Object obj, double time) throws InterruptedException
obj
- The object to wait on.time
- The number of real seconds to wait.
InterruptedException
- If the thread is interrupted.public void gameSleep(double time) throws InterruptedException
time
- The number of game seconds to sleep.
InterruptedException
- If the thread is interrupted.public void gameWait(Object obj, double time) throws InterruptedException
obj
- The object.time
- The number of game seconds to wait.
InterruptedException
- If the thread is interrupted.public void freeze(boolean freeze)
freeze
- true if the game should freeze, false if it should
unfreeze.public void run()
run
in interface Runnable
run
in class Thread
|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |