
Public class Paddle extends Actor A paddle object has the following fields: width – of the paddle height – of the paddle moveAmount – amount to move the paddle color – of the paddle BreakoutĦ What can actors do? Double click on the Actor class Breakoutĥ The Paddle Class Paddle is a subclass of Actor Use the paddle to hit the ball into the bricks to get rid of them Get rid of all the bricks to win the game The ball will bounce off most of the walls, paddle, and bricks You get up to three balls to use If you still have bricks after using 3 balls you lose If a ball hits the bottom wall it is removed and a new ball is added Use the exported applet of Breakout in Breakout-export to show them the final game working.

BreakoutĤ Game Rules Use the left and right arrow keys to move the paddle There are Bricks, a Message that says we are starting with Ball 1, a Ball, and a Paddle But if you click on act or run nothing happens Give your students the Breakout-Start and Breakout-export folders. The next demo is the introduction to interfaces lesson from the text book A Gentle Introduction to Object Oriented Programming with Karel J Robot where each contractor implements a Worker interface to build a part of the house.Presentation on theme: "Breakout in Greenfoot Barb Ericson"- Presentation transcript:ġ Breakout in Greenfoot Barb Ericson Institute of Technology September 2010 BreakoutĢ What are the objects? Open Breakout.html in Breakout-exportĪnd play the game (use the arrow keys to move the paddle and hit the ball into the bricks) How do you lose? How do you win? What are the objects in the game? Breakout
Greenfoot world api simulator#
Karel J Robot is another good simulator that can used for labs (also available to educators via GreenRoom), as can any tile-based game or application.

A cell can really only live or die is represented by an Actor subclass but should never be able to behave as one, ie move or rotate. The logic behind the simulation is very easy to understand and implement, and this allows the student to focus on design issues that interfaces help with. I use Conway's Game Of Life as a project for a few labs. You will see these issues clearly if you create any scaffolded exercises or simulations of your own. In many applications programmers are making use of the World/Actor mechanism (by subclassing), yet these classes often have their own unique behavior and semantics that are separate and distinct from the Actor class and are only Actors to leverage the Greenfoot World/Actor architecture. In a Greenfoot application most visible objects are Actors. Using interfaces add clarity to the design and responsibility of classes in an application.
Greenfoot world api code#
This is very useful and worth demonstrating via code completion (ctrl+.) and compiler errors. On the other hand, when working programmatically the coder will be restricted to the methods defined by the declared type ( the interface). Even if the declared type is an interface. This can be confusing as students will be able to execute (via the context menu) all methods that are in its hierarchy: Object, Actor, ASubClass, etc.


Using and demonstrating interfaces will take some work though.Īnything that gets added to the world will be displayed and interacted with as it's actual type via the context menu. One huge advantage to using Greenfoot is the visualization and interactive nature of the application.
