From 96377f0c1b9a3e97de767d0ef413fea0a2847a87 Mon Sep 17 00:00:00 2001 From: Nao Pross Date: Wed, 12 Dec 2018 02:55:28 +0100 Subject: Separate UPS from FPS, make thread for GameWindow (graphics thread) The separation of game logic updates from render updates is necessary to proceed on the implementation of sprites. Otherwise the speed of animations of menus and sprites would depend on the game update speed. This commit breaks PerfView. --- src/subconscious/graphics/GameWindow.java | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) (limited to 'src/subconscious/graphics/GameWindow.java') diff --git a/src/subconscious/graphics/GameWindow.java b/src/subconscious/graphics/GameWindow.java index 12de165..66fe26e 100644 --- a/src/subconscious/graphics/GameWindow.java +++ b/src/subconscious/graphics/GameWindow.java @@ -19,7 +19,7 @@ import java.awt.event.WindowEvent; * unloading scenes, and the window itself */ @SuppressWarnings("serial") -public class GameWindow extends Frame implements WindowListener { +public class GameWindow extends Frame implements Runnable, WindowListener { public static final Dimension WINDOW_SIZE = new Dimension(1280, 720); private Panel root; @@ -51,13 +51,10 @@ public class GameWindow extends Frame implements WindowListener { this.add(this.root, BorderLayout.CENTER); this.pack(); this.setVisible(true); - - // start Window Loop - this.loop(); } - // ovserver of this.game - private void loop() { + @Override + public void run() { // load the first scene this.loadScene(new MainMenuScene(this.game)); -- cgit v1.2.1