Skip to content

Commit

Permalink
renaming
Browse files Browse the repository at this point in the history
  • Loading branch information
PavelCz committed Apr 11, 2014
1 parent 5b39d53 commit d56e20a
Showing 1 changed file with 24 additions and 24 deletions.
48 changes: 24 additions & 24 deletions src/engine/PathTiler.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@

public class PathTiler {
private Sprite corner1, corner2, corner3, corner4, horizontal, vertical, top, bottom, left, right;
private Sprite[][] path;
private Sprite[][] tiles;

public PathTiler(int[][] path1) {
public PathTiler(int[][] path) {
this.corner1 = new Sprite("veins/VeinCorner.png");
this.corner2 = new Sprite("veins/VeinCorner2.png");
this.corner3 = new Sprite("veins/VeinCorner3.png");
Expand All @@ -17,45 +17,45 @@ public PathTiler(int[][] path1) {
this.bottom = new Sprite("veins/VeinBottomEnd.png");
this.left = new Sprite("veins/VeinLeftEnd.png");
this.right = new Sprite("veins/VeinRightEnd.png");
this.path = new Sprite[path1.length][path1[0].length];
this.tiles = new Sprite[path.length][path[0].length];

for (int y = 0; y < path1.length; ++y) {
for (int x = 0; x < path1[0].length; ++x) {
if (path1[y][x] == 5) {
for (int y = 0; y < path.length; ++y) {
for (int x = 0; x < path[0].length; ++x) {
if (path[y][x] == 5) {
boolean above = false, below = false, left = false, right = false;
if (y - 1 >= 0 && path1[y - 1][x] == 5) {
if (y - 1 >= 0 && path[y - 1][x] == 5) {
above = true;
}
if (y + 1 < path1.length && path1[y + 1][x] == 5) {
if (y + 1 < path.length && path[y + 1][x] == 5) {
below = true;
}
if (x - 1 >= 0 && path1[y][x - 1] == 5) {
if (x - 1 >= 0 && path[y][x - 1] == 5) {
left = true;
}
if (x + 1 < path1[0].length && path1[y][x + 1] == 5) {
if (x + 1 < path[0].length && path[y][x + 1] == 5) {
right = true;
}

if (below && !above && !right && !left) {
this.path[y][x] = this.top;
this.tiles[y][x] = this.top;
} else if (!below && above && !right && !left) {
this.path[y][x] = this.bottom;
this.tiles[y][x] = this.bottom;
} else if (!below && !above && right && !left) {
this.path[y][x] = this.left;
this.tiles[y][x] = this.left;
} else if (!below && !above && !right && left) {
this.path[y][x] = this.right;
this.tiles[y][x] = this.right;
} else if (below && above && !right && !left) {
this.path[y][x] = this.vertical;
this.tiles[y][x] = this.vertical;
} else if (!below && !above && right && left) {
this.path[y][x] = this.horizontal;
this.tiles[y][x] = this.horizontal;
} else if (!below && above && right && !left) {
this.path[y][x] = this.corner1;
this.tiles[y][x] = this.corner1;
} else if (below && !above && right && !left) {
this.path[y][x] = this.corner2;
this.tiles[y][x] = this.corner2;
} else if (below && !above && !right && left) {
this.path[y][x] = this.corner3;
this.tiles[y][x] = this.corner3;
} else if (!below && above && !right && left) {
this.path[y][x] = this.corner4;
this.tiles[y][x] = this.corner4;
}

}
Expand All @@ -65,10 +65,10 @@ public PathTiler(int[][] path1) {
}

public void render() {
for (int y = 0; y < this.path.length; ++y) {
for (int x = 0; x < this.path[0].length; ++x) {
if (this.path[y][x] != null) {
this.path[y][x].draw(x * 50, y * 50);
for (int y = 0; y < this.tiles.length; ++y) {
for (int x = 0; x < this.tiles[0].length; ++x) {
if (this.tiles[y][x] != null) {
this.tiles[y][x].draw(x * 50, y * 50);
}
}
}
Expand Down

0 comments on commit d56e20a

Please sign in to comment.