2929import com .redomar .game .net .packets .Packet00Login ;
3030import com .redomar .game .script .Printing ;
3131
32-
3332public class Game extends Canvas implements Runnable {
34-
33+
3534 // Setting the size and name of the frame/canvas
3635 private static final long serialVersionUID = 1L ;
3736 private static final String game_Version = "v1.6.1 Alpha" ;
@@ -59,7 +58,8 @@ public class Game extends Canvas implements Runnable {
5958 .getData ();
6059 private int [] colours = new int [6 * 6 * 6 ];
6160
62- private BufferedImage image2 = new BufferedImage (WIDTH , HEIGHT - 30 , BufferedImage .TYPE_INT_RGB );
61+ private BufferedImage image2 = new BufferedImage (WIDTH , HEIGHT - 30 ,
62+ BufferedImage .TYPE_INT_RGB );
6363 private Screen screen ;
6464 private InputHandler input ;
6565 private WindowHandler window ;
@@ -76,8 +76,7 @@ public class Game extends Canvas implements Runnable {
7676 private GameClient socketClient ;
7777 private GameServer socketServer ;
7878 private Printing print = new Printing ();
79-
80-
79+
8180 public Game () {
8281 setMinimumSize (new Dimension (WIDTH * SCALE , HEIGHT * SCALE ));
8382 setMaximumSize (new Dimension (WIDTH * SCALE , HEIGHT * SCALE ));
@@ -113,7 +112,8 @@ public void init() {
113112 setWindow (new WindowHandler (this ));
114113 setMap ("/levels/custom_level.png" );
115114 setMap (1 );
116- Packet00Login loginPacket = new Packet00Login (player .getUsername (), player .getX (), player .getY ());
115+ Packet00Login loginPacket = new Packet00Login (player .getUsername (),
116+ player .getX (), player .getY ());
117117
118118 if (socketServer != null ) {
119119 socketServer .addConnection ((PlayerMP ) getPlayer (), loginPacket );
@@ -129,24 +129,24 @@ public void setMap(String Map_str) {
129129 getJdata_UserName (), null , -1 ));
130130 level .addEntity (player );
131131 }
132-
133- public static void npcSpawn (){
134- if (isNpc () == true ){
132+
133+ public static void npcSpawn () {
134+ if (isNpc () == true ) {
135135 game .setDummy (new Dummy (Game .getLevel (), "h" , 215 , 215 , 500 , 543 ));
136136 game .level .addEntity (Game .getDummy ());
137137 }
138138 }
139-
140- public static void npcKill (){
141- if (isNpc () == false ){
139+
140+ public static void npcKill () {
141+ if (isNpc () == false ) {
142142 game .level .removeEntity (Game .getDummy ());
143143 }
144144 }
145145
146146 public synchronized void start () {
147147 running = true ;
148148 new Thread (this , "GAME" ).start ();
149-
149+
150150 if (getJdata_Host () == 0 ) {
151151 socketServer = new GameServer (this );
152152 socketServer .start ();
@@ -240,67 +240,80 @@ public void render() {
240240 }
241241 }
242242 }
243-
244- if (noAudioDevice == false ){
245- if (input .isPlayMusic () == true && notActive == true ){
246- int musicOption = JOptionPane .showConfirmDialog (this , "You are about to turn on music and can be VERY loud" , "Music Options" , 2 , 2 );
247- if (musicOption == 0 ){
243+
244+ if (noAudioDevice == false ) {
245+ if (input .isPlayMusic () == true && notActive == true ) {
246+ int musicOption = JOptionPane .showConfirmDialog (this ,
247+ "You are about to turn on music and can be VERY loud" ,
248+ "Music Options" , 2 , 2 );
249+ if (musicOption == 0 ) {
248250 musicThread .start ();
249251 notActive = false ;
250252 } else {
251- //System.out.println("[GAME] Canceled music option");
253+ // System.out.println("[GAME] Canceled music option");
252254 print .print (" Canceled music option" , 1 );
253255 input .setPlayMusic (false );
254256 }
255- }
257+ }
256258 }
257-
258- if (isChangeLevel () == true && getTickCount () % 60 == 0 ){
259+
260+ if (isChangeLevel () == true && getTickCount () % 60 == 0 ) {
259261 Game .setChangeLevel (true );
260262 setChangeLevel (false );
261263 }
262-
263- if (changeLevel == true ){
264- if (getMap () == 1 ){
265- setMap ("/levels/water_level.png" );
264+
265+ if (changeLevel == true ) {
266+ if (getMap () == 1 ) {
267+ setMap ("/levels/water_level.png" );
266268 setMap (2 );
267- }else if (getMap () == 2 ){
269+ } else if (getMap () == 2 ) {
268270 setMap ("/levels/custom_level.png" );
269271 setMap (1 );
270272 }
271273 changeLevel = false ;
272274 }
273-
275+
274276 Graphics g = bs .getDrawGraphics ();
275277 g .drawRect (0 , 0 , getWidth (), getHeight ());
276- g .drawImage (image , 0 , 0 , getWidth (), getHeight ()- 30 , null );
277- // Font.render("Hi", screen, 0, 0, Colours.get(-1, -1, -1, 555), 1);
278- g .drawImage (image2 , 0 , getHeight ()- 30 , getWidth (), getHeight (), null );
278+ g .drawImage (image , 0 , 0 , getWidth (), getHeight () - 30 , null );
279+ // Font.render("Hi", screen, 0, 0, Colours.get(-1, -1, -1, 555), 1);
280+ g .drawImage (image2 , 0 , getHeight () - 30 , getWidth (), getHeight (), null );
279281 g .setColor (Color .WHITE );
280282 g .setFont (font .getSegoe ());
281- g .drawString ("Welcome " +WordUtils .capitalizeFully (player .getSantizedUsername ()), 3 , getHeight ()-17 );
283+ g .drawString (
284+ "Welcome "
285+ + WordUtils .capitalizeFully (player
286+ .getSantizedUsername ()), 3 , getHeight () - 17 );
282287 g .setColor (Color .YELLOW );
283- g .drawString (time .getTime (), (getWidth () - 58 ), (getHeight ()- 3 ));
288+ g .drawString (time .getTime (), (getWidth () - 58 ), (getHeight () - 3 ));
284289 g .setColor (Color .WHITE );
285- if (noAudioDevice == true ){
290+ if (noAudioDevice == true ) {
286291 g .setColor (Color .RED );
287- g .drawString ("MUSIC is OFF | no audio device for playback" , 3 , getHeight ()-3 );
292+ g .drawString ("MUSIC is OFF | no audio device for playback" , 3 ,
293+ getHeight () - 3 );
288294 trigger ++;
289- if (trigger == 25 ){
290- JOptionPane .showMessageDialog (this , "No Audio device found" , "Audio Issue" , 0 );
295+ if (trigger == 25 ) {
296+ JOptionPane .showMessageDialog (this , "No Audio device found" ,
297+ "Audio Issue" , 0 );
291298 }
292- } else if (notActive == true ){
299+ } else if (notActive == true ) {
293300 g .setColor (Color .RED );
294- g .drawString ("MUSIC is OFF | press 'M' to start" , 3 , getHeight ()-3 );
295- } else {
301+ g .drawString ("MUSIC is OFF | press 'M' to start" , 3 ,
302+ getHeight () - 3 );
303+ } else {
296304 g .setColor (Color .GREEN );
297- g .drawString ("MUSIC is ON | You cannot turn off the music" , 3 , getHeight ()-3 );
305+ g .drawString ("MUSIC is ON | You cannot turn off the music" , 3 ,
306+ getHeight () - 3 );
298307 g .setColor (Color .WHITE );
299- setNowPlaying (WordUtils .capitalize (music .getSongName ()[music .getSongNumber ()].substring (7 , (music .getSongName ()[music .getSongNumber ()].length () - 4 ))));
300- if (getNowPlaying ().startsWith ("T" )){
301- g .drawString (nowPlaying , getWidth () - (nowPlaying .length () * 9 ) + 12 , getHeight () - 17 );
308+ setNowPlaying (WordUtils .capitalize (music .getSongName ()[music
309+ .getSongNumber ()].substring (7 ,
310+ (music .getSongName ()[music .getSongNumber ()].length () - 4 ))));
311+ if (getNowPlaying ().startsWith ("T" )) {
312+ g .drawString (nowPlaying , getWidth () - (nowPlaying .length () * 9 )
313+ + 12 , getHeight () - 17 );
302314 } else {
303- g .drawString (nowPlaying , getWidth () - (nowPlaying .length () * 9 ) + 8 , getHeight () - 17 );
315+ g .drawString (nowPlaying , getWidth () - (nowPlaying .length () * 9 )
316+ + 8 , getHeight () - 17 );
304317 }
305318 }
306319 g .dispose ();
0 commit comments