obstacles and chest loot

This commit is contained in:
2025-12-13 00:44:53 +01:00
parent 1d6f53a70e
commit 825b084a68
11 changed files with 169 additions and 38 deletions

View File

@@ -230,6 +230,7 @@ public class Entity {
}
}
public void use(Entity entity) {
} //If entity is consumable
public void checkDrop() {
@@ -255,6 +256,36 @@ public class Entity {
}
}
}
public void interact() {
}
public int getDetected(Entity user, Entity[][] target, String targetName) {
int index = 999;
int nextWorldX = user.getLeftX();
int nextWorldY = user.getTopY();
switch(user.direction) {
case UP -> nextWorldY = user.getTopY()-1;
case DOWN -> nextWorldY = user.getBottomY()+1;
case LEFT -> nextWorldX = user.getLeftX()-1;
case RIGHT -> nextWorldX = user.getRightX()+1;
}
int col = nextWorldX / panel.tileSize;
int row = nextWorldY / panel.tileSize;
for(int i = 0; i < target[panel.currentMap.getIndex()].length; i++) {
if(target[panel.currentMap.getIndex()][i] == null) continue;
if(
target[panel.currentMap.getIndex()][i].getCol() == col &&
target[panel.currentMap.getIndex()][i].getRow() == row &&
target[panel.currentMap.getIndex()][i].name.equalsIgnoreCase(targetName)
) {
index = i;
break;
}
}
return index;
}
// PARTICLE SETUP
public Color getParticleColor() {
@@ -285,6 +316,26 @@ public class Entity {
panel.particleList.add(p4);
}
// GETTERS
public int getLeftX() {
return worldX + solidArea.x;
}
public int getRightX() {
return worldX + solidArea.x + solidArea.width;
}
public int getTopY() {
return worldY + solidArea.y;
}
public int getBottomY() {
return worldY + solidArea.y + solidArea.height;
}
public int getCol() {
return (worldX + solidArea.x) / panel.tileSize;
}
public int getRow() {
return (worldY + solidArea.y) / panel.tileSize;
}
// SETTING THINGS UP
BufferedImage parseSprite() {
return switch (direction) {