Skip to content

Commit 34073ce

Browse files
committed
Merge branch 'feature' into aside
2 parents 5d7933b + f80d4d3 commit 34073ce

File tree

6 files changed

+51
-32
lines changed

6 files changed

+51
-32
lines changed

src/com/redomar/game/Game.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,10 @@ public class Game extends Canvas implements Runnable {
8686
private GameServer socketServer;
8787
private Printing print = new Printing();
8888

89+
/**
90+
* @author Redomar
91+
* @version Alpha 1.7
92+
*/
8993
public Game() {
9094
setMinimumSize(new Dimension(WIDTH * SCALE, HEIGHT * SCALE));
9195
setMaximumSize(new Dimension(WIDTH * SCALE, HEIGHT * SCALE));

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,12 +20,13 @@ public class Dummy extends Mob {
2020
private static double speed = 0.75;
2121
private List<Node> path = null;
2222
private int time = 0;
23+
private static int[] collisionBoders = {0, 7, 0, 7};
2324

2425
private Swim swim;
2526

2627
public Dummy(LevelHandler level, String name, int x, int y, int shirtCol,
2728
int faceCol) {
28-
super(level, "h", x, y, speed);
29+
super(level, "h", x, y, speed, collisionBoders);
2930
this.faceCol = faceCol;
3031
this.shirtCol = shirtCol;
3132
this.colour = Colours.get(-1, 111, shirtCol, faceCol);

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

Lines changed: 19 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -22,13 +22,21 @@ public abstract class Mob extends Entity {
2222
protected boolean isMuddy = false;
2323
protected boolean changeLevels = false;
2424
protected int ticker;
25-
26-
public Mob(LevelHandler level, String name, int x, int y, double speed) {
25+
/**
26+
* [0] Contains the <strong>xMin</strong><br>
27+
* [1] Contains the <strong>xMax</strong><br>
28+
* [2] Contains the <strong>yMin</strong><br>
29+
* [3] Contains the <strong>yMax
30+
*/
31+
protected int[] collisionBoders = new int[4];
32+
33+
public Mob(LevelHandler level, String name, int x, int y, double speed, int[] collisionBoders) {
2734
super(level);
2835
this.name = name;
2936
this.setX(x);
3037
this.setY(y);
3138
this.speed = speed;
39+
this.collisionBoders = collisionBoders;
3240
}
3341

3442
public void move(double xa, double ya) {
@@ -90,10 +98,10 @@ public void move(double xa, double ya) {
9098
}
9199

92100
public boolean hasCollided(double xa, double ya){
93-
int xMin = 0;
94-
int xMax = 7;
95-
int yMin = 3;
96-
int yMax = 7;
101+
int xMin = collisionBoders[0];
102+
int xMax = collisionBoders[1];
103+
int yMin = collisionBoders[2];
104+
int yMax = collisionBoders[3];
97105

98106
for (int x = xMin; x < xMax; x++) {
99107
if (isSolid((int) xa, (int) ya, x, yMin)) {
@@ -169,13 +177,13 @@ protected void aStarMovementAI(int x, int y, int px, int py, double xa,
169177
if(path != null) {
170178
if(path.size() > 0){
171179
Vector2i vector = path.get(path.size() - 1).tile;
172-
if(x < vector.getX() << 3) xa++;
173-
if(x > vector.getX() << 3) xa--;
174-
if(y < vector.getY() << 3) ya++;
175-
if(y > vector.getY() << 3) ya--;
180+
if(x < vector.getX() << 3) xa =+ speed;
181+
if(x > vector.getX() << 3) xa =- speed;
182+
if(y < vector.getY() << 3) ya =+ speed;
183+
if(y > vector.getY() << 3) ya =- speed;
184+
moveMob(xa, ya, mob);
176185
}
177186
}
178-
moveMob(xa, ya, mob);
179187
}
180188

181189
protected void followMovementAI(int x, int y, int px, int py, double xa,

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,12 +24,13 @@ public class Player extends Mob {
2424
private String userName;
2525
private boolean[] swimType;
2626
private int[] swimColour;
27+
private static int[] collisionBoders = {-2, 8, 0, 7};
2728

2829
public static String guestPlayerName = customeName.setName("Player ");
2930

3031
public Player(LevelHandler level, int x, int y, InputHandler input,
3132
String userName, int shirtCol, int faceCol) {
32-
super(level, "Player", x, y, speed);
33+
super(level, "Player", x, y, speed, collisionBoders);
3334
this.input = input;
3435
this.userName = userName;
3536
this.faceCol = faceCol;

src/com/redomar/game/level/LevelHandler.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -237,7 +237,7 @@ public List<Node> findPath(Vector2i start, Vector2i goal){
237237
if(at == null) continue;
238238
if(at.isSolid()) continue;
239239
Vector2i a = new Vector2i(x + xi, y + yi);
240-
double gCost = current.gCost + getDistance(current.tile, a);
240+
double gCost = current.gCost + (getDistance(current.tile, a) == 1 ? 1 : 0.95);
241241
double hCost = getDistance(a, goal);
242242
Node node = new Node(a, current, gCost, hCost);
243243
if(isVectorInList(closedList, a) && gCost >= node.gCost) continue;

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

Lines changed: 23 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,9 @@ private void render() {
112112
if (isGameOver()) {
113113
g.drawString("GAME OVER... What will you do now?", 35, 30);
114114
} else {
115-
String name = (Game.getJdata_UserName().length() >= 1) ? WordUtils.capitalizeFully(Game.getJdata_UserName()).toString() : "Player";
115+
String name = (Game.getJdata_UserName().length() >= 1) ? WordUtils
116+
.capitalizeFully(Game.getJdata_UserName()).toString()
117+
: "Player";
116118
g.drawString("Welcome to JavaGame " + name, 35, 30);
117119
}
118120
g.drawLine(10, (HEIGHT * 3), 10, 10);
@@ -188,41 +190,44 @@ public static void play() {
188190
splash.setProgress(92, "Aquring data: Multiplayer");
189191
Thread.sleep(125);
190192
UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
191-
String multiMsg = "Sorry but multiplayer has been disabled on this version.\nIf you would like multiplayer checkout Alpha 1.6";
192-
JOptionPane.showMessageDialog(Game.getGame(), multiMsg, "Multiplayer Warning", JOptionPane.WARNING_MESSAGE);
193-
//Game.setJdata_Host(JOptionPane.showConfirmDialog(Game.getGame(), "Do you want to be the HOST?"));
193+
String multiMsg = "Sorry but multiplayer has been disabled on this version.\nIf you would like multiplayer checkout Alpha 1.6";
194+
JOptionPane.showMessageDialog(Game.getGame(), multiMsg,
195+
"Multiplayer Warning", JOptionPane.WARNING_MESSAGE);
196+
// Game.setJdata_Host(JOptionPane.showConfirmDialog(Game.getGame(),
197+
// "Do you want to be the HOST?"));
194198
Game.setJdata_Host(1);
195-
if (Game.getJdata_Host() != 1) { //Game.getJdata_Host() == 1
199+
if (Game.getJdata_Host() != 1) { // Game.getJdata_Host() == 1
196200
Game.setJdata_IP(JOptionPane.showInputDialog(Game.getGame(),
197201
"Enter the name \nleave blank for local"));
198202
}
199203
Thread.sleep(125);
200204
splash.setProgress(94, "Aquring data: Username");
205+
String s = JOptionPane.showInputDialog(Game.getGame(),
206+
"Enter a name");
207+
if (s != null) {
208+
Game.setJdata_UserName(s);
209+
}
201210
Thread.sleep(125);
202-
splash.setProgress(95, "Initalizing as Server:Host");
203-
Game.setJdata_UserName(JOptionPane.showInputDialog(Game.getGame(),
204-
"Enter a name"));
205-
Thread.sleep(250);
206211
splash.setProgress(96, "Collecting Player Data");
207-
Object[] options = { "African", "Caucasian"};
212+
Object[] options = { "African", "Caucasian" };
208213
int n = JOptionPane.showOptionDialog(frame,
209-
"Choose a race for the charater to be",
210-
"Choose a race", JOptionPane.YES_NO_OPTION,
211-
JOptionPane.QUESTION_MESSAGE, null, options, options[0]);
212-
if(n == 0){
214+
"Choose a race for the charater to be", "Choose a race",
215+
JOptionPane.YES_NO_OPTION, JOptionPane.QUESTION_MESSAGE,
216+
null, options, options[0]);
217+
if (n == 0) {
213218
Game.setAternateColsR(true);
214-
}else{
219+
} else {
215220
Game.setAternateColsR(false);
216221
}
217222
Thread.sleep(250);
218-
Object[] options1 = { "Orange", "Black"};
223+
Object[] options1 = { "Orange", "Black" };
219224
int n1 = JOptionPane.showOptionDialog(frame,
220225
"Which Colour do you want the shirt to be?",
221226
"Choose a shirt Colour", JOptionPane.YES_NO_OPTION,
222227
JOptionPane.QUESTION_MESSAGE, null, options1, options1[0]);
223-
if(n1 == 0){
228+
if (n1 == 0) {
224229
Game.setAternateColsS(true);
225-
}else{
230+
} else {
226231
Game.setAternateColsS(false);
227232
}
228233
splash.setProgress(97, "Connecting as" + Game.getJdata_UserName());

0 commit comments

Comments
 (0)