aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/fr/umlv
diff options
context:
space:
mode:
authorAdam NAILI2018-02-01 20:58:24 +0100
committerAdam NAILI2018-02-01 20:58:24 +0100
commita07c49065165b2f896684a57d647f2b1a13b68ca (patch)
treedc825b31d14503208e8250a001b5ec128afb81c1 /src/main/java/fr/umlv
parent5bff076cc86aa7c09baea850c3617ee2c1253594 (diff)
parent735be27e8802740cf0986bb6d14e720234889aae (diff)
downloadwallj-a07c49065165b2f896684a57d647f2b1a13b68ca.tar.gz
Merge branch 'master' of https://github.com/pacien/upem-java-wallj
Diffstat (limited to 'src/main/java/fr/umlv')
-rw-r--r--src/main/java/fr/umlv/java/wallj/block/Block.java49
-rw-r--r--src/main/java/fr/umlv/java/wallj/block/BlockFactory.java5
-rw-r--r--src/main/java/fr/umlv/java/wallj/block/BombBlock.java59
-rw-r--r--src/main/java/fr/umlv/java/wallj/block/GarbageBlock.java23
-rw-r--r--src/main/java/fr/umlv/java/wallj/block/JBoxBlock.java36
-rw-r--r--src/main/java/fr/umlv/java/wallj/block/RobotBlock.java62
-rw-r--r--src/main/java/fr/umlv/java/wallj/block/SolidDef.java45
-rw-r--r--src/main/java/fr/umlv/java/wallj/block/TrashBlock.java23
-rw-r--r--src/main/java/fr/umlv/java/wallj/block/WallBlock.java23
-rw-r--r--src/main/java/fr/umlv/java/wallj/context/Context.java15
-rw-r--r--src/main/java/fr/umlv/java/wallj/context/Game.java10
-rw-r--r--src/main/java/fr/umlv/java/wallj/context/InputHandler.java12
-rw-r--r--src/main/java/fr/umlv/java/wallj/context/Stage.java56
-rw-r--r--src/main/java/fr/umlv/java/wallj/context/Updateable.java28
-rw-r--r--src/main/java/fr/umlv/java/wallj/controller/BlockController.java21
-rw-r--r--src/main/java/fr/umlv/java/wallj/controller/BlockControllerFactory.java49
-rw-r--r--src/main/java/fr/umlv/java/wallj/controller/BombDisplayController.java35
-rw-r--r--src/main/java/fr/umlv/java/wallj/controller/BombPhysicsController.java26
-rw-r--r--src/main/java/fr/umlv/java/wallj/controller/Controller.java12
-rw-r--r--src/main/java/fr/umlv/java/wallj/controller/GameStateController.java (renamed from src/main/java/fr/umlv/java/wallj/controller/GameController.java)7
-rw-r--r--src/main/java/fr/umlv/java/wallj/controller/GarbageDisplayController.java30
-rw-r--r--src/main/java/fr/umlv/java/wallj/controller/GarbagePhysicsController.java26
-rw-r--r--src/main/java/fr/umlv/java/wallj/controller/PhysicsController.java12
-rw-r--r--src/main/java/fr/umlv/java/wallj/controller/RobotDisplayController.java30
-rw-r--r--src/main/java/fr/umlv/java/wallj/controller/RobotPhysicsController.java26
-rw-r--r--src/main/java/fr/umlv/java/wallj/controller/StagePhysicsController.java30
-rw-r--r--src/main/java/fr/umlv/java/wallj/controller/TrashDisplayController.java30
-rw-r--r--src/main/java/fr/umlv/java/wallj/controller/TrashPhysicsController.java26
-rw-r--r--src/main/java/fr/umlv/java/wallj/controller/WallDisplayController.java30
-rw-r--r--src/main/java/fr/umlv/java/wallj/controller/WallPhysicsController.java26
-rw-r--r--src/main/java/fr/umlv/java/wallj/event/AddBombEvent.java21
-rw-r--r--src/main/java/fr/umlv/java/wallj/event/BombSetupEvent.java28
-rw-r--r--src/main/java/fr/umlv/java/wallj/event/BombSetupOrder.java (renamed from src/main/java/fr/umlv/java/wallj/event/DropBombEvent.java)4
-rw-r--r--src/main/java/fr/umlv/java/wallj/event/ConfirmOrder.java (renamed from src/main/java/fr/umlv/java/wallj/event/ConfirmEvent.java)4
-rw-r--r--src/main/java/fr/umlv/java/wallj/event/Event.java11
-rw-r--r--src/main/java/fr/umlv/java/wallj/event/GameOverEvent.java2
-rw-r--r--src/main/java/fr/umlv/java/wallj/event/InputEvent.java2
-rw-r--r--src/main/java/fr/umlv/java/wallj/event/MoveRobotEvent.java22
-rw-r--r--src/main/java/fr/umlv/java/wallj/event/MoveRobotOrder.java28
-rw-r--r--src/main/java/fr/umlv/java/wallj/viewer/Viewer.java5
40 files changed, 487 insertions, 502 deletions
diff --git a/src/main/java/fr/umlv/java/wallj/block/Block.java b/src/main/java/fr/umlv/java/wallj/block/Block.java
index d3c349e..7ae9c06 100644
--- a/src/main/java/fr/umlv/java/wallj/block/Block.java
+++ b/src/main/java/fr/umlv/java/wallj/block/Block.java
@@ -1,44 +1,25 @@
1package fr.umlv.java.wallj.block; 1package fr.umlv.java.wallj.block;
2 2
3import fr.umlv.java.wallj.board.TileVec2; 3import fr.umlv.java.wallj.board.TileVec2;
4import fr.umlv.java.wallj.context.Context; 4import fr.umlv.java.wallj.context.Updateable;
5import fr.umlv.java.wallj.controller.BlockController;
6import fr.umlv.java.wallj.controller.Controller;
7import fr.umlv.java.wallj.event.Event;
8import org.jbox2d.common.Vec2; 5import org.jbox2d.common.Vec2;
6import org.jbox2d.dynamics.World;
9 7
10import java.util.*; 8import java.util.*;
11import java.util.stream.Collectors;
12 9
13/** 10/**
14 * A block. 11 * A block.
15 * 12 *
16 * @author Pacien TRAN-GIRARD 13 * @author Pacien TRAN-GIRARD
17 */ 14 */
18public abstract class Block { 15public abstract class Block implements Updateable {
19
20 private final BlockType type; 16 private final BlockType type;
21 private List<Controller> controllers;
22 private Vec2 pos;
23 17
24 /** 18 /**
25 * @param type type of block 19 * @param type type of block
26 * @param pos initial position
27 */ 20 */
28 Block(BlockType type, Vec2 pos) { 21 Block(BlockType type) {
29 this.type = Objects.requireNonNull(type); 22 this.type = Objects.requireNonNull(type);
30 this.pos = Objects.requireNonNull(pos).clone();
31 }
32
33 void setControllers(List<BlockController> l) {
34 controllers = Collections.unmodifiableList(new LinkedList<>(Objects.requireNonNull(l)));
35 }
36
37 /**
38 * @param pos new position to set
39 */
40 public void setPos(Vec2 pos) {
41 this.pos = Objects.requireNonNull(pos).clone();
42 } 23 }
43 24
44 /** 25 /**
@@ -49,27 +30,19 @@ public abstract class Block {
49 } 30 }
50 31
51 /** 32 /**
52 * @return the current position
53 */
54 public Vec2 getPos() {
55 return pos.clone();
56 }
57
58 /**
59 * @return the current tile position 33 * @return the current tile position
60 */ 34 */
61 public TileVec2 getTile() { 35 public TileVec2 getTile() {
62 return TileVec2.of(pos); 36 return TileVec2.of(getPos());
63 } 37 }
64 38
65 /** 39 /**
66 * @param ctx execution context 40 * @return the current position
67 * @return list of generated events
68 */ 41 */
69 public List<Event> update(Context ctx) { 42 public abstract Vec2 getPos();
70 return controllers.stream()
71 .flatMap(controller -> controller.update(ctx).stream())
72 .collect(Collectors.toList());
73 }
74 43
44 /**
45 * @param world a JBox2D world
46 */
47 public abstract void link(World world);
75} 48}
diff --git a/src/main/java/fr/umlv/java/wallj/block/BlockFactory.java b/src/main/java/fr/umlv/java/wallj/block/BlockFactory.java
index 951d182..acd280f 100644
--- a/src/main/java/fr/umlv/java/wallj/block/BlockFactory.java
+++ b/src/main/java/fr/umlv/java/wallj/block/BlockFactory.java
@@ -1,7 +1,6 @@
1package fr.umlv.java.wallj.block; 1package fr.umlv.java.wallj.block;
2 2
3import fr.umlv.java.wallj.board.TileVec2; 3import fr.umlv.java.wallj.board.TileVec2;
4import fr.umlv.java.wallj.controller.BlockControllerFactory;
5import org.jbox2d.common.Vec2; 4import org.jbox2d.common.Vec2;
6 5
7/** 6/**
@@ -30,9 +29,7 @@ public final class BlockFactory {
30 } 29 }
31 30
32 public static Block build(BlockType type, TileVec2 pos) { 31 public static Block build(BlockType type, TileVec2 pos) {
33 Block block = forType(type, pos.toVec2()); 32 return forType(type, pos.toVec2());
34 if (block != null) block.setControllers(BlockControllerFactory.build(block));
35 return block;
36 } 33 }
37 34
38 private BlockFactory() { 35 private BlockFactory() {
diff --git a/src/main/java/fr/umlv/java/wallj/block/BombBlock.java b/src/main/java/fr/umlv/java/wallj/block/BombBlock.java
index de7a3b9..f58f1cc 100644
--- a/src/main/java/fr/umlv/java/wallj/block/BombBlock.java
+++ b/src/main/java/fr/umlv/java/wallj/block/BombBlock.java
@@ -1,28 +1,69 @@
1package fr.umlv.java.wallj.block; 1package fr.umlv.java.wallj.block;
2 2
3import fr.umlv.java.wallj.board.TileVec2;
4import fr.umlv.java.wallj.context.Context;
5import fr.umlv.java.wallj.context.GraphicsContext;
6import fr.umlv.java.wallj.event.Event;
3import org.jbox2d.common.Vec2; 7import org.jbox2d.common.Vec2;
8import org.jbox2d.dynamics.BodyType;
9
10import java.awt.*;
11import java.time.Duration;
12import java.util.Arrays;
13import java.util.Collections;
14import java.util.List;
4 15
5/** 16/**
6 * A bomb block. 17 * A bomb block.
7 * 18 *
8 * @author Pacien TRAN-GIRARD 19 * @author Pacien TRAN-GIRARD
20 * @author Adam NAILI