Add HPB to the beam weapon :3

This commit is contained in:
Jan Philipp Timme 2015-01-06 13:35:02 +01:00
parent fc762b3caf
commit ce668182ed
3 changed files with 44 additions and 0 deletions

BIN
res/images/hpb_shout.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 38 KiB

View File

@ -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;
}
}
}

View File

@ -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();
}