I want to check if the location that the code randomly chose is randomly chosen or not, but it seems like i cant get it working...
can someone teach me what did i do wrong and what's the correct way to do it?
here's the entire world code:
import greenfoot.*;
public class Minigame1 extends World
{
private Actor Walls = new SimpleActor();
private Actor MiniTaihei = new SimpleActor();
SimpleActor walls = new SimpleActor();
public Minigame1()
{
super(20, 10, 30);
// setBackground
GreenfootImage bg = new GreenfootImage("sand2.jpg");
bg.scale(getCellSize(), getCellSize());
setBackground(bg);
// add actor to world
addObject(MiniTaihei, 0, 9);
}
public void act()
{
for (int i = 0; i <= 15;)
{
int RandX = (1 + Greenfoot.getRandomNumber(19));
int RandY = (Greenfoot.getRandomNumber(9));
while (getObject(RandX, RandY)!=null)
{
int RandX = (1 + Greenfoot.getRandomNumber(19));
int RandY = (Greenfoot.getRandomNumber(9));
}
addObject(walls, RandX, RandY);
i++;
}
}
}

