aboutsummaryrefslogtreecommitdiffstats
path: root/src/main/java/Subconscious.java
diff options
context:
space:
mode:
authorNao Pross <naopross@thearcway.org>2018-02-11 21:25:48 +0100
committerNao Pross <naopross@thearcway.org>2018-02-11 21:25:48 +0100
commite7d4d7e9bdb628b1ae7966c96ffc40b1c192cf66 (patch)
tree051a2d11cc12cac5e2c40ad174a77600f9c1f077 /src/main/java/Subconscious.java
parentadd pan, add zoom, add weapon (diff)
downloadSubconscious-old-e7d4d7e9bdb628b1ae7966c96ffc40b1c192cf66.tar.gz
Subconscious-old-e7d4d7e9bdb628b1ae7966c96ffc40b1c192cf66.zip
Remove redundant scenesOffsetX/Y, replaced with panX
Diffstat (limited to 'src/main/java/Subconscious.java')
-rw-r--r--src/main/java/Subconscious.java24
1 files changed, 18 insertions, 6 deletions
diff --git a/src/main/java/Subconscious.java b/src/main/java/Subconscious.java
index cbb17dc..59824c2 100644
--- a/src/main/java/Subconscious.java
+++ b/src/main/java/Subconscious.java
@@ -96,9 +96,9 @@ public class Subconscious
@Override
public void run() {
long beforeTime, afterTime, sleepTime;
+ int skipFrame = 0;
window.setVisible(true);
-
beforeTime = System.currentTimeMillis();
running = true;
@@ -111,6 +111,14 @@ public class Subconscious
afterTime = System.currentTimeMillis();
sleepTime = RENDER_PERIOD_MS - (beforeTime - afterTime);
+ if (sleepTime < 0) {
+ skipFrame++;
+ continue;
+ }
+
+ if (skipFrame > 0)
+ skipFrame--;
+
try {
Thread.sleep(sleepTime);
} catch (InterruptedException ex) {}
@@ -138,13 +146,15 @@ public class Subconscious
@Override public void mouseReleased(MouseEvent e) {}
@Override public void mouseEntered(MouseEvent e) {}
@Override public void mouseExited(MouseEvent e) {}
- @Override public void mouseClicked(MouseEvent e) {
+ @Override
+ public void mouseClicked(MouseEvent e) {
currentScene.mouseClicked(e.getX(), e.getY());
}
@Override public void keyPressed(KeyEvent e) {}
@Override public void keyTyped(KeyEvent e) {}
- @Override public void keyReleased(KeyEvent e) {
+ @Override
+ public void keyReleased(KeyEvent e) {
int keyCode = e.getKeyCode();
if (keyCode == KeyEvent.VK_Q && e.isControlDown()) {
@@ -176,9 +186,10 @@ public class Subconscious
}
}
- @Override public void mouseWheelMoved(MouseWheelEvent e) {
+ @Override
+ public void mouseWheelMoved(MouseWheelEvent e) {
int value = e.getWheelRotation();
- currentScene.zoom(value*-3);
+ currentScene.zoom(value * -1);
//rerender
dbImage = null;
}
@@ -186,7 +197,8 @@ public class Subconscious
@Override public void componentHidden(ComponentEvent e) {}
@Override public void componentShown(ComponentEvent e) {}
@Override public void componentMoved(ComponentEvent e) {}
- @Override public void componentResized(ComponentEvent e) {
+ @Override
+ public void componentResized(ComponentEvent e) {
dbImage = null; // create new image with the correct size
}