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

2013/2/16

HELP!

zxcvbnmuluk zxcvbnmuluk

2013/2/16

#
how to make a life in little crab scenarios? and how to make if crab eat 3 worms add 1 lobster. PLEASE THE CODE, HELP ME. thanks
-nic- -nic-

2013/2/16

#
First im not sure as to what your first question is, more details would be helpful, For the eating of the wroms to add lobsters i assume you have got the code to eat the lobster, You would need to create a varible to hold the amount worms eaten by the crab In the Crab class add this
public int WormsEaten = 0;
Then every time the crab eats a worm add the line to the method called:
WormsEaten++;
Then to test if the crab has eaten three worms add the code:
if(WormsEaten>3)
{
  WormsEaten=-3;
  Lobster lob = new Lobster();
  getWorld().addObject(lob,Put in X and ,Y postion)
}
You need to login to post a reply.