Skip to content

Commit 839d1dc

Browse files
committed
Added a button to show the Dev stats
1 parent e3346c0 commit 839d1dc

File tree

3 files changed

+46
-2
lines changed

3 files changed

+46
-2
lines changed

src/com/redomar/game/Game.java

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,7 @@ public class Game extends Canvas implements Runnable {
5353
private static int fps;
5454
private static int tps;
5555
private static int steps;
56+
private static boolean[] devMode = new boolean[2];
5657

5758
private static JFrame frame;
5859

@@ -98,6 +99,8 @@ public Game() {
9899
getFrame().setLocationRelativeTo(null);
99100
getFrame().setVisible(true);
100101

102+
setDevMode(false);
103+
setDevTime(false);
101104
}
102105

103106
public void init() {
@@ -309,7 +312,7 @@ public void render() {
309312
g.drawString("Press Q to quit", (getWidth()/2)-("Press Q to quit".length()*3), getHeight() -17);
310313
g.setColor(Color.YELLOW);
311314
g.drawString(time.getTime(), (getWidth() - 58), (getHeight() - 3));
312-
status(g, true);
315+
status(g, isDevMode());
313316
g.setColor(Color.WHITE);
314317
if (noAudioDevice == true) {
315318
g.setColor(Color.RED);
@@ -541,4 +544,20 @@ public void setInput(InputHandler input) {
541544
Game.input = input;
542545
}
543546

547+
public static boolean isDevMode() {
548+
return devMode[0];
549+
}
550+
551+
public static void setDevMode(boolean devMode) {
552+
Game.devMode[0] = devMode;
553+
}
554+
555+
public static boolean isDevTime() {
556+
return devMode[1];
557+
}
558+
559+
public static void setDevTime(boolean devTime) {
560+
Game.devMode[1] = devTime;
561+
}
562+
544563
}

src/com/redomar/game/InputHandler.java

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
import java.awt.event.KeyEvent;
44
import java.awt.event.KeyListener;
55

6+
import com.redomar.game.lib.SleepThread;
67
import com.redomar.game.script.PrintTypes;
78
import com.redomar.game.script.Printing;
89

@@ -40,7 +41,7 @@ public void toggle(boolean isPressed) {
4041
private boolean PlayMusic = false;
4142
private int map;
4243
private boolean untoggle = false;
43-
44+
4445
public void keyPressed(KeyEvent e) {
4546
toggleKey(e.getKeyCode(), true);
4647
}
@@ -110,6 +111,14 @@ public void toggleKey(int keyCode, boolean isPressed) {
110111
Game.getFrame().dispose();
111112
System.exit(1);
112113
}
114+
115+
if (keyCode == KeyEvent.VK_BACK_QUOTE){
116+
if (Game.isDevTime() == false && Game.isDevMode() == false){
117+
Game.setDevMode(true);
118+
Game.setDevTime(true);
119+
new Thread(new SleepThread());
120+
}
121+
}
113122
}
114123

115124
public void untoggle(boolean toggle){
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
package com.redomar.game.lib;
2+
3+
import com.redomar.game.Game;
4+
5+
public class SleepThread implements Runnable{
6+
7+
public void run() {
8+
try {
9+
Thread.sleep(1500);
10+
Game.setDevTime(false);
11+
System.out.println("time up");
12+
} catch (InterruptedException e) {
13+
e.printStackTrace();
14+
}
15+
}
16+
}

0 commit comments

Comments
 (0)