use of com.b3dgs.lionengine.Timing in project lionengine by b3dgs.
the class UtilSequenceTest method testPause.
/**
* Test pause.
*/
@Test
public void testPause() {
final Timing timing = new Timing();
Assert.assertTrue(String.valueOf(timing.elapsed()), timing.elapsed() == 0);
timing.start();
UtilSequence.pause(Constant.HUNDRED);
Assert.assertTrue(String.valueOf(timing.elapsed()), timing.elapsed() > 0);
}
use of com.b3dgs.lionengine.Timing in project lionengine by b3dgs.
the class Sequence method start.
/*
* Sequencable
*/
@Override
public void start(Screen screen) {
this.screen = screen;
screen.addListener(this);
if (cursorVisibility != null) {
setSystemCursorVisible(cursorVisibility.booleanValue());
}
nextSequence = null;
initResolution(resolution);
// Prepare sequence to be started
currentFrameRate = config.getOutput().getRate();
screen.requestFocus();
load();
onLoaded(Constant.EXTRP, screen.getGraphic());
// Main loop
final Timing updateFpsTimer = new Timing();
updateFpsTimer.start();
loop.start(screen, new Frame() {
@Override
public void update(double extrp) {
Sequence.this.update(extrp);
}
@Override
public void render() {
Sequence.this.render();
}
@Override
public void computeFrameRate(long lastTime, long currentTime) {
Sequence.this.computeFrameRate(updateFpsTimer, lastTime, currentTime);
}
});
screen.removeListener(this);
}
use of com.b3dgs.lionengine.Timing in project lionengine by b3dgs.
the class UtilSequenceTest method testPause.
/**
* Test pause.
*/
@Test
void testPause() {
final Timing timing = new Timing();
assertTrue(timing.elapsed() == 0, String.valueOf(timing.elapsed()));
timing.start();
UtilSequence.pause(Constant.HUNDRED);
assertTrue(timing.elapsed() > 0, String.valueOf(timing.elapsed()));
}
use of com.b3dgs.lionengine.Timing in project lionengine by b3dgs.
the class ServerUdp method taskBandwidth.
private void taskBandwidth() {
final Timing timing = new Timing();
while (running) {
timing.start();
try {
Thread.sleep(Constant.THOUSAND);
} catch (@SuppressWarnings("unused") final InterruptedException exception) {
Thread.currentThread().interrupt();
break;
}
final float elapsed = timing.elapsed() / (float) Constant.THOUSAND;
timing.restart();
final float factor = 1 / 1024f * elapsed;
bandwidthUp = bandwidthUpSum.getAndSet(0) * factor;
bandwidthDown = bandwidthDownSum.getAndSet(0) * factor;
}
}
use of com.b3dgs.lionengine.Timing in project lionengine by b3dgs.
the class UtilSequenceTest method testPauseInterrupted.
/**
* Test pause interrupted.
*/
@Test
void testPauseInterrupted() {
final Timing timing = new Timing();
timing.start();
final Thread thread = new Thread(() -> UtilSequence.pause(Constant.THOUSAND));
thread.start();
thread.interrupt();
assertTrue(timing.elapsed() < Constant.THOUSAND, String.valueOf(timing.elapsed()));
}
Aggregations