added player stats and re-ordered some classes

This commit is contained in:
2025-11-30 01:53:28 +01:00
parent 5879aec9a2
commit 298e6c624e
14 changed files with 69 additions and 40 deletions

View File

@@ -0,0 +1,53 @@
package de.miaurizius.jgame2d.entity.npc;
import de.miaurizius.jgame2d.core.enums.Direction;
import de.miaurizius.jgame2d.core.GamePanel;
import de.miaurizius.jgame2d.core.enums.EntityType;
import de.miaurizius.jgame2d.entity.Entity;
import java.util.Random;
public class OldManNPC extends Entity {
public OldManNPC(GamePanel panel) {
super(panel);
type = EntityType.NPC;
name = "oldman-npc";
direction = Direction.DOWN;
speed = 1;
getImage();
setDialogue();
}
public void getImage() {
up1 = initEntitySprites("npc/oldman_up_1");
up2 = initEntitySprites("npc/oldman_up_2");
down1 = initEntitySprites("npc/oldman_down_1");
down2 = initEntitySprites("npc/oldman_down_2");
left1 = initEntitySprites("npc/oldman_left_1");
left2 = initEntitySprites("npc/oldman_left_2");
right1 = initEntitySprites("npc/oldman_right_1");
right2 = initEntitySprites("npc/oldman_right_2");
}
public void setDialogue() {
dialogue[0] = "Hello, lad.";
dialogue[1] = "So you've come to this island to \nfind the treasure?";
dialogue[2] = "I used to be a great wizard but now... \nI'm a bit too old for taking an \nadventure.";
dialogue[3] = "Well, good luck on you.";
dialogue[4] = "I heard drinking the water of the \nholy lake makes you feel fine again...";
}
public void setAction() {
actionLock++;
if(actionLock != 120) return; //lock action for x frames
Random rand = new Random();
int i = rand.nextInt(100)+1; //Generate number between 1 and 100
if(i <= 25) direction = Direction.UP;
if(i > 25 && i <= 50) direction = Direction.DOWN;
if(i > 50 && i <= 75) direction = Direction.LEFT;
if(i > 75) direction = Direction.RIGHT;
actionLock = 0;
}
}