Create TimingThread to better control worker timings.
This commit is contained in:
1 parent
b42c8f3a1a
commit
a733187887
10 files changed
+146
-109
No files matched your search
@@ -0,0 +1,28 @@
|
||||
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 TimingThread {
|
||||
|
||||
private GameFrame gf;
|
||||
|
||||
public PaintThread(GameFrame gf) {
|
||||
this.gf = gf;
|
||||
this.setName("GameThread");
|
||||
this.setHz(60);
|
||||
}
|
||||
|
||||
public void work() {
|
||||
//Trigger redrawing the things. Important: AWT-Context needed here!
|
||||
EventQueue.invokeLater(new Runnable() {
|
||||
public void run() {
|
||||
gf.draw();
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user