From 5666fd6863573de4d42c37fc8e0e2b0559c7b068 Mon Sep 17 00:00:00 2001 From: fdai7012 Date: Tue, 23 Jan 2024 15:41:43 +0100 Subject: [PATCH] Refactored Input forwarding to own function --- src/main/java/pacmanGame/Program.java | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/src/main/java/pacmanGame/Program.java b/src/main/java/pacmanGame/Program.java index 6352548..734bfc4 100644 --- a/src/main/java/pacmanGame/Program.java +++ b/src/main/java/pacmanGame/Program.java @@ -29,10 +29,7 @@ public class Program { boolean running = true; while(running) { - for (char inputChar : input.inputList) { - gameManager.ProcessInput(inputChar); - } - input.inputList.clear(); + ForwardInputToGameManager(); gameManager.Update(); @@ -44,6 +41,13 @@ public class Program { } } + public void ForwardInputToGameManager() { + for (char inputChar : input.inputList) { + gameManager.ProcessInput(inputChar); + } + input.inputList.clear(); + } + public void CreateAndShowGUI() { frame = new JFrame("PacmaaaAAAYYYHAAAaaam"); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);