diff --git a/src/main/java/Ant.java b/src/main/java/Ant.java index a4dc715..c3a901c 100644 --- a/src/main/java/Ant.java +++ b/src/main/java/Ant.java @@ -23,23 +23,15 @@ public class Ant { private AStarSearch aStarSearch; private LinkedList> allPath2D = new LinkedList>(); - public Ant(Tile start, Tile goal, int tileSize, Tile[][] tiles) { + public Ant(Tile start, Tile goal, int tileSize, Tile[][] tiles, Image antImage) { this.start = start; this.goal = goal; this.tiles = tiles; - loadAntImg(); + this.antImage = antImage; antX = start.getXpixel(); antY = start.getYpixel(); } - private void loadAntImg() { - try { - antImage = ImageIO.read(getClass().getResource("/assets/images/ant.png")); - } catch (IOException e) { - e.printStackTrace(); - } - } - public void draw(Graphics g, int tileSize) { g.drawImage(antImage, antX, antY, tileSize, tileSize, null); } diff --git a/src/main/java/Game.java b/src/main/java/Game.java index 7cb2093..d231c3a 100644 --- a/src/main/java/Game.java +++ b/src/main/java/Game.java @@ -317,7 +317,7 @@ public void actionPerformed(ActionEvent e) { if (startTile != null && goalTile != null) { resetCameFrom(tiles); // useful if the user wants to search for the second time or more - ant = new Ant(startTile, goalTile, TILE_SIZE, tiles); + ant = new Ant(startTile, goalTile, TILE_SIZE, tiles, antImage); startClicked = true; startTimeBeforeAnimation = System.currentTimeMillis(); ant.search();