|
|
@ -75,6 +75,9 @@ public class LLSIG implements KeyListener{ |
|
|
|
public static double LAST_MISS = 0; |
|
|
|
public static double LAST_MISS = 0; |
|
|
|
public static int COMBO = 0; |
|
|
|
public static int COMBO = 0; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public final static long TIMEPERTICK = 16666667l; |
|
|
|
|
|
|
|
public static double DRAWTIME=0; |
|
|
|
|
|
|
|
|
|
|
|
public static Clip metronome_click1,metronome_click2; |
|
|
|
public static Clip metronome_click1,metronome_click2; |
|
|
|
|
|
|
|
|
|
|
|
LLSIG(JFrame f) { |
|
|
|
LLSIG(JFrame f) { |
|
|
@ -119,8 +122,11 @@ public class LLSIG implements KeyListener{ |
|
|
|
window.add(canvas); |
|
|
|
window.add(canvas); |
|
|
|
window.setVisible(true); |
|
|
|
window.setVisible(true); |
|
|
|
window.addKeyListener(this); |
|
|
|
window.addKeyListener(this); |
|
|
|
gameLoop = new Thread() { |
|
|
|
|
|
|
|
|
|
|
|
new Thread() { |
|
|
|
public void run(){ |
|
|
|
public void run(){ |
|
|
|
|
|
|
|
while (true) { |
|
|
|
|
|
|
|
long startTime = System.nanoTime(); |
|
|
|
frameCount++; |
|
|
|
frameCount++; |
|
|
|
if (PLAYING) { |
|
|
|
if (PLAYING) { |
|
|
|
for (BeatTiming bt : timings) { |
|
|
|
for (BeatTiming bt : timings) { |
|
|
@ -153,11 +159,26 @@ public class LLSIG implements KeyListener{ |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
window.repaint(); |
|
|
|
window.repaint(); |
|
|
|
|
|
|
|
long endTime = System.nanoTime(); |
|
|
|
|
|
|
|
long diff = endTime-startTime; |
|
|
|
|
|
|
|
if (diff>TIMEPERTICK) { //Took longer than 1/60th of a second. No sleep.
|
|
|
|
|
|
|
|
System.err.println("Frame Drawing took longer than "+TIMEPERTICK+"ns to calculate ("+diff+"ns total)!"); |
|
|
|
|
|
|
|
} else { |
|
|
|
|
|
|
|
try { |
|
|
|
|
|
|
|
long sleepTime = TIMEPERTICK - diff; |
|
|
|
|
|
|
|
long millis = (sleepTime)/1000000; |
|
|
|
|
|
|
|
int nanos = (int)(sleepTime-(((sleepTime)/1000000)*1000000)); |
|
|
|
|
|
|
|
//System.out.println("FRAME DRAWING: Sleeping for ("+millis+"ms,"+nanos+"ns) - "+(diff)+"ns");
|
|
|
|
|
|
|
|
DRAWTIME = (double)diff/1000000; |
|
|
|
|
|
|
|
f.setTitle("Game Loop: "+DRAWTIME+"ms"); |
|
|
|
|
|
|
|
Thread.sleep(millis,nanos); |
|
|
|
|
|
|
|
} catch (InterruptedException e) { |
|
|
|
|
|
|
|
e.printStackTrace(); |
|
|
|
} |
|
|
|
} |
|
|
|
}; |
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
//SaveSongData("MiChi - ONE-315959669",lanes);
|
|
|
|
} |
|
|
|
stpe.scheduleAtFixedRate(gameLoop, 0, 16666666l, TimeUnit.NANOSECONDS); |
|
|
|
}.start(); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
private void LoadSongData(String song,List<Lane> lanes) { |
|
|
|
private void LoadSongData(String song,List<Lane> lanes) { |
|
|
|