aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorpacien2018-02-02 18:33:15 +0100
committerpacien2018-02-02 18:33:15 +0100
commitd799681be0e96652fa6781f40b763c4d2d708984 (patch)
tree77925c981c678179c6d34b62c940abead5c20d6d
parent7be75b7b406049d73e43f9232dac10b89dce6dcb (diff)
downloadwallj-d799681be0e96652fa6781f40b763c4d2d708984.tar.gz
More documentation
Signed-off-by: pacien <pacien.trangirard@pacien.net>
-rw-r--r--src/main/java/fr/umlv/java/wallj/block/BlockFactory.java7
-rw-r--r--src/main/java/fr/umlv/java/wallj/block/BlockType.java2
-rw-r--r--src/main/java/fr/umlv/java/wallj/block/SolidDef.java15
-rw-r--r--src/main/java/fr/umlv/java/wallj/board/BoardParser.java2
-rw-r--r--src/main/java/fr/umlv/java/wallj/board/PathFinder.java2
-rw-r--r--src/main/java/fr/umlv/java/wallj/board/TileVec2.java2
6 files changed, 20 insertions, 10 deletions
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 acd280f..6911c88 100644
--- a/src/main/java/fr/umlv/java/wallj/block/BlockFactory.java
+++ b/src/main/java/fr/umlv/java/wallj/block/BlockFactory.java
@@ -9,7 +9,6 @@ import org.jbox2d.common.Vec2;
9 * @author Pacien TRAN-GIRARD 9 * @author Pacien TRAN-GIRARD
10 */ 10 */
11public final class BlockFactory { 11public final class BlockFactory {
12
13 private static Block forType(BlockType t, Vec2 pos) { 12 private static Block forType(BlockType t, Vec2 pos) {
14 switch (t) { 13 switch (t) {
15 case WALL: 14 case WALL:
@@ -28,6 +27,11 @@ public final class BlockFactory {
28 } 27 }
29 } 28 }
30 29
30 /**
31 * @param type the type of the block to build
32 * @param pos the initial position of the block
33 * @return the built block
34 */
31 public static Block build(BlockType type, TileVec2 pos) { 35 public static Block build(BlockType type, TileVec2 pos) {
32 return forType(type, pos.toVec2()); 36 return forType(type, pos.toVec2());
33 } 37 }
@@ -35,5 +39,4 @@ public final class BlockFactory {
35 private BlockFactory() { 39 private BlockFactory() {
36 // static class 40 // static class
37 } 41 }
38
39} 42}
diff --git a/src/main/java/fr/umlv/java/wallj/block/BlockType.java b/src/main/java/fr/umlv/java/wallj/block/BlockType.java
index 6ef1df3..84faa39 100644
--- a/src/main/java/fr/umlv/java/wallj/block/BlockType.java
+++ b/src/main/java/fr/umlv/java/wallj/block/BlockType.java
@@ -6,7 +6,6 @@ package fr.umlv.java.wallj.block;
6 * @author Pacien TRAN-GIRARD 6 * @author Pacien TRAN-GIRARD
7 */ 7 */
8public enum BlockType { 8public enum BlockType {
9
10 FREE(false, true, true, false), 9 FREE(false, true, true, false),
11 WALL(true, false, false, false), 10 WALL(true, false, false, false),
12 TRASH(true, true, false, false), 11 TRASH(true, true, false, false),
@@ -53,5 +52,4 @@ public enum BlockType {
53 public boolean isMovableByExplosion() { 52 public boolean isMovableByExplosion() {
54 return movableByExplosion; 53 return movableByExplosion;
55 } 54 }
56
57} 55}
diff --git a/src/main/java/fr/umlv/java/wallj/block/SolidDef.java b/src/main/java/fr/umlv/java/wallj/block/SolidDef.java
index bfc1743..496c602 100644
--- a/src/main/java/fr/umlv/java/wallj/block/SolidDef.java
+++ b/src/main/java/fr/umlv/java/wallj/block/SolidDef.java
@@ -13,6 +13,11 @@ import org.jbox2d.dynamics.FixtureDef;
13 * @author Pacien TRAN-GIRARD 13 * @author Pacien TRAN-GIRARD
14 */ 14 */
15public final class SolidDef { 15public final class SolidDef {
16 /**
17 * @param bodyType type of body
18 * @param pos initial position of the body
19 * @return a corresponding body definition
20 */
16 public static BodyDef bodyDefOf(BodyType bodyType, Vec2 pos) { 21 public static BodyDef bodyDefOf(BodyType bodyType, Vec2 pos) {
17 BodyDef def = new BodyDef(); 22 BodyDef def = new BodyDef();
18 def.type = bodyType; 23 def.type = bodyType;
@@ -20,6 +25,10 @@ public final class SolidDef {
20 return def; 25 return def;
21 } 26 }
22 27
28 /**
29 * @param shape a shape definition
30 * @return a corresponding fixture definition
31 */
23 public static FixtureDef fixtureDefOf(Shape shape) { 32 public static FixtureDef fixtureDefOf(Shape shape) {
24 FixtureDef def = new FixtureDef(); 33 FixtureDef def = new FixtureDef();
25 def.shape = shape; 34 def.shape = shape;
@@ -27,12 +36,18 @@ public final class SolidDef {
27 return def; 36 return def;
28 } 37 }
29 38
39 /**
40 * @return a tile square shape definition
41 */
30 public static PolygonShape squareShape() { 42 public static PolygonShape squareShape() {
31 PolygonShape shape = new PolygonShape(); 43 PolygonShape shape = new PolygonShape();
32 shape.setAsBox(TileVec2.TILE_DIM, TileVec2.TILE_DIM); 44 shape.setAsBox(TileVec2.TILE_DIM, TileVec2.TILE_DIM);
33 return shape; 45 return shape;
34 } 46 }
35 47
48 /**
49 * @return a circle shape definition fitting in a tile
50 */
36 public static CircleShape circleShape() { 51 public static CircleShape circleShape() {
37 CircleShape shape = new CircleShape(); 52 CircleShape shape = new CircleShape();
38 shape.m_radius = TileVec2.TILE_DIM / 2; 53 shape.m_radius = TileVec2.TILE_DIM / 2;
diff --git a/src/main/java/fr/umlv/java/wallj/board/BoardParser.java b/src/main/java/fr/umlv/java/wallj/board/BoardParser.java
index 3b77767..90fd9c2 100644
--- a/src/main/java/fr/umlv/java/wallj/board/BoardParser.java
+++ b/src/main/java/fr/umlv/java/wallj/board/BoardParser.java
@@ -15,7 +15,6 @@ import java.util.stream.Collectors;
15 * @author Pacien TRAN-GIRARD 15 * @author Pacien TRAN-GIRARD
16 */ 16 */
17public final class BoardParser { 17public final class BoardParser {
18
19 private static Board buildBoard(List<List<BlockType>> map) { 18 private static Board buildBoard(List<List<BlockType>> map) {
20 if (!Matrix.isShapeValid(map)) throw new IllegalArgumentException("Board must be rectangular."); 19 if (!Matrix.isShapeValid(map)) throw new IllegalArgumentException("Board must be rectangular.");
21 20
@@ -65,5 +64,4 @@ public final class BoardParser {
65 private BoardParser() { 64 private BoardParser() {
66 // static class 65 // static class
67 } 66 }
68
69} 67}
diff --git a/src/main/java/fr/umlv/java/wallj/board/PathFinder.java b/src/main/java/fr/umlv/java/wallj/board/PathFinder.java
index 2f2f009..c530d83 100644
--- a/src/main/java/fr/umlv/java/wallj/board/PathFinder.java
+++ b/src/main/java/fr/umlv/java/wallj/board/PathFinder.java
@@ -10,7 +10,6 @@ import java.util.stream.Collectors;
10 * @author Pacien TRAN-GIRARD 10 * @author Pacien TRAN-GIRARD
11 */ 11 */
12public class PathFinder { 12public class PathFinder {
13
14 private static final int LEAP_COST = 1; 13 private static final int LEAP_COST = 1;
15 14
16 private static class Node<T> { 15 private static class Node<T> {
@@ -129,5 +128,4 @@ public class PathFinder {
129 if (startNode == null) throw new IllegalArgumentException("Invalid starting point."); 128 if (startNode == null) throw new IllegalArgumentException("Invalid starting point.");
130 return findPath(startNode, target, PathFinder::euclideanDistance); 129 return findPath(startNode, target, PathFinder::euclideanDistance);
131 } 130 }
132
133} 131}
diff --git a/src/main/java/fr/umlv/java/wallj/board/TileVec2.java b/src/main/java/fr/umlv/java/wallj/board/TileVec2.java
index 1d95690..4165c81 100644
--- a/src/main/java/fr/umlv/java/wallj/board/TileVec2.java
+++ b/src/main/java/fr/umlv/java/wallj/board/TileVec2.java
@@ -13,7 +13,6 @@ import java.util.stream.Collectors;
13 * @author Pacien TRAN-GIRARD 13 * @author Pacien TRAN-GIRARD
14 */ 14 */
15public final class TileVec2 { 15public final class TileVec2 {
16
17 public static final int TILE_DIM = 20; 16 public static final int TILE_DIM = 20;
18 private static final List<TileVec2> NEIGHBOR_OFFSETS = Arrays.asList( 17 private static final List<TileVec2> NEIGHBOR_OFFSETS = Arrays.asList(
19 of(0, -1), 18 of(0, -1),
@@ -98,5 +97,4 @@ public final class TileVec2 {
98 ", row=" + row + 97 ", row=" + row +
99 '}'; 98 '}';
100 } 99 }
101
102} 100}