Skip to content

Commit cb3599e

Browse files
committed
Started work on Selecting charater race
1 parent c8187f8 commit cb3599e

File tree

6 files changed

+86
-13
lines changed

6 files changed

+86
-13
lines changed

src/com/redomar/game/Game.java

Lines changed: 48 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,9 @@ public class Game extends Canvas implements Runnable {
4646
private static boolean changeLevel = false;
4747
private static boolean npc = false;
4848
private static int map = 0;
49+
private static int shirtCol;
50+
private static int faceCol;
51+
private static boolean[] alternateCols = new boolean[2];
4952

5053
private JFrame frame;
5154

@@ -125,8 +128,20 @@ public void init() {
125128

126129
public void setMap(String Map_str) {
127130
setLevel(new LevelHandler(Map_str));
131+
if(alternateCols[0]){
132+
Game.setShirtCol(240);
133+
}
134+
if(!alternateCols[0]){
135+
Game.setShirtCol(111);
136+
}
137+
if(alternateCols[1]){
138+
Game.setFaceCol(310);
139+
}
140+
if(!alternateCols[1]){
141+
Game.setFaceCol(444);
142+
}
128143
setPlayer(new PlayerMP(getLevel(), 100, 100, input,
129-
getJdata_UserName(), null, -1));
144+
getJdata_UserName(), null, -1, shirtCol, faceCol));
130145
level.addEntity(player);
131146
}
132147

@@ -456,4 +471,36 @@ public static String getGameVersion() {
456471
return game_Version;
457472
}
458473

474+
public static int getShirtCol() {
475+
return shirtCol;
476+
}
477+
478+
public static void setShirtCol(int shirtCol) {
479+
Game.shirtCol = shirtCol;
480+
}
481+
482+
public static int getFaceCol() {
483+
return faceCol;
484+
}
485+
486+
public static void setFaceCol(int faceCol) {
487+
Game.faceCol = faceCol;
488+
}
489+
490+
public static boolean[] getAlternateCols() {
491+
return alternateCols;
492+
}
493+
494+
public static void setAlternateCols(boolean[] alternateCols) {
495+
Game.alternateCols = alternateCols;
496+
}
497+
498+
public static void setAternateColsR(boolean alternateCols){
499+
Game.alternateCols[1] = alternateCols;
500+
}
501+
502+
public static void setAternateColsS(boolean alternateCols){
503+
Game.alternateCols[0] = alternateCols;
504+
}
505+
459506
}

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

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ public class Player extends Mob {
1616
private static Name customeName = new Name();
1717
private Swim swim;
1818

19-
private int colour = Colours.get(-1, 111, 240, 310);
19+
private int colour, shirtCol, faceCol;
2020
private int tickCount = 0;
2121
private String userName;
2222
private boolean[] swimType;
@@ -25,10 +25,13 @@ public class Player extends Mob {
2525
public static String guestPlayerName = customeName.setName("Player ");
2626

2727
public Player(LevelHandler level, int x, int y, InputHandler input,
28-
String userName) {
28+
String userName, int shirtCol, int faceCol) {
2929
super(level, "Player", x, y, 1);
3030
this.input = input;
3131
this.userName = userName;
32+
this.faceCol = faceCol;
33+
this.shirtCol = shirtCol;
34+
this.colour = Colours.get(-1, 111, shirtCol, faceCol);
3235
}
3336

3437
public void tick() {
@@ -104,7 +107,7 @@ public void render(Screen screen) {
104107
int waterColour = 0;
105108
yOffset += 4;
106109

107-
colour = Colours.get(-1, 111, -1, 310);
110+
colour = Colours.get(-1, 111, -1, faceCol);
108111

109112
if (tickCount % 60 < 15) {
110113
waterColour = Colours.get(-1, -1, swimColour[0], -1);
@@ -135,7 +138,7 @@ public void render(Screen screen) {
135138
screen.render((xOffset + modifier - (modifier * flipBottom)),
136139
(yOffset + modifier), ((xTile + 1) + (yTile + 1) * 32),
137140
colour, flipBottom, scale);
138-
colour = Colours.get(-1, 111, 240, 310);
141+
colour = Colours.get(-1, 111, shirtCol, faceCol);
139142
;
140143
}
141144

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

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,15 +11,15 @@ public class PlayerMP extends Player {
1111
public int port;
1212

1313
public PlayerMP(LevelHandler level, int x, int y, InputHandler input,
14-
String userName, InetAddress ipAddress, int port) {
15-
super(level, x, y, input, userName);
14+
String userName, InetAddress ipAddress, int port, int shirtCol, int faceCol) {
15+
super(level, x, y, input, userName, shirtCol, faceCol);
1616
this.ipAddess = ipAddress;
1717
this.port = port;
1818
}
1919

2020
public PlayerMP(LevelHandler level, int x, int y, String userName,
21-
InetAddress ipAddress, int port) {
22-
super(level, x, y, null, userName);
21+
InetAddress ipAddress, int port, int shirtCol, int faceCol) {
22+
super(level, x, y, null, userName, shirtCol, faceCol);
2323
this.ipAddess = ipAddress;
2424
this.port = port;
2525
}

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

Lines changed: 25 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -191,11 +191,34 @@ public static void play() {
191191
"Enter the name \nleave blank for local"));
192192
}
193193
Thread.sleep(125);
194-
splash.setProgress(95, "Aquring data: Username");
194+
splash.setProgress(94, "Aquring data: Username");
195195
Thread.sleep(125);
196-
splash.setProgress(96, "Initalizing as Server:Host");
196+
splash.setProgress(95, "Initalizing as Server:Host");
197197
Game.setJdata_UserName(JOptionPane.showInputDialog(Game.getGame(),
198198
"Enter a name"));
199+
Thread.sleep(250);
200+
splash.setProgress(96, "Collecting Player Data");
201+
Object[] options = { "African", "Caucasian"};
202+
int n = JOptionPane.showOptionDialog(frame,
203+
"Choose a race for the charater to be",
204+
"Choose a race", JOptionPane.YES_NO_OPTION,
205+
JOptionPane.QUESTION_MESSAGE, null, options, options[0]);
206+
if(n == 0){
207+
Game.setAternateColsR(true);
208+
}else{
209+
Game.setAternateColsR(false);
210+
}
211+
Thread.sleep(250);
212+
Object[] options1 = { "Orange", "Black"};
213+
int n1 = JOptionPane.showOptionDialog(frame,
214+
"Which Colour do you want the shirt to be?",
215+
"Choose a shirt Colour", JOptionPane.YES_NO_OPTION,
216+
JOptionPane.QUESTION_MESSAGE, null, options1, options1[0]);
217+
if(n1 == 0){
218+
Game.setAternateColsS(true);
219+
}else{
220+
Game.setAternateColsS(false);
221+
}
199222
splash.setProgress(97, "Connecting as" + Game.getJdata_UserName());
200223
Thread.sleep(250);
201224
splash.splashOff();

src/com/redomar/game/net/GameClient.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ private void handleLogin(Packet00Login packet, InetAddress address, int port) {
7979
System.out.println("[" + address.getHostAddress() + ":" + port + "] "
8080
+ packet.getUsername() + " has joined...");
8181
PlayerMP player = new PlayerMP(Game.getLevel(), packet.getX(),
82-
packet.getY(), packet.getUsername(), address, port);
82+
packet.getY(), packet.getUsername(), address, port, Game.getShirtCol(), Game.getFaceCol());
8383
Game.getLevel().addEntity(player);
8484
}
8585

src/com/redomar/game/net/GameServer.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ private void parsePacket(byte[] data, InetAddress address, int port) {
6767
+ "] " + ((Packet00Login) packet).getUsername()
6868
+ " has connected...");
6969
PlayerMP player = new PlayerMP(Game.getLevel(), 10, 10,
70-
((Packet00Login) packet).getUsername(), address, port);
70+
((Packet00Login) packet).getUsername(), address, port, Game.getShirtCol(), Game.getFaceCol());
7171
this.addConnection(player, (Packet00Login) packet);
7272
break;
7373
case DISCONNECT:

0 commit comments

Comments
 (0)