Table of Contents
Acknowledgments
About the 2nd edition
Introduction
1 Getting to know Greenfoot
1.1 Getting started
1.2 Objects and classes
1.3 Interacting with objects
1.4 Return types
1.5 Parameters
1.6 Greenfoot execution
1.7 A second example
1.8 Understanding the class diagram
1.9 Playing with Asteroids
1.10 Source code
1.11 Summary
2 The first program: Little Crab
2.1 The Little Crab scenario
2.2 Making the crab move
2.3 Turning
2.4 Dealing with screen edges
2.5 Summary of programming techniques
Drill and practice
3 Improving the Crab— more sophisticated programming
3.1 Adding random behavior
3.2 Adding worms
3.3 Eating worms
3.4 Creating new methods
3.5 Adding a Lobster
3.6 Keyboard control
3.7 Ending the game
3.8 Adding sound
3.9 Making your own sounds
3.10 Code completion
3.11 Summary of programming techniques
Drill and practice
4 Finishing the crab game
4.1 Adding objects automatically
4.2 Creating new objects
4.3 Variables
4.4 Assignment
4.5 Object variables
4.6 Using variables
4.7 Adding objects to the world
4.8 Save The World
4.9 Animating images
4.10 Greenfoot images
4.11 Instance variables (fields)
4.12 Using actor constructors
4.13 Alternating the images
4.14 The if/else statement
4.15 Counting worms
4.16 More ideas
4.17 Summary of programming techniques
Drill and practice
Interlude 1: Sharing your scenarios
I1.1 Sharing your scenario
I1.2 Publishing to the Greenfoot website
I1.3 Export to a web page
I1.4 Export to application
I1.4 Export to Greenfoot archive
5 Scoring
5.1 WBC: The starting point
5.2 WhiteCell: constrained movement
5.3 Bacteria: making yourself disappear
5.4 Bloodstream: creating new objects
5.5 Side-scroll movement
5.6 Adding viruses
5.7 Collision: Removing bacteria
5.8 Variable speed
5.9 Red blood cells
5.10 Adding borders
5.11 Finally: Adding a score
5.12 Scoring in the World
5.13 Abstraction: Generalizing the scoring
5.14 Adding game time
5.15 Summary of programming techniques
Drill and practice
6 Making music: An on-screen piano
6.1 Animating the key
6.2 Producing the sound
6.3 Abstraction: Creating multiple keys
6.4 Building the piano
6.5 Using loops: the while loop
6.6 Using arrays
6.7 Summary of programming techniques
Drill and practice
7 Object interaction: an introduction
7.1 Interacting objects
7.2 Object references
7.3 Interacting with the world
7.4 Interacting with actors
7.5 The null value
7.6 Interacting with groups of actors
7.7 Using Java library classes
7.8 The List type
7.9 A list of leaves
7.10 The for-each loop
7.11 Summary of programming techniques
Drill and practice
8 Interacting objects: Newton’s Lab
8.1 The starting point: Newton’s Lab
8.2 Helper classes: SmoothMover and Vector
8.3 The existing Body class
8.4 First extension: Creating movement
8.5 The Color class
8.6 Adding gravitational force
8.7 Applying gravity
8.8 Trying it out
8.9 Gravity and music
8.10 Summary of programming techniques
Drill and practice
9 Collision detection: Asteroids
9.1 Investigation: What is there?
9.2 Painting stars
9.3 Turning
9.4 Flying forward
9.5 Colliding with asteroids
9.6 Game over
9.7 Adding fire power: The proton wave
9.8 Growing the wave
9.9 Interacting with objects in range
9.10 Further development
9.11 Summary of programming techniques
Drill and practice
Interlude 2: The Greeps competition
I2.1 How to get started
I2.2 Programming your Greeps
I2.3 Running the competition
I2.4 Technicalities
10 Creating images and sound
10.1 Preparation
10.2 Working with sound
10.3 Sound recording in Greenfoot
10.4 External sound recording and editing
10.5 Sound file formats and file sizes
10.6 More control: The GreenfootSound class
10.7 Working with images
10.8 Image files and file formats
10.9 Drawing images
10.10 Combining images files and dynamic drawing
10.11 Summary
Drill and practice
11 Simulations
11.1 Foxes and rabbits
11.2 Ants
11.3 Collecting food
11.4 Setting up the world
11.5 Adding pheromones
11.6 Path forming
11.7 Summary
12 Greenfoot and the Kinect
12.1 What the Kinect can do
12.2 Installing the software
12.3 Getting started
12.4 The simple camera
12.5 The next step: Greenscreen
12.6 Stick-figure: Tracking users
12.7 Painting with your hands
12.8 A simple Kinect game: Pong
12.9 Summary
Drill and practice
13 Additional scenario ideas
13.1 Marbles
13.2 Lifts
13.3 Boids
13.4 Explosion
13.5 Breakout
13.6 Platform jumper
13.7 Wave
13.8 Map
13.9 Summary
Appendix A: Installing Greenfoot
A.1 Installing Greenfoot
A.2 Installing the book scenarios
Appendix B: Greenfoot API
Appendix C: Collision detection
C.1 Method summary
C.2 Convenience methods
C.3 Low versus high resolution
C.4 Intersecting objects
C.5 Objects at offset
C.6 Neighbors
C.7 Objects in range
Appendix D: Some Java details
D.1 Java data types
D.2 Java operators
D.3 Java control structures
|