import greenfoot.*;
public class Spaceship extends CollisionObjects
{
Explosion hit = new Explosion();
int hitcounter = 0;
int timer = 40;
int aftel = timer;
Healthbar0 healthbar0 = new Healthbar0();
Healthbar1 healthbar1 = new Healthbar1();
Healthbar2 healthbar2 = new Healthbar2();
Healthbar3 healthbar3 = new Healthbar3();
Healthbar4 healthbar4 = new Healthbar4();
Healthbar5 healthbar5 = new Healthbar5();
Healthbar6 healthbar6 = new Healthbar6();
Healthbar7 healthbar7 = new Healthbar7();
Healthbar8 healthbar8 = new Healthbar8();
Healthbar9 healthbar9 = new Healthbar9();
Healthbar10 healthbar10 = new Healthbar10();
public void act()
{
hit();
switch (hitcounter){
case 0:
getWorld().addObject(healthbar0,24,2);
System.out.println("0");
break;
case 1:
getWorld().removeObject(healthbar0);
getWorld().addObject(healthbar1,24,2);
System.out.println("1");
break;
case 2:
getWorld().removeObject(healthbar1);
getWorld().addObject(healthbar2,24,2);
System.out.println("2");
break;
case 3:
getWorld().removeObject(healthbar2);
getWorld().addObject(healthbar3,24,2);
System.out.println("3");
break;
case 4:
getWorld().removeObject(healthbar3);
getWorld().addObject(healthbar4,24,2);
System.out.println("4");
break;
case 5:
getWorld().removeObject(healthbar4);
getWorld().addObject(healthbar5,24,2);
System.out.println("5");
break;
case 6:
getWorld().removeObject(healthbar5);
getWorld().addObject(healthbar6,24,2);
System.out.println("6");
break;
case 7:
getWorld().removeObject(healthbar6);
getWorld().addObject(healthbar7,24,2);
System.out.println("7");
break;
case 8:
getWorld().removeObject(healthbar7);
getWorld().addObject(healthbar8,24,2);
System.out.println("8");
break;
case 9:
getWorld().removeObject(healthbar8);
getWorld().addObject(healthbar9,24,2);
System.out.println("9");
break;
case 10:
getWorld().removeObject(healthbar9);
getWorld().addObject(healthbar10,24,2);
System.out.println("10");
break;
}
}
public void hit(){
Actor BadGuy = getOneIntersectingObject(BadGuy.class);
if(BadGuy != null) {
setImage("broken.jpg");
Greenfoot.playSound("alert.mp3");
Damage hit2 = new Damage();
getWorld().addObject(hit2,30,50);
getWorld().removeObject(BadGuy);
hitcounter++;
}
}
}

