aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/fr/umlv
diff options
context:
space:
mode:
Diffstat (limited to 'src/main/java/fr/umlv')
-rw-r--r--src/main/java/fr/umlv/java/wallj/viewer/Viewer.java22
1 files changed, 7 insertions, 15 deletions
diff --git a/src/main/java/fr/umlv/java/wallj/viewer/Viewer.java b/src/main/java/fr/umlv/java/wallj/viewer/Viewer.java
index 030dc97..0fee046 100644
--- a/src/main/java/fr/umlv/java/wallj/viewer/Viewer.java
+++ b/src/main/java/fr/umlv/java/wallj/viewer/Viewer.java
@@ -49,7 +49,13 @@ public final class Viewer {
49 Duration last = lastExecDuration; 49 Duration last = lastExecDuration;
50 long timeBeforeExec = System.currentTimeMillis(); 50 long timeBeforeExec = System.currentTimeMillis();
51 applicationContext.renderFrame(graphics2D -> { 51 applicationContext.renderFrame(graphics2D -> {
52 events.addAll(renderFrame(graphics2D, applicationContext, events, last)); //add the new events returned by updates 52 InputHandler inputHandler = new InputHandler(applicationContext);
53 ScreenManager screenManager = new ScreenManager(applicationContext, graphics2D);
54 events.addAll(inputHandler.getEvents());
55 Context context = new Context(currentGame, events, screenManager.clearScreen(), last);
56 List<Event> newEvents = currentGame.update(context); //return new events created from update();
57 events.clear();
58 events.addAll(newEvents); //add the new events returned by updates
53 }); 59 });
54 long timeAfterExec = System.currentTimeMillis(); 60 long timeAfterExec = System.currentTimeMillis();
55 lastExecDuration = Duration.ofMillis(timeAfterExec - timeBeforeExec); 61 lastExecDuration = Duration.ofMillis(timeAfterExec - timeBeforeExec);
@@ -62,19 +68,5 @@ public final class Viewer {
62 } 68 }
63 applicationContext.exit(0); 69 applicationContext.exit(0);
64 } 70 }
65
66 /**
67 * @param graphics2D the graphic2D from Zen 5
68 * @param applicationContext the application context from Zen 5
69 */
70 public List<Event> renderFrame(Graphics2D graphics2D, ApplicationContext applicationContext, List<Event> events, Duration lastExecDuration) {
71 InputHandler inputHandler = new InputHandler(applicationContext);
72 ScreenManager screenManager = new ScreenManager(applicationContext, graphics2D);
73 events.addAll(inputHandler.getEvents());
74 Context context = new Context(currentGame, events, screenManager.clearScreen(), lastExecDuration);
75 List<Event> newEvents = currentGame.update(context); //return new events created from update();
76 events.clear();
77 return newEvents;
78 }
79} 71}
80 72