Greenfoot Avoider Game Tutorial

by Michael L. Haungs

Introduction

How to use this tutorial

This tutorial is heavily based on the AS3 Avoider Game Tutorial by Michael James Williams. As with that tutorial, the main purpose of this one is to teach basic programming concepts and gain familiarity with the development environment. As you proceed, think about the concepts and how you would use them in your own game. Experiment with the code and try new things. If you are looking for a quick "how-to" example, this is not the tutorial for you.

About Greenfoot

Excerpt from the Greenfoot website:

Greenfoot teaches object orientation with Java. Create 'actors' which live in 'worlds' to build games, simulations, and other graphical programs.

Greenfoot is visual and interactive. Visualisation and interaction tools are built into the environment.

The actors are programmed in standard textual Java code, providing a combination of programming experience in a traditional text-based language with visual execution.

Learn more about Greenfoot at greenfoot.org.

NOTE: This tutorial assumes you have worked through the basic Greenfoot Tutorials.

Avoider Game

This is a simple game where you control a character using the mouse to try and avoid oncoming enemies. As the game progresses, the enemies become harder to avoid. In this tutorial, you will learn how to:

  • Create introduction and game over screens,
  • display a user score,
  • use the mouse to control the movement of an actor,
  • play background music,
  • dynamically spawn enemies and destroy them when they are no longer on the screen,
  • and create game levels.

You can play the completed game here.

Next...

Now that you are familiar with the game we are going to create, Greenfoot, and the educational purpose of this tutorial, it's time to start coding. Go to Avoider Game - Part I to begin.