Greenfoot: Ants

There are many ants in the simulation, each one running the code in the classes.

AntWorld

Right click the AntWorld class icon and choose Open editor. What are the screen settings for this simulation? What is a simulation? Why is this a simulation rather than a game?

Comment on the first line of the constructor AntWorld(). What is the resolution of the screen area? What is the size of a cell?

What is the purpose of the three similar functions in the constructor?

Food

Comment on the origins of the foodCounter object.

Name and describe the purpose of three properties of the class Food.

What does the Food constructor do?

Ant

Comment on the link between the definition for Ant and the display of many ants running around the screen.

Describe what the Ant class achieves. What does an ant do in the simulation?

Pheromone

When is a pheromone brought into the AntWorld?

What happens to a pheromone when it is produced?

What happens to the image when the pheromone's value is divisible by 4?

What are the default shape and colour of a pheromone?

How is the appearance of a pheromone altered when it has been dropped?

Own Scenario 10: Space Image

Create a new scenario with a black background. Draw this using methods from the GreenfootImage class.

Add stars as white dots to simulate space.

Add stars of different sizes.

This could serve as the background to a game based in space.

Try animating the stars to create the 'Star Trek' look.

Own Scenario 11: Animation

Use the Animated Actor video  to help you with this exercise.

Create an animated actor. Download the AnimatedActor class from the Helper Classes page and paste the code into a new class under actor. Create a sequence of images with a base name such as 'stickman', a file suffix such as 'jpg' (.png allows transparency) and a sequence of number after the base name (0, 1, 2...).

Home Page