-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathGame.java
More file actions
43 lines (34 loc) · 855 Bytes
/
Game.java
File metadata and controls
43 lines (34 loc) · 855 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
import java.awt.EventQueue;
import java.awt.event.WindowEvent;
import javax.swing.JFrame;
public class Game extends JFrame {
public static final int WIDTH = 800;
public static final int HEIGHT = 600;
public static boolean[] keys = new boolean[128];
public static Game game;
public static int highScore = 0;
public Game() {
initUI();
}
private void initUI() {
add(new Board());
setTitle("Road Runner");
setSize(WIDTH, HEIGHT);
setLocationRelativeTo(null);
setResizable(false);
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
}
/**
* Closes the application
*/
public static void close() {
game.dispatchEvent(new WindowEvent(game, WindowEvent.WINDOW_CLOSING));
}
public static void main(String[] args) {
EventQueue.invokeLater(() -> {
game = new Game();
game.setVisible(true);
Menu.init();
});
}
}