diff --git a/src/GamePanel.java b/src/GamePanel.java index cb6eb55..fcd9a8f 100644 --- a/src/GamePanel.java +++ b/src/GamePanel.java @@ -348,12 +348,12 @@ public class GamePanel extends JPanel implements Runnable, KeyListener, Serializ // increment sprite image to be used and keeps it below 12 playerFrame = (playerFrame + 1) % 11; playerFrameCounter -= 5; - // if the player has moved enough to justify a frame change, a new save will also be made - try { - FileManager.writeObjectToFile("local/game_state", new ArrayList()); // this is placeholder, replace with this - } catch (IOException e) { - e.printStackTrace(); - } +// // if the player has moved enough to justify a frame change, a new save will also be made +// try { +// FileManager.writeObjectToFile("local/game_state", new ArrayList()); // this is placeholder, replace with this +// } catch (IOException e) { +// e.printStackTrace(); +// } } } repaint(); diff --git a/src/Player.java b/src/Player.java index 120288b..25af147 100644 --- a/src/Player.java +++ b/src/Player.java @@ -303,8 +303,30 @@ public class Player extends GenericSprite { boolean[][]vis = new boolean[1000][18]; LinkedList xx = new LinkedList<>(); LinkedList yy = new LinkedList<>(); + xx.add(pX); + yy.add(pY); dis[pX][pY] = 0; vis[pX][pY] = true; + while(!xx.isEmpty()){ + int tempX = xx.poll(); + int tempY = yy.poll(); + for(int[]a: check){ + try{ + int newX = tempX + a[0]; + int newY = tempY + a[1]; + if(dis[tempX][tempY]+1<(Math.min(3,dis[newX][newY]))){ + dis[newX][newY] = dis[tempX][tempY]+1; + xx.add(newX); + yy.add(newY); + } + } catch(Exception e){ + + } + } + } + if(dis[pX][pY]<=3){ + return true; + } return false; } public void mouseDragged(MouseEvent e) {