-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathWindow.java
55 lines (43 loc) · 1.22 KB
/
Window.java
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
44
45
46
47
48
49
50
51
52
53
54
55
import javax.swing.JFrame;
import javax.swing.*;
import javax.sound.sampled.AudioInputStream;
import javax.sound.sampled.AudioSystem;
import javax.sound.sampled.Clip;
import java.io.*;
/**
* The main class, the constructer creates the frame bard etc, and then the main function starts everything off
* @author Maaike, Jonas, Andreas, Thijs
*/
public class Window {
public static final int WIDTH = 250, HEIGHT = 780;
private JFrame frame2;
private Board board;
public Window(){
/**
* make a frame and put the gameboard in it
*/
frame2 = new JFrame("Tetris Game");
frame2.setSize(WIDTH, HEIGHT);
frame2.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame2.setResizable(false);
frame2.setLocationRelativeTo(null);
board = new Board();
frame2.add(board);
frame2.addKeyListener(board);
frame2.setVisible(true);
/**
* A try catch to play some background music in a loop
*/
try{
AudioInputStream audioInputStream = AudioSystem.getAudioInputStream(this.getClass().getResource("tetris.wav"));
Clip clip = AudioSystem.getClip();
clip.open(audioInputStream);
clip.start();
}
catch(Exception ex){
}
}
public static void main(String[] args) {
Window window = new Window();
}
}