now Gaps that are converted to Fields show up correctly

This commit is contained in:
Kjistóf 2016-05-13 23:17:42 +02:00
parent 46ecc68500
commit 7d059701cc
3 changed files with 21 additions and 0 deletions

View File

@ -32,4 +32,13 @@ public class Display extends JPanel{
for(Drawer visual : visuals) for(Drawer visual : visuals)
g.drawImage(visual.getImage(), visual.getTileX() * 64, visual.getTileY() * 64, null); g.drawImage(visual.getImage(), visual.getTileX() * 64, visual.getTileY() * 64, null);
} }
public void gapMagic(Gap gap, Field field, int mapwidth) {
try {
visuals.set((gap.getY()*mapwidth)+gap.getX(), new FieldDrawer(field));
}
catch (IOException e) {
Control.ioErrorMessage();
}
}
} }

View File

@ -7,6 +7,7 @@ import java.util.Map;
public class Dungeon { public class Dungeon {
private int ZPMsToWin = 0; private int ZPMsToWin = 0;
private long timeLimit = 0; private long timeLimit = 0;
private int mapWidth = 0;
/* NOTE: this function assumes that the parameter input is a well-formatted dungeon file. /* NOTE: this function assumes that the parameter input is a well-formatted dungeon file.
@ -53,6 +54,8 @@ public class Dungeon {
int width = Integer.parseInt(sizedata[0]); int width = Integer.parseInt(sizedata[0]);
int height = Integer.parseInt(sizedata[1]); int height = Integer.parseInt(sizedata[1]);
mapWidth = width; // remember this value
Tile[][] dungeon = new Tile[width][height]; Tile[][] dungeon = new Tile[width][height];
String line = null; String line = null;
@ -200,4 +203,8 @@ public class Dungeon {
public long getTimeLimit() { public long getTimeLimit() {
return timeLimit; return timeLimit;
} }
public int getMapWidth() {
return mapWidth;
}
} }

View File

@ -25,6 +25,9 @@ public class Game {
Field field = new Field(); Field field = new Field();
Tile callertile = caller.getCurrentTile(); Tile callertile = caller.getCurrentTile();
field.setX(callertile.getX());
field.setY(callertile.getY());
field.setAdajacentTile(caller.getCurrentTile().getAdjacentTile(Direction.NORTH), Direction.NORTH); field.setAdajacentTile(caller.getCurrentTile().getAdjacentTile(Direction.NORTH), Direction.NORTH);
callertile.getAdjacentTile(Direction.NORTH).setAdajacentTile(field, Direction.SOUTH); callertile.getAdjacentTile(Direction.NORTH).setAdajacentTile(field, Direction.SOUTH);
@ -37,6 +40,8 @@ public class Game {
field.setAdajacentTile(caller.getCurrentTile().getAdjacentTile(Direction.EAST), Direction.EAST); field.setAdajacentTile(caller.getCurrentTile().getAdjacentTile(Direction.EAST), Direction.EAST);
callertile.getAdjacentTile(Direction.EAST).setAdajacentTile(field, Direction.WEST); callertile.getAdjacentTile(Direction.EAST).setAdajacentTile(field, Direction.WEST);
display.gapMagic((Gap)callertile, field, dungeon.getMapWidth());
Game.instance.updateDisplay(); Game.instance.updateDisplay();
} }