Greenfoot (Programming Club)

The purpose of these resources is to support teachers in running a number of session to help pupils to develop their Java abilities using the Greenfoot environment (for information on how to install Greenfoot please visit their website). These resources are intended for use as part of an after school clubs although they can be adapted as required. Resources for 10 hour long sessions are provided and they cover making three different games/scenarios using Greenfoot. These scenarios are as follows.

1.       Ship Game – player navigates a ship around the screen to collect crates while avoiding submarines that will stop them.
2.       Air Raid Game – player controls a rocket launcher that moves along the bottom of the screen. Rockets are launched to destroy crates dropped to destroy planes flying across the top of the screen.
3.       Cannon Game – player controls a cannon that must shoot over a wall to hit a target on the other side of the screen.

Resources Provided

Each session starts with an activity that requires pupils to do some research or practices skills learnt in previous sessions. In some cases tables are provided that the pupils must fill out. Where this is the case an editable document in rich text format is provided so that pupils can do all work on the computer.

The code required to start each session is also provided. This can be used to provide additional scaffolding for weaker students or provide organisers with guidance on what the finished code should look like. It should be noted that even though the final versions contain all the necessary code some variables would need to be changed to make the games properly playable. This is on purpose and students should be encouraged to customise the scenarios whenever possible.

Additional Assistance

While it is intended that more capable students should be able to work with these resources relatively independently it should be noted that students will require assistance particularly in the first few sessions. In particular the java syntax and matching of brackets seems to cause some difficulty when students are starting off and some additional assistance may be required. Personally I have found using the auto-layout feature and the colour coding of code blocks in the BlueJ editor to be very useful for this.

CodeBreaker Sessions Overview

The purpose of this table is to provide an overview of the skills and techniques that participants should cover in each of the 10 sessions provided. This can be used by those delivering the sessions to ensure that participants are focusing on the important aspects of each session. Alternatively you can use this overview to select only those sessions that cover the particular skills you want to deliver. Please note that while certain programming concepts are used throughout each of the sessions they are only listed once in the table.

Session Num

Programming Concepts
(only new concepts are listed)

Greenfoot Skills

Scenario Outcomes

  • Classes represent objects in a program.
  • Use of methods and parameters.
  • Use of conditional statements (if).
  • Layout of the Greenfoot IDE
  • Creation of Actors.
  • Use of act method to set Actor behaviour.
  • Using Greenfoot class to access keyboard input.

Simple scenario where a ship is moved around the screen using the arrows. All objects added to world manually.

  • Use of local variables
  • ü      Use of coordinates in graphical systems.
  • ü      Class constructors
  • Collision detection
  • Use of sounds
  • Accessing the world object.
  • Automatic setup of world.

Improvement of scenario from session one. Able to collect crates. Enemy ships are included and hitting one ends the game.

  • Use of random numbers for unpredictable behaviours.
  • Boolean operators in conditionals (OR).
  • Boundary checking in graphical system.
  • Generating random numbers.
  • Changing Actor location.

Improved enemy ship behaviour. Crates reappear elsewhere rather than removed.

  • Instantiation of objects.
  • Removal of objects.
  • Creating new actors.
  • Removing objects from world.
  • Add objects on the “fly”
  • Rotating objects to direction.

Add all 4 classes (plane, launcher, rocket, crate). Movement of the launcher and ability to fire.

  • Class properties.
  • Use of random numbers.
  • Delaying actor actions.

Movement of plane and ability to drop crates. Delays between rocket launches.

  • If/else statements.
  • Accessor methods.
  • Return types.
  • Use of World class to hold game level information.
  • Calling methods from the IDE.

Added collision detection so that rockets can hit planes and crates. Add methods to allow score to be tracked.

  • Casting object to correct type.
  • Using predefined classes.
  • Delay program for a period of time.
  • Stop program execution when game is over.

Added facility to track lives and stop the game when all lives are lost.  Used StatusBoard actor to display score. Add intro sound with delay.

  • Importing java classes.
  • Finding the size of a collection.
  • Use of the modulo operator.
  • Adding a Game Over screen as an actor.
  • Getting list of all actors of a particular type.
  • Changing images used.

Last refinement of the game. Puts a plane back in if all are shot down. Increase the number of planes every 5 points. Game over screen displayed at the end.

  • Using Colours in Java.
  • Use of loops to repeat tasks (for).
  • Displaying text on an actor.
  • Complete setup for cannon game.

Creation of all the elements of the cannon game and the initial setup for the game.

  • Using vectors to calculate motion.
  • Actor behaves as if gravity present.

Added the cannon balls to the game and get them to behave as if there was gravity.



  1. All support material (~6Mb)
  2. Session 1  
  3. Session 2 and Worksheet 
  4. Session 3 and Worksheet
  5. Session 4 and worksheet
  6. Session 5 and Worksheet
  7. Session 6
  8. Session 7
  9. Session 8 
  10. Session 9 and Worksheet
  11. Session 10
  12. Code Examples (~4Mb)
  13. Support Material (.DOC/.RTF format)

Also see:

Computing at School is supported and endorsed by: