Skip to content

Commit

Permalink
make the game show score after death, popup at 40 to ask to continue
Browse files Browse the repository at this point in the history
  • Loading branch information
ThatGamerBlue committed Jun 23, 2022
1 parent b408ee7 commit 21c2ab3
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
import java.awt.event.KeyListener;
import java.util.HashSet;
import java.util.Set;
import javax.swing.JOptionPane;

public class GameHandler implements KeyListener {
private static final int DEFAULT_REFRESH_INTERVAL = 100;
Expand Down Expand Up @@ -37,6 +38,9 @@ public GameHandler(SnakeGame game) {
}

public void reset() {
if (score != 0) {
JOptionPane.showMessageDialog(null, "You died! Your score: " + score, "OpenOSRS Snake", JOptionPane.INFORMATION_MESSAGE);
}
head = new SnakePart();
SnakePart current = head;
current.x = MIDDLE_X;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import java.awt.Graphics;
import java.awt.Image;
import javax.swing.JFrame;
import javax.swing.JOptionPane;
import javax.swing.JPanel;
import lombok.SneakyThrows;
import net.runelite.client.RuneLite;
Expand All @@ -30,13 +31,18 @@ public void start(Component component) {
}

public void stop() throws Exception {
running = false;
Component c = component;
while (c != null) {
c.setVisible(false);
c = c.getParent();
int option = JOptionPane.showConfirmDialog(null,
"You scored 40! Press Yes to launch OpenOSRS, press No to keep playing snake.",
"OpenOSRS Snake", JOptionPane.YES_NO_OPTION);
if (option == JOptionPane.YES_OPTION) {
running = false;
Component c = component;
while (c != null) {
c.setVisible(false);
c = c.getParent();
}
RuneLite.oldMain(arguments);
}
RuneLite.oldMain(arguments);
}

@SneakyThrows
Expand Down

0 comments on commit 21c2ab3

Please sign in to comment.