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.awt.event.KeyListener;
|
||||||
import java.util.HashSet;
|
import java.util.HashSet;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
import javax.swing.JOptionPane;
|
||||||
|
|
||||||
public class GameHandler implements KeyListener {
|
public class GameHandler implements KeyListener {
|
||||||
private static final int DEFAULT_REFRESH_INTERVAL = 100;
|
private static final int DEFAULT_REFRESH_INTERVAL = 100;
|
||||||
@@ -37,6 +38,9 @@ public class GameHandler implements KeyListener {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void reset() {
|
public void reset() {
|
||||||
|
if (score != 0) {
|
||||||
|
JOptionPane.showMessageDialog(null, "You died! Your score: " + score, "OpenOSRS Snake", JOptionPane.INFORMATION_MESSAGE);
|
||||||
|
}
|
||||||
head = new SnakePart();
|
head = new SnakePart();
|
||||||
SnakePart current = head;
|
SnakePart current = head;
|
||||||
current.x = MIDDLE_X;
|
current.x = MIDDLE_X;
|
||||||
|
|||||||
@@ -5,6 +5,7 @@ import java.awt.Component;
|
|||||||
import java.awt.Graphics;
|
import java.awt.Graphics;
|
||||||
import java.awt.Image;
|
import java.awt.Image;
|
||||||
import javax.swing.JFrame;
|
import javax.swing.JFrame;
|
||||||
|
import javax.swing.JOptionPane;
|
||||||
import javax.swing.JPanel;
|
import javax.swing.JPanel;
|
||||||
import lombok.SneakyThrows;
|
import lombok.SneakyThrows;
|
||||||
import net.runelite.client.RuneLite;
|
import net.runelite.client.RuneLite;
|
||||||
@@ -30,13 +31,18 @@ public class SnakeGame {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void stop() throws Exception {
|
public void stop() throws Exception {
|
||||||
running = false;
|
int option = JOptionPane.showConfirmDialog(null,
|
||||||
Component c = component;
|
"You scored 40! Press Yes to launch OpenOSRS, press No to keep playing snake.",
|
||||||
while (c != null) {
|
"OpenOSRS Snake", JOptionPane.YES_NO_OPTION);
|
||||||
c.setVisible(false);
|
if (option == JOptionPane.YES_OPTION) {
|
||||||
c = c.getParent();
|
running = false;
|
||||||
|
Component c = component;
|
||||||
|
while (c != null) {
|
||||||
|
c.setVisible(false);
|
||||||
|
c = c.getParent();
|
||||||
|
}
|
||||||
|
RuneLite.oldMain(arguments);
|
||||||
}
|
}
|
||||||
RuneLite.oldMain(arguments);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@SneakyThrows
|
@SneakyThrows
|
||||||
|
|||||||
Reference in New Issue
Block a user