Skip to content

Commit 25cbc41

Browse files
committed
Added Help Menu
Corrected spelling
1 parent ef1441e commit 25cbc41

File tree

3 files changed

+76
-1
lines changed

3 files changed

+76
-1
lines changed

src/com/redomar/game/HelpMenu.java

Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
package com.redomar.game;
2+
3+
import java.awt.*;
4+
import java.awt.image.BufferedImage;
5+
import java.io.IOException;
6+
import javax.imageio.ImageIO;
7+
import javax.swing.*;
8+
9+
/**
10+
* Created with IntelliJ IDEA.
11+
* User: Gagandeep Bali
12+
* Date: 7/1/14
13+
* Time: 9:44 AM
14+
* To change this template use File | Settings | File Templates.
15+
*/
16+
public class HelpMenu {
17+
18+
private MyPanel contentPane;
19+
20+
private void displayGUI() {
21+
JFrame frame = new JFrame("Image Example");
22+
frame.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
23+
24+
contentPane = new MyPanel();
25+
26+
frame.setContentPane(contentPane);
27+
frame.setLocationRelativeTo(null);
28+
frame.pack();
29+
frame.setLocationByPlatform(true);
30+
frame.setVisible(true);
31+
}
32+
33+
private class MyPanel extends JPanel {
34+
35+
private BufferedImage image;
36+
37+
public MyPanel() {
38+
try {
39+
image = ImageIO.read(MyPanel.class.getResource("/controls/controls.png"));
40+
} catch (IOException ioe) {
41+
ioe.printStackTrace();
42+
}
43+
}
44+
45+
@Override
46+
public Dimension getPreferredSize() {
47+
return image == null ? new Dimension(400, 300): new Dimension(image.getWidth(), image.getHeight());
48+
}
49+
50+
@Override
51+
protected void paintComponent(Graphics g) {
52+
super.paintComponent(g);
53+
g.drawImage(image, 0, 0, this);
54+
}
55+
}
56+
57+
public static void run() {
58+
Runnable runnable = new Runnable() {
59+
@Override
60+
public void run() {
61+
new HelpMenu().displayGUI();
62+
}
63+
};
64+
EventQueue.invokeLater(runnable);
65+
}
66+
}

src/com/redomar/game/menu/Menu.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ public static void play() {
7575
splash.setProgress(90, "Collecting Player Data");
7676
Object[] options = {"African", "Caucasian"};
7777
int n = JOptionPane.showOptionDialog(frame,
78-
"Choose a race for the charater to be", "Choose a race",
78+
"Choose a race for the character to be", "Choose a race",
7979
JOptionPane.YES_NO_OPTION, JOptionPane.QUESTION_MESSAGE,
8080
null, options, options[0]);
8181
if (n == 0) {

src/com/redomar/game/menu/MenuInput.java

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,15 @@
11
package com.redomar.game.menu;
22

33
import com.redomar.game.Game;
4+
import com.redomar.game.HelpMenu;
45

56
import java.awt.event.KeyEvent;
67
import java.awt.event.KeyListener;
78

89
public class MenuInput implements KeyListener {
910

1011
private boolean ticket = false;
12+
private boolean help = false;
1113

1214
public void keyPressed(KeyEvent e) {
1315
toggleKey(e.getKeyCode());
@@ -55,6 +57,13 @@ private void toggleKey(int keyCode) {
5557
if (keyCode == KeyEvent.VK_ESCAPE) {
5658
System.exit(1);
5759
}
60+
61+
if (keyCode == KeyEvent.VK_H){
62+
HelpMenu h = new HelpMenu();
63+
if (!help)
64+
h.run();
65+
help = true;
66+
}
5867
}
5968

6069
}

0 commit comments

Comments
 (0)