Hi, the main problem of my other post has been resolved now but is there any way to use getX and getY in the world? I'm trying to use it as I used in in my Virus class: gets the X, Y of the Survivor class before it is removed and is replaced by Virus. It works in the Virus class but now I need the world to randomly select a survivor, get its X. Y and replace with Virus at the start of the game.
/**
* Infect a Survivor with Virus
*/
public void infect()
{
if(Greenfoot.getRandomNumber(100) <50)
{
removeObject(SurvivorWASD);
createNewVirusWASD();
}
if(Greenfoot.getRandomNumber(100) >50)
{
removeObject(SurvivorARROW);
}
}
/**
* Create a new Virus(WASD) in the same location as the Survivor was.
*/
private void createNewVirusWASD()
{
VirusWASD newVirusWASD;
newVirusWASD = new VirusWASD();
World world;
world = getTwoPlayer();
int worldWidth = world.getWidth();
int worldHeight = world.getHeight();
int x = getX();
int y = getY();
world.addObject(newVirusWASD, getWidth(), getHeight());
}
