This site requires JavaScript, please enable it in your browser!
Greenfoot back
Game/maniac
Game/maniac wrote ...

2013/1/12

Why does the AI not work

Game/maniac Game/maniac

2013/1/12

#
I am try to make an AI for an enemy but for some reason the enemy only travels up and left. This is the moving code:
public void ovalMove()
    {
        int RandomMoveX = Greenfoot.getRandomNumber(1);
        int RandomMoveY = Greenfoot.getRandomNumber(1);
        if(RandomMoveX == 0 && !WallL())
        {
            setLocation(getX()-4, getY());
        }else if(RandomMoveX == 1 && !WallR()){
            setLocation(getX()+4, getY());
        }
        if(RandomMoveY == 0 && !Ceiling()){
            setLocation(getX(), getY()-4);
        }else if(RandomMoveY == 1 && !Ground()){
            setLocation(getX(), getY()+4);
        }
    }
Game/maniac Game/maniac

2013/1/12

#
never mind I fixed it
You need to login to post a reply.