Greenfoot - UNC A

Greenfoot Getting Started Open the Greenfoot download site: http://www.greenfoot.org/download/ Select Greenfoot 2.0.1 For other systems (executable jar file). Download the .jar file to your Desktop. You can also download Greenfoot to your personal

computer, but Java is a prerequisite. Installing Greenfoot Open a terminal window and type the command below to change to your Desktop directory : cd Desktop Run the installer by typing the following

command in your terminal window: java -jar Greenfoot-generic-201.jar (you must be in your Desktop directory) The Installer Accept the default directories in the installer

pop-up window. Complete the installation. The installer will install Greenfoot in your Desktop directory. Running Greenfoot To run Greenfoot, simply type the following command in the terminal

window: greenfoot/greenfoot (you must be in your Desktop directory) Choose this one Cleanup Move the .jar file to the trash Empty the trash

What is Greenfoot? Who developed it? Greenfoot supports development of graphical applications in the Java Programming Language. Greenfoot was designed and implemented at the University of Kent, England, and Deakin University, Melbourne, Australia.

First Look You should see something similar to what is displayed as a background to this slide. Getting Started World Execution

Controls Class Diagram Objects and Classes Right Click on Wombat

Drag to World Click New Wombat() Populate the world Press Run to run the simulation Interacting with Objects

Right Click on the Wombat Invoke the Move method Return values Parameters

Directions 2 1 0 3 Invoking wombatWorld Methods

right-click the WombatWorld class and select new WombatWorld(). What happens? What type of function is WombatWorld()? How did you know that? right-click in the world grid Try populate(). Try randomLeaves(int howMany).

Change the Scenario Asteroids scenario Understanding the Class Diagram World Class is always there in Greenfoot scenarios, it is built-in. Space represents a specific world for this scenario

Arrows show relationships Explosion and Mover are subclasses of Actor Bullet, Rocket, and Asteroid are subclasses of Mover. Vector is a helper class Inspect Create a few objects

Right Click on an Object and Select Inspect Inspect Right Click on the Object and

Select Inspect Editing Code Change back to the Wombat scenario Right-click on the Wombat class icon and select Open editor Changing the Wombat Class Add the following method to the Wombat

class: public void turnRandom() { // get a random number between 0 and 3... int turns = Greenfoot.getRandomNumber(4); // ...an turn left that many times. for(int i=0; i

} Change act() public void act() { if(foundLeaf()) { eatLeaf(); } else if(canMove()) {

move(); } else { turnRandom(); // change turnLeft(); to turnRandom(); } } Compile

Before you can execute your class changes you must compile your project. Compile within the editor, or Compile from Greenfoots main window. Once you have successfully compiled, you can create objects again. Compilation (if successful) automatically instantiates a world object.

Changing Images 2 ways to change the image of objects Change the image of a class, changing the image for all objects of that class. Select Set Image... from the classs pop-up menu. Change the image of a object, changing only the individual object. Objects can change images as often as desired

Call the setImage method inherited from Actor. one version of setImage() has a parameter of type GreenfootImage one version of setImage() takes a String that is the name of an image file. Documentation

To make changes to object behavior, you often need to make use of some standard Greenfoot classes. Greenfoot provides four important classes that you should know about: 1. 2. 3. 4.

World Actor GreenfootImage Greenfoot.

Greenfoots online documentation: http://www.greenfoot.org/doc/ Video tutorials In Class Activity If there isnt one, create a Rock class---it doesnt need to do anything. Modify wombatWorlds populate() to initialize the world with 2 rocks, 3 wombat and

7 leaves to the wombatWorld. Run the simulation and notice that the wombats walk through the rocks. Modify the Wombat class so that it cant walk through rocks. (BIG HINT: look at the Wombat2 scenario for a solution.)

Recently Viewed Presentations

  • Introduction to Marketing Planning - WOU Homepage

    Introduction to Marketing Planning - WOU Homepage

    Introduction to Marketing Planning New Brand Monk Ad Problems Second life Facebook Solid Ink Today's discussion Overview of Marketing Planning Marketing Planning Defined Contents of a marketing Plan Developing a Marketing Plan Research and Analyze the Current Situation Understand markets...
  • Shani Mootoo, Valmikis Daughter (2008) She would embark

    Shani Mootoo, Valmikis Daughter (2008) She would embark

    "Located in South Trinidad, the town of San Fernando is second in size only to Port of Spain in the North of the island.In a country with two major ethnic groups, San Fernando is also regarded, to some extent, as...
  • Brief overview of digital services/ challenges/ aspirations ...

    Brief overview of digital services/ challenges/ aspirations ...

    Sherpa services, SHERPA FACT checks if compliance with funder open access policies can be achieved with a particular journal. SHERPA RoMEO enables researchers and librarians to see publishers' conditions for open access archiving on a journal-by-journal basis.
  • Writing - SELU

    Writing - SELU

    Documents Supporting Writing. Rubrics - one for each grade, holistic, 1-4 scale (with 3 being independently proficient), criteria matched to grade-level curricula, applied to multiple samples across multiple contexts, most recent and most consistent evidence honoured. Writing continuum (1-12) ...
  • <Insert Lesson, Module, or Course Title>

    <Insert Lesson, Module, or Course Title>

    Profile APA, MSc. Statistics, MSc. Economics, MA Arabic, MA Islamic Studies Project Manager/ Sr. Financial Consultant Oracle EBS Instructor in OTS/ TE Oracle Certified professional Oracle Certified Support Specialist Salaih Muhammad (ACA) Muhammad Ali MSc Accounting & Finance Functional Consultant...
  • Classic Template - White

    Classic Template - White

    Exposures from chipping, cutting, sawing, drilling, grinding, sanding, and crushing of concrete, brick, block, rock, and stone products (such as in construction operations) Exposures from using sand products (such as glass manufacturing, foundries, and sand blasting)
  • Chapter 22: The Nervous and Endocrine Systems

    Chapter 22: The Nervous and Endocrine Systems

    Sensitive to red, blue, and green light. Rods: Night vision. Not sensitive to colors. Retina: Thin layer of tissue on the back of the eye that contains rods and cones. Rods and cones. ... Endocrine glands: Release hormones into the...
  • Wisconsin NEMT Driver/Attendant Training Course - MTM Inc

    Wisconsin NEMT Driver/Attendant Training Course - MTM Inc

    Recordkeeping: Trip Logs & Signatures. MTM must receive clear trip documentation to verify member attendance & pay claims. Critical Daily Trip Log (see Attachment C) items: Trip numbers. Driver's license numbers. Last five digits of Vehicle Identification Numbers (VINs) Pick-Up...