From 66ca4c453a6dc67e3b09ef3365c3b4805c44910d Mon Sep 17 00:00:00 2001 From: Adam NAILI Date: Sun, 14 Jan 2018 20:33:17 +0100 Subject: Implementing Display controllers (and changing null in some Physics controllers to test the displays) --- .../umlv/java/wallj/controller/BombDisplayController.java | 14 ++++++++++++-- .../umlv/java/wallj/controller/BombPhysicsController.java | 3 ++- .../java/wallj/controller/GarbageDisplayController.java | 9 +++++++-- .../umlv/java/wallj/controller/RobotDisplayController.java | 9 +++++++-- .../umlv/java/wallj/controller/RobotPhysicsController.java | 3 ++- .../umlv/java/wallj/controller/TrashDisplayController.java | 9 +++++++-- .../umlv/java/wallj/controller/WallDisplayController.java | 2 +- 7 files changed, 38 insertions(+), 11 deletions(-) (limited to 'src/main/java/fr/umlv') diff --git a/src/main/java/fr/umlv/java/wallj/controller/BombDisplayController.java b/src/main/java/fr/umlv/java/wallj/controller/BombDisplayController.java index aa652a8..86a857f 100644 --- a/src/main/java/fr/umlv/java/wallj/controller/BombDisplayController.java +++ b/src/main/java/fr/umlv/java/wallj/controller/BombDisplayController.java @@ -1,9 +1,14 @@ package fr.umlv.java.wallj.controller; +import fr.umlv.java.wallj.board.TileVec2; import fr.umlv.java.wallj.context.Context; +import fr.umlv.java.wallj.context.GraphicsContext; import fr.umlv.java.wallj.event.Event; import fr.umlv.java.wallj.model.BombBlock; +import org.jbox2d.common.Vec2; +import java.awt.*; +import java.util.Collections; import java.util.List; import java.util.Objects; @@ -18,8 +23,13 @@ public class BombDisplayController extends DisplayController { @Override public List update(Context context) { - //TODO - return null; + GraphicsContext graphicsContext = context.getGraphicsContext(); + graphicsContext.paintCircle(Color.BLACK, bomb.getPos(), TileVec2.TILE_DIM); + Vec2 textPosition = bomb.getPos(); + textPosition.x += TileVec2.TILE_DIM / 4.0f; + textPosition.y += 3 * TileVec2.TILE_DIM / 4.0f; + graphicsContext.paintString(Color.RED, textPosition, Integer.toString(bomb.getTimer())); + return Collections.emptyList(); } } diff --git a/src/main/java/fr/umlv/java/wallj/controller/BombPhysicsController.java b/src/main/java/fr/umlv/java/wallj/controller/BombPhysicsController.java index 45a3626..ed7e520 100644 --- a/src/main/java/fr/umlv/java/wallj/controller/BombPhysicsController.java +++ b/src/main/java/fr/umlv/java/wallj/controller/BombPhysicsController.java @@ -4,6 +4,7 @@ import fr.umlv.java.wallj.context.Context; import fr.umlv.java.wallj.event.Event; import fr.umlv.java.wallj.model.BombBlock; +import java.util.Collections; import java.util.List; import java.util.Objects; @@ -19,7 +20,7 @@ public class BombPhysicsController extends PhysicsController { @Override public List update(Context context) { //TODO - return null; + return Collections.emptyList(); } } diff --git a/src/main/java/fr/umlv/java/wallj/controller/GarbageDisplayController.java b/src/main/java/fr/umlv/java/wallj/controller/GarbageDisplayController.java index e878fb2..e5e53ab 100644 --- a/src/main/java/fr/umlv/java/wallj/controller/GarbageDisplayController.java +++ b/src/main/java/fr/umlv/java/wallj/controller/GarbageDisplayController.java @@ -1,9 +1,13 @@ package fr.umlv.java.wallj.controller; +import fr.umlv.java.wallj.board.TileVec2; import fr.umlv.java.wallj.context.Context; +import fr.umlv.java.wallj.context.GraphicsContext; import fr.umlv.java.wallj.event.Event; import fr.umlv.java.wallj.model.GarbageBlock; +import java.awt.*; +import java.util.Collections; import java.util.List; import java.util.Objects; @@ -18,8 +22,9 @@ public class GarbageDisplayController extends DisplayController { @Override public List update(Context context) { - //TODO - return null; + GraphicsContext graphicsContext = context.getGraphicsContext(); + graphicsContext.paintCircle(new Color(102, 51, 0), garbage.getPos(),TileVec2.TILE_DIM); + return Collections.emptyList(); } } diff --git a/src/main/java/fr/umlv/java/wallj/controller/RobotDisplayController.java b/src/main/java/fr/umlv/java/wallj/controller/RobotDisplayController.java index 96ba68c..de3c4c4 100644 --- a/src/main/java/fr/umlv/java/wallj/controller/RobotDisplayController.java +++ b/src/main/java/fr/umlv/java/wallj/controller/RobotDisplayController.java @@ -1,9 +1,13 @@ package fr.umlv.java.wallj.controller; +import fr.umlv.java.wallj.board.TileVec2; import fr.umlv.java.wallj.context.Context; +import fr.umlv.java.wallj.context.GraphicsContext; import fr.umlv.java.wallj.event.Event; import fr.umlv.java.wallj.model.RobotBlock; +import java.awt.*; +import java.util.Collections; import java.util.List; import java.util.Objects; @@ -18,8 +22,9 @@ public class RobotDisplayController extends DisplayController { @Override public List update(Context context) { - //TODO - return null; + GraphicsContext graphicsContext = context.getGraphicsContext(); + graphicsContext.paintCircle(Color.BLUE,robot.getPos(),TileVec2.TILE_DIM/2); + return Collections.emptyList(); } } diff --git a/src/main/java/fr/umlv/java/wallj/controller/RobotPhysicsController.java b/src/main/java/fr/umlv/java/wallj/controller/RobotPhysicsController.java index f320480..57d098c 100644 --- a/src/main/java/fr/umlv/java/wallj/controller/RobotPhysicsController.java +++ b/src/main/java/fr/umlv/java/wallj/controller/RobotPhysicsController.java @@ -4,6 +4,7 @@ import fr.umlv.java.wallj.context.Context; import fr.umlv.java.wallj.event.Event; import fr.umlv.java.wallj.model.RobotBlock; +import java.util.Collections; import java.util.List; import java.util.Objects; @@ -19,7 +20,7 @@ public class RobotPhysicsController extends PhysicsController { @Override public List update(Context context) { //TODO - return null; + return Collections.emptyList(); } } diff --git a/src/main/java/fr/umlv/java/wallj/controller/TrashDisplayController.java b/src/main/java/fr/umlv/java/wallj/controller/TrashDisplayController.java index dfba9be..523528b 100644 --- a/src/main/java/fr/umlv/java/wallj/controller/TrashDisplayController.java +++ b/src/main/java/fr/umlv/java/wallj/controller/TrashDisplayController.java @@ -1,9 +1,13 @@ package fr.umlv.java.wallj.controller; +import fr.umlv.java.wallj.board.TileVec2; import fr.umlv.java.wallj.context.Context; +import fr.umlv.java.wallj.context.GraphicsContext; import fr.umlv.java.wallj.event.Event; import fr.umlv.java.wallj.model.TrashBlock; +import java.awt.*; +import java.util.Collections; import java.util.List; import java.util.Objects; @@ -18,8 +22,9 @@ public class TrashDisplayController extends DisplayController { @Override public List update(Context context) { - //TODO - return null; + GraphicsContext graphicsContext = context.getGraphicsContext(); + graphicsContext.paintRectangle(Color.RED,trash.getPos(), TileVec2.TILE_DIM,TileVec2.TILE_DIM); + return Collections.emptyList(); } } diff --git a/src/main/java/fr/umlv/java/wallj/controller/WallDisplayController.java b/src/main/java/fr/umlv/java/wallj/controller/WallDisplayController.java index 7b7011c..428f83c 100644 --- a/src/main/java/fr/umlv/java/wallj/controller/WallDisplayController.java +++ b/src/main/java/fr/umlv/java/wallj/controller/WallDisplayController.java @@ -23,7 +23,7 @@ public class WallDisplayController extends BlockController { @Override public List update(Context context) { GraphicsContext graphicsContext = context.getGraphicsContext(); - graphicsContext.paintRectangle(Color.GRAY,wall.getPos(), TileVec2.TILE_DIM,TileVec2.TILE_DIM); + graphicsContext.paintRectangle(Color.BLACK,wall.getPos(), TileVec2.TILE_DIM,TileVec2.TILE_DIM); return Collections.emptyList(); } -- cgit v1.2.3