Optimized code, everything is buffered in a buffered image now

This commit is contained in:
jancoow
2015-06-07 14:22:56 +02:00
parent 396769317c
commit 750f525c2d
15 changed files with 237 additions and 233 deletions
+7 -4
View File
@@ -2,6 +2,7 @@ package control;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.util.TimerTask;
import javax.swing.Timer;
@@ -12,7 +13,7 @@ import control.button.ButtonListener;
import control.joystick.JoystickEvent;
import control.joystick.JoystickListener;
public class GameControl implements JoystickListener, ButtonListener,ActionListener {
public class GameControl implements JoystickListener, ButtonListener, ActionListener {
private long lastTime = System.currentTimeMillis();
GameModel model;
@@ -20,12 +21,13 @@ public class GameControl implements JoystickListener, ButtonListener,ActionListe
GameStateManager gsm;
Timer update;
public GameControl(GameModel model, GameView view,GameStateManager gsm)
public GameControl(final GameModel model, final GameView view,GameStateManager gsm)
{
this.model = model;
this.view = view;
this.gsm = gsm;
update = new Timer(1000/60, this);
view.setIgnoreRepaint(true);
update = new Timer(1000/60,this);
update.start();
}
@@ -51,6 +53,7 @@ public class GameControl implements JoystickListener, ButtonListener,ActionListe
long currentTime = System.currentTimeMillis();
model.update(currentTime - lastTime);
lastTime = currentTime;
view.repaint();
view.repaint();
}
}
+2
View File
@@ -14,6 +14,7 @@ public class GameStateManager {
private List<GameState> gamestates;
public GameState currentState;
private int index = 0;
public int fps;
public enum State {
TITLE_STATE,
@@ -44,5 +45,6 @@ public class GameStateManager {
public void update(float factor){
currentState.update(factor);
fps = (int) (60/(factor/10));
}
}
-5
View File
@@ -1,5 +0,0 @@
package control;
public class JoyStick {
}
-22
View File
@@ -73,26 +73,4 @@ public class LedHandler {
err.printStackTrace();
}
}
public void strobo(){
boolean on = true;
while(true){
if(on){
for(int i = 1; i < 66; i++){
setLed(i, 0, 0, 0);
}
}else{
for(int i = 1; i < 66; i++){
setLed(i, 255, 255, 255);
}
}
on = !on;
show();
try {
Thread.sleep(100);
} catch (InterruptedException e) {
e.printStackTrace();
}
}
}
}