private int shootTimer = 0;
boolean invincible = false;
private int invincibleTimer = 0;
private int cooldownTimer = 0;
/**
* Act - do whatever the Player_1 wants to do. This method is called whenever
* the 'Act' or 'Run' button gets pressed in the environment.
*/
public void act()
{
//The Planes actions
move();
shootTimer++;
shoot();
hit();
invincible();
invincibleTimer++;
cooldownTimer ++;
}
public void invincible()
{
if (Greenfoot.isKeyDown("i") && cooldownTimer >= 120)
{
invincible = true;
this.setImage(new GreenfootImage("Player 1 Inv.png"));
invincibleTimer = 0;
}
if (invincibleTimer >=90)
{
invincible = false;
this. setImage(new GreenfootImage("Player 1.png"));
//cooldownTimer = 0; <-- as soon as bring it in it disables the powerup
}
}
