Add isVisible method
This commit is contained in:
parent
c3d05b56bb
commit
987e7b82e0
@ -13,24 +13,28 @@ public class Enemy {
|
||||
private static final int enemyHeight = enemy.getHeight();
|
||||
|
||||
private final int x, y;
|
||||
private boolean isVisible;
|
||||
private boolean visible;
|
||||
|
||||
public Enemy(int x, int y) {
|
||||
this.x = x;
|
||||
this.y = y;
|
||||
isVisible = true;
|
||||
visible = true;
|
||||
}
|
||||
|
||||
public boolean isVisible() {
|
||||
return visible;
|
||||
}
|
||||
|
||||
public boolean isCollide(int sx, int sy) {
|
||||
if (inRange(sx, x, x + enemyWidth) && inRange(sy, y, y + enemyHeight)) {
|
||||
isVisible = false;
|
||||
visible = false;
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public void draw(Graphics g) {
|
||||
if (isVisible) {
|
||||
if (visible) {
|
||||
g.drawImage(enemy, x, y);
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user