Presentation is loading. Please wait.

Presentation is loading. Please wait.

Teaching with Greenfoot

Similar presentations

Presentation on theme: "Teaching with Greenfoot"— Presentation transcript:

1 Teaching with Greenfoot
For teachers of ICS3U/4u

2 NOTE TO TEACHERS Everything you see here (these slides, code samples, programs) are on your complimentary USB drive.

3 Agenda Intro – What is Greenfoot (5 minutes)
Greenfoot Basics – (15 minutes) First look at Greenfoot – Creating a World and Actors Basic Concept Demo Important Elements of a good scenario Hands On Part 1 (20 minutes) Create your World, your Actor and create movement Collision Detection Tutorial (10 minutes) Detect Objects colliding and triggering events Adding Sound Hands On Part 2 (remaining time…)

4 What is greenfoot? Greenfoot is:
A simple yet useful Java IDE similar to BlueJ An easy-to-use 2D graphics engine An object based programming tool that allows for easy demonstration and instruction of object oriented programming through visual examples Easy to learn for any experienced Java programmer

5 Why Greenfoot? Java is a great academic language – it’s strict structure and object oriented nature makes it ideal for UCS3U/4U However, Java has an antiquated, tedious set of graphics commands. Students quickly tire of text-only programming in Java, and often struggle with Java’s built in graphics Greenfoot provides an easier approach to creating games and visual simulations

6 Getting started Greenfoot is available for Mac OSX, Windows and Linux – (Java must be installed) Can easily be installed by your TST If it is not possible to have it installed, there is a Windows-only “Greenfoot on a Stick” version that can be run from a USB key – which is what we will be working with today

7 Pros and cons PROS CONS Easy to start programming games and simulations complete with 2D graphics and sound Mouse support Extensible with the full Java programming language Makes for fun tasks and assignments Effective way to teach and demonstrate OOP Poor support for text(although you can use the System console) No 3D Ultimately limited to games of moderate complexity Must use included IDE

8 Some additional benefits
Good for teaching Linked Lists – some Greenfoot methods return a linked list of objects Useful for teaching inheritance – all sub-classes of Actors can be further inherited from, leaving the potential to create and use different super classes to good effect Grade 11 students can usually have basic functionality of some sort working within 1 period Module available for XBox360 Kinect module – It is possible to use Greenfoot to program for body motion capture! (although I haven’t tried…)

9 Greenfoot Resources The development staff of Greenfoot is active in creating a plethora of resources on an on-going basis, including: The Greenroom – Discussion forum and resources for teachers, requires registration from teacher address - Numerous online resources for learning Greenfoot - Scenario (and code) sharing - Discussion Forum for students – And more…

10 First look at Greenfoot
IDE, Actor and World creation Tutorial

11 Actor All objects that will move within the game world should be sub-classes of Actor (It is possible to create non-Actor classes within Greenfoot – useful for advanced projects) You can declare abstract sub-classes of Actor and then create sub-sub-classes – useful for creating related types of objects (I.e. different enemies in a game)

12 World Your program begins by you creating a sub-class of World – defining your own game world Typically, the World will own the Actors. Includes a number of global variables – world size, act() order, state of execution (is the game currently running), etc.

13 Persistent Actors In many programs, you will want to keep a permanent reference to your Actors This is best accomplished by defining your Actors within the constructor of your World class Your World can contain methods that allow Actors to communicate

14 Persistent Actor DEMo

15 The “main” method No main() method in Greenfoot
The scenarios are run in “acts” where the act() method of every class gets called once per frame Use your World (the class you created which inherits from World, not World itself) as you would a main method. You can add an act() method to your World (and you should!)

16 Building your World Some things that you should consider for your World: setPaintOrder() – allows you to control which Actors are displayed on top and which will appear behind setActOrder() – set the order in which classes’ act() methods get called in each act. Store permanent references to Actors which you will need to manage later Instance variables for your data and for program flow

17 Your first game! Frogger Game!
Little Frogger must cross the road without getting smushed Example solutions (basic and advanced) on your USB key

18 Process Part 1 – Create the basic objects
A World with a background image A little Frogger Actor that takes input from the keyboard Cars (or other Enemies) (Actors) that cross the road and threaten to kill our poor frog! Part 2 – Add collision detection and associated actions Part 3 – Finishing Touches, polish, as time allows Sounds Displaying Text (score, level, etc)

19 Various Resources Greenfoot on a Stick – Greenfoot and all associated Java libraries, runnable off of a USB key – best free paint program I’ve been able to find. Does transparency. Frogger! (my 3-4 hours of coding version) A few other scenarios

Download ppt "Teaching with Greenfoot"

Similar presentations

Ads by Google