A new version of this scenario was uploaded on Fri May 04 01:32:05 UTC 2012
*Progressive difficulty: every time you eat a piece of food, the snake moves faster.
*Bug fixes
I'm doing a similar game as a school project, but i am in need of code to make the food spawn randomly on the map over and over again as i eat it. As of now i can only get the food to spawn over and over again in the same place.
Here's an example from my code:
public void placeFood(int amountOfFood)
{
for (int i = 0; i < amountOfFood; i++)
{
addObject(new Food(), Greenfoot.getRandomNumber(59)+1, Greenfoot.getRandomNumber(39)+1);
}
}
Here's an example from my code:
public void placeFood(int amountOfFood)
{
for (int i = 0; i < amountOfFood; i++)
{
addObject(new Food(), Greenfoot.getRandomNumber(59)+1, Greenfoot.getRandomNumber(39)+1);
}
}
A new version of this scenario was uploaded on Fri May 04 14:01:07 UTC 2012
*Published source code
Each body segment (the size of the head) is an individual object. I created an array of those objects, and when the snake moves, an object gets the location of the body part that was 1 place before it in the array.
newbie installation problem: I am running the latest Greenfoot 3.5.1 but it fails to open the snake game:
the world could not be constructed. The world subclass may not have a public constructor without parameters, or may not be public.
2012/5/4
2012/5/4
2012/5/4
2012/11/18
2012/11/19
2016/8/12
2016/8/12
2018/11/9