The simulation project I'm using here is downloaded from: http://www.pembinatrails.ca/fortrichmondcollegiate/compsci/cprsci40s/Greenfoot/ants/page1.htm
However this project is not complete and the Food class is missing..
Quote:
Create a new class called Food. This class does not need a fixed image. You will draw the image from within the class.
We would like the food image to be in a certain size, transparent and with some dots spread over it so that it looks like a pile of crumbs. To make the look more natural, the most crumbs should be toward the middle and other crumbs should be in a rough circle-shape around the middle area. To achieve this, we need to use Gaussian distribution by setting the coordinates of the dots.
Function GreenfootImage distributeCrumbs(int s) in Food Class:
I have used the Random class in Java and called the float nextGaussian() funciton. However, by default the mean is 0 and deviation is (-1,1), which means the majority of the returned value is around 0 and the range is (-1,1), and thus we need to "project" those values to the x and y coordinates of the transparent food image, which is of size 32x32.
The food files displayed on the images above and below are set up as follows:
background.drawImage(Food.distributeCrumbs(70),90,30);
background.drawImage(Food.distributeCrumbs(70),200,300);
background.drawImage(Food.distributeCrumbs(40),200,290);
background.drawImage(Food.distributeCrumbs(30),400,140);





