11package com .redomar .game ;
22
3+ import com .redomar .game .audio .AudioHandler ;
34import com .redomar .game .entities .Dummy ;
45import com .redomar .game .entities .Player ;
56import com .redomar .game .entities .Vendor ;
67import com .redomar .game .gfx .Screen ;
78import com .redomar .game .gfx .SpriteSheet ;
89import com .redomar .game .level .LevelHandler ;
910import com .redomar .game .lib .Font ;
10- import com .redomar .game .lib .Music ;
1111import com .redomar .game .lib .Time ;
1212import com .redomar .game .script .PrintTypes ;
1313import com .redomar .game .script .Printing ;
@@ -24,7 +24,7 @@ public class Game extends Canvas implements Runnable {
2424
2525 // Setting the size and name of the frame/canvas
2626 private static final long serialVersionUID = 1L ;
27- private static final String game_Version = "v1.8.2 Alpha" ;
27+ private static final String game_Version = "v1.8.3 Alpha" ;
2828 private static final int WIDTH = 160 ;
2929 private static final int HEIGHT = (WIDTH / 3 * 2 );
3030 private static final int SCALE = 3 ;
@@ -47,7 +47,7 @@ public class Game extends Canvas implements Runnable {
4747 private static boolean closingMode ;
4848
4949 private static JFrame frame ;
50-
50+ private static AudioHandler backgroundMusic ;
5151 private static boolean running = false ;
5252 private static InputHandler input ;
5353 private static MouseHandler mouse ;
@@ -66,18 +66,15 @@ public class Game extends Canvas implements Runnable {
6666 private Player player ;
6767 private Dummy dummy ;
6868 private Vendor vendor ;
69- private Music music = new Music ();
7069 private Font font = new Font ();
71- private Thread musicThread = new Thread (music , "MUSIC" );
7270 private String nowPlaying ;
7371 private boolean notActive = true ;
74- private boolean noAudioDevice = false ;
7572 private int trigger = 0 ;
7673 private Printing print = new Printing ();
7774
7875 /**
7976 * @author Redomar
80- * @version Alpha 1.8.2
77+ * @version Alpha 1.8.3
8178 */
8279 public Game () {
8380 context = InputContext .getInstance ();
@@ -264,14 +261,22 @@ public static void setAlternateCols(boolean[] alternateCols) {
264261 Game .alternateCols = alternateCols ;
265262 }
266263
267- public static void setAternateColsR (boolean alternateCols ) {
264+ public static void setAlternateColsR (boolean alternateCols ) {
268265 Game .alternateCols [1 ] = alternateCols ;
269266 }
270267
271- public static void setAternateColsS (boolean alternateCols ) {
268+ public static void setAlternateColsS (boolean alternateCols ) {
272269 Game .alternateCols [0 ] = alternateCols ;
273270 }
274271
272+ public static void setBackgroundMusic (AudioHandler backgroundMusic ) {
273+ Game .backgroundMusic = backgroundMusic ;
274+ }
275+
276+ public static AudioHandler getBackgroundMusic (){
277+ return Game .backgroundMusic ;
278+ }
279+
275280 public static InputHandler getInput () {
276281 return input ;
277282 }
@@ -425,22 +430,6 @@ public void render() {
425430 }
426431 }
427432
428- if (!noAudioDevice ) {
429- if (input .isPlayMusic () && notActive == true ) {
430- int musicOption = JOptionPane .showConfirmDialog (this ,
431- "You are about to turn on music and can be VERY loud" ,
432- "Music Options" , 2 , 2 );
433- if (musicOption == 0 ) {
434- musicThread .start ();
435- notActive = false ;
436- } else {
437- // System.out.println("[GAME] Canceled music option");
438- print .print (" Canceled music option" , PrintTypes .GAME );
439- input .setPlayMusic (false );
440- }
441- }
442- }
443-
444433 if (isChangeLevel () == true && getTickCount () % 60 == 0 ) {
445434 Game .setChangeLevel (true );
446435 setChangeLevel (false );
@@ -478,7 +467,7 @@ public void render() {
478467 g .drawString (
479468 "Welcome "
480469 + WordUtils .capitalizeFully (player
481- .getSantizedUsername ()), 3 , getHeight () - 17 );
470+ .getSanitisedUsername ()), 3 , getHeight () - 17 );
482471 g .setColor (Color .ORANGE );
483472
484473 if (context .getLocale ().getCountry ().equals ("BE" )
@@ -491,35 +480,9 @@ public void render() {
491480 }
492481 g .setColor (Color .YELLOW );
493482 g .drawString (time .getTime (), (getWidth () - 58 ), (getHeight () - 3 ));
494- g .setColor (Color .WHITE );
495- if (noAudioDevice == true ) {
496- g .setColor (Color .RED );
497- g .drawString ("MUSIC is OFF | no audio device for playback" , 3 ,
498- getHeight () - 3 );
499- trigger ++;
500- if (trigger == 25 ) {
501- JOptionPane .showMessageDialog (this , "No Audio device found" ,
502- "Audio Issue" , 0 );
503- }
504- } else if (notActive == true ) {
505- g .setColor (Color .RED );
506- g .drawString ("MUSIC is OFF | press 'M' to start" , 3 ,
507- getHeight () - 3 );
508- } else {
509- g .setColor (Color .GREEN );
510- g .drawString ("MUSIC is ON | You cannot turn off the music" , 3 ,
511- getHeight () - 3 );
512- g .setColor (Color .WHITE );
513- setNowPlaying (WordUtils .capitalize (music .getSongName ()[music
514- .getSongNumber ()].substring (7 ,
515- (music .getSongName ()[music .getSongNumber ()].length () - 4 ))));
516- if (getNowPlaying ().startsWith ("T" )) {
517- g .drawString (nowPlaying , getWidth () - (nowPlaying .length () * 9 )
518- + 12 , getHeight () - 17 );
519- } else {
520- g .drawString (nowPlaying , getWidth () - (nowPlaying .length () * 9 )
521- + 8 , getHeight () - 17 );
522- }
483+ g .setColor (Color .GREEN );
484+ if (backgroundMusic .getActive ()) {
485+ g .drawString ("MUSIC is ON " , 3 , getHeight () - 3 );
523486 }
524487 g .dispose ();
525488 bs .show ();
0 commit comments