Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

bug fix for bomb animation with finishpoint

  • Loading branch information...
commit f00a7e55fbf288379d1ecf13543ee0d252b9c786 1 parent 88ba618
@Phhere Phhere authored
View
61 src/entities/BombAnimation.java
@@ -38,6 +38,8 @@
*/
private int killDelay;
+ private ArrayList<Entity> toPlace = new ArrayList<Entity>();
+
/**
* @param x
* @param y
@@ -47,8 +49,8 @@ public BombAnimation(int x, int y) {
this.explosionImages = Sprite.load("explosion_temp.png", 100, 100);
this.exposionTimeDefault = 40;
this.explosionTime = this.exposionTimeDefault;
- this.collideMap = new int[][] { { 0, 0, 1, 0, 0 }, { 0, 0, 1, 0, 0 },
- { 1, 1, 1, 1, 1 }, { 0, 0, 1, 0, 0 }, { 0, 0, 1, 0, 0 } };
+ this.collideMap = new int[][] { { 0, 0, 1, 0, 0 }, { 0, 0, 1, 0, 0 }, { 1, 1, 1, 1, 1 }, { 0, 0, 1, 0, 0 },
+ { 0, 0, 1, 0, 0 } };
this.playerKilled = null;
this.killDelay = 10;
}
@@ -73,24 +75,24 @@ public void action(double delta) {
this.explosionTime--;
} else {
this.removed = true;
+ for (Entity e : this.toPlace) {
+ Game.entities.add(e);
+ }
}
List<Entity> entities = null;
- int x_tmp = this.x - (2 * Game.BLOCK_SIZE), y_tmp = this.y
- - (2 * Game.BLOCK_SIZE);
+ int x_tmp = this.x - (2 * Game.BLOCK_SIZE), y_tmp = this.y - (2 * Game.BLOCK_SIZE);
entities = new ArrayList<Entity>();
if (this.explosionTime < (this.exposionTimeDefault * 0.7)) {
for (int x = 0; x < 5; x++) {
for (int y = 0; y < 5; y++) {
if (this.collideMap[y][x] == 1) {
- entities.addAll(Game.getEntities(new Box(x_tmp
- + (x * Game.BLOCK_SIZE), this.y,
+ entities.addAll(Game.getEntities(new Box(x_tmp + (x * Game.BLOCK_SIZE), this.y,
+ Game.BLOCK_SIZE, Game.BLOCK_SIZE)));
+ entities.addAll(Game.getEntities(new Box(this.x, y_tmp + (y * Game.BLOCK_SIZE),
Game.BLOCK_SIZE, Game.BLOCK_SIZE)));
- entities.addAll(Game.getEntities(new Box(this.x, y_tmp
- + (y * Game.BLOCK_SIZE), Game.BLOCK_SIZE,
- Game.BLOCK_SIZE)));
}
}
}
@@ -98,18 +100,15 @@ public void action(double delta) {
for (int x = 1; x < 4; x++) {
for (int y = 1; y < 4; y++) {
if (this.collideMap[y][x] == 1) {
- entities.addAll(Game.getEntities(new Box(x_tmp
- + (x * Game.BLOCK_SIZE), this.y,
+ entities.addAll(Game.getEntities(new Box(x_tmp + (x * Game.BLOCK_SIZE), this.y,
+ Game.BLOCK_SIZE, Game.BLOCK_SIZE)));
+ entities.addAll(Game.getEntities(new Box(this.x, y_tmp + (y * Game.BLOCK_SIZE),
Game.BLOCK_SIZE, Game.BLOCK_SIZE)));
- entities.addAll(Game.getEntities(new Box(this.x, y_tmp
- + (y * Game.BLOCK_SIZE), Game.BLOCK_SIZE,
- Game.BLOCK_SIZE)));
}
}
}
} else {
- entities = Game.getEntities(new Box(this.x, this.y,
- Game.BLOCK_SIZE, Game.BLOCK_SIZE));
+ entities = Game.getEntities(new Box(this.x, this.y, Game.BLOCK_SIZE, Game.BLOCK_SIZE));
}
for (Entity e : entities) {
@@ -128,21 +127,18 @@ public void action(double delta) {
@Override
public void draw(Graphics g) {
- int x_tmp = this.x - (2 * Game.BLOCK_SIZE), y_tmp = this.y
- - (2 * Game.BLOCK_SIZE);
+ int x_tmp = this.x - (2 * Game.BLOCK_SIZE), y_tmp = this.y - (2 * Game.BLOCK_SIZE);
if (this.explosionTime < (this.exposionTimeDefault * 0.7)) {
for (int x = 0; x < 5; x++) {
if (this.collideMap[2][x] == 1) {
- g.drawImage((this.explosionImages[0][0]).image, x_tmp
- + (x * Game.BLOCK_SIZE), this.y, Game.BLOCK_SIZE,
- Game.BLOCK_SIZE, null);
+ g.drawImage((this.explosionImages[0][0]).image, x_tmp + (x * Game.BLOCK_SIZE), this.y,
+ Game.BLOCK_SIZE, Game.BLOCK_SIZE, null);
}
if (this.collideMap[x][2] == 1) {
- g.drawImage((this.explosionImages[2][0]).image, this.x,
- y_tmp + (x * Game.BLOCK_SIZE), Game.BLOCK_SIZE,
- Game.BLOCK_SIZE, null);
+ g.drawImage((this.explosionImages[2][0]).image, this.x, y_tmp + (x * Game.BLOCK_SIZE),
+ Game.BLOCK_SIZE, Game.BLOCK_SIZE, null);
}
}
@@ -152,20 +148,17 @@ else if (this.explosionTime < (this.exposionTimeDefault * 0.9)) {
for (int x = 1; x < 4; x++) {
if (this.collideMap[2][x] == 1) {
- g.drawImage((this.explosionImages[0][0]).image, x_tmp
- + (x * Game.BLOCK_SIZE), this.y, Game.BLOCK_SIZE,
- Game.BLOCK_SIZE, null);
+ g.drawImage((this.explosionImages[0][0]).image, x_tmp + (x * Game.BLOCK_SIZE), this.y,
+ Game.BLOCK_SIZE, Game.BLOCK_SIZE, null);
}
if (this.collideMap[x][2] == 1) {
- g.drawImage((this.explosionImages[2][0]).image, this.x,
- y_tmp + (x * Game.BLOCK_SIZE), Game.BLOCK_SIZE,
- Game.BLOCK_SIZE, null);
+ g.drawImage((this.explosionImages[2][0]).image, this.x, y_tmp + (x * Game.BLOCK_SIZE),
+ Game.BLOCK_SIZE, Game.BLOCK_SIZE, null);
}
}
}
- g.drawImage((this.explosionImages[1][0]).image, this.x, this.y,
- Game.BLOCK_SIZE, Game.BLOCK_SIZE, null);
+ g.drawImage((this.explosionImages[1][0]).image, this.x, this.y, Game.BLOCK_SIZE, Game.BLOCK_SIZE, null);
}
@@ -213,4 +206,8 @@ public void collide(Entity e) {
}
}
}
+
+ public void addAfterExplosion(Entity e) {
+ this.toPlace.add(e);
+ }
}
View
2  src/entities/WallWithFinishingPoint.java
@@ -24,7 +24,7 @@ public void collide(Entity e) {
if (e instanceof BombAnimation) {
this.removed = true;
Game.staticBackground.add(new Background(this.x, this.y));
- Game.entities.add(new Finishpoint(this.x, this.y));
+ ((BombAnimation) e).addAfterExplosion(new Finishpoint(this.x, this.y));
}
}
}
Please sign in to comment.
Something went wrong with that request. Please try again.