aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/docs/class.puml11
-rw-r--r--src/main/java/fr/umlv/java/wallj/context/Context.java2
-rw-r--r--src/main/java/fr/umlv/java/wallj/context/Game.java2
-rw-r--r--src/main/java/fr/umlv/java/wallj/context/GraphicsContext.java28
-rw-r--r--src/main/java/fr/umlv/java/wallj/context/InputHandler.java8
-rw-r--r--src/main/java/fr/umlv/java/wallj/context/ScreenManager.java35
-rw-r--r--src/main/java/fr/umlv/java/wallj/event/AddBombEvent.java2
-rw-r--r--src/main/java/fr/umlv/java/wallj/event/ConfirmEvent.java2
-rw-r--r--src/main/java/fr/umlv/java/wallj/event/DropBombEvent.java2
-rw-r--r--src/main/java/fr/umlv/java/wallj/event/GameEvent.java5
-rw-r--r--src/main/java/fr/umlv/java/wallj/event/InputEvent.java5
-rw-r--r--src/main/java/fr/umlv/java/wallj/event/MoveRobotEvent.java2
-rw-r--r--src/main/java/fr/umlv/java/wallj/viewer/Viewer.java16
13 files changed, 102 insertions, 18 deletions
diff --git a/src/docs/class.puml b/src/docs/class.puml
index 0997356..21add0d 100644
--- a/src/docs/class.puml
+++ b/src/docs/class.puml
@@ -20,7 +20,7 @@ package viewer {
20 Stage 20 Stage
21 void main(String[]) 21 void main(String[])
22 void eventLoop(ApplicationContext) 22 void eventLoop(ApplicationContext)
23 void renderFrame(Graphics2D) 23 void renderFrame(Graphics2D,ApplicationContext)
24 } 24 }
25} 25}
26 26
@@ -35,8 +35,8 @@ package context {
35 class GraphicsContext { 35 class GraphicsContext {
36 final Graphics2D 36 final Graphics2D
37 final ScreenInfo 37 final ScreenInfo
38 paintCircle(Color, Vec2, int) 38 paintCircle(Color, Vec2, float)
39 paintSquare(Color, Vec2, int) 39 paintSquare(Color, Vec2, float, float)
40 } 40 }
41 41
42 class InputHandler { 42 class InputHandler {
@@ -46,8 +46,9 @@ package context {
46 } 46 }
47 47
48 class ScreenManager { 48 class ScreenManager {
49 private ApplicationContext 49 private final ApplicationContext
50 ScreenManager(ApplicationContext) 50 private final Graphics2D
51 ScreenManager(ApplicationContext,Graphics2D)
51 GraphicsContext clearScreen() 52 GraphicsContext clearScreen()
52 } 53 }
53 54
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 a924c2b..1f188de 100644
--- a/src/main/java/fr/umlv/java/wallj/context/Context.java
+++ b/src/main/java/fr/umlv/java/wallj/context/Context.java
@@ -7,7 +7,7 @@ import java.util.List;
7import java.util.Objects; 7import java.util.Objects;
8 8
9/** 9/**
10 * A context used to store the current state of the application at one tick. 10 * A context used to store the current state of the application at one tick
11 */ 11 */
12public final class Context { 12public final class Context {
13 //TODO Class Context 13 //TODO Class Context
diff --git a/src/main/java/fr/umlv/java/wallj/context/Game.java b/src/main/java/fr/umlv/java/wallj/context/Game.java
index b3418c4..ba7cb58 100644
--- a/src/main/java/fr/umlv/java/wallj/context/Game.java
+++ b/src/main/java/fr/umlv/java/wallj/context/Game.java
@@ -9,7 +9,7 @@ import java.util.NoSuchElementException;
9import java.util.Objects; 9import java.util.Objects;
10 10
11/** 11/**
12 * A game 12 * A game.
13 */ 13 */
14public final class Game { 14public final class Game {
15 //TODO 15 //TODO
diff --git a/src/main/java/fr/umlv/java/wallj/context/GraphicsContext.java b/src/main/java/fr/umlv/java/wallj/context/GraphicsContext.java
index 214eeb0..46c326a 100644
--- a/src/main/java/fr/umlv/java/wallj/context/GraphicsContext.java
+++ b/src/main/java/fr/umlv/java/wallj/context/GraphicsContext.java
@@ -1,12 +1,15 @@
1package fr.umlv.java.wallj.context; 1package fr.umlv.java.wallj.context;
2 2
3import fr.umlv.zen5.ScreenInfo; 3import fr.umlv.zen5.ScreenInfo;
4import org.jbox2d.common.Vec2;
4 5
5import java.awt.Graphics2D; 6import java.awt.*;
7import java.awt.geom.Ellipse2D;
8import java.awt.geom.Rectangle2D;
6import java.util.Objects; 9import java.util.Objects;
7 10
8/** 11/**
9 * A context of the current graphic status of the application 12 * A context of the current graphic status of the application.
10 */ 13 */
11public final class GraphicsContext { 14public final class GraphicsContext {
12 //TODO Class GraphicsContext 15 //TODO Class GraphicsContext
@@ -35,4 +38,25 @@ public final class GraphicsContext {
35 public ScreenInfo getScreenInfo() { 38 public ScreenInfo getScreenInfo() {
36 return screenInfo; 39 return screenInfo;
37 } 40 }
41
42 /**
43 * @param color the color of the circle
44 * @param position the upper left corner of the rectangle frame that contains the circle
45 * @param size size of the circle
46 */
47 public void paintCircle(Color color, Vec2 position, float size) {
48 graphics2D.setColor(color);
49 graphics2D.fill(new Ellipse2D.Float(position.x, position.y, size, size));
50 }
51
52 /**
53 * @param color the color of the rectangle
54 * @param position the upper left corner of the rectangle
55 * @param width width of the rectangle
56 * @param height height of the rectangle
57 */
58 public void paintRectangle(Color color, Vec2 position, float width, float height) {
59 graphics2D.setColor(color);
60 graphics2D.fill(new Rectangle2D.Float(position.x, position.y, width, height));
61 }
38} 62}
diff --git a/src/main/java/fr/umlv/java/wallj/context/InputHandler.java b/src/main/java/fr/umlv/java/wallj/context/InputHandler.java
index 2881da9..171f665 100644
--- a/src/main/java/fr/umlv/java/wallj/context/InputHandler.java
+++ b/src/main/java/fr/umlv/java/wallj/context/InputHandler.java
@@ -13,21 +13,23 @@ import java.util.LinkedList;
13import java.util.List; 13import java.util.List;
14import java.util.Objects; 14import java.util.Objects;
15 15
16import static fr.umlv.java.wallj.board.TileVec2.of;
17 16
17/**
18 * Treats the inputs from the keyboard and mouse provided by Zen 5 and creates Events meaningful for the game.
19 */
18public final class InputHandler { 20public final class InputHandler {
19 //TODO Class InputHandler 21 //TODO Class InputHandler
20 private final ApplicationContext applicationContext; 22 private final ApplicationContext applicationContext;
21 23
22 /** 24 /**
23 * @param applicationContext 25 * @param applicationContext the Zen5 application context
24 */ 26 */
25 public InputHandler(ApplicationContext applicationContext) { 27 public InputHandler(ApplicationContext applicationContext) {
26 this.applicationContext = Objects.requireNonNull(applicationContext); 28 this.applicationContext = Objects.requireNonNull(applicationContext);
27 } 29 }
28 30
29 /** 31 /**
30 * @return 32 * @return the list of events converted from Zen 5 events to game events
31 */ 33 */
32 List<fr.umlv.java.wallj.event.Event> getEvents() { 34 List<fr.umlv.java.wallj.event.Event> getEvents() {
33 LinkedList<fr.umlv.java.wallj.event.Event> events = new LinkedList<>(); 35 LinkedList<fr.umlv.java.wallj.event.Event> events = new LinkedList<>();
diff --git a/src/main/java/fr/umlv/java/wallj/context/ScreenManager.java b/src/main/java/fr/umlv/java/wallj/context/ScreenManager.java
index 4587355..9d6255f 100644
--- a/src/main/java/fr/umlv/java/wallj/context/ScreenManager.java
+++ b/src/main/java/fr/umlv/java/wallj/context/ScreenManager.java
@@ -1,5 +1,38 @@
1package fr.umlv.java.wallj.context; 1package fr.umlv.java.wallj.context;
2 2
3public class ScreenManager { 3import fr.umlv.zen5.ApplicationContext;
4import fr.umlv.zen5.ScreenInfo;
5import org.jbox2d.common.Vec2;
6
7import java.awt.Graphics2D;
8import java.util.Objects;
9
10/**
11 * Cleans the GraphicsContext
12 */
13public final class ScreenManager {
4 //TODO Class ScreenManager 14 //TODO Class ScreenManager
15 private final ApplicationContext applicationContext;
16 private final Graphics2D graphics2D;
17
18 /**
19 *
20 * @param applicationContext the current application context
21 * @param graphics2D the current graphics2D
22 */
23 public ScreenManager(ApplicationContext applicationContext, Graphics2D graphics2D) {
24 this.applicationContext = Objects.requireNonNull(applicationContext);
25 this.graphics2D = Objects.requireNonNull(graphics2D);
26 }
27
28 /**
29 *
30 * @return a graphic context
31 */
32 public GraphicsContext clearScreen() {
33 ScreenInfo screenInfo = applicationContext.getScreenInfo();
34 GraphicsContext graphicsContext = new GraphicsContext(graphics2D, screenInfo);
35 graphicsContext.paintRectangle(graphics2D.getBackground(), new Vec2(0, 0), screenInfo.getWidth(), screenInfo.getHeight());
36 return graphicsContext;
37 }
5} 38}
diff --git a/src/main/java/fr/umlv/java/wallj/event/AddBombEvent.java b/src/main/java/fr/umlv/java/wallj/event/AddBombEvent.java
index 368171e..e726911 100644
--- a/src/main/java/fr/umlv/java/wallj/event/AddBombEvent.java
+++ b/src/main/java/fr/umlv/java/wallj/event/AddBombEvent.java
@@ -4,7 +4,7 @@ import fr.umlv.java.wallj.board.TileVec2;
4 4
5import java.util.Objects; 5import java.util.Objects;
6 6