added hit detection when player hits monsters
This commit is contained in:
@@ -20,6 +20,7 @@ public class Entity {
|
||||
public BufferedImage attackUp1, attackUp2, attackDown1, attackDown2, attackLeft1, attackLeft2, attackRight1, attackRight2;
|
||||
public BufferedImage image, image2, image3;
|
||||
public Rectangle solidArea = new Rectangle(0, 0, 48, 48);
|
||||
public Rectangle attackArea = new Rectangle(0, 0, 0, 0);
|
||||
public int solidAreaDefaultX, solidAreaDefaultY;
|
||||
public boolean collision = false;
|
||||
String[] dialogue = new String[20];
|
||||
@@ -119,6 +120,15 @@ public class Entity {
|
||||
};
|
||||
}
|
||||
|
||||
BufferedImage parseSpriteATK() {
|
||||
return switch (direction) {
|
||||
case UP -> (spriteNum == 1) ? attackUp1 : attackUp2;
|
||||
case DOWN -> (spriteNum == 1) ? attackDown1 : attackDown2;
|
||||
case LEFT -> (spriteNum == 1) ? attackLeft1 : attackLeft2;
|
||||
case RIGHT -> (spriteNum == 1) ? attackRight1 : attackRight2;
|
||||
};
|
||||
}
|
||||
|
||||
public BufferedImage initEntitySprites(String name) {
|
||||
try {
|
||||
return Utility.scaleImage(ImageIO.read(new FileInputStream("assets/" + name + ".png")), panel.tileSize, panel.tileSize);
|
||||
|
||||
Reference in New Issue
Block a user