Hey guys I have a game where the Alligator tries to catch all of the frogs before the Camel can reach him. Right now I have it set so if the Camel hits the Alligator the Camel disappears and it is replaced with an image saying "player 2 wins!" I want to make it if the Alligator hits all of the frogs than the Alligator will disappear and it will be replaced with an image that says "Player 1 wins!"
I keep running into an error tho, here is my code
import greenfoot.*; // (World, Actor, GreenfootImage, Greenfoot and MouseInfo)
/**
* Write a description of class Aligator here.
*
* @author (your name)
* @version (a version number or a date)
*/
public class Aligator extends Mover
{
int shootdelay=0;
int mindelay=5;
public void act()
{
//Sets the rocket as a smaller image.
GreenfootImage img = getImage();
setImage(img);
img.scale(120,32);
shootdelay++;
if(getWorld().getObjects(Frog.class) == null || getWorld().getObjects(Frog.class).isEmpty())
{
{ getWorld().removeObject(this);
setImage(new GreenfootImage("player1.jpg"));
setLocation(425, 275);
// GreenfootImage img = getImage();
img.scale(850,550);
Greenfoot.stop();
}
}
if(Greenfoot.isKeyDown("up"))
{
move(5);
int w=getWorld().getWidth();
int h=getWorld().getHeight();
setLocation((getX()+w)%w, ((getY()+h)%h));
}
if (Greenfoot.isKeyDown("left"))
{
turn(-4);
}
if(Greenfoot.isKeyDown("right"))
{
turn(4);
}
if(Greenfoot.isKeyDown("space"))
{
shoot();
}
}
//Shoots the bullet
public void shoot()
{
if(shootdelay >= mindelay)
{
int rot = getRotation()-10;
int xOffset = (int)(40 *Math.cos(Math.toRadians(rot)));
int yOffset = (int)(40 *Math.sin(Math.toRadians(rot)));
Bullet b = new Bullet(getRotation());
getWorld().addObject(b, getX()+xOffset, getY()+yOffset);
shootdelay = 0;
}
}
}


