diff --git a/src/de/teamteamteam/spacescooter/threads/BasicTimer.java b/src/de/teamteamteam/spacescooter/threads/BasicTimer.java deleted file mode 100644 index a47ae4e..0000000 --- a/src/de/teamteamteam/spacescooter/threads/BasicTimer.java +++ /dev/null @@ -1,48 +0,0 @@ -package de.teamteamteam.spacescooter.threads; - -public class BasicTimer { - private int fps; - private long timeThen; - boolean newVersion = true; - public BasicTimer(int frameRate) { - if (System.getProperty("java.version").startsWith("1.4")) - newVersion = false; - if (newVersion) { - fps = frameRate; - timeThen = System.nanoTime(); - } - else { - fps = frameRate; - System.out.println("Old Version Detected: Running Old Java Timer Version"); - timeThen = System.currentTimeMillis(); - } - } - public void changeFPS(int frameRate) { - fps = frameRate; - } - public void sync() { - if (newVersion) { - long gapTo = 1000000000L / fps + timeThen; - long timeNow = System.nanoTime(); - - while (gapTo > timeNow) { - try { Thread.sleep(1); - } catch (InterruptedException e) {} - timeNow = System.nanoTime(); - } - - timeThen = timeNow; - } else { - long gapTo = 1000 / fps + timeThen; - long timeNow = System.currentTimeMillis(); - - while (gapTo > timeNow) { - try { Thread.sleep(1); - } catch (InterruptedException e) {} - timeNow = System.currentTimeMillis(); - } - - timeThen = timeNow; - } - } -} \ No newline at end of file diff --git a/src/de/teamteamteam/spacescooter/threads/PaintThread.java b/src/de/teamteamteam/spacescooter/threads/PaintThread.java deleted file mode 100644 index e01b3e5..0000000 --- a/src/de/teamteamteam/spacescooter/threads/PaintThread.java +++ /dev/null @@ -1,31 +0,0 @@ -package de.teamteamteam.spacescooter.threads; - -import java.awt.EventQueue; - -import de.teamteamteam.spacescooter.gui.GameFrame; - -/** - * This thread triggers about 60 redraws per second. - */ -public class PaintThread extends Thread { - - private GameFrame gf; - BasicTimer timer = new BasicTimer(120); - - public PaintThread(GameFrame gf) { - this.gf = gf; - } - - public void run() { - final GameFrame gf = this.gf; // :'-( - while (true) { - timer.sync(); - //Trigger redrawing the things. Important: AWT-Context needed here! - EventQueue.invokeLater(new Runnable() { - public void run() { - gf.draw(); - } - }); - } - } -}