From b796df4759a2f6ca03bf0a353db262388caedeca Mon Sep 17 00:00:00 2001 From: John Date: Fri, 17 Jun 2022 13:09:50 -0400 Subject: [PATCH] Add boss portrait, reduce frequency of saves --- img/dialogue/Bouncer.png | Bin 0 -> 739 bytes src/GamePanel.java | 22 +++++++++++++--------- 2 files changed, 13 insertions(+), 9 deletions(-) create mode 100644 img/dialogue/Bouncer.png diff --git a/img/dialogue/Bouncer.png b/img/dialogue/Bouncer.png new file mode 100644 index 0000000000000000000000000000000000000000..429d30482153a849a74d5681df3d4c5c749de574 GIT binary patch literal 739 zcmV<90v!E`P)?Wfvd` z5kb!dDgpx#b^yi~B8t5WGe~;@$>u4~k5GjI_A zrLq+3)(!w8Sfrx)fqJifJAkNG%qB+L-|ZB@QSK$Se&2V!PXPsW6hJ|*SD+XGYz1;J)Mh}=Rb&8Z{5}94$>KntYtZ+y*O6%9 zb-<<;C>6WGigoclq2(#)O~BTYT##Gdqs!kWRP-7ECJ+LU3P37LplAya z1PRXcU23K1C19Z~2lUVv_!0mnkP*~V#6|!sP|BmA>}`Pm2QW`~7vKsgTY=dNz#o_8 VYwu?hZa4q{002ovPDHLkV1i#1Fwg)1 literal 0 HcmV?d00001 diff --git a/src/GamePanel.java b/src/GamePanel.java index 23b5f70..7901a24 100644 --- a/src/GamePanel.java +++ b/src/GamePanel.java @@ -42,7 +42,7 @@ public class GamePanel extends JPanel implements Runnable, KeyListener, Serializ public int playerFrame, enemyFrame; // keeps track of how many ticks has elapsed since last frame change public int playerFrameCounter = 0; - public int enemyFrameCounter = 0; + public int timeSinceLastSave = 0; public boolean isPaused, isDialogue, waitForDialogue, mouseAlreadyTranslated; public PauseMenu pauseMenu; public DialogueMenu dialogueMenu; @@ -388,14 +388,18 @@ public class GamePanel extends JPanel implements Runnable, KeyListener, Serializ playerFrameCounter -= 5; } } - // a new save is made every tick - bombCount = LevelManager.bombs; - try { - // atomic save to prevent EOF errors - FileManager.writeObjectToFile("local\\temp_state.dat", this); - Files.move(Path.of("local", "temp_state.dat"), Path.of("local", "game_state.dat"), ATOMIC_MOVE); - } catch (IOException | ConcurrentModificationException e) { - e.printStackTrace(); + // a new save is made every 100 ticks + timeSinceLastSave++; + if (timeSinceLastSave >= 100) { + timeSinceLastSave -= 100; + bombCount = LevelManager.bombs; + try { + // atomic save to prevent EOF errors + FileManager.writeObjectToFile("local\\temp_state.dat", this); + Files.move(Path.of("local", "temp_state.dat"), Path.of("local", "game_state.dat"), ATOMIC_MOVE); + } catch (IOException | ConcurrentModificationException e) { + e.printStackTrace(); + } } repaint(); delta--;