Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save nanonull/b56b3d71779b6c62aa52 to your computer and use it in GitHub Desktop.
Save nanonull/b56b3d71779b6c62aa52 to your computer and use it in GitHub Desktop.
@Test
public void test_interval_delta_when_world_step_is_bigger_than_system_interval() {
IntervalSystem intervalSystem = new IntervalSystem();
World world = new World(new WorldConfiguration()
.setSystem(intervalSystem));
float worldTotalTime=0;
float intervalSystemTotalIntervalTime=0;
for (int i = 0; i < 4; i++) {
world.delta = 2f;
worldTotalTime+=2f;
world.process();
// intervalSystem has 1 second interval
// so it will run processing round on each world step
intervalSystemTotalIntervalTime +=intervalSystem.getIntervalDelta();
System.out.println(intervalSystem.getIntervalDelta());
}
Assert.assertEquals(worldTotalTime, 2 * 4, ACC);
Assert.assertEquals(intervalSystemTotalIntervalTime, 2 * 4, ACC);
}
private static class IntervalSystem extends IntervalEntitySystem {
@SuppressWarnings("unchecked")
public IntervalSystem() {
super(Aspect.all(ComponentX.class), 1);
}
@Override
protected void processSystem() {
System.out.println("processSystem");
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment