Could someone please post the coding to make the AI (computer controlled player) to move randomly and kill the player on impact?


1 2 3 4 | if (Greenfoot.getRandomNumber(how often you want the action to happen, 2 =very often 100 +=less often)== 0 ) { //action goes here } |
1 2 3 4 5 6 7 8 | public void act() { Actor actor = getOneIntersectingObject(enemy. class ); if (actor != null ) { getWorld().removeObject( this ); } } |
1 2 3 4 | if (Greenfoot.getRandomNumber( 5 )== 0 ) { setLocation(getX()+ 5 , getY()); } |
1 2 3 4 5 6 7 8 | public void act() { Actor actor = getOneIntersectingObject(enemy. class ); if (actor != null ) { getWorld().removeObject( this ); } } |
1 2 3 4 5 6 7 | public void act() { if (Greenfoot.getRandomNumber( 5 )== 0 ) { setLocation(getX()+ 5 , getY()); } } |