diff --git a/cicaprojekt/Display.java b/cicaprojekt/Display.java index 0a77bbc..a2e4821 100644 --- a/cicaprojekt/Display.java +++ b/cicaprojekt/Display.java @@ -32,4 +32,13 @@ public class Display extends JPanel{ for(Drawer visual : visuals) 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(); + } + } } \ No newline at end of file diff --git a/cicaprojekt/Dungeon.java b/cicaprojekt/Dungeon.java index 4bff975..741b4a0 100644 --- a/cicaprojekt/Dungeon.java +++ b/cicaprojekt/Dungeon.java @@ -7,6 +7,7 @@ import java.util.Map; public class Dungeon { private int ZPMsToWin = 0; private long timeLimit = 0; + private int mapWidth = 0; /* 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 height = Integer.parseInt(sizedata[1]); + mapWidth = width; // remember this value + Tile[][] dungeon = new Tile[width][height]; String line = null; @@ -200,4 +203,8 @@ public class Dungeon { public long getTimeLimit() { return timeLimit; } + + public int getMapWidth() { + return mapWidth; + } } \ No newline at end of file diff --git a/cicaprojekt/Game.java b/cicaprojekt/Game.java index b0da708..2f392df 100644 --- a/cicaprojekt/Game.java +++ b/cicaprojekt/Game.java @@ -25,6 +25,9 @@ public class Game { Field field = new Field(); Tile callertile = caller.getCurrentTile(); + field.setX(callertile.getX()); + field.setY(callertile.getY()); + field.setAdajacentTile(caller.getCurrentTile().getAdjacentTile(Direction.NORTH), Direction.NORTH); callertile.getAdjacentTile(Direction.NORTH).setAdajacentTile(field, Direction.SOUTH); @@ -37,6 +40,8 @@ public class Game { field.setAdajacentTile(caller.getCurrentTile().getAdjacentTile(Direction.EAST), Direction.EAST); callertile.getAdjacentTile(Direction.EAST).setAdajacentTile(field, Direction.WEST); + display.gapMagic((Gap)callertile, field, dungeon.getMapWidth()); + Game.instance.updateDisplay(); }