Files
JGame2D/src/de/miaurizius/jgame2d/tile/interactive/InteractiveTile.java

55 lines
1.5 KiB
Java

package de.miaurizius.jgame2d.tile.interactive;
import de.miaurizius.jgame2d.core.GamePanel;
import de.miaurizius.jgame2d.entity.Entity;
import java.awt.*;
public class InteractiveTile extends Entity {
GamePanel panel;
public boolean destructible;
public InteractiveTile(GamePanel panel, int col, int row) {
super(panel);
this.panel = panel;
}
// GENERAL
@Override
public void update() {
// INVINCIBLE COUNTER
if(!invincible) return;
invincibleCount++;
if(invincibleCount > 20) {
invincible = false;
invincibleCount = 0;
}
}
@Override
public void draw(Graphics2D graphics2D) {
int screenX = worldX - panel.player.worldX + panel.player.screenX;
int screenY = worldY - panel.player.worldY + panel.player.screenY;
if(worldX + panel.tileSize > panel.player.worldX - panel.player.screenX &&
worldX - panel.tileSize < panel.player.worldX + panel.player.screenX &&
worldY + panel.tileSize > panel.player.worldY - panel.player.screenY &&
worldY - panel.tileSize < panel.player.worldY + panel.player.screenY
) {
graphics2D.drawImage(down1, screenX, screenY, null);
}
}
// PRE-CONFIGURED
public void playSE() {}
// UTILITY
public boolean meetItemReq(Entity entity) {
return false;
}
public InteractiveTile getDestroyedForm() {
return null;
}
}