First bug free game?
This commit is contained in:
+14
-12
@@ -1,34 +1,36 @@
|
||||
package model;
|
||||
|
||||
import java.awt.Color;
|
||||
import java.awt.event.ActionEvent;
|
||||
import java.awt.event.ActionListener;
|
||||
|
||||
import javax.swing.Timer;
|
||||
|
||||
import view.GameView;
|
||||
import control.GameStateManager;
|
||||
import control.button.ButtonHandler;
|
||||
|
||||
public class GameModel implements ActionListener{
|
||||
|
||||
GameView view;
|
||||
Timer update;
|
||||
Player player;
|
||||
public static Color[] colors = {Color.MAGENTA,Color.RED,Color.GREEN,Color.YELLOW,Color.CYAN,Color.BLUE};
|
||||
GameStateManager gsm;
|
||||
|
||||
|
||||
public GameModel(GameView view)
|
||||
public GameModel(GameView view,GameStateManager gsm)
|
||||
{
|
||||
this.view = view;
|
||||
player = new Player(1920/2, 1080/2);
|
||||
update = new Timer(1000/10, this);
|
||||
this.view = view;
|
||||
this.gsm = gsm;
|
||||
update = new Timer(1000/30, this);
|
||||
update.start();
|
||||
}
|
||||
|
||||
public void update(){
|
||||
player.update();
|
||||
view.setPlayer(player);
|
||||
|
||||
for(int i = 1; i < ButtonHandler.getButtons().size(); i++){
|
||||
ButtonHandler.getButtons().get(i).setColor(colors[i-1]);;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
update();
|
||||
gsm.update();
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user