From 3cd96daaf22236e4eb15c6422f772abf08351023 Mon Sep 17 00:00:00 2001 From: Starla Insigna Date: Thu, 12 Feb 2009 09:30:29 -0500 Subject: Engine: Rewrote Interval Interval previously used milliseconds, but now it uses nanoseconds (which, according to System, is more accurate). Fixes #11 --- .../fourisland/fourpuzzle/gamestate/TitleScreenGameState.java | 4 ++-- src/com/fourisland/fourpuzzle/util/Interval.java | 10 +++++----- 2 files changed, 7 insertions(+), 7 deletions(-) (limited to 'src/com') diff --git a/src/com/fourisland/fourpuzzle/gamestate/TitleScreenGameState.java b/src/com/fourisland/fourpuzzle/gamestate/TitleScreenGameState.java index 6e87dd0..272c4f0 100755 --- a/src/com/fourisland/fourpuzzle/gamestate/TitleScreenGameState.java +++ b/src/com/fourisland/fourpuzzle/gamestate/TitleScreenGameState.java @@ -94,12 +94,12 @@ public class TitleScreenGameState implements GameState { { choices.moveUp(); - pt.setTimer(2); + pt.setTimer(1); } else if (Game.getKey().getKeyCode() == KeyEvent.VK_DOWN) { choices.moveDown(); - pt.setTimer(2); + pt.setTimer(1); } } } diff --git a/src/com/fourisland/fourpuzzle/util/Interval.java b/src/com/fourisland/fourpuzzle/util/Interval.java index 21a7a74..27d9e6a 100755 --- a/src/com/fourisland/fourpuzzle/util/Interval.java +++ b/src/com/fourisland/fourpuzzle/util/Interval.java @@ -21,20 +21,20 @@ public class Interval { public static Interval createTickInterval(int ticks) { - return new Interval(Game.FPS*ticks); + return createMillisInterval(Game.FPS*ticks); } public static Interval createMillisInterval(int millis) { - return new Interval(millis); + return new Interval(millis*1000000); } - private long last = System.currentTimeMillis(); + private long last = System.nanoTime(); public boolean isElapsed() { - if (last+wait < System.currentTimeMillis()) + if (last+wait < System.nanoTime()) { - last = System.currentTimeMillis(); + last = System.nanoTime(); return true; } -- cgit 1.4.1