added monster damage
This commit is contained in:
@@ -4,6 +4,7 @@ import de.miaurizius.jgame2d.core.Boot;
|
||||
import de.miaurizius.jgame2d.core.enums.Direction;
|
||||
import de.miaurizius.jgame2d.core.GamePanel;
|
||||
import de.miaurizius.jgame2d.core.Utility;
|
||||
import de.miaurizius.jgame2d.core.enums.EntityType;
|
||||
|
||||
import javax.imageio.ImageIO;
|
||||
import java.awt.*;
|
||||
@@ -25,11 +26,14 @@ public class Entity {
|
||||
public int solidAreaDefaultX, solidAreaDefaultY;
|
||||
public boolean collisionOn = false;
|
||||
public int actionLock = 0;
|
||||
public boolean invincible = false;
|
||||
public int invincibleCount = 0;
|
||||
String[] dialogue = new String[20];
|
||||
int dialogueIndex = 0;
|
||||
public BufferedImage image, image2, image3;
|
||||
public String name;
|
||||
public boolean collision = false;
|
||||
public EntityType type;
|
||||
|
||||
// CHARACTER STATUS
|
||||
public int maxLife;
|
||||
@@ -61,7 +65,13 @@ public class Entity {
|
||||
panel.collisionH.checkObject(this, false);
|
||||
panel.collisionH.checkEntity(this, panel.npc);
|
||||
panel.collisionH.checkEntity(this, panel.monster);
|
||||
panel.collisionH.checkPlayer(this);
|
||||
boolean contactPlayer = panel.collisionH.checkPlayer(this);
|
||||
|
||||
if(this.type == EntityType.MONSTER && contactPlayer) {
|
||||
if(panel.player.invincible) return;
|
||||
panel.player.life -= 1;
|
||||
panel.player.invincible = true;
|
||||
}
|
||||
|
||||
if(!collisionOn) {
|
||||
switch (direction) {
|
||||
@@ -81,7 +91,7 @@ public class Entity {
|
||||
}
|
||||
}
|
||||
|
||||
public void draw(Graphics graphics2d) {
|
||||
public void draw(Graphics2D graphics2d) {
|
||||
int screenX = worldX - panel.player.worldX + panel.player.screenX;
|
||||
int screenY = worldY - panel.player.worldY + panel.player.screenY;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user