Skip to content

Commit f537015

Browse files
committed
Enabled Menu
1 parent 7082d7f commit f537015

File tree

3 files changed

+82
-56
lines changed

3 files changed

+82
-56
lines changed

src/com/redomar/game/Game.java

Lines changed: 30 additions & 53 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@
1111

1212
import javax.swing.JFrame;
1313
import javax.swing.JOptionPane;
14-
import javax.swing.UIManager;
1514

1615
import org.apache.commons.lang3.text.WordUtils;
1716

@@ -29,14 +28,12 @@
2928
import com.redomar.game.net.GameServer;
3029
import com.redomar.game.net.packets.Packet00Login;
3130
import com.redomar.game.script.Printing;
32-
import com.thehowtotutorial.splashscreen.JSplash;
3331

34-
public class Game extends Canvas implements Runnable {
3532

36-
private static final long serialVersionUID = 1L;
37-
private static final String game_Version = "v1.5.3 Alpha";
33+
public class Game extends Canvas implements Runnable {
3834

3935
// Setting the size and name of the frame/canvas
36+
private static final long serialVersionUID = 1L;
4037
private static final int WIDTH = 160;
4138
private static final int HEIGHT = (WIDTH / 3 * 2);
4239
private static final int SCALE = 3;
@@ -128,7 +125,7 @@ public void init() {
128125
public void setMap(String Map_str) {
129126
setLevel(new LevelHandler(Map_str));
130127
setPlayer(new PlayerMP(getLevel(), 100, 100, input,
131-
Jdata_UserName, null, -1));
128+
getJdata_UserName(), null, -1));
132129
level.addEntity(player);
133130
}
134131

@@ -149,12 +146,12 @@ public synchronized void start() {
149146
running = true;
150147
new Thread(this, "GAME").start();
151148

152-
if (Jdata_Host == 0) {
149+
if (getJdata_Host() == 0) {
153150
socketServer = new GameServer(this);
154151
socketServer.start();
155152
}
156153

157-
setSocketClient(new GameClient(this, Jdata_IP));
154+
setSocketClient(new GameClient(this, getJdata_IP()));
158155
getSocketClient().start();
159156
}
160157

@@ -310,51 +307,7 @@ public void render() {
310307
}
311308

312309
public static void main(String[] args) {
313-
Menu.main(null);
314-
}
315-
316-
public static void play(){
317-
try {
318-
JSplash splash = new JSplash(Game.class.getResource("/splash/splash.png"), true, true, false, game_Version, null, Color.RED, Color.ORANGE);
319-
splash.toFront();
320-
splash.requestFocus();
321-
splash.splashOn();
322-
splash.setProgress(10, "Initializing Game");
323-
Thread.sleep(250);
324-
splash.setProgress(25, "Loading Classes");
325-
Thread.sleep(125);
326-
splash.setProgress(35, "Applying Configurations");
327-
Thread.sleep(125);
328-
splash.setProgress(40, "Loading Sprites");
329-
Thread.sleep(250);
330-
splash.setProgress(50, "Loading Textures");
331-
Thread.sleep(125);
332-
splash.setProgress(60, "Loading Map");
333-
Thread.sleep(500);
334-
splash.setProgress(80, "Configuring Map");
335-
Thread.sleep(125);
336-
splash.setProgress(90, "Pulling InputPanes");
337-
Thread.sleep(250);
338-
splash.setProgress(92, "Aquring data: Multiplayer");
339-
Thread.sleep(125);
340-
UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
341-
Jdata_Host = JOptionPane.showConfirmDialog(getGame(), "Do you want to be the HOST?");
342-
if (Jdata_Host == 1){
343-
Jdata_IP = JOptionPane.showInputDialog(getGame(), "Enter the name \nleave blank for local");
344-
}
345-
Thread.sleep(125);
346-
splash.setProgress(95, "Aquring data: Username");
347-
Thread.sleep(125);
348-
splash.setProgress(96, "Initalizing as Server:Host");
349-
Jdata_UserName = JOptionPane.showInputDialog(getGame(), "Enter a name");
350-
splash.setProgress(97, "Connecting as" + Jdata_UserName);
351-
Thread.sleep(250);
352-
splash.splashOff();
353-
new Game().start();
354-
// new Menu().start();
355-
} catch (Exception e) {
356-
e.printStackTrace();
357-
}
310+
new Menu().start();
358311
}
359312

360313
public JFrame getFrame() {
@@ -461,4 +414,28 @@ public void setDummy(Dummy dummy) {
461414
this.dummy = dummy;
462415
}
463416

417+
public static String getJdata_IP() {
418+
return Jdata_IP;
419+
}
420+
421+
public static void setJdata_IP(String jdata_IP) {
422+
Jdata_IP = jdata_IP;
423+
}
424+
425+
public static int getJdata_Host() {
426+
return Jdata_Host;
427+
}
428+
429+
public static void setJdata_Host(int jdata_Host) {
430+
Jdata_Host = jdata_Host;
431+
}
432+
433+
public static String getJdata_UserName() {
434+
return Jdata_UserName;
435+
}
436+
437+
public static void setJdata_UserName(String jdata_UserName) {
438+
Jdata_UserName = jdata_UserName;
439+
}
440+
464441
}

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ public void mouseClicked(MouseEvent e) {
4242
Menu.setRunning(false);
4343
Menu.getFrame().setVisible(false);
4444
Menu.getFrame().stopFrame();
45-
Game.play();
45+
new Game().start();
4646
}
4747
//EXIT game
4848
if(e.getY() > 160 && e.getY() < 250){

src/com/redomar/game/menu/Menu.java

Lines changed: 51 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,19 @@
66
import java.awt.event.MouseMotionListener;
77
import java.awt.image.BufferStrategy;
88

9+
import javax.swing.JOptionPane;
10+
import javax.swing.UIManager;
11+
12+
import com.redomar.game.Game;
913
import com.redomar.game.lib.Font;
1014
import com.redomar.game.lib.Mouse;
15+
import com.thehowtotutorial.splashscreen.JSplash;
1116

1217

1318

1419
public class Menu implements Runnable{
1520

21+
private static final String game_Version = "v1.5.3 Alpha";
1622
private static final int WIDTH = 160;
1723
private static final int HEIGHT = (WIDTH / 3 * 2);
1824
private static final int SCALE = 3;
@@ -23,7 +29,7 @@ public class Menu implements Runnable{
2329
private static boolean selectedExit = false;
2430
private static boolean gameOver = false;
2531

26-
private static DedicatedJFrame frame = new DedicatedJFrame(WIDTH, HEIGHT, SCALE, NAME);
32+
private static DedicatedJFrame frame;// = new DedicatedJFrame(WIDTH, HEIGHT, SCALE, NAME);
2733
private Font font = new Font();
2834
private MouseListener Mouse = new Mouse();
2935

@@ -32,6 +38,7 @@ public class Menu implements Runnable{
3238

3339
public synchronized void start() {
3440
running = true;
41+
play();
3542
new Thread(this, "MENU").start();
3643
}
3744

@@ -149,7 +156,49 @@ private void render() {
149156
public static void main(String[] args) {
150157
new Menu().start();
151158
}
152-
159+
160+
public static void play(){
161+
try {
162+
JSplash splash = new JSplash(Game.class.getResource("/splash/splash.png"), true, true, false, game_Version, null, Color.RED, Color.ORANGE);
163+
splash.toFront();
164+
splash.requestFocus();
165+
splash.splashOn();
166+
splash.setProgress(10, "Initializing Game");
167+
Thread.sleep(250);
168+
splash.setProgress(25, "Loading Classes");
169+
Thread.sleep(125);
170+
splash.setProgress(35, "Applying Configurations");
171+
Thread.sleep(125);
172+
splash.setProgress(40, "Loading Sprites");
173+
Thread.sleep(250);
174+
splash.setProgress(50, "Loading Textures");
175+
Thread.sleep(125);
176+
splash.setProgress(60, "Loading Map");
177+
Thread.sleep(500);
178+
splash.setProgress(80, "Configuring Map");
179+
Thread.sleep(125);
180+
splash.setProgress(90, "Pulling InputPanes");
181+
Thread.sleep(250);
182+
splash.setProgress(92, "Aquring data: Multiplayer");
183+
Thread.sleep(125);
184+
UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
185+
Game.setJdata_Host(JOptionPane.showConfirmDialog(Game.getGame(), "Do you want to be the HOST?"));
186+
if (Game.getJdata_Host() == 1){
187+
Game.setJdata_IP(JOptionPane.showInputDialog(Game.getGame(), "Enter the name \nleave blank for local"));
188+
}
189+
Thread.sleep(125);
190+
splash.setProgress(95, "Aquring data: Username");
191+
Thread.sleep(125);
192+
splash.setProgress(96, "Initalizing as Server:Host");
193+
Game.setJdata_UserName(JOptionPane.showInputDialog(Game.getGame(), "Enter a name"));
194+
splash.setProgress(97, "Connecting as" + Game.getJdata_UserName());
195+
Thread.sleep(250);
196+
splash.splashOff();
197+
frame = new DedicatedJFrame(WIDTH, HEIGHT, SCALE, NAME);
198+
} catch (Exception e) {
199+
e.printStackTrace();
200+
}
201+
}
153202
public static DedicatedJFrame getFrame() {
154203
return Menu.frame;
155204
}

0 commit comments

Comments
 (0)