-
Notifications
You must be signed in to change notification settings - Fork 0
/
Menu.java
110 lines (88 loc) · 3.82 KB
/
Menu.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.*;
import java.awt.*;
import javax.swing.JMenu;
import java.awt.event.*;
import java.awt.event.KeyEvent;
public class Menu extends JPanel
{
private JMenuBar menuBar;
private JMenu game, help, options;
private JMenuItem instructions, about, exit, menuItem, pause,next,last,hs;
private JCheckBoxMenuItem mute;
public Menu()
{
setLayout(new GridLayout(1, 4));
menuBar = new JMenuBar();
add(menuBar);
game = new JMenu("Game");
game.setMnemonic(KeyEvent.VK_M);
menuBar.add(game);
menuItem = new JMenuItem("New Game");
menuItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_N, ActionEvent.CTRL_MASK));
menuItem.addActionListener(new Resetter());
game.add(menuItem);
pause = new JMenuItem("Pause");
pause.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_P,ActionEvent.CTRL_MASK));
pause.addActionListener(new Listener1());
game.add(pause);
game.addSeparator();
help = new JMenu("Help");
instructions = new JMenuItem("Instructions");
instructions.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_I,ActionEvent.CTRL_MASK));
instructions.addActionListener(new Listener2());
help.add(instructions);
about = new JMenuItem("About");
about.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_A,ActionEvent.CTRL_MASK));
about.addActionListener(new Listener4());
help.add(about);
menuBar.add(help);
options=new JMenu("Options");
game.add(options);
exit = new JMenuItem("Exit");
exit.addActionListener(new Listener3());
exit.setAccelerator(KeyStroke.getKeyStroke(
KeyEvent.VK_F4, ActionEvent.ALT_MASK));
game.add(exit);
}
private class Resetter implements ActionListener
{
public void actionPerformed(ActionEvent e)
{
if(Panel.t.isRunning())
Panel.pauseGame();
Panel.screen.run();
//Panel.screen.gameOver=false;
Panel.t.start();
}
}
private class Listener1 implements ActionListener
{
public void actionPerformed(ActionEvent e)
{
Panel.pauseGame();
}
}
private class Listener2 implements ActionListener
{
public void actionPerformed(ActionEvent e)
{
Panel.pauseGame();
//JOptionPane.showMessageDialog(null," Instructions:\nYour girlfriend has been stolen by aliens\n and now you go to seek revenge on them.\n Of course you will never actually defeat them all,\n but you can at least do some dammage.\n Bosses come every 5 waves.\n Watch out for those red dots too,\n they may have little health but they can pack a punch.\nArrows: Move\nSpaceBar: Shoot\nPause: Control P\nMute/Unmute: Control M\n PowerUps:\nRed: Health/Shield boost\nBlue: Faster Shot\nGreen: Damange Upgrade\nMagenta: Extra Shots");
}
}
private class Listener3 implements ActionListener
{
public void actionPerformed(ActionEvent e)
{
System.exit(0);
}
}
private class Listener4 implements ActionListener
{
public void actionPerformed(ActionEvent e)
{
Panel.pauseGame();
//JOptionPane.showMessageDialog(null," Creators:\nJireh Miaw and Mitchell Smith \n Created in Lab 232A at TJHSST \n emails:\[email protected]\[email protected]");
}
}
}