I'm a first time programmer. :( What would be the code I need to like switch to a "next level" screen after killing 2 enemies? I'm trying to make a tank game, and here is the code for the good tank's bullet:
I sort of don't know what to do if there's more than 1 tank. How do I go from the game world to the "proceed to the next level" screen?
int count=0;
public void act()
{
count++;
move(10);
World world = getWorld();
Actor Evil_Tank;
Evil_Tank = getOneObjectAtOffset(0, 0, Evil_Tank.class);
if(Evil_Tank !=null)
{
world.removeObject(Evil_Tank);
world.addObject(new Explosion(), getX(), getY());
Greenfoot.playSound("Explosion.wav");
victory();
}
else
{
{
if(getX() <= 5)
setLocation(world.getWidth()-8, getY());
if(getX() >= world.getWidth()-5)
setLocation(10, getY());
if(getY() <= 5)
setLocation(getX(), world.getHeight()-8);
if(getY() >= world.getHeight()-5)
setLocation(getX(), 10);
}
if(count==55)
world.removeObject(this);
}
}
public void victory()
{
Win_Screen win_screen = new Win_Screen();
Greenfoot.setWorld(win_screen);
((Game_World)getWorld()).sound2.stop();
}
}
