Skip to content

Commit d36e906

Browse files
committed
Added a Mini HUD
1 parent 19c614c commit d36e906

File tree

2 files changed

+24
-5
lines changed

2 files changed

+24
-5
lines changed

src/com/redomar/game/Game.java

Lines changed: 22 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -48,13 +48,15 @@ public class Game extends Canvas implements Runnable {
4848
.getData();
4949
private int[] colours = new int[6 * 6 * 6];
5050

51+
private BufferedImage image2 = new BufferedImage(WIDTH, HEIGHT - 30, BufferedImage.TYPE_INT_RGB);
5152
private Screen screen;
5253
private InputHandler input;
5354
private WindowHandler window;
5455
private LevelHandler level;
5556
private Player player;
5657
private Music music = new Music();
5758
public Thread musicThread = new Thread(music);
59+
public String nowPlaying = "Playing Music";
5860

5961
public boolean notActive = true;
6062

@@ -212,18 +214,27 @@ public void render() {
212214
int musicOption = JOptionPane.showConfirmDialog(this, "You are about to turn on music and can be VERY loud", "Music Options", 2, 2);
213215
if (musicOption == 0){
214216
musicThread.start();
215-
notActive = false;
217+
notActive = false;
216218
} else {
217219
System.out.println("Canceled");
218220
input.PlayMusic = false;
219221
}
220222
}
221223

222-
223224
Graphics g = bs.getDrawGraphics();
224225

225226
g.drawRect(0, 0, getWidth(), getHeight());
226-
g.drawImage(image, 0, 0, getWidth(), getHeight(), null);
227+
g.drawImage(image, 0, 0, getWidth(), getHeight()-30, null);
228+
// Font.render("Hi", screen, 0, 0, Colours.get(-1, -1, -1, 555), 1);
229+
g.drawImage(image2, 0, getHeight()-30, getWidth(), getHeight(), null);
230+
g.setColor(Color.WHITE);
231+
g.drawString("Welcome "+player.getUsername(), 0, getHeight()-19);
232+
if (notActive == true){
233+
g.drawString("MUSIC is OFF | press 'M' to start", 0, getHeight()-8);
234+
} else{
235+
g.drawString("MUSIC is ON | You cannot turn off the music", 0, getHeight()-8);
236+
g.drawString(nowPlaying, (getWidth() - nowPlaying.length()) - (120 + nowPlaying.length()), getHeight() - 20 );
237+
}
227238
g.dispose();
228239
bs.show();
229240
}
@@ -310,4 +321,12 @@ public void setWindow(WindowHandler window) {
310321
this.window = window;
311322
}
312323

324+
public String getNowPlaying() {
325+
return nowPlaying;
326+
}
327+
328+
public void setNowPlaying(String nowPlaying) {
329+
this.nowPlaying = nowPlaying;
330+
}
331+
313332
}

src/com/redomar/game/lib/Music.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,9 +41,9 @@ public void run() {
4141
try {
4242
Thread.sleep(300);
4343
initSongNumber();
44-
System.out.println("[MUSIC] loading song: " + songName[songNumber].substring(7, (songName[songNumber].length() - 4)));
44+
//System.out.println("[MUSIC] loading song: " + songName[songNumber].substring(7, (songName[songNumber].length() - 4)));
4545
Music music = new Music(Game.class.getResourceAsStream(songName[songNumber]));
46-
Thread.sleep(100);
46+
//Thread.sleep(100);
4747
System.out.println("[MUSIC] playing song: " + songName[songNumber].substring(7, (songName[songNumber].length() - 4)));
4848
music.Play();
4949
this.run();

0 commit comments

Comments
 (0)