소스 검색

Fixed timing

Kenneth van Ewijk 10 년 전
부모
커밋
61757652c3
1개의 변경된 파일5개의 추가작업 그리고 2개의 파일을 삭제
  1. 5 2
      control/GameControl.java

+ 5 - 2
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();				
 	}