Entities verwalten sich jetzt ein Stück weit selbst.

This commit is contained in:
JPT committed 2014-10-21 13:40:13 +02:00
1 parent 2be8fa2bec
commit 061ab3c9c1
6 files changed
+77 -45

No files matched your search

@@ -1,7 +1,12 @@
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;
@@ -11,13 +16,19 @@ public class PaintThread extends Thread {
}
public void run() {
final GameFrame gf = this.gf; // :'-(
while (true) {
try {
Thread.sleep(16);
} catch (InterruptedException e) {
System.err.println(e);
}
this.gf.repaint();
//Trigger redrawing the things. Important: AWT-Context needed here!
EventQueue.invokeLater(new Runnable() {
public void run() {
gf.drawEntities();
}
});
}
}
}