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

2013/7/21

How to make a Crab each time it moves it uses 1/20 of a Worm worth of energy

1
2
3
4
regba regba

2013/7/22

#
OK I understand for the negative number, that means I can leave it as it is then. what about the option for crabs dying because they eat all the worms, I guess it will never happens because the moves will occur before they eat all the worms, am I correct?
danpost danpost

2013/7/22

#
It is possible that the majority of the time that could be the case. It really depends on a lot of things (the size of the world, the size of the actors, the distance moved per act, ratio of crabs to worms, and even the way the actors move could be an influence among other things). However, if there is ANY chance that the worms are all eaten before all the crabs die, then you should have code in your project to stop the scenario when this condition occurs.
navydoc6436 navydoc6436

2013/7/22

#
regba post your code and I can let you know so it can be modified. Did it last semester.
regba regba

2013/7/22

#
OK. I thank you very much danpost for sticking up with me all this time, and I thank all of you who also help me out for this project. I know one thing Coding is interesting but NOT easy at ALL!!! Thank you very much.
navydoc6436 navydoc6436

2013/7/22

#
regba have you solved everything else? Or is this all you need help with now? If so post your crab class code and I can let you know what the issues is
navydoc6436 navydoc6436

2013/7/22

#
It would be a great help to others with the same issue since the greenfoot labs tend to be the same for all teachers.
regba regba

2013/7/22

#
Check on the second page the codes I pasted the code there.
navydoc6436 navydoc6436

2013/7/22

#
Didn't see anything that solved your R6
regba regba

2013/7/22

#
wormsEaten = wormsEaten - 1; //R6 if (wormsEaten == 0) // R6 { getWorld().removeObject(this); }
navydoc6436 navydoc6436

2013/7/22

#
Just wanted to let you know that code is incorrect. Your not getting rid of the crabs at the required 0 worms
danpost danpost

2013/7/22

#
Actually, the code is correct. And, it is the code that is required for R6.
regba regba

2013/7/22

#
Yes I know I brought it up to danpost, and this is what he said: It is possible that the majority of the time that could be the case (to eat all the worms). It really depends on a lot of things (the size of the world, the size of the actors, the distance moved per act, ratio of crabs to worms, and even the way the actors move could be an influence among other things). However, if there is ANY chance that the worms are all eaten before all the crabs die, then you should have code in your project to stop the scenario when this condition occurs.
danpost danpost

2013/7/22

#
(to eat all the worms): I did not say that (or mean that). You said that the crabs run out of energy and die before all the worms are eaten. And, I was saying that this could be the case most of the time (to NOT eat all the worms before all the crabs run out of energy and die).
regba regba

2013/7/22

#
No it is not before, it is either or. Here are the choices: Once a Crab has reached zero Worms eaten, it dies and disappears from the world. Stop the game once all the Worms have been eaten or all the Crabs have died.
regba regba

2013/7/22

#
What am I doing wrong?
There are more replies on the next page.
1
2
3
4