does anyone know how to make an object fall randomly? Like I'm making a game and I want stuff to move down randomly
public void WorldName()
{
//add this 'false', so objects can be outside the world boundaries
super(/*x*/, /*y*/, 1, false);
}
public void act()
{
if (Greenfoot.getRandomNumber(100))
{
addObject(new Block(), 5+Greenfoot.getRandomNumber(getWidth()-6), -5);
}
}public Block()
{
GreenfootImage img = new GreenfootImage(11,11);
img.fill();
setImage(img);
}
public void act()
{
setLocation(getX(), getY()+1); //higher number = faster falling
if (getY() > getWorld().getHeight()) removeObject(this);
}