Skip to content

Commit f414d28

Browse files
committed
moddified dummy ai swimming
1 parent 4748e2a commit f414d28

File tree

2 files changed

+22
-28
lines changed

2 files changed

+22
-28
lines changed

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

Lines changed: 20 additions & 26 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,8 @@ public class Dummy extends Mob {
1112
private int tickCount = 0;
1213
private int xa = 0;
1314
private int ya = 0;
15+
16+
private Swim swim;
1417

1518
public Dummy(LevelHandler level, String name, int x, int y, int shirtCol,
1619
int faceCol) {
@@ -24,37 +27,20 @@ public void tick() {
2427

2528
followMovementAI(getX(), getY(), Game.getPlayer().getX(), Game
2629
.getPlayer().getY(), xa, ya, this);
27-
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-
}
4530

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-
}
31+
swimming();
5432

5533
tickCount++;
5634

5735
}
36+
37+
private void swimming(){
38+
setSwim(new Swim(level, getX(), getY()));
39+
40+
isSwimming = getSwim().water(isSwimming);
41+
isMagma = getSwim().magma(isMagma);
42+
isMuddy = getSwim().mud(isMuddy);
43+
}
5844

5945
public void render(Screen screen) {
6046
int xTile = 8;
@@ -193,4 +179,12 @@ public boolean hasCollided(int xa, int ya) {
193179

194180
return false;
195181
}
182+
183+
public Swim getSwim() {
184+
return swim;
185+
}
186+
187+
public void setSwim(Swim swim) {
188+
this.swim = swim;
189+
}
196190
}

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ public void tick() {
6262
isMoving = false;
6363
}
6464

65-
Swimming();
65+
swimming();
6666

6767
if (level.getTile(this.getX() >> 3, this.getY() >> 3).getId() == 11) {
6868
changeLevels = true;
@@ -71,7 +71,7 @@ public void tick() {
7171
tickCount++;
7272
}
7373

74-
private void Swimming() {
74+
private void swimming() {
7575

7676
setSwim(new Swim(level, getX(), getY()));
7777

0 commit comments

Comments
 (0)