aboutsummaryrefslogtreecommitdiff
path: root/src/main
diff options
context:
space:
mode:
Diffstat (limited to 'src/main')
-rw-r--r--src/main/java/fr/umlv/java/wallj/context/Context.java15
-rw-r--r--src/main/java/fr/umlv/java/wallj/viewer/Viewer.java5
2 files changed, 17 insertions, 3 deletions
diff --git a/src/main/java/fr/umlv/java/wallj/context/Context.java b/src/main/java/fr/umlv/java/wallj/context/Context.java
index bb684b8..a8796e5 100644
--- a/src/main/java/fr/umlv/java/wallj/context/Context.java
+++ b/src/main/java/fr/umlv/java/wallj/context/Context.java
@@ -2,6 +2,7 @@ package fr.umlv.java.wallj.context;
2 2
3import fr.umlv.java.wallj.event.Event; 3import fr.umlv.java.wallj.event.Event;
4 4
5import java.time.Duration;
5import java.util.List; 6import java.util.List;
6import java.util.Objects; 7import java.util.Objects;
7 8
@@ -15,16 +16,19 @@ public final class Context {
15 private final Game game; 16 private final Game game;
16 private final List<Event> events; 17 private final List<Event> events;
17 private final GraphicsContext graphicsContext; 18 private final GraphicsContext graphicsContext;
19 private final Duration timeDelta;
18 20
19 /** 21 /**
20 * @param game the current game 22 * @param game the current game
21 * @param events the list of events of the tick 23 * @param events the list of events of the tick
22 * @param graphicsContext the current graphics context 24 * @param graphicsContext the current graphics context
25 * @param timeDelta elapsed time since last update
23 */ 26 */
24 public Context(Game game, List<Event> events, GraphicsContext graphicsContext) { 27 public Context(Game game, List<Event> events, GraphicsContext graphicsContext, Duration timeDelta) {
25 this.game = Objects.requireNonNull(game); 28 this.game = Objects.requireNonNull(game);
26 this.events = Objects.requireNonNull(events); 29 this.events = Objects.requireNonNull(events);
27 this.graphicsContext = Objects.requireNonNull(graphicsContext); 30 this.graphicsContext = Objects.requireNonNull(graphicsContext);
31 this.timeDelta = Objects.requireNonNull(timeDelta);
28 } 32 }
29 33
30 /** 34 /**
@@ -47,4 +51,11 @@ public final class Context {
47 public GraphicsContext getGraphicsContext() { 51 public GraphicsContext getGraphicsContext() {
48 return graphicsContext; 52 return graphicsContext;
49 } 53 }
54
55 /**
56 * @return the elapsed time since last update
57 */
58 public Duration getTimeDelta() {
59 return timeDelta;
60 }
50} 61}
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 a87f418..463a461 100644
--- a/src/main/java/fr/umlv/java/wallj/viewer/Viewer.java
+++ b/src/main/java/fr/umlv/java/wallj/viewer/Viewer.java
@@ -17,12 +17,15 @@ import java.io.IOException;
17import java.net.URISyntaxException; 17import java.net.URISyntaxException;
18import java.nio.file.Path; 18import java.nio.file.Path;
19import java.nio.file.Paths; 19import java.nio.file.Paths;
20import java.time.Duration;
20import java.util.LinkedList; 21import java.util.LinkedList;
21import java.util.List; 22import java.util.List;
22import java.util.Objects; 23import java.util.Objects;
23 24
24/** 25/**
25 * Link between application and Zen 5 26 * Link between application and Zen 5
27 *
28 * @author Adam NAILI
26 */ 29 */
27public final class Viewer { 30public final class Viewer {
28 31
@@ -54,7 +57,7 @@ public final class Viewer {
54 InputHandler inputHandler = new InputHandler(applicationContext); 57 InputHandler inputHandler = new InputHandler(applicationContext);
55 ScreenManager screenManager = new ScreenManager(applicationContext, graphics2D); 58 ScreenManager screenManager = new ScreenManager(applicationContext, graphics2D);
56 events.addAll(inputHandler.getEvents()); 59 events.addAll(inputHandler.getEvents());
57 Context context = new Context(currentGame, events, screenManager.clearScreen()); 60 Context context = new Context(currentGame, events, screenManager.clearScreen(), Duration.ZERO); // TODO: duration
58 List<Event> newEvents = currentGame.update(context); //return new events created from update(); 61 List<Event> newEvents = currentGame.update(context); //return new events created from update();
59 events.clear(); 62 events.clear();
60 return newEvents; 63 return newEvents;