diff --git a/res/images/hpb_shout.png b/res/images/hpb_shout.png new file mode 100644 index 0000000..caf9b9a Binary files /dev/null and b/res/images/hpb_shout.png differ diff --git a/src/de/teamteamteam/spacescooter/entity/FlashImage.java b/src/de/teamteamteam/spacescooter/entity/FlashImage.java new file mode 100644 index 0000000..9c8f915 --- /dev/null +++ b/src/de/teamteamteam/spacescooter/entity/FlashImage.java @@ -0,0 +1,43 @@ +package de.teamteamteam.spacescooter.entity; + +/** + * Image that will position itself centered on the given position and lives for a + * short period of time. + */ +public class FlashImage extends Entity { + + /** + * Internal lifetime counter. + */ + private int lifetime; + + /** + * Internal tick counter. + */ + private int tickCounter; + + /** + * Default constructor. + */ + public FlashImage(int x, int y, String imagefilename, int lifetime) { + super(x, y); + this.setImage(imagefilename); + this.setPosition(x - (this.getImageWidth()/2), y - (this.getImageHeight()/2)); + this.lifetime = lifetime; + } + + /** + * Just wait for the time to run out and remove itself after that. + */ + public void update() { + this.tickCounter++; + if(tickCounter == 10) { + this.lifetime--; + if(this.lifetime == 0) { + this.remove(); + } + this.tickCounter = 0; + } + } + +} diff --git a/src/de/teamteamteam/spacescooter/entity/Player.java b/src/de/teamteamteam/spacescooter/entity/Player.java index f948047..7377ede 100644 --- a/src/de/teamteamteam/spacescooter/entity/Player.java +++ b/src/de/teamteamteam/spacescooter/entity/Player.java @@ -225,6 +225,7 @@ public class Player extends ShootingEntity implements KeyboardListener { @Override public void createBeam() { super.createBeam(); + new FlashImage(this.getX(), this.getY(), "images/hpb_shout.png", 3); this.removeSecondaryWeaponAmount(); }