Explosions added. They explode.

This commit is contained in:
Licht 2014-10-31 12:10:41 +01:00
parent 617d0c2da1
commit 68a0d139af
3 changed files with 47 additions and 0 deletions

View File

@ -0,0 +1,44 @@
package de.teamteamteam.spacescooter.entity;
public class Explosion extends Entity {
private int count = 71;
public Explosion(int x, int y) {
super(x, y);
this.setImage("images/explosion1.png");
this.setPosition(x - (this.getWidth()/2), y - (this.getHeight()/2));
}
public void update() {
if (count >= 0) {
count--;
} else {
this.remove();
}
switch (count) {
case 70:
this.setImage("images/explosion1.png");
break;
case 60:
this.setImage("images/explosion2.png");
break;
case 50:
this.setImage("images/explosion3.png");
break;
case 40:
this.setImage("images/explosion4.png");
break;
case 30:
this.setImage("images/explosion5.png");
break;
case 20:
this.setImage("images/explosion6.png");
break;
case 10:
this.setImage("images/explosion7.png");
break;
}
}
}

View File

@ -79,6 +79,7 @@ public abstract class LivingEntity extends Entity implements Collidable {
this.healthPoints -= damage;
if (this.isAlive() == false) {
if(GameConfig.DEBUG) System.out.println(this + " ist gestorben. RIP");
Screen.currentScreen.addEntity(new Explosion(this.x, this.y));
this.remove();
}
}

View File

@ -9,6 +9,7 @@ import de.teamteamteam.spacescooter.background.StarBackground;
import de.teamteamteam.spacescooter.control.Keyboard;
import de.teamteamteam.spacescooter.entity.EnemyOne;
import de.teamteamteam.spacescooter.entity.Entity;
import de.teamteamteam.spacescooter.entity.Explosion;
import de.teamteamteam.spacescooter.entity.Player;
public class GameScreen extends Screen {
@ -21,6 +22,7 @@ public class GameScreen extends Screen {
this.entities.add(new EnemyOne(450, 100));
this.entities.add(new EnemyOne(750, 550));
this.entities.add(new EnemyOne(150, 250));
this.entities.add(new Explosion(200, 200));
}
@Override