Could someone please post the coding to make the AI (computer controlled player) to move randomly and kill the player on impact?
if(Greenfoot.getRandomNumber(how often you want the action to happen, 2=very often 100+=less often)==0)
{
//action goes here
}public void act()
{
Actor actor = getOneIntersectingObject(enemy.class);
if(actor != null)
{
getWorld().removeObject(this);
}
}if(Greenfoot.getRandomNumber(5)==0)
{
setLocation(getX()+5, getY());
}public void act()
{
Actor actor = getOneIntersectingObject(enemy.class);
if(actor != null)
{
getWorld().removeObject(this);
}
}public void act()
{
if(Greenfoot.getRandomNumber(5)==0)
{
setLocation(getX()+5, getY());
}
}