-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDoomMaze.java
More file actions
243 lines (224 loc) · 6.76 KB
/
DoomMaze.java
File metadata and controls
243 lines (224 loc) · 6.76 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
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
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
package DoomMaze;
import javax.swing.*;
import java.awt.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
public class DoomMaze {
private JButton startButton, first, second, third;
private JPanel titlePanel, gamePanel, choicePanel;
private JPanel startButtonPanel;
private JLabel titleLabel;
private JFrame frame;
private JTextArea TextField;
private Container contain;
private Font slime = new Font("Algerian", Font.BOLD, 80);
private Font miniSlime = new Font("Algerian", Font.BOLD, 30);
private TitleScreenHandler TSH = new TitleScreenHandler();
private ChoiceOption choices = new ChoiceOption();
private String pos, monster, yourChoice;
public DoomMaze() {
frame = new JFrame("Doom Maze");
frame.setSize(900,600);
frame.setLayout(null);
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
contain = frame.getContentPane();
titlePanel = new JPanel();
titlePanel.setBounds(0,0, 900, 400);
titlePanel.setBackground(Color.black);
titleLabel = new JLabel("Doom Maze");
titleLabel.setForeground(Color.red);
titleLabel.setBounds(0, 0, 800, 400);
titleLabel.setFont(slime);
titlePanel.add(titleLabel);
contain.add(titlePanel);
startButtonPanel = new JPanel();
startButtonPanel.setBounds(0,400,900,300);
startButtonPanel.setBackground(Color.black);
startButton = new JButton("Start Adventure!");
startButton.setBackground(Color.black);
startButton.setForeground(Color.red);
startButton.setFont(slime);
startButton.setFocusPainted(false);
startButton.addActionListener(TSH);
startButtonPanel.add(startButton);
contain.add(startButtonPanel);
frame.setVisible(true);
}
public static void main(String[] args) {
new DoomMaze();
}
public void gameScreen() {
startButtonPanel.setVisible(false);
titlePanel.setVisible(false);
gamePanel = new JPanel();
gamePanel.setBounds(0, 0, 900, 200);
gamePanel.setBackground(Color.black);
TextField = new JTextArea("Where would you like to go first?");
TextField.setBounds(0,0,900,200);
TextField.setBackground(Color.black);
TextField.setForeground(Color.red);
TextField.setFont(miniSlime);
TextField.setLineWrap(true);
gamePanel.add(TextField);
contain.add(gamePanel);
choicePanel = new JPanel();
choicePanel.setBounds(0,200,900,400);
choicePanel.setBackground(Color.black);
choicePanel.setLayout(new GridLayout(1,3));
first = new JButton("first");
first.setBackground(Color.black);
first.setForeground(Color.red);
first.setFont(miniSlime);
first.setFocusPainted(false);
first.addActionListener(choices);
first.setActionCommand("1");
choicePanel.add(first);
second = new JButton("second");
second.setBackground(Color.black);
second.setForeground(Color.red);
second.setFont(miniSlime);
second.setFocusPainted(false);
second.addActionListener(choices);
second.setActionCommand("2");
choicePanel.add(second);
third = new JButton("third");
third.setBackground(Color.black);
third.setForeground(Color.red);
third.setFont(miniSlime);
third.setFocusPainted(false);
third.addActionListener(choices);
third.setActionCommand("3");
choicePanel.add(third);
contain.add(choicePanel);
start();
}
public void start() {
pos = "start";
TextField.setText("You have entered the dungeon, three paths, where do you go?");
first.setText("Left");
second.setText("Middle");
third.setText("Right");
}
public void spider() {
pos = "spider";
monster = pos;
TextField.setText("Giant spiders are lurking in the darkness. However, there is a chest.");
first.setText("Go back");
second.setText("Fight");
third.setText("Hide");
}
public void cyclops() {
pos = "cyclops";
monster = pos;
TextField.setText("Cyclops are roaming. They don't notice you.");
first.setText("Run by");
second.setText("Attack");
third.setText("Go back");
}
public void centaur() {
pos = "centaur";
monster = "pos";
TextField.setText("Doors close, and a drunken centaur is angerily killing its underlings");
first.setText("fight");
second.setText("");
third.setText("");
}
public void hideFromSpider() {
pos = "hideFromSpider";
monster = "spider";
TextField.setText("The spiders are unable to find you. They get into a blood thirsty rage and fight each other");
first.setText("Go back");
second.setText("Try to run");
third.setText("");
}
public void wyvern() {
pos = "wyverns";
monster = "wyverns";
TextField.setText("Doors slam shut. An ancient wyvern is sleeping in his cave");
first.setText("Throw rock");
second.setText("Greet");
third.setText("Sneak attack");
}
public void awaken() {
pos = "woke";
TextField.setText("The wyvern has risen and flies at you");
first.setText("Duck");
second.setText("Panic");
third.setText("");
}
public void death() {
pos = "death";
TextField.setText(monster + " got the best of you!!!");
first.setText("Restart");
second.setText("");
third.setText("");
}
public void victory() {
TextField.setText("The wyvern has missed and as crushed by falling rocks. You now have reached the end");
first.setText("");
second.setText("");
third.setText("");
}
public class TitleScreenHandler implements ActionListener{
public void actionPerformed(ActionEvent e) {
gameScreen();
}
}
public class ChoiceOption implements ActionListener{
public void actionPerformed(ActionEvent e) {
yourChoice = e.getActionCommand();
if(pos.equals("start")) {
start();
if(yourChoice.equals("1")) {
spider();
}else if(yourChoice.equals("2")) {
cyclops();
}else if(yourChoice.equals("3")) {
centaur();
}
}else if(pos.equals("spider")) {
if(yourChoice.equals("1")) {
start();
}else if(yourChoice.equals("2")) {
death();
}else if(yourChoice.equals("3")) {
hideFromSpider();
}
}else if(pos.equals("death")) {
if(yourChoice.equals("1")) {
start();
}
}else if(pos.equals("hideFromSpider")) {
if(yourChoice.equals("1")) {
start();
}else if(yourChoice.equals("2")) {
death();
}
}else if(pos.equals("cyclops")) {
if(yourChoice.equals("1")) {
wyvern();
}else if(yourChoice.equals("2")) {
death();
}else if(yourChoice.equals("3")) {
start();
}
}else if(pos.equals("centaur")) {
if(yourChoice.equals("1")) {
death();
}
}else if(pos.equals("wyverns")) {
if(yourChoice.equals("3")) {
death();
}else {
awaken();
}
}else if(pos.equals("woke")) {
if(yourChoice.equals("1")) {
victory();
}else if(yourChoice.equals("2")) {
death();
}
}
}
}
}