summaryrefslogtreecommitdiffstats
path: root/src/Map.java
diff options
context:
space:
mode:
authorNao Pross <naopross@thearcway.org>2018-11-19 09:12:42 +0100
committerNao Pross <naopross@thearcway.org>2018-11-19 09:12:42 +0100
commit9dca8d0f3610e2cd1079f9705f1da31ff19aba93 (patch)
treef3e421cf2e8e676bbeec2fb111cd5930b4cb3031 /src/Map.java
parentUpdate makefile (diff)
downloadSubconscious-java-9dca8d0f3610e2cd1079f9705f1da31ff19aba93.tar.gz
Subconscious-java-9dca8d0f3610e2cd1079f9705f1da31ff19aba93.zip
Add Actor.SkillSet, remove useless members in various strucutres
Diffstat (limited to 'src/Map.java')
-rw-r--r--src/Map.java26
1 files changed, 13 insertions, 13 deletions
diff --git a/src/Map.java b/src/Map.java
index a870604..0e0d1e3 100644
--- a/src/Map.java
+++ b/src/Map.java
@@ -15,11 +15,11 @@ public class Map {
public Map(Dimension size) {
this.size = size;
- // TODO: replace with Dimension.height and Dimension.width which are integer public members
- this.grid = new Tile[(int) this.size.getWidth() * (int) this.size.getHeight()];
- for (int x = 0; x < this.size.getWidth(); x++) {
- for (int y = 0; y < this.size.getHeight(); y++) {
- this.grid[x * (int) this.size.getWidth() + y] = new Tile(Tile.Type.GRASS, x, y);
+ // Populate grid with GRASS tiles
+ this.grid = new Tile[this.size.width * this.size.height];
+ for (int x = 0; x < this.size.width; x++) {
+ for (int y = 0; y < this.size.height; y++) {
+ this.grid[x * this.size.width + y] = new Tile(Tile.Type.GRASS, x, y);
}
}
}
@@ -56,7 +56,7 @@ public class Map {
Tile workingTile = this.getTile(x, y);
double bestDistance = 1000000000;
Tile bestTile = workingTile;
-
+
while (true) {
for (Tile i : workingTile.getAdjacent(this)) {
if (i.getDistance() < bestDistance) {
@@ -79,15 +79,15 @@ public class Map {
// TODO: if this is needed for something, implement copy constructors for Actor and Tile
// and delete this code
for (Actor actor : actorsList) {
- Actor newActor = new Actor(actor.getName(), actor.getHP(), actor.isEnemy(), actor.getAgility());
+ Actor newActor = new Actor(actor.getName(), actor.getHP(), actor.isEnemy(), actor.getSkills().agility);
newActor.place(actor.getX(), actor.getY());
this.actors.add(newActor);
}
- for (int x = 0; x < this.size.getWidth(); x++) {
- for (int y = 0; y < this.size.getHeight(); y++) {
- Tile.Type oldTileType = tileGrid[x * (int) this.size.getWidth() + y].getType();
- this.grid[x * (int) this.size.getWidth() + y] = new Tile(oldTileType, x, y);
+ for (int x = 0; x < this.size.width; x++) {
+ for (int y = 0; y < this.size.height; y++) {
+ Tile.Type oldTileType = tileGrid[x * this.size.width + y].getType();
+ this.grid[x * this.size.width + y] = new Tile(oldTileType, x, y);
}
}
}
@@ -139,11 +139,11 @@ public class Map {
}
public Tile getTile(int x, int y) {
- return this.grid[x * (int) this.size.getWidth() + y];
+ return this.grid[x * this.size.width + y];
}
public int getSize() {
- return (int) this.size.getWidth();
+ return this.size.width;
}
public ArrayList<Actor> getActors() {