I'm making a game that has a percent chance to change the image of an actor if it is next to a certain actor. How do I do this?
if (Greenfoot.getRandomNumber(100) < 20) { // change the image here }
public boolean infect; { World theWorld = getWorld(); if (Greenfoot.getRandomNumber(100) < 25) { setImage("ppl2.gif"); } List Uninfect = getObjectsInRange(2, InfectLv1.class); if(Uninfect.isEmpty()) return false; else { return true; }
public boolean infect() { // code here }
if (Uninfect.isEmpty()) { return false; } else { return true; }
return !Uninfect.isEmpty();
return !(Uninfect.isEmpty());
return ((getObjectsInRange(2,InfectLv1.class)).size() != 0);
public boolean infect() { World theWorld = getWorld(); if (Greenfoot.getRandomNumber(100) < 100) <set for 100% { setImage("ppl2.gif"); } { return ((getObjectsInRange(2, InfectLv1.class)).size() != 0); } }