diff options
author | Starla Insigna <hatkirby@fourisland.com> | 2009-02-12 09:30:29 -0500 |
---|---|---|
committer | Starla Insigna <hatkirby@fourisland.com> | 2009-02-12 09:30:29 -0500 |
commit | 3cd96daaf22236e4eb15c6422f772abf08351023 (patch) | |
tree | 9ba2bf9ea58cab997c36db6dc50d0573d86f2699 /src | |
parent | 25cac8db589a689df121b2a9f4142fdc1cef2fee (diff) | |
download | fourpuzzle-3cd96daaf22236e4eb15c6422f772abf08351023.tar.gz fourpuzzle-3cd96daaf22236e4eb15c6422f772abf08351023.tar.bz2 fourpuzzle-3cd96daaf22236e4eb15c6422f772abf08351023.zip |
Engine: Rewrote Interval
Interval previously used milliseconds, but now it uses nanoseconds (which, according to System, is more accurate). Fixes #11
Diffstat (limited to 'src')
-rwxr-xr-x | src/com/fourisland/fourpuzzle/gamestate/TitleScreenGameState.java | 4 | ||||
-rwxr-xr-x | src/com/fourisland/fourpuzzle/util/Interval.java | 10 |
2 files changed, 7 insertions, 7 deletions
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 { | |||
94 | { | 94 | { |
95 | choices.moveUp(); | 95 | choices.moveUp(); |
96 | 96 | ||
97 | pt.setTimer(2); | 97 | pt.setTimer(1); |
98 | } else if (Game.getKey().getKeyCode() == KeyEvent.VK_DOWN) | 98 | } else if (Game.getKey().getKeyCode() == KeyEvent.VK_DOWN) |
99 | { | 99 | { |
100 | choices.moveDown(); | 100 | choices.moveDown(); |
101 | 101 | ||
102 | pt.setTimer(2); | 102 | pt.setTimer(1); |
103 | } | 103 | } |
104 | } | 104 | } |
105 | } | 105 | } |
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 { | |||
21 | 21 | ||
22 | public static Interval createTickInterval(int ticks) | 22 | public static Interval createTickInterval(int ticks) |
23 | { | 23 | { |
24 | return new Interval(Game.FPS*ticks); | 24 | return createMillisInterval(Game.FPS*ticks); |
25 | } | 25 | } |
26 | 26 | ||
27 | public static Interval createMillisInterval(int millis) | 27 | public static Interval createMillisInterval(int millis) |
28 | { | 28 | { |
29 | return new Interval(millis); | 29 | return new Interval(millis*1000000); |
30 | } | 30 | } |
31 | 31 | ||
32 | private long last = System.currentTimeMillis(); | 32 | private long last = System.nanoTime(); |
33 | public boolean isElapsed() | 33 | public boolean isElapsed() |
34 | { | 34 | { |
35 | if (last+wait < System.currentTimeMillis()) | 35 | if (last+wait < System.nanoTime()) |
36 | { | 36 | { |
37 | last = System.currentTimeMillis(); | 37 | last = System.nanoTime(); |
38 | 38 | ||
39 | return true; | 39 | return true; |
40 | } | 40 | } |