introduction to greenfoot

17
Introduction Introduction To To Greenfoot Greenfoot

Upload: eze

Post on 08-Feb-2016

114 views

Category:

Documents


4 download

DESCRIPTION

Introduction To Greenfoot. What is Greenfoot? Greenfoot: is an Integrated Development Environment. (Remember, an IDE is a program that lets you create other programs) uses the Java Programming Language. is aimed at creating 2D graphical applications. Greenfoot is great for creating: - PowerPoint PPT Presentation

TRANSCRIPT

Page 1: Introduction  To Greenfoot

Introduction Introduction ToTo

GreenfootGreenfoot

Page 2: Introduction  To Greenfoot

What is Greenfoot?What is Greenfoot?

Greenfoot:Greenfoot:– is an Integrated Development Environment.is an Integrated Development Environment.

(Remember, an IDE is a program that lets you (Remember, an IDE is a program that lets you create other programs)create other programs)

– uses the Java Programming Language.uses the Java Programming Language.– is aimed at creating 2D graphical is aimed at creating 2D graphical

applications.applications.

Page 3: Introduction  To Greenfoot

Greenfoot is great for creating:Greenfoot is great for creating:

– Games (biomekanoidchicken)Games (biomekanoidchicken)

– ApplicationsApplications

– Simulations (ants)Simulations (ants)

Page 4: Introduction  To Greenfoot

In Greenfoot, programs and In Greenfoot, programs and applications are called “Scenarios.”applications are called “Scenarios.”

To open a Scenario:To open a Scenario:– Open GreenfootOpen Greenfoot– Scenario Scenario Open Scenario Open Scenario – Find the Greenfoot Folder Find the Greenfoot Folder Find the Find the

Scenario folder Scenario folder Look for this icon: Look for this icon:

Page 5: Introduction  To Greenfoot

Greenfoot uses 2 superclasses:Greenfoot uses 2 superclasses:

– 1. World – The instance of this class becomes 1. World – The instance of this class becomes the world in which the actor objects do things.the world in which the actor objects do things.

– 2. Actor – This class contains data properties 2. Actor – This class contains data properties and methods that allow for actor objects to and methods that allow for actor objects to exist in the instance of the world class.exist in the instance of the world class.

– (We will learn more about super and sub (We will learn more about super and sub classes later…)classes later…)

Page 6: Introduction  To Greenfoot

The Greenfoot IDEThe Greenfoot IDE

World Object

Class

Diagrams

Actor Object

Page 7: Introduction  To Greenfoot

Compiling classes:Compiling classes: If a class is striped, it

needs to be compiled.

Page 8: Introduction  To Greenfoot

Adding objects to the world:Adding objects to the world:

You can right-click a class,

to see its constructor.

Select the constructor, and then you can add an

instance of the class to the

world.

Shift-Click: Another way of adding objects is to

click on the class, press shift, and click in the

world.

Page 9: Introduction  To Greenfoot

Running the World:Running the World:The Act button calls the Act Method. The objects in the

world will do whatever they are programmed to do.

The Run button simply calls the Act method over and over

again.

The speed at which the Run button calls the act method can be altered

here.

Page 10: Introduction  To Greenfoot

To see an object’s methods:To see an object’s methods:– Right-Click an object in the world.Right-Click an object in the world.– You can also execute those methods.You can also execute those methods.– This is great for interactive testing.This is great for interactive testing.

Page 11: Introduction  To Greenfoot

To alter the code for a class:To alter the code for a class:

– Double-click the class. This opens the Double-click the class. This opens the BluJ editor.BluJ editor.

– Change the code.Change the code.

– Save or Compile!Save or Compile!

Page 12: Introduction  To Greenfoot

Question:Question:– Does the Crab class from the demo have Does the Crab class from the demo have

a move( ) method defined in it?a move( ) method defined in it?

Page 13: Introduction  To Greenfoot

There is no move( ) method in the Crab There is no move( ) method in the Crab class. So where is that method coming class. So where is that method coming from?from?

Notice how the Crab class from the demo Notice how the Crab class from the demo has a class above it named Animal.has a class above it named Animal.

The Crab class has access to ALL of the The Crab class has access to ALL of the Animal class’ methods.Animal class’ methods.

Page 14: Introduction  To Greenfoot

Here is the move( ) method in the code Here is the move( ) method in the code from the Animal class:from the Animal class:

This Crab class uses the Animal class’ This Crab class uses the Animal class’ move( ) method to move in the world.move( ) method to move in the world.

We will learn more about this later….We will learn more about this later….

Page 15: Introduction  To Greenfoot

Code that you used today:Code that you used today:

move( ); //This moves the object forward.move( ); //This moves the object forward.

turn(-12); //This turns the object -12 degreesturn(-12); //This turns the object -12 degrees

if(Greenfoot.isKeyDown(“left”))if(Greenfoot.isKeyDown(“left”)){{ turn(12);turn(12);} //This code turns the object whenever the left } //This code turns the object whenever the left

key is pressed down.key is pressed down.

Page 16: Introduction  To Greenfoot

Opening Greenfoot Projects from Opening Greenfoot Projects from www.classofcrow.comwww.classofcrow.com::

– Mister Crow will be giving you incomplete Greenfoot Mister Crow will be giving you incomplete Greenfoot projects (for now).projects (for now).

– These will usually be found on the website in a zipped These will usually be found on the website in a zipped format.format.

– ““Zipped” means that a folder with files is compressed and Zipped” means that a folder with files is compressed and zipped into ONE file. zipped into ONE file.

– You have to have a program like 7-zip to UNZIP those files. You have to have a program like 7-zip to UNZIP those files. 7-Zip is free and it is already loaded on our computers.7-Zip is free and it is already loaded on our computers.

– Download the file Download the file Right-click on it Right-click on it – Select “7-Zip” Select “7-Zip” Select “Extract Here” Select “Extract Here” The files and The files and

folder will be unzipped. folder will be unzipped.

Page 17: Introduction  To Greenfoot

Saving Greenfoot Projects for grading:Saving Greenfoot Projects for grading:

– When you are finished with your project go to:When you are finished with your project go to:– Scenario Scenario “Save a copy as” “Save a copy as”– Name the folder:Name the folder:

crow(period)_(ProjectNumber)_(LastNameFirstInitcrow(period)_(ProjectNumber)_(LastNameFirstInitial)ial)

– For Example:For Example:

crow3_121_SmithJcrow3_121_SmithJ

– This folder will go in the CLASS folder on the This folder will go in the CLASS folder on the due date.due date.