make heart collectable

This commit is contained in:
2025-12-07 00:44:56 +01:00
parent 54458293ba
commit 6254eb2501
6 changed files with 63 additions and 15 deletions

View File

@@ -48,6 +48,8 @@ public class Player extends Entity {
// DEFAULT
public void update() {
if(life > maxLife) life = maxLife;
if(attacking) {
attacking();
return;
@@ -124,14 +126,22 @@ public class Player extends Entity {
// INTERACTION
public void pickObject(int index) {
if(index == 999) return;
if(inventory.size() == maxInvSize) {
panel.ui.addMessage("Your inventory is full!");
return;
if(index == 999 || panel.obj[index] == null) return;
// PICKUP ONLY
if(panel.obj[index].type == EntityType.PICKUP) {
panel.obj[index].use(this);
}
// INVENTORY ITEMS
else {
if(inventory.size() == maxInvSize) {
panel.ui.addMessage("Your inventory is full!");
return;
}
inventory.add(panel.obj[index]);
panel.playSE(1);
panel.ui.addMessage("Picked up " + panel.obj[index].name + "!");
}
inventory.add(panel.obj[index]);
panel.playSE(1);
panel.ui.addMessage("Picked up " + panel.obj[index].name + "!");
panel.obj[index] = null;
}