make the game show score after death, popup at 40 to ask to continue
This commit is contained in:
@@ -9,6 +9,7 @@ import java.awt.event.KeyEvent;
|
||||
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;
|
||||
@@ -37,6 +38,9 @@ public class GameHandler implements KeyListener {
|
||||
}
|
||||
|
||||
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;
|
||||
|
||||
@@ -5,6 +5,7 @@ import java.awt.Component;
|
||||
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;
|
||||
@@ -30,13 +31,18 @@ public class SnakeGame {
|
||||
}
|
||||
|
||||
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
|
||||
|
||||
Reference in New Issue
Block a user