aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorpacien2018-02-01 21:48:36 +0100
committerpacien2018-02-01 21:48:36 +0100
commit6dd0e213ba1f82941c7cc5f41f72aea29fb257a7 (patch)
tree847b0a4014431841063fed5e7754c959fb65e54b
parent5664d1c145d7432f4052b0299af076d0630ecc8b (diff)
parent2b72b904a9b93503c781b57b0cbcff01bfb7dd8a (diff)
downloadwallj-6dd0e213ba1f82941c7cc5f41f72aea29fb257a7.tar.gz
Merge branch 'master' of https://github.com/pacien/upem-java-wallj
-rw-r--r--src/docs/class.puml1
-rw-r--r--src/main/java/fr/umlv/java/wallj/viewer/Viewer.java22
2 files changed, 7 insertions, 16 deletions
diff --git a/src/docs/class.puml b/src/docs/class.puml
index 779f764..075aa39 100644
--- a/src/docs/class.puml
+++ b/src/docs/class.puml
@@ -13,7 +13,6 @@ package viewer {
13 final Game 13 final Game
14 Viewer(List<Board>) 14 Viewer(List<Board>)
15 void eventLoop(ApplicationContext) 15 void eventLoop(ApplicationContext)
16 void renderFrame(Graphics2D,ApplicationContext,List<Event>)
17 } 16 }
18} 17}
19 18
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