Skip to content

Commit

Permalink
bug fix for bomb animation with finishpoint
Browse files Browse the repository at this point in the history
  • Loading branch information
Phhere committed Jun 14, 2012
1 parent 88ba618 commit f00a7e5
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 33 deletions.
61 changes: 29 additions & 32 deletions src/entities/BombAnimation.java
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,8 @@ public class BombAnimation extends Entity {
*/
private int killDelay;

private ArrayList<Entity> toPlace = new ArrayList<Entity>();

/**
* @param x
* @param y
Expand All @@ -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;
}
Expand All @@ -73,43 +75,40 @@ 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)));
}
}
}
} else if (this.explosionTime < (this.exposionTimeDefault * 0.9)) {
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) {
Expand All @@ -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);
}
}

Expand All @@ -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);

}

Expand Down Expand Up @@ -213,4 +206,8 @@ public void collide(Entity e) {
}
}
}

public void addAfterExplosion(Entity e) {
this.toPlace.add(e);
}
}
2 changes: 1 addition & 1 deletion src/entities/WallWithFinishingPoint.java
Original file line number Diff line number Diff line change
Expand Up @@ -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));
}
}
}

0 comments on commit f00a7e5

Please sign in to comment.