-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathScreen.java
110 lines (85 loc) · 2.61 KB
/
Screen.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
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
import javax.swing.JPanel;
import java.awt.Dimension;
import java.awt.Graphics;
import java.awt.Color;
import java.awt.Font;
import java.awt.image.BufferedImage;
import java.io.File;
import java.io.IOException;
import javax.imageio.ImageIO;
import java.awt.event.KeyListener;
import java.awt.event.KeyEvent;
import javax.swing.JButton;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.MouseListener;
import java.awt.event.MouseEvent;
import javax.swing.JFrame;
import javax.swing.JButton;
import assets.GameLogic;
import assets.Interview;
import assets.Intro;
import assets.SearchRoom;
import javax.swing.JTextField;
public class Screen extends JPanel implements KeyListener, MouseListener {
private SearchRoom msearchRoom;
private GameLogic mGameLogic;
private Interview mInterview;
private Intro mIntro;
public Screen(JFrame fr) {
mGameLogic = new GameLogic();
msearchRoom = new SearchRoom(mGameLogic, this);
mInterview = new Interview(mGameLogic);
mIntro = new Intro(mGameLogic);
fr.add(this);
addKeyListener(this);
addMouseListener(this);
setLayout(null);
setFocusable(true);
}
@Override
public Dimension getPreferredSize() {
return new Dimension(1800, 800);
}
@Override
public void paintComponent(Graphics g) {
super.paintComponent(g);
if (mGameLogic.currentRoom == mGameLogic.ROOM_INTRO) {
mIntro.renderScene(g);
}
if (mGameLogic.currentRoom == mGameLogic.ROOM_SEARCH) {
msearchRoom.renderScene(g);
}
if (mGameLogic.currentRoom == mGameLogic.ROOM_INTERVIEW) {
mInterview.renderScene(g);
}
repaint();
}
public void keyPressed(KeyEvent e) {
if (mGameLogic.currentRoom.equals(mGameLogic.ROOM_INTRO)) {
mIntro.keyEvent(e);
} else if (mGameLogic.currentRoom.equals(mGameLogic.ROOM_INTERVIEW)) {
mInterview.keyEvent(e);
} else if (mGameLogic.currentRoom == mGameLogic.ROOM_SEARCH) {
msearchRoom.keyEvent(e);
}
repaint();
}
public void keyReleased(KeyEvent e) {
}
public void keyTyped(KeyEvent e) {
}
public void mouseClicked(MouseEvent e) {
}
public void mousePressed(MouseEvent e) {
if (mGameLogic.currentRoom.equals(mGameLogic.ROOM_SEARCH)) {
msearchRoom.mouseEvent(e);
}
}
public void mouseReleased(MouseEvent e) {
}
public void mouseEntered(MouseEvent e) {
}
public void mouseExited(MouseEvent e) {
}
}