Skip to content

Commit 21416a8

Browse files
committed
Merge remote-tracking branch 'origin/aside'
2 parents 75b2b4c + 875778c commit 21416a8

File tree

3 files changed

+49
-58
lines changed

3 files changed

+49
-58
lines changed

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

Lines changed: 19 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
package com.redomar.game.entities;
22

33
import com.redomar.game.Game;
4+
import com.redomar.game.entities.efx.Swim;
45
import com.redomar.game.gfx.Colours;
56
import com.redomar.game.gfx.Screen;
67
import com.redomar.game.level.LevelHandler;
@@ -11,6 +12,9 @@ public class Dummy extends Mob {
1112
private int tickCount = 0;
1213
private int xa = 0;
1314
private int ya = 0;
15+
private boolean[] swimType;
16+
17+
private Swim swim;
1418

1519
public Dummy(LevelHandler level, String name, int x, int y, int shirtCol,
1620
int faceCol) {
@@ -25,32 +29,11 @@ public void tick() {
2529
followMovementAI(getX(), getY(), Game.getPlayer().getX(), Game
2630
.getPlayer().getY(), xa, ya, this);
2731

28-
if (level.getTile(this.getX() >> 3, this.getY() >> 3).getId() == 4) {
29-
isSwimming = true;
30-
}
31-
32-
if (isSwimming
33-
&& level.getTile(this.getX() >> 3, this.getY() >> 3).getId() != 4) {
34-
isSwimming = false;
35-
}
36-
37-
if (level.getTile(this.getX() >> 3, this.getY() >> 3).getId() == 12) {
38-
isMagma = true;
39-
}
40-
41-
if (isMagma
42-
&& level.getTile(this.getX() >> 3, this.getY() >> 3).getId() != 12) {
43-
isMagma = false;
44-
}
45-
46-
if (level.getTile(this.getX() >> 3, this.getY() >> 3).getId() == 14){
47-
isMuddy = true;
48-
}
49-
50-
if(isMuddy
51-
&& level.getTile(this.getX() >> 3, this.getY() >> 3).getId() != 14){
52-
isMuddy = false;
53-
}
32+
setSwim(new Swim(level, getX(), getY()));
33+
swimType = getSwim().swimming(isSwimming, isMagma, isMuddy);
34+
isSwimming = swimType[0];
35+
isMagma = swimType[1];
36+
isMuddy = swimType[2];
5437

5538
tickCount++;
5639

@@ -121,12 +104,12 @@ public void render(Screen screen) {
121104
screen.render(xOffset + 8, yOffset + 3, 31 + 31 * 32, waterColour,
122105
0x01, 1);
123106
}
124-
107+
125108
if (isMuddy) {
126109
int waterColour = 0;
127110
yOffset += 4;
128111

129-
colour = Colours.get(-1, 111, -1, 310);
112+
colour = Colours.get(-1, 111, -1, faceCol);
130113

131114
if (tickCount % 60 < 15) {
132115
waterColour = Colours.get(-1, -1, 422, -1);
@@ -193,4 +176,12 @@ public boolean hasCollided(int xa, int ya) {
193176

194177
return false;
195178
}
179+
180+
public Swim getSwim() {
181+
return swim;
182+
}
183+
184+
public void setSwim(Swim swim) {
185+
this.swim = swim;
186+
}
196187
}

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

Lines changed: 8 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ public class Player extends Mob {
1919
private int colour = Colours.get(-1, 111, 240, 310);
2020
private int tickCount = 0;
2121
private String userName;
22-
22+
private boolean[] swimType;
2323

2424
public static String guestPlayerName = customeName.setName("Player ");
2525

@@ -61,8 +61,12 @@ public void tick() {
6161
} else {
6262
isMoving = false;
6363
}
64-
65-
Swimming();
64+
65+
setSwim(new Swim(level, getX(), getY()));
66+
swimType = getSwim().swimming(isSwimming, isMagma, isMuddy);
67+
isSwimming = swimType[0];
68+
isMagma = swimType[1];
69+
isMuddy = swimType[2];
6670

6771
if (level.getTile(this.getX() >> 3, this.getY() >> 3).getId() == 11) {
6872
changeLevels = true;
@@ -71,15 +75,6 @@ public void tick() {
7175
tickCount++;
7276
}
7377

74-
private void Swimming() {
75-
76-
setSwim(new Swim(level, getX(), getY()));
77-
78-
isSwimming = getSwim().water(isSwimming);
79-
isMagma = getSwim().magma(isMagma);
80-
isMuddy = getSwim().mud(isMuddy);
81-
}
82-
8378
public void render(Screen screen) {
8479
int xTile = 0;
8580
int yTile = 28;
@@ -149,7 +144,7 @@ public void render(Screen screen) {
149144
screen.render(xOffset + 8, yOffset + 3, 31 + 31 * 32, waterColour,
150145
0x01, 1);
151146
}
152-
147+
153148
if (isMuddy) {
154149
int waterColour = 0;
155150
yOffset += 4;

src/com/redomar/game/entities/efx/Swim.java

Lines changed: 22 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -3,53 +3,58 @@
33
import com.redomar.game.level.LevelHandler;
44

55
public class Swim {
6-
6+
77
private static LevelHandler level;
88
private int x;
99
private int y;
1010

11-
public Swim(LevelHandler level, int x, int y){
11+
public Swim(LevelHandler level, int x, int y) {
1212
Swim.level = level;
1313
this.x = x;
1414
this.y = y;
1515
}
16-
17-
public boolean water(boolean isSwimming){
16+
17+
public boolean water(boolean isSwimming) {
1818
if (level.getTile(x >> 3, y >> 3).getId() == 4) {
1919
isSwimming = true;
2020
}
2121

22-
if (isSwimming
23-
&& level.getTile(x >> 3, y >> 3).getId() != 4) {
22+
if (isSwimming && level.getTile(x >> 3, y >> 3).getId() != 4) {
2423
isSwimming = false;
2524
}
2625
return isSwimming;
2726
}
28-
29-
public boolean magma(boolean isMagma){
27+
28+
public boolean magma(boolean isMagma) {
3029
if (level.getTile(x >> 3, y >> 3).getId() == 12) {
3130
isMagma = true;
3231
}
3332

34-
if (isMagma
35-
&& level.getTile(x >> 3, y >> 3).getId() != 12) {
33+
if (isMagma && level.getTile(x >> 3, y >> 3).getId() != 12) {
3634
isMagma = false;
3735
}
38-
36+
3937
return isMagma;
4038
}
41-
42-
public boolean mud(boolean isMuddy){
39+
40+
public boolean mud(boolean isMuddy) {
4341
if (level.getTile(x >> 3, y >> 3).getId() == 14) {
4442
isMuddy = true;
4543
}
4644

47-
if (isMuddy
48-
&& level.getTile(x >> 3, y >> 3).getId() != 14) {
45+
if (isMuddy && level.getTile(x >> 3, y >> 3).getId() != 14) {
4946
isMuddy = false;
5047
}
51-
48+
5249
return isMuddy;
5350
}
54-
51+
52+
public boolean[] swimming(boolean isSwimming, boolean isMagma, boolean isMuddy) {
53+
boolean[] swimminhType;
54+
swimminhType = new boolean[3];
55+
swimminhType[0] = water(isSwimming);
56+
swimminhType[1] = magma(isMagma);
57+
swimminhType[2] = mud(isMuddy);
58+
return swimminhType;
59+
}
5560
}

0 commit comments

Comments
 (0)