Do a slight improvement on GameMap and add 'performed' flag to Movement
This commit is contained in:
@@ -27,7 +27,7 @@ public class GameMap {
|
||||
@Getter
|
||||
private final int cols;
|
||||
|
||||
public GameMap(TileSet tileSet, int rows, int cols, float scale) {
|
||||
private GameMap(TileSet tileSet, int rows, int cols, float scale) {
|
||||
this.tileSet = tileSet;
|
||||
this.rows = rows;
|
||||
this.cols = cols;
|
||||
@@ -37,6 +37,16 @@ public class GameMap {
|
||||
map = new Tile[LAYERS][rows * cols];
|
||||
passageMap = new PassageAbility[rows * cols];
|
||||
Arrays.fill(passageMap, 0, rows * cols, PassageAbility.ALLOW);
|
||||
|
||||
for(int i=0; i<rows; ++i) {
|
||||
setPassageAbility(i, 0, PassageAbility.BLOCK);
|
||||
setPassageAbility(i, cols-1, PassageAbility.BLOCK);
|
||||
}
|
||||
|
||||
for(int i=0; i<cols; ++i) {
|
||||
setPassageAbility( 0, i, PassageAbility.BLOCK);
|
||||
setPassageAbility( rows-1, i, PassageAbility.BLOCK);
|
||||
}
|
||||
}
|
||||
|
||||
public void setTile(int layer, int row, int col, Tile tile) {
|
||||
@@ -89,4 +99,8 @@ public class GameMap {
|
||||
|
||||
return isTargetReachable && canMoveFromCurrentTile;
|
||||
}
|
||||
|
||||
public static GameMap empty(TileSet tileSet, int rows, int cols, float scale) {
|
||||
return new GameMap(tileSet, rows, cols, scale);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -10,9 +10,11 @@ import org.joml.Vector2i;
|
||||
public class Movement {
|
||||
private final MovableObject object;
|
||||
private final Direction direction;
|
||||
private boolean performed = false;
|
||||
|
||||
public boolean perform() {
|
||||
return object.move(direction);
|
||||
performed = object.move(direction);
|
||||
return performed;
|
||||
}
|
||||
|
||||
public Vector2i getSourceCoordinate() {
|
||||
|
||||
Reference in New Issue
Block a user