Compare commits

...

2 Commits

2 changed files with 14 additions and 18 deletions

View File

@@ -121,7 +121,8 @@ public class Entity {
knockback = false; knockback = false;
knockbackCount = 0; knockbackCount = 0;
speed = defaultSpeed; speed = defaultSpeed;
} else if(attacking) attacking(); else { } else if(attacking) attacking();
else {
setAction(); setAction();
checkCollision(); checkCollision();
@@ -182,7 +183,6 @@ public class Entity {
hpBarCount = 0; hpBarCount = 0;
changeOpacity(graphics2d, 0.4f); changeOpacity(graphics2d, 0.4f);
} }
//TODO: fix attacking sprite drawing position for monsters
if(dying) dyingAnimation(graphics2d); if(dying) dyingAnimation(graphics2d);
if(type == EntityType.PLAYER || name.equals("orc")) { // only modify sprite render position for player because I dont know yet how monster attack sprite are gonna look if(type == EntityType.PLAYER || name.equals("orc")) { // only modify sprite render position for player because I dont know yet how monster attack sprite are gonna look
if(attacking) graphics2d.drawImage(parseSpriteATK(), if(attacking) graphics2d.drawImage(parseSpriteATK(),
@@ -223,7 +223,7 @@ public class Entity {
solidArea.width = attackArea.width; solidArea.width = attackArea.width;
solidArea.height = attackArea.height; solidArea.height = attackArea.height;
if(type == EntityType.MONSTER) if(panel.collisionH.checkPlayer(this)) damagePlayer(attackValue); if(type == EntityType.MONSTER) if(panel.collisionH.checkPlayer(this)) damagePlayer(attack);
if(type == EntityType.PLAYER) { if(type == EntityType.PLAYER) {
int monsterIndex = panel.collisionH.checkEntity(this, panel.monster[panel.currentMap.getIndex()]); int monsterIndex = panel.collisionH.checkEntity(this, panel.monster[panel.currentMap.getIndex()]);
@@ -400,7 +400,7 @@ public class Entity {
return Math.abs(worldY - target.worldY); return Math.abs(worldY - target.worldY);
} }
public int dTile(Entity target) { public int dTile(Entity target) {
if(Objects.equals(name, "orc")) System.out.println("dX: " + dX(target) + " dY: " + dY(target)); //if(Objects.equals(name, "orc")) System.out.println("dX: " + dX(target) + " dY: " + dY(target));
return (dX(target) + dY(target)) / panel.tileSize; return (dX(target) + dY(target)) / panel.tileSize;
} }
public int getGoalCol(Entity target) { public int getGoalCol(Entity target) {
@@ -532,7 +532,7 @@ public class Entity {
} }
} }
public void checkStopChasing(Entity target, int distance, int rate) { public void checkStopChasing(Entity target, int distance, int rate) {
if(Objects.equals(name, "orc")) System.out.println("dTile: " + dTile(target) + " distance: " + distance); //if(Objects.equals(name, "orc")) System.out.println("dTile: " + dTile(target) + " distance: " + distance);
if(dTile(target) > distance) onPath = false; if(dTile(target) > distance) onPath = false;
} }
public void checkStartChasing(Entity target, int distance, int rate) { public void checkStartChasing(Entity target, int distance, int rate) {

View File

@@ -39,12 +39,8 @@ public class OrcMON extends Entity {
// INTERACTION // INTERACTION
public void setAction() { public void setAction() {
if(!onPath) checkStartChasing(panel.player, 10 ,100); if(!onPath) checkStartChasing(panel.player, 10 ,100); else followPlayer();
checkStopChasing(panel.player, 15, 100); checkStopChasing(panel.player, 15, 100);
if(onPath) {
followPlayer();
return;
}
setRandomDirection(); setRandomDirection();
if(!attacking) checkAttack(30, panel.tileSize*4, panel.tileSize); if(!attacking) checkAttack(30, panel.tileSize*4, panel.tileSize);
} }
@@ -71,13 +67,13 @@ public class OrcMON extends Entity {
right2 = initEntitySprites("monster/orc_right_2"); right2 = initEntitySprites("monster/orc_right_2");
} }
public void getAttackImage() { public void getAttackImage() {
attackUp1 = initEntitySprites("monster/orc_attack_up_1"); attackUp1 = initEntitySprites("monster/orc_attack_up_1", panel.tileSize, panel.tileSize * 2);
attackUp2 = initEntitySprites("monster/orc_attack_up_2"); attackUp2 = initEntitySprites("monster/orc_attack_up_2", panel.tileSize, panel.tileSize * 2);
attackDown1 = initEntitySprites("monster/orc_attack_down_1"); attackDown1 = initEntitySprites("monster/orc_attack_down_1", panel.tileSize, panel.tileSize * 2);
attackDown2 = initEntitySprites("monster/orc_attack_down_2"); attackDown2 = initEntitySprites("monster/orc_attack_down_2", panel.tileSize, panel.tileSize * 2);
attackLeft1 = initEntitySprites("monster/orc_attack_left_1"); attackLeft1 = initEntitySprites("monster/orc_attack_left_1", panel.tileSize*2, panel.tileSize);
attackLeft2 = initEntitySprites("monster/orc_attack_left_2"); attackLeft2 = initEntitySprites("monster/orc_attack_left_2", panel.tileSize*2, panel.tileSize);
attackRight1 = initEntitySprites("monster/orc_attack_right_1"); attackRight1 = initEntitySprites("monster/orc_attack_right_1", panel.tileSize*2, panel.tileSize);
attackRight2 = initEntitySprites("monster/orc_attack_right_2"); attackRight2 = initEntitySprites("monster/orc_attack_right_2", panel.tileSize*2, panel.tileSize);
} }
} }