-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathGameFrame.java
More file actions
32 lines (26 loc) · 1.22 KB
/
Copy pathGameFrame.java
File metadata and controls
32 lines (26 loc) · 1.22 KB
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
/*
* Authors: Jerry Li & Victor Jiang
* Date: June 13, 2025
* Description: This class provides the main game window
*/
import java.awt.*;
import javax.swing.*;
public class GameFrame extends JFrame {
GamePanel panel; // A panel where the game content will be displayed.
// Constructor for the GameFrame class.
public GameFrame() {
ImageIcon icon = null;
panel = new GamePanel(); // Initialize the game panel.
this.add(panel); // Add the game panel to the frame.
this.setTitle("Endless Night"); // Set the title of the window.
this.setResizable(false); // Prevent the window from being resized.
this.setBackground(Color.BLACK); // Set the background color of the frame.
this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); // Ensure the application exits when the window is closed.
// Set the icon of the window using an image from the assets folder.
icon = new ImageIcon("./assets/images/logo.png");
this.setIconImage(icon.getImage());
this.pack(); // Adjust the frame size to fit the components.
this.setVisible(true); // Make the frame visible.
this.setLocationRelativeTo(null); // Center the frame on the screen.
}
}