Skip to content

Commit 416b7d5

Browse files
committed
Fixed a bug
fixed a bug where the game would crash if the player was next to the wall modifed the mod speeds
1 parent 5d7933b commit 416b7d5

File tree

1 file changed

+8
-8
lines changed

1 file changed

+8
-8
lines changed

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

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -90,9 +90,9 @@ public void move(double xa, double ya) {
9090
}
9191

9292
public boolean hasCollided(double xa, double ya){
93-
int xMin = 0;
94-
int xMax = 7;
95-
int yMin = 3;
93+
int xMin = -2;
94+
int xMax = 8;
95+
int yMin = 0;
9696
int yMax = 7;
9797

9898
for (int x = xMin; x < xMax; x++) {
@@ -169,13 +169,13 @@ protected void aStarMovementAI(int x, int y, int px, int py, double xa,
169169
if(path != null) {
170170
if(path.size() > 0){
171171
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--;
172+
if(x < vector.getX() << 3) xa =+ speed;
173+
if(x > vector.getX() << 3) xa =- speed;
174+
if(y < vector.getY() << 3) ya =+ speed;
175+
if(y > vector.getY() << 3) ya =- speed;
176+
moveMob(xa, ya, mob);
176177
}
177178
}
178-
moveMob(xa, ya, mob);
179179
}
180180

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

0 commit comments

Comments
 (0)