don't pass deltas as param

This commit is contained in:
yugecin 2017-01-17 18:45:17 +01:00
parent f0883ff1af
commit 580b4142f6
8 changed files with 27 additions and 25 deletions

View File

@ -84,7 +84,7 @@ public class DisplayContainer implements ErrorDumpable, KeyListener, MouseListen
public int targetRenderInterval;
public int targetBackgroundRenderInterval;
public int realRenderInterval;
public int renderDelta;
public int delta;
public int timeSinceLastRender;
@ -122,7 +122,7 @@ public class DisplayContainer implements ErrorDumpable, KeyListener, MouseListen
targetBackgroundRenderInterval = 41; // ~24 fps
lastFrame = getTime();
delta = 1;
realRenderInterval = 1;
renderDelta = 1;
}
public void init(Class<? extends OpsuState> startingState) {
@ -144,7 +144,7 @@ public class DisplayContainer implements ErrorDumpable, KeyListener, MouseListen
input.poll(width, height);
mouseX = input.getMouseX();
mouseY = input.getMouseY();
state.update(delta);
state.update();
int maxRenderInterval;
if (Display.isVisible() && Display.isActive()) {
@ -163,13 +163,14 @@ public class DisplayContainer implements ErrorDumpable, KeyListener, MouseListen
graphics.resetTransform();
*/
state.preRenderUpdate(timeSinceLastRender);
renderDelta = timeSinceLastRender;
state.preRenderUpdate();
state.render(graphics);
fpsState.render(graphics);
bubNotifState.render(graphics, timeSinceLastRender);
barNotifState.render(graphics, timeSinceLastRender);
bubNotifState.render(graphics);
barNotifState.render(graphics);
realRenderInterval = timeSinceLastRender;
timeSinceLastRender = 0;
Display.update(false);

View File

@ -22,8 +22,8 @@ import yugecin.opsudance.core.errorhandling.ErrorDumpable;
public interface OpsuState extends ErrorDumpable {
void update(int delta);
void preRenderUpdate(int delta);
void update();
void preRenderUpdate();
void render(Graphics g);
void enter();
void leave();

View File

@ -66,11 +66,11 @@ public class BarNotificationState implements EventListener<BarNotificationEvent>
});
}
public void render(Graphics g, int delta) {
public void render(Graphics g) {
if (timeShown >= TOTAL_TIME) {
return;
}
timeShown += delta;
timeShown += displayContainer.renderDelta;
processAnimations();
g.setColor(bgcol);
g.fillRect(0, displayContainer.height / 2 - barHalfHeight, displayContainer.width, barHalfHeight * 2);

View File

@ -57,12 +57,12 @@ public class BubbleNotificationState implements EventListener<BubbleNotification
});
}
public void render(Graphics g, int delta) {
public void render(Graphics g) {
ListIterator<Notification> iter = bubbles.listIterator();
if (!iter.hasNext()) {
return;
}
addAnimationTime += delta;
addAnimationTime += displayContainer.renderDelta;
if (addAnimationTime > IN_TIME) {
finishAddAnimation();
}
@ -72,7 +72,7 @@ public class BubbleNotificationState implements EventListener<BubbleNotification
if (animateUp && addAnimationTime < IN_TIME) {
next.y = next.baseY - (int) (addAnimationHeight * AnimationEquation.OUT_QUINT.calc((float) addAnimationTime / IN_TIME));
}
if (next.render(g, displayContainer.mouseX, displayContainer.mouseY, delta)) {
if (next.render(g, displayContainer.mouseX, displayContainer.mouseY, displayContainer.renderDelta)) {
iter.remove();
}
animateUp = true;

View File

@ -39,7 +39,7 @@ public class FpsRenderState implements EventListener<ResolutionChangedEvent> {
public void render(Graphics g) {
int x = this.x;
x = drawText(g, (1000 / displayContainer.realRenderInterval) + " fps", x, this.y);
x = drawText(g, (1000 / displayContainer.renderDelta) + " fps", x, this.y);
drawText(g, (1000 / displayContainer.delta) + " ups", x, this.y);
}

View File

@ -49,16 +49,17 @@ public abstract class TransitionState extends BaseOpsuState {
}
@Override
public void update(int delta) {
applicableState.update(delta);
transitionTime += delta;
public void update() {
applicableState.update();
transitionTime += displayContainer.delta;
if (transitionTime >= transitionTargetTime) {
finish();
}
}
@Override
public void preRenderUpdate(int delta) {
public void preRenderUpdate() {
applicableState.preRenderUpdate();
}
@Override

View File

@ -38,8 +38,8 @@ public class EmptyRedState implements OpsuState {
}
@Override
public void update(int delta) {
counter -= delta;
public void update() {
counter -= displayContainer.delta;
if (counter < 0) {
counter = 10000; // to prevent more calls to switch, as this will keep rendering until state transitioned
System.out.println(System.currentTimeMillis() - start);
@ -48,7 +48,7 @@ public class EmptyRedState implements OpsuState {
}
@Override
public void preRenderUpdate(int delta) {
public void preRenderUpdate() {
}
@Override

View File

@ -35,8 +35,8 @@ public class EmptyState implements OpsuState {
}
@Override
public void update(int delta) {
counter -= delta;
public void update() {
counter -= displayContainer.delta;
if (counter < 0) {
counter = 10000; // to prevent more calls to switch, as this will keep rending until state transitioned
displayContainer.switchState(EmptyRedState.class);
@ -44,7 +44,7 @@ public class EmptyState implements OpsuState {
}
@Override
public void preRenderUpdate(int delta) {
public void preRenderUpdate() {
}
@Override