I need help getting my Creeps spawning into my world. I have tried a lot of things and cannot figure it out. here is the code:
Creepers super Class:
public static int type;
int[]WayX;
int[]WayY;
int index=0;
double distance=150;
private int max=20;
private int spawn=0;
private static int hp;
private static int speed;
static Counter counter;
public Creepers(int hp,int speed)
{
this.hp=hp;
this.speed=speed;
setRotation(90);
if (IntroScreen.level==3)
{
setRotation(180);
}
}
public void act()
{
spawn(hp,speed);
Waypoints();
}
public void Waypoints()
{
if(IntroScreen.level == 1)
{
WayX= new int[]{94,94,188,188,281,281,374,374,467,467,563,563,599};
WayY= new int[]{108,223,223,28,28,372,372,83,83,314,314,140,140};
move();
}else if (IntroScreen.level == 2){
WayX= new int[] {478,487,272,272,599};
WayY= new int[]{171,380,380,19,19};
move();
}else if (IntroScreen.level == 3){
WayX=new int[] {355,246,246,463,463,134,134,572,572,27,27};
WayY=new int[] {248,248,115,115,314,314,49,49,381,381,10};
move();
}else if (IntroScreen.level == 4){
WayX= new int[]{319,319,56,56,431,431,525,525,599};
WayY= new int[]{376,21,21,288,288,21,21,375,375};
move();
}
}
public void spawn(int hp, int speed)
{
Creepers creeper = new Creepers(hp,speed);
int random= (int)((Math.random()*3));
random=type;
if( getWorld().setBackground(Stage1.class) )
{
if(random==1)getWorld().addObject(creeper,0,108);
if(random==2)getWorld().addObject(creeper,0,108);
if(random==3)getWorld().addObject(creeper,0,108);
}
if (IntroScreen.level ==2)
{
if(random==1)getWorld().addObject(creeper,0,171);
if(random==2)getWorld().addObject(creeper,0,171);
if(random==3)getWorld().addObject(creeper,0,171);
}
if (IntroScreen.level == 3)
{
if(random==1)getWorld().addObject(creeper,0,248);
if(random==2)getWorld().addObject(creeper,0,248);
if(random==3)getWorld().addObject(creeper,0,248);
}
if (IntroScreen.level == 4)
{
if(random==1)getWorld().addObject(creeper,0,376);
if(random==2)getWorld().addObject(creeper,0,376);
if(random==3)getWorld().addObject(creeper,0,376);
}
System.out.println(random);
}
public void move()
{
move(1);
double theDistance = (int)(Math.hypot(WayX[index] - getX(), WayY[index] - getY()));
if (theDistance < .01 )
{
for (int i=0;i<theDistance;i++)
{
distance=theDistance;
index++;
}
}
turnTowards(WayX[index], WayY[index]);
if(count>=425&&spawn>=445)
{
getWorld().removeObject(this);
}
}
// public void death()
// {
// World world = getWorld();
// if ((getWorld!=null)&&())
// {
//
// }
// }
}

