Spawn Explosions centered, add getter for centered coordinates.

This commit is contained in:
Jan Philipp Timme 2014-11-28 23:29:56 +01:00
parent b8b0023b02
commit 9a3ac5c9af
7 changed files with 22 additions and 8 deletions

View File

@ -80,19 +80,33 @@ public abstract class Entity implements Updateable, Paintable {
/**
* Get the X-Position of the Entity.
* Get the X-Position of the Entity. (top left corner)
*/
public int getX() {
return this.x;
}
/**
* Get the Y-Position of the Entity.
* Get the Y-Position of the Entity. (top left corner)
*/
public int getY() {
return this.y;
}
/**
* Get the centered X-Position of the Entity.
*/
public int getCenteredX() {
return this.x + (this.width / 2);
}
/**
* Get the centered Y-Position of the Entity.
*/
public int getCenteredY() {
return this.y + (this.height / 2);
}
/**
* Set the Entities new absolute position.
*/

View File

@ -38,7 +38,7 @@ public class EnemyBoss extends Enemy{
*/
@Override
public void explode() {
new MultiExplosion(this.getX(), this.getY());
new MultiExplosion(this.getCenteredX(), this.getCenteredY());
}
@Override

View File

@ -38,7 +38,7 @@ public class EnemyBossMinion extends Enemy{
* Custom MultiExplosion for this enemy.
*/
public void explode() {
new MultiExplosion(this.getX(), this.getY());
new MultiExplosion(this.getCenteredX(), this.getCenteredY());
}
@Override

View File

@ -68,7 +68,7 @@ public class EnemyFour extends Enemy{
@Override
public void explode() {
new ExplosionOne(this.getX(), this.getY());
new ExplosionOne(this.getCenteredX(), this.getCenteredY());
}
}

View File

@ -25,7 +25,7 @@ public class EnemyOne extends Enemy {
@Override
public void explode() {
new ExplosionOne(this.getX(), this.getY());
new ExplosionOne(this.getCenteredX(), this.getCenteredY());
}
}

View File

@ -41,7 +41,7 @@ public class EnemyThree extends Enemy{
*/
@Override
public void explode() {
new MultiExplosion(this.getX(), this.getY());
new MultiExplosion(this.getCenteredX(), this.getCenteredY());
}
@Override

View File

@ -32,7 +32,7 @@ public class EnemyTwo extends Enemy{
@Override
public void explode() {
new ExplosionTwo(this.getX(), this.getY());
new ExplosionTwo(this.getCenteredX(), this.getCenteredY());
}
}