File tree 2 files changed +13
-14
lines changed 2 files changed +13
-14
lines changed Original file line number Diff line number Diff line change 7
7
import javax .swing .*;
8
8
9
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.
10
+ * Credit to Gagandeep Bali @ stackoverflow
15
11
*/
16
12
public class HelpMenu {
17
13
18
14
private MyPanel contentPane ;
19
15
20
16
private void displayGUI () {
21
- JFrame frame = new JFrame ("Image Example " );
17
+ JFrame frame = new JFrame ("Help Menu " );
22
18
frame .setDefaultCloseOperation (JFrame .DISPOSE_ON_CLOSE );
23
19
24
20
contentPane = new MyPanel ();
@@ -34,7 +30,7 @@ private class MyPanel extends JPanel {
34
30
35
31
private BufferedImage image ;
36
32
37
- public MyPanel () {
33
+ private MyPanel () {
38
34
try {
39
35
image = ImageIO .read (MyPanel .class .getResource ("/controls/controls.png" ));
40
36
} catch (IOException ioe ) {
@@ -55,12 +51,7 @@ protected void paintComponent(Graphics g) {
55
51
}
56
52
57
53
public static void run () {
58
- Runnable runnable = new Runnable () {
59
- @ Override
60
- public void run () {
61
- new HelpMenu ().displayGUI ();
62
- }
63
- };
54
+ Runnable runnable = () -> new HelpMenu ().displayGUI ();
64
55
EventQueue .invokeLater (runnable );
65
56
}
66
57
}
Original file line number Diff line number Diff line change @@ -19,6 +19,7 @@ public class InputHandler implements KeyListener {
19
19
private Printing print = new Printing ();
20
20
private int map ;
21
21
private boolean ignoreInput = false ;
22
+ private boolean toggleMusic = false ;
22
23
private PopUp popup = new PopUp ();
23
24
24
25
public InputHandler (Game game ) {
@@ -70,11 +71,18 @@ private void toggleKey(int keyCode, boolean isPressed) {
70
71
}
71
72
72
73
if (keyCode == KeyEvent .VK_M ) {
73
- Game .getBackgroundMusic ().play ();
74
+ if (!toggleMusic ){
75
+ Game .getBackgroundMusic ().play ();
76
+ print .print ("Playing Music" , PrintTypes .MUSIC );
77
+ toggleMusic = true ;
78
+ }
74
79
}
75
80
76
81
if (keyCode == KeyEvent .VK_COMMA ) {
77
82
Game .getBackgroundMusic ().stop ();
83
+ if (toggleMusic )
84
+ print .print ("Stopping Music" , PrintTypes .MUSIC );
85
+ toggleMusic = false ;
78
86
}
79
87
80
88
You can’t perform that action at this time.
0 commit comments