Skip to content

Commit 39c7340

Browse files
committed
Merger with aside
fix a few bugs during merge
2 parents 4bed898 + e612873 commit 39c7340

File tree

5 files changed

+142
-108
lines changed

5 files changed

+142
-108
lines changed

src/com/redomar/game/Game.java

Lines changed: 36 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

@@ -24,18 +23,18 @@
2423
import com.redomar.game.lib.Font;
2524
import com.redomar.game.lib.Music;
2625
import com.redomar.game.lib.Time;
26+
import com.redomar.game.menu.Menu;
2727
import com.redomar.game.net.GameClient;
2828
import com.redomar.game.net.GameServer;
2929
import com.redomar.game.net.packets.Packet00Login;
3030
import com.redomar.game.script.Printing;
31-
import com.thehowtotutorial.splashscreen.JSplash;
3231

33-
public class Game extends Canvas implements Runnable {
3432

33+
public class Game extends Canvas implements Runnable {
34+
35+
// Setting the size and name of the frame/canvas
3536
private static final long serialVersionUID = 1L;
3637
private static final String game_Version = "v1.6.1 Alpha";
37-
38-
// Setting the size and name of the frame/canvas
3938
private static final int WIDTH = 160;
4039
private static final int HEIGHT = (WIDTH / 3 * 2);
4140
private static final int SCALE = 3;
@@ -127,7 +126,7 @@ public void init() {
127126
public void setMap(String Map_str) {
128127
setLevel(new LevelHandler(Map_str));
129128
setPlayer(new PlayerMP(getLevel(), 100, 100, input,
130-
Jdata_UserName, null, -1));
129+
getJdata_UserName(), null, -1));
131130
level.addEntity(player);
132131
}
133132

@@ -148,12 +147,12 @@ public synchronized void start() {
148147
running = true;
149148
new Thread(this, "GAME").start();
150149

151-
if (Jdata_Host == 0) {
150+
if (getJdata_Host() == 0) {
152151
socketServer = new GameServer(this);
153152
socketServer.start();
154153
}
155154

156-
setSocketClient(new GameClient(this, Jdata_IP));
155+
setSocketClient(new GameClient(this, getJdata_IP()));
157156
getSocketClient().start();
158157
}
159158

@@ -309,51 +308,7 @@ public void render() {
309308
}
310309

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

359314
public JFrame getFrame() {
@@ -460,4 +415,32 @@ public void setDummy(Dummy dummy) {
460415
this.dummy = dummy;
461416
}
462417

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

src/com/redomar/game/entities/Mob.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ public abstract class Mob extends Entity {
99

1010
protected String name;
1111
protected Random random = new Random();
12-
protected int speed;
12+
protected double speed;
1313
protected int numSteps = 0;
1414
protected boolean isMoving;
1515
protected int movingDir = 1;
@@ -19,7 +19,7 @@ public abstract class Mob extends Entity {
1919
protected boolean changeLevels = false;
2020
protected int ticker;
2121

22-
public Mob(LevelHandler level, String name, int x, int y, int speed) {
22+
public Mob(LevelHandler level, String name, int x, int y, double speed) {
2323
super(level);
2424
this.name = name;
2525
this.setX(x);
@@ -48,8 +48,8 @@ public void move(int xa, int ya) {
4848
if (xa > 0) {
4949
movingDir = 3;
5050
}
51-
setX(getX() + xa * speed);
52-
setY(getY() + ya * speed);
51+
setX(getX() + xa * (int)speed);
52+
setY(getY() + ya * (int)speed);
5353
}
5454
}
5555

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

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -14,15 +14,15 @@ public void mouseDragged(MouseEvent e) {
1414
}
1515

1616
public void mouseMoved(MouseEvent e) {
17-
if (e.getX() > 35 && e.getX() < 440){
17+
if (e.getX() > 35 && e.getX() < 455){
1818
//START is being selected
19-
if(e.getY() > 35 && e.getY() < 125){
19+
if(e.getY() > 38 && e.getY() < 150){
2020
Menu.setSelectedStart(true);
2121
}else{
2222
Menu.setSelectedStart(false);
2323
}
2424
//EXIT is being selected
25-
if(e.getY() > 160 && e.getY() < 250){
25+
if(e.getY() > 170 && e.getY() < 280){
2626
Menu.setSelectedExit(true);
2727
}else{
2828
Menu.setSelectedExit(false);
@@ -36,16 +36,16 @@ public void mouseMoved(MouseEvent e) {
3636

3737
public void mouseClicked(MouseEvent e) {
3838
if(Menu.isRunning()){
39-
if (e.getX() > 35 && e.getX() < 440){
39+
if (e.getX() > 35 && e.getX() < 455){
4040
//START game
41-
if(e.getY() > 35 && e.getY() < 125){
41+
if(e.getY() > 38 && e.getY() < 150){
4242
Menu.setRunning(false);
4343
Menu.getFrame().setVisible(false);
4444
Menu.getFrame().stopFrame();
45-
Game.play();
45+
new Game().start();
4646
}
4747
//EXIT game
48-
if(e.getY() > 160 && e.getY() < 250){
48+
if(e.getY() > 170 && e.getY() < 280){
4949
Menu.setRunning(false);
5050
Menu.getFrame().setVisible(false);
5151
Menu.getFrame().stopFrame();

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

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,10 @@ public class DedicatedJFrame extends Canvas {
1212
private static JFrame frame;
1313

1414
public DedicatedJFrame(int WIDTH, int HEIGHT, int SCALE, String NAME){
15+
setMinimumSize(new Dimension(WIDTH * SCALE, HEIGHT * SCALE));
16+
setMaximumSize(new Dimension(WIDTH * SCALE, HEIGHT * SCALE));
17+
setPreferredSize(new Dimension(WIDTH * SCALE, HEIGHT * SCALE));
18+
1519
setFrame(new JFrame(NAME));
1620
getFrame().setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
1721
getFrame().setLayout(new BorderLayout());
@@ -20,10 +24,6 @@ public DedicatedJFrame(int WIDTH, int HEIGHT, int SCALE, String NAME){
2024
getFrame().setResizable(false);
2125
getFrame().setLocationRelativeTo(null);
2226
getFrame().setVisible(true);
23-
24-
getFrame().setMinimumSize(new Dimension(WIDTH * SCALE, HEIGHT * SCALE));
25-
getFrame().setMaximumSize(new Dimension(WIDTH * SCALE, HEIGHT * SCALE));
26-
getFrame().setPreferredSize(new Dimension(WIDTH * SCALE, HEIGHT * SCALE));
2727
}
2828

2929
public JFrame getFrame() {

0 commit comments

Comments
 (0)