diff options
Diffstat (limited to 'src')
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; | |||
7 | import java.util.Objects; | 7 | import 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 | */ |
12 | public final class Context { | 12 | public 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; | |||
9 | import java.util.Objects; | 9 | import java.util.Objects; |
10 | 10 | ||
11 | /** | 11 | /** |
12 | * A game | 12 | * A game. |
13 | */ | 13 | */ |
14 | public final class Game { | 14 | public 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 @@ | |||
1 | package fr.umlv.java.wallj.context; | 1 | package fr.umlv.java.wallj.context; |
2 | 2 | ||
3 | import fr.umlv.zen5.ScreenInfo; | 3 | import fr.umlv.zen5.ScreenInfo; |
4 | import org.jbox2d.common.Vec2; | ||
4 | 5 | ||
5 | import java.awt.Graphics2D; | 6 | import java.awt.*; |
7 | import java.awt.geom.Ellipse2D; | ||
8 | import java.awt.geom.Rectangle2D; | ||
6 | import java.util.Objects; | 9 | import 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 | */ |
11 | public final class GraphicsContext { | 14 | public 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; | |||
13 | import java.util.List; | 13 | import java.util.List; |
14 | import java.util.Objects; | 14 | import java.util.Objects; |
15 | 15 | ||
16 | import 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 | */ | ||
18 | public final class InputHandler { | 20 | public 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 @@ | |||
1 | package fr.umlv.java.wallj.context; | 1 | package fr.umlv.java.wallj.context; |
2 | 2 | ||
3 | public class ScreenManager { | 3 | import fr.umlv.zen5.ApplicationContext; |
4 | import fr.umlv.zen5.ScreenInfo; | ||
5 | import org.jbox2d.common.Vec2; | ||
6 | |||
7 | import java.awt.Graphics2D; | ||
8 | import java.util.Objects; | ||
9 | |||
10 | /** | ||
11 | * Cleans the GraphicsContext | ||
12 | */ | ||
13 | public 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 | ||
5 | import java.util.Objects; | 5 | import java.util.Objects; |