-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathGameFrame.java
More file actions
31 lines (25 loc) · 820 Bytes
/
GameFrame.java
File metadata and controls
31 lines (25 loc) · 820 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
import javax.swing.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
public final class GameFrame extends JFrame {
private static final int WINDOW_WIDTH = 800;
private static final int WINDOW_HEIGHT = 600;
/**
* Constructor to create and set up the game frame.
*/
public GameFrame() {
setTitle("Space Invaders");
setSize(WINDOW_WIDTH, WINDOW_HEIGHT);
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
GamePanel gamePanel = new GamePanel();
add(gamePanel);
Timer timer = new Timer(10, new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
gamePanel.update();
gamePanel.repaint();
}
});
timer.start();
}
}