player can now choose between different shields and weapons. added consumable items (healing potion)

This commit is contained in:
2025-11-30 18:29:47 +01:00
parent fb96035c99
commit 51c262d9ac
13 changed files with 167 additions and 24 deletions

View File

@@ -0,0 +1,22 @@
package de.miaurizius.jgame2d.entity.item;
import de.miaurizius.jgame2d.core.GamePanel;
import de.miaurizius.jgame2d.core.enums.EntityType;
import de.miaurizius.jgame2d.entity.Entity;
public class AxeObj extends Entity {
public AxeObj(GamePanel panel) {
super(panel);
name = "Woodcutter's Axe";
description = "[" + name + "]\nA bit rusty but still can \ncut some trees.";
type = EntityType.WEAPON;
weaponType = EntityType.WeaponType.AXE;
down1 = initEntitySprites("/objects/axe");
attackValue = 2;
attackArea.width = 30;
attackArea.height = 30;
}
}

View File

@@ -8,7 +8,7 @@ public class BootsObj extends Entity {
public BootsObj(GamePanel panel) {
super(panel);
name = "boots";
name = "Boots";
type = EntityType.ITEM;
down1 = initEntitySprites("objects/boots.png");
}

View File

@@ -8,7 +8,7 @@ public class HeartObj extends Entity {
public HeartObj(GamePanel panel) {
super(panel);
name = "heart";
name = "Heart Container";
type = EntityType.ITEM;
image = initEntitySprites("objects/heart_full");
image2 = initEntitySprites("objects/heart_half");

View File

@@ -0,0 +1,19 @@
package de.miaurizius.jgame2d.entity.item;
import de.miaurizius.jgame2d.core.GamePanel;
import de.miaurizius.jgame2d.core.enums.EntityType;
import de.miaurizius.jgame2d.entity.Entity;
public class IronShieldObj extends Entity {
public IronShieldObj(GamePanel panel) {
super(panel);
name = "Iron Shield";
description = "[" + name + "]\nAn iron shield. It's very\nheavy.";
type = EntityType.SHIELD;
down1 = initEntitySprites("objects/shield_blue");
defenseValue = 2;
}
}

View File

@@ -0,0 +1,33 @@
package de.miaurizius.jgame2d.entity.item;
import de.miaurizius.jgame2d.core.GamePanel;
import de.miaurizius.jgame2d.core.enums.EntityType;
import de.miaurizius.jgame2d.core.enums.GameState;
import de.miaurizius.jgame2d.entity.Entity;
public class PotionObj extends Entity {
GamePanel panel;
int value = 2;
public PotionObj(GamePanel panel) {
super(panel);
this.panel = panel;
type = EntityType.ITEM;
consumable = true;
name = "Red Potion";
down1 = initEntitySprites("objects/potion_red");
description = "[" + name + "]\nHeals your life by " + value + ".";
}
public void use(Entity entity) {
panel.gameState = GameState.DIALOGUE;
panel.ui.currentDialogue = "You drank a " + name + "!\n" +
"Your life has been recovered by " + value + ".";
entity.life += value;
if(panel.player.life > panel.player.maxLife) panel.player.life = panel.player.maxLife;
panel.playSE(2);
}
}

View File

@@ -10,7 +10,7 @@ public class ShieldWoodObj extends Entity {
super(panel);
name = "Wooden Shield";
description = "[" + name + "]\nAn old shield. It's not\nthat strong but its okay.";
type = EntityType.ITEM;
type = EntityType.SHIELD;
down1 = initEntitySprites("objects/shield_wood");
defenseValue = 1;
}

View File

@@ -11,9 +11,13 @@ public class SwordNormalObj extends Entity {
name = "Normal Sword";
description = "[" + name + "]\nAn old sword.";
type = EntityType.ITEM;
type = EntityType.WEAPON;
weaponType = EntityType.WeaponType.SWORD;
down1 = initEntitySprites("objects/sword_normal");
attackValue = 1;
attackArea.width = 36;
attackArea.height = 36;
}
}