Book Image

Creative Greenfoot: RAW

By : Michael Haungs
Book Image

Creative Greenfoot: RAW

By: Michael Haungs

Overview of this book

Table of Contents (17 chapters)
Creative Greenfoot
Credits
About the Author
About the Reviewers
www.PacktPub.com
Preface
Index

Built-in collision detection methods


We are going to go through all the methods provided by Greenfoot to do collision detection. First, we will go over some methods and discuss their intended use. Then, we'll discuss the remaining methods in the context of more advanced collision detection methods (border-based and hidden-sprite). We have already used a few collision detection methods in the implementation of Avoider Game. We will only briefly describe those particular methods here. Finally, we will not discuss getNeighbors() and intersects(), as those methods are only useful for Greenfoot scenarios that contain worlds that are created with a cell size greater than one.

Note

Cell size and Greenfoot worlds

Until now, we have only created worlds (AvoiderWorld and ZombieInvasionWorld) that have set the cellSize parameter of the World constructor to 1. The following is an excerpt from Greenfoot's documentation on the World class:

public World(int worldWidth, int worldHeight, int cellSize)

Construct...