22
33import java .awt .BorderLayout ;
44import java .awt .Canvas ;
5+ import java .awt .Color ;
56import java .awt .Dimension ;
67import java .awt .Graphics ;
78import java .awt .image .BufferStrategy ;
1920import com .redomar .game .net .GameClient ;
2021import com .redomar .game .net .GameServer ;
2122import com .redomar .game .net .packets .Packet00Login ;
23+ import com .thehowtotutorial .splashscreen .JSplash ;
2224
2325public class Game extends Canvas implements Runnable {
2426
@@ -30,6 +32,8 @@ public class Game extends Canvas implements Runnable {
3032 public static final int SCALE = 3 ;
3133 public static final String NAME = "Game" ;
3234 public static Game game ;
35+ private static int Jdata_Host ;
36+ private static String Jdata_UserName ;
3337
3438 private JFrame frame ;
3539
@@ -50,7 +54,7 @@ public class Game extends Canvas implements Runnable {
5054
5155 private GameClient socketClient ;
5256 private GameServer socketServer ;
53-
57+
5458 public Game () {
5559 setMinimumSize (new Dimension (WIDTH * SCALE , HEIGHT * SCALE ));
5660 setMaximumSize (new Dimension (WIDTH * SCALE , HEIGHT * SCALE ));
@@ -87,7 +91,7 @@ public void init() {
8791 setLevel (new LevelHandler ("/levels/water_level.png" ));
8892
8993 setPlayer (new PlayerMP (getLevel (), 100 , 100 , input ,
90- JOptionPane . showInputDialog ( this , "Enter a name" ) , null , -1 ));
94+ Jdata_UserName , null , -1 ));
9195
9296 level .addEntity (player );
9397 Packet00Login loginPacket = new Packet00Login (player .getUsername (), player .x , player .y );
@@ -104,7 +108,7 @@ public synchronized void start() {
104108 running = true ;
105109 new Thread (this ).start ();
106110
107- if (JOptionPane . showConfirmDialog ( this , "Do you want to be the HOST?" ) == 0 ) {
111+ if (Jdata_Host == 0 ) {
108112 socketServer = new GameServer (this );
109113 socketServer .start ();
110114 }
@@ -207,7 +211,41 @@ public void render() {
207211 }
208212
209213 public static void main (String [] args ) {
210- new Game ().start ();
214+ try {
215+ JSplash splash = new JSplash (Game .class .getResource ("/splash/splash.png" ), true , true , false , "v1.3 Alpha" , null , Color .RED , Color .ORANGE );
216+ splash .splashOn ();
217+ splash .setProgress (10 , "Initializing Game" );
218+ Thread .sleep (1500 );
219+ splash .setProgress (25 , "Loading Classes" );
220+ Thread .sleep (1000 );
221+ splash .setProgress (35 , "Applying Configurations" );
222+ Thread .sleep (1000 );
223+ splash .setProgress (40 , "Loading Sprites" );
224+ Thread .sleep (1500 );
225+ splash .setProgress (50 , "Loading Textures" );
226+ Thread .sleep (1000 );
227+ splash .setProgress (60 , "Loading Map" );
228+ Thread .sleep (3000 );
229+ splash .setProgress (80 , "Configuring Map" );
230+ Thread .sleep (1000 );
231+ splash .setProgress (90 , "Pulling InputPanes" );
232+ Thread .sleep (1500 );
233+ splash .setProgress (92 , "Aquring data: Multiplayer" );
234+ Thread .sleep (200 );
235+ Jdata_Host = JOptionPane .showConfirmDialog (game , "Do you want to be the HOST?" );
236+ Thread .sleep (200 );
237+ if (Jdata_Host == 0 ){
238+ splash .setProgress (95 , "Aquring data: Username" );
239+ Thread .sleep (200 );
240+ Jdata_UserName = JOptionPane .showInputDialog (game , "Enter a name" );
241+ Thread .sleep (200 );
242+ }
243+ splash .splashOff ();
244+ new Game ().start ();
245+ } catch (Exception e ) {
246+ e .printStackTrace ();
247+ }
248+
211249 }
212250
213251 public JFrame getFrame () {
0 commit comments