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
About the Author
About the Reviewers

Mapped worlds

There are definitely times when you are going to want a specific background for your game or simulation. In these cases, it is not sufficient to randomly generate actors to simulate a moving background. The methods we will explore next consist of creating a background image that is much larger than the dimensions of the screen and moving it appropriately to simulate motion. In addition, we will learn how to place actors in this larger world.


Our side-scrolling example is a scenario that allows the user to walk through a mountain forest to find a lake at the end. The user will only be able to walk left and right, not up and down. Figure 4 shows the completed application.

Figure 4: This is a screenshot of HikingWorld

To create this side-scrolling world, we are going to need a large image to serve as the background. For this example, I have created a 2400 x 400 image shown in Figure 5. Since our scenario has a viewable screen size of 600 x 400, the image is six times...