Merge remote-tracking branch 'origin/master'
commit
913b742a18
|
@ -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();
|
||||
|
|
|
@ -303,8 +303,30 @@ public class Player extends GenericSprite {
|
|||
boolean[][]vis = new boolean[1000][18];
|
||||
LinkedList<Integer> xx = new LinkedList<>();
|
||||
LinkedList<Integer> 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) {
|
||||
|
|
Loading…
Reference in New Issue