mirror of
https://github.com/simon987/Much-Assembly-Required.git
synced 2025-12-15 23:59:09 +00:00
Added jump/warp movement, animation needs changing
This commit is contained in:
@@ -6,6 +6,7 @@ public enum Action {
|
||||
WALKING,
|
||||
WITHDRAWING,
|
||||
DEPOSITING,
|
||||
LISTENING
|
||||
LISTENING,
|
||||
JUMPING
|
||||
|
||||
}
|
||||
|
||||
@@ -47,24 +47,24 @@ public abstract class GameObject implements JSONSerialisable {
|
||||
* Increment the location of the game object by 1 tile
|
||||
* Collision checks happen here
|
||||
*/
|
||||
public boolean incrementLocation() {
|
||||
public boolean incrementLocation(int distance) {
|
||||
|
||||
int newX = 0, newY = 0;
|
||||
|
||||
if (direction == Direction.NORTH) {
|
||||
newX = x;
|
||||
newY = (y - 1);
|
||||
newY = (y - distance);
|
||||
|
||||
} else if (direction == Direction.EAST) {
|
||||
newX = (x + 1);
|
||||
newX = (x + distance);
|
||||
newY = y;
|
||||
|
||||
} else if (direction == Direction.SOUTH) {
|
||||
newX = x;
|
||||
newY = (y + 1);
|
||||
newY = (y + distance);
|
||||
|
||||
} else if (direction == Direction.WEST) {
|
||||
newX = (x - 1);
|
||||
newX = (x - distance);
|
||||
newY = y;
|
||||
}
|
||||
|
||||
@@ -81,13 +81,17 @@ public abstract class GameObject implements JSONSerialisable {
|
||||
}
|
||||
|
||||
if (leftWorld != null) {
|
||||
world.getGameObjects().remove(this);
|
||||
world.decUpdatable();
|
||||
leftWorld.getGameObjects().add(this);
|
||||
leftWorld.incUpdatable();
|
||||
setWorld(leftWorld);
|
||||
if(!leftWorld.isTileBlocked(World.WORLD_SIZE+newX, newY)) {
|
||||
world.getGameObjects().remove(this);
|
||||
world.decUpdatable();
|
||||
leftWorld.getGameObjects().add(this);
|
||||
leftWorld.incUpdatable();
|
||||
setWorld(leftWorld);
|
||||
|
||||
x = World.WORLD_SIZE - 1;
|
||||
x = World.WORLD_SIZE + newX;
|
||||
} else if (distance > 1) {
|
||||
return incrementLocation(distance-1);
|
||||
}
|
||||
}
|
||||
} else if (newX >= World.WORLD_SIZE) {
|
||||
//Move object to adjacent World (right)
|
||||
@@ -100,13 +104,17 @@ public abstract class GameObject implements JSONSerialisable {
|
||||
}
|
||||
|
||||
if (rightWorld != null) {
|
||||
world.getGameObjects().remove(this);
|
||||
world.decUpdatable();
|
||||
rightWorld.getGameObjects().add(this);
|
||||
rightWorld.incUpdatable();
|
||||
setWorld(rightWorld);
|
||||
if(!rightWorld.isTileBlocked(newX-World.WORLD_SIZE, y)) {
|
||||
world.getGameObjects().remove(this);
|
||||
world.decUpdatable();
|
||||
rightWorld.getGameObjects().add(this);
|
||||
rightWorld.incUpdatable();
|
||||
setWorld(rightWorld);
|
||||
|
||||
x = 0;
|
||||
x = newX - World.WORLD_SIZE;
|
||||
} else if (distance > 1) {
|
||||
return incrementLocation(distance-1);
|
||||
}
|
||||
}
|
||||
} else if (newY < 0) {
|
||||
//Move object to adjacent World (up)
|
||||
@@ -120,13 +128,17 @@ public abstract class GameObject implements JSONSerialisable {
|
||||
}
|
||||
|
||||
if (upWorld != null) {
|
||||
world.getGameObjects().remove(this);
|
||||
world.decUpdatable();
|
||||
upWorld.getGameObjects().add(this);
|
||||
upWorld.incUpdatable();
|
||||
setWorld(upWorld);
|
||||
if (!upWorld.isTileBlocked(x, World.WORLD_SIZE+newY)) {
|
||||
world.getGameObjects().remove(this);
|
||||
world.decUpdatable();
|
||||
upWorld.getGameObjects().add(this);
|
||||
upWorld.incUpdatable();
|
||||
setWorld(upWorld);
|
||||
|
||||
y = World.WORLD_SIZE - 1;
|
||||
y = World.WORLD_SIZE + newY;
|
||||
} else if (distance > 1) {
|
||||
return incrementLocation(distance-1);
|
||||
}
|
||||
}
|
||||
} else if (newY >= World.WORLD_SIZE) {
|
||||
//Move object to adjacent World (down)
|
||||
@@ -140,13 +152,17 @@ public abstract class GameObject implements JSONSerialisable {
|
||||
|
||||
|
||||
if (downWorld != null) {
|
||||
world.getGameObjects().remove(this);
|
||||
world.decUpdatable();
|
||||
downWorld.getGameObjects().add(this);
|
||||
downWorld.incUpdatable();
|
||||
setWorld(downWorld);
|
||||
if (!downWorld.isTileBlocked(x,newY-World.WORLD_SIZE)) {
|
||||
world.getGameObjects().remove(this);
|
||||
world.decUpdatable();
|
||||
downWorld.getGameObjects().add(this);
|
||||
downWorld.incUpdatable();
|
||||
setWorld(downWorld);
|
||||
|
||||
y = 0;
|
||||
y = newY - World.WORLD_SIZE;
|
||||
} else if (distance > 1) {
|
||||
return incrementLocation(distance-1);
|
||||
}
|
||||
}
|
||||
}
|
||||
//Check collision
|
||||
@@ -154,7 +170,9 @@ public abstract class GameObject implements JSONSerialisable {
|
||||
//Tile is passable
|
||||
x = newX;
|
||||
y = newY;
|
||||
} else {
|
||||
} else if (distance > 1) {
|
||||
return incrementLocation(distance-1);
|
||||
}else {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user