Timer changed from control to model
This commit is contained in:
+14
-2
@@ -1,10 +1,16 @@
|
||||
package model;
|
||||
|
||||
import java.awt.event.ActionEvent;
|
||||
import java.awt.event.ActionListener;
|
||||
|
||||
import javax.swing.Timer;
|
||||
|
||||
import view.GameView;
|
||||
|
||||
public class GameModel{
|
||||
public class GameModel implements ActionListener{
|
||||
|
||||
GameView view;
|
||||
Timer update;
|
||||
Player player;
|
||||
|
||||
|
||||
@@ -12,11 +18,17 @@ public class GameModel{
|
||||
{
|
||||
this.view = view;
|
||||
player = new Player(1920/2, 1080/2);
|
||||
|
||||
update = new Timer(1000/10, this);
|
||||
update.start();
|
||||
}
|
||||
|
||||
public void update(){
|
||||
player.update();
|
||||
view.setPlayer(player);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
update();
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user