added monster damage
This commit is contained in:
@@ -34,10 +34,10 @@ public class Player extends Entity {
|
||||
}
|
||||
|
||||
public void setDefaultValues() {
|
||||
// worldX = panel.tileSize * 23;
|
||||
// worldY = panel.tileSize * 21;
|
||||
worldX = panel.tileSize * 10;
|
||||
worldY = panel.tileSize * 13;
|
||||
worldX = panel.tileSize * 23;
|
||||
worldY = panel.tileSize * 21;
|
||||
// worldX = panel.tileSize * 10;
|
||||
// worldY = panel.tileSize * 13;
|
||||
speed = 4;
|
||||
direction = Direction.DOWN;
|
||||
|
||||
@@ -79,6 +79,7 @@ public class Player extends Entity {
|
||||
|
||||
// CHECK MONSTER COLLISION
|
||||
int monsterIndex = panel.collisionH.checkEntity(this, panel.monster);
|
||||
interactMonster(monsterIndex);
|
||||
|
||||
// CHECK EVENT
|
||||
panel.eventH.checkEvent();
|
||||
@@ -102,6 +103,25 @@ public class Player extends Entity {
|
||||
spriteCounter = 0;
|
||||
}
|
||||
}
|
||||
if(!invincible) return;
|
||||
invincibleCount++;
|
||||
if(invincibleCount > 60) {
|
||||
invincible = false;
|
||||
invincibleCount = 0;
|
||||
}
|
||||
}
|
||||
|
||||
public void draw(Graphics2D graphics2d) {
|
||||
int screenX = worldX - panel.player.worldX + panel.player.screenX;
|
||||
int screenY = worldY - panel.player.worldY + panel.player.screenY;
|
||||
|
||||
if(invincible) {
|
||||
graphics2d.setComposite(AlphaComposite.getInstance(AlphaComposite.SRC_OVER, 0.3f));
|
||||
}
|
||||
|
||||
graphics2d.drawImage(parseSprite(), screenX, screenY, null);
|
||||
|
||||
graphics2d.setComposite(AlphaComposite.getInstance(AlphaComposite.SRC_OVER, 1f));
|
||||
}
|
||||
|
||||
public void pickObject(int index) {
|
||||
@@ -115,8 +135,11 @@ public class Player extends Entity {
|
||||
panel.npc[index].speak();
|
||||
}
|
||||
|
||||
public void draw(Graphics2D graphics2d) {
|
||||
graphics2d.drawImage(parseSprite(), screenX, screenY, null);
|
||||
public void interactMonster(int index) {
|
||||
if(index == 999) return;
|
||||
if(invincible) return;
|
||||
life -= 1;
|
||||
invincible = true;
|
||||
}
|
||||
|
||||
public void speak() {
|
||||
|
||||
Reference in New Issue
Block a user