From 61757652c39df66e19cf91c0906e55992e4de579 Mon Sep 17 00:00:00 2001 From: Kenneth van Ewijk Date: Thu, 11 Jun 2015 12:48:48 +0200 Subject: [PATCH] Fixed timing --- control/GameControl.java | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/control/GameControl.java b/control/GameControl.java index 42bdbb4..1458380 100644 --- a/control/GameControl.java +++ b/control/GameControl.java @@ -26,7 +26,7 @@ public class GameControl implements JoystickListener, ButtonListener, ActionList this.view = view; this.gsm = gsm; view.setIgnoreRepaint(true); - update = new Timer(1000/60,this); + update = new Timer(0,this); update.start(); // Timer update = new Timer(); // update.schedule(new TimerTask() { @@ -62,7 +62,10 @@ public class GameControl implements JoystickListener, ButtonListener, ActionList @Override public void actionPerformed(ActionEvent e) { long currentTime = System.currentTimeMillis(); - model.update(currentTime - lastTime); + long time = currentTime - lastTime; + if(time > 1000/60) + time = 1000/60; + model.update(time); lastTime = currentTime; view.repaint(); }