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

2012/11/24

NEED HELP-

1
2
danpost danpost

2012/11/24

#
Where is the condition I said you should put in there? That method should look more like the following at this point:
private void eat()
{
    Actor food=getOneObjectAtOffset(0, 0, Food.class);
    if (food!=null){
        SnakeEarth snakeEarth=(SnakeEarth)getWorld();
        snakeEarth.removeObject(food);
        if(length<10) {
            snakeEarth.addArray();
            snakeEarth.snake[length]=new Snake();
            snakeEarth.addObject(snakeEarth.snake[length], getX(), getY());
            length++;
        }
    }
}
which adds the condition that the length be less than 10 in order to increase the size of the snake.
myheartwillgoon myheartwillgoon

2012/11/24

#
Ohh Thanks a lot danpost. Now it works fine. But you are great danpost coz u reply every post very instance, I mean very quick. May God bless you (if u beleive in God) and I really wish u to live every day, every moment very nicely without having any difficulties... Here is not the End, I will come with my more problems and questions later...
danpost danpost

2012/11/25

#
May you also continue centered on God and his good graces, with thanksgiving in all things.
You need to login to post a reply.
1
2