Greenfoot Game Programming Club.

Slides:



Advertisements
Similar presentations
Introduction to Eclipse. Start Eclipse Click and then click Eclipse from the menu: Or open a shell and type eclipse after the prompt.
Advertisements

Problem Solving with Data Structures using Java: A Multimedia Approach Chapter 14: Using an Existing Simulation Package Download greenfoot and install.
Getting to know Greenfoot
XP Tutorial 4 New Perspectives on Microsoft Windows XP 1 Microsoft Windows XP Personalizing Your Windows Environment Tutorial 4.
COMPREHENSIVE Windows Tutorial 3 Personalizing Your Windows Environment.
Games and Simulations O-O Programming in Java The Walker School
Animation Mrs. C. Furman. Animation  We can animate our crab by switching the image between two pictures.  crab.png and crab2.png.
Chapter 2 - The First Program: Little Crab
Program: Little Crab Mr Gano.
Boardmaker 6 Basic Tutorial
Georgia Institute of Technology DrJava Appendix A Barb Ericson Georgia Institute of Technology May 2006.
Greenfoot Asteroids Mrs. C. Furman August 16, 2010.
Code Club Session 3 Shark Eats Fish. Picture of finished product here.
Wombats Creating Games with Greenfoot The Walker School – Games and Simulations
Chapter 1 - Getting to know Greenfoot Bruce Chittenden.
Chapter 1 - Getting to know Greenfoot Acknowledgement: Michael Kolling & Bruce Chittenden.
Drawing forecast charts. Open NeLant basic map area.
Creating a Web Page HTML, FrontPage, Word, Composer.
Access Tutorial 10 Automating Tasks with Macros
InDesign CS3 Lessons 1 and 2. Work Area When First Opened.
01-Intro-Object-Oriented-Prog-Alice1 Barb Ericson Georgia Institute of Technology Aug 2009 Introduction to Object-Oriented Programming in Alice.
CHAPTER 1 XNA Game Studio 4.0. Your First Project A computer game is not just a program—it is also lots of other bits and pieces that make playing the.
1 CSC 221: Computer Programming I Fall 2004 Objects and classes: a first pass  software objects, classes, object-oriented design  BlueJ IDE, compilation.
Welcome to the CRE Programming Club! Robert Eckstein and Robert Heard.
Created by NW 2012 – please note all copyright on images used is property of copyright holder. Note: some of the more complicated descriptions are taken.
Hello! Keep watching … I’ll show you how to use a mouse.
Karel J Robot An introduction to BlueJ and Object- Oriented Programming.
Greenfoot. Getting Started Open the Greenfoot download site: Select Greenfoot
Question and Answer Session for Nonprofit Leadership Faculty Facilitator: Peggy McCoey Assistant Professor and Program Director MS in Computer Information.
CPSC1301 Computer Science 1 Overview of Dr. Java.
Chapter One An Introduction to Visual Basic 2010 Programming with Microsoft Visual Basic th Edition.
Chapter 1 - Getting to know Greenfoot
Create Forms Lesson 5. Objectives Software Orientation The Forms group (below) is located on the Create tab in the Ribbon and can be used to create a.
Copyright © Curt Hill Turtles The beginning of media computation.
Moving Around in Scratch The Basics… -You do want to have Scratch open as you will be creating a program. -Follow the instructions and if you have questions.
Digital Stories Using Microsoft Photo Story 3 for Windows Carrie Roth (248)
Lecture 4. Greenfoot 1 Pablo Romero, Department of Informatics Greenfoot Programming simulations and games in Java.
1 CSC 221: Computer Programming I Spring 2008 Objects and classes: a broad view  software objects, classes, object-oriented design  BlueJ IDE, compilation.
EIE375 BlueJ: Getting Started Dr Lawrence Cheung.
Creating Greenfoot Backgrounds. GIMP: GIMP: is a software graphics editor is a software graphics editor is similar to Adobe Photoshop – but FREE. is similar.
GISMO/GEBndPlan Overview Geographic Information System Mapping Object.
Lesson 1: Writing a program. Java Java is a programming language Computer cannot understand it, though it can be translated ( compiled ) so a computer.
Advanced Stuff Learning by example: Responding to the mouse.
Kakihijau.googlepages.com Introduction To Greenfoot Part-1.
Lesson 2: Reading a program. Remember: from yesterday We learned about… Precise language is needed to program Actors and Classes Methods – step by step.
Kakihijau.googlepages.com Introduction To Greenfoot Part-2.
Introduction To Greenfoot
1 Colorado Space Grant Consortium Gateway To Space ASEN / ASTR 2500 Class #13 Gateway To Space ASEN / ASTR 2500 Class #13.
Chapter 2 – The Little Crab Program:. Little Crab Scenario Inheritance: The Arrows Denote Hierarchy Crab is an Animal Animal is an Actor Therefore, It.
MICROSOFT WORD PRESENTATION. Word Processing  Software that is designed for the entry, editing, and printing of documents.  Windows Version = Microsoft.
Kakihijau.googlepages.com Introduction To Greenfoot Part-3.
Instructions for using this template. Remember this is Jeopardy, so where I have written “Answer” this is the prompt the students will see, and where.
Chapter 2: The Visual Studio.NET Development Environment Visual Basic.NET Programming: From Problem Analysis to Program Design.
Troubleshooting Dashhawk Issues. Here's what you have to do to have the DashHawk run properly Go to the ACTUAL PROGRAM file (not the short cut)
Introducing Scratch Learning resources for the implementation of the scenario
1 Development Environments AUBG, COS dept Lecture Title: Dev Env: BlueJ (Extract from Syllabus) Reference:
Digital Literacy Introduction to Computers Unit 1, Lesson 1.
Chapter 11 Enhancing an Online Form and Using Macros Microsoft Word 2013.
Greenfoot.
June 17, 2009 Office 2007 Tips & Tricks.
Chapter 4 - Finishing the Crab Game
Chapter 2: The Visual Studio .NET Development Environment
Appendix A Barb Ericson Georgia Institute of Technology May 2006
Introduction To Greenfoot
Creating Games with Greenfoot
Version 2.
The Little Crab Scenario
Methods, Data and Data Types
Greenfoot November 8, 2009.
Bishopston Comprehensive School
Presentation transcript:

Greenfoot Game Programming Club

Keywords Class Methods Compile Parameters Scenario Act World Run Actor Execution Controls Methods Parameters Act Run int

Reference Resources: Greenfoot Tutorials located on - missallgar-iteach.org>Gaming Programming Project>Greenfoot You can download Greenfoot to your personal computer from the Greenfoot website. Java™ is a prerequisite for Greenfoot.

What is Greenfoot? Who developed it? “Greenfoot is a software tool designed to let beginners get experience with object-oriented programming. It 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 Open Greenfoot from Start Menu If it doesn’t load with the Wombat scenario, open it by selecting Scenario/Open/Wombats. You should see something similar to what is displayed as a background to this slide.

Screen Layout Large grid = “ the world Class display “World” and “Actor” classes part of Greenfoot Other classes belong to the wombat scenario. Execution Controls ( ‘Act’, ‘Run’, slider).

The [wombat] World Turns Place objects into the world Right click on the Wombat class, select ‘New Wombat()’. Then place the new wombat in the world. You have just created a wombat object and placed it into the world. Use the same process to add several leaves Shortcut: Make sure the Leaf class is selected, then hold down the Shift key and click into the world several times.

The [wombat] World Turns Make objects act Click the ‘Act’ button in the execution controls. Each object now acts – that is: each object does whatever it wants to do. Run a scenario Click the ‘Run’ button. This is equivalent to clicking the Act button over and over again, very quickly. You will notice that the Run button changes to a ‘Pause’ button. Clicking it stops the whole show.

Invoke Single Methods Make sure you have a wombat in the world, and the scenario is not running. Then right-click on the wombat, and you see that objects in the world also have a pop-up menu (Figure 2). Try turnLeft(). Try getLeavesEaten(). Try act().

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? Try populate(). Try randomLeaves(int howMany).

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); // ...and turn left that many times. for(int i=0; i<turns; i++) { turnLeft(); }

Change act() public void act() { if(foundLeaf()) { eatLeaf(); } else if(canMove()) { move(); else { turnLeft(); // change turnLeft() to turnRandom();

Compile Before you can execute your class changes you must compile your project. Compile within the editor, or Compile from Greenfoot’s 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 You can change the image of a class, which will change the default image for all objects of that class. Select ‘Set Image...’ from the class’s pop-up menu. Try this - change the leaf’s image to something else An object may change its image programmatically, which will change only the individual object. Each object can change its image as often as it likes. calling the ‘setImage’ method inherited from Actor. one version of setImage() expects a parameter of type GreenfootImage one version of setImage() takes the name of a file (and then reads that image file into a GreenfootImage and sets it).

Change to Left-facing Wombat When the Wombat Moves Left Conveniently, the ‘wombats’ project contains a file named ‘wombat-left.gif’ in its ‘images’ sub-folder. To change the wombat image use the following method call. setImage("wombat-left.gif"); Edit the Wombat’s setDirection(int Direction) method to display the correct image when he is moving left.

Code /* if you want to use the left facing image for upwards movement add case NORTH : setImage("wombat-left.gif"); setRotation(90); break; */ case WEST : setRotation(0);

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: World Actor GreenfootImage Greenfoot. Greenfoot’s online documentation: http://www.greenfoot.org/doc/

Inspecting an Object Invoke the ‘Inspect’ function from the menu of any wombat in the world. Populate the world and then inspect one of the wombats. What do you see? some fields defined in the Wombat class (such as ‘leavesEaten’) some fields that are not defined in Wombat. The additional fields (such as x, y and rotation) are inherited from Actor and are present in all Greenfoot objects. If a value is shown as an arrow symbol, then the field contains a reference to another object, which can be inspected in turn (by selecting and clicking ‘Inspect’).

Create a New Class Create a new actor class. Choose ‘New subclass’ from the pop-up menu of Actor. This will create a new class as a subclass of Actor. When prompted for a class name, type ‘Rock’. You are also prompted to select an image for the class. Select the image, click Ok, and a new class named Rock is created. Open the editor for that class. Why don’t we have to write code for the rock class?

Create a New Class Answer: Because rocks don’t act. Close the editor, compile and test (create an object) – there are your rocks! Now populate the scenario a bit and test the wombats. (You can use the world’s populate() and randomLeaves() methods, and then add some rocks by hand.) You will notice that you have rocks, but the wombats still run through them. Can you modify the Wombat class so that they don’t run through the rocks?

In Class Activity Add a Kangaroo class to the scenario. (In case you weren’t taught kangaroo behavior, a kangaroo will jump over at least one grid square with each move but, like a Wombat, will eat a leaf on the square on which she lands.) Modify wombatWorld’s populate() to initialize the world with 2 rocks, 1 kangaroo, 1 wombat and 7 leaves to the wombatWorld.

Final Request So that the wombat scenario reverts to its original state, if you modified the original, please reboot the computer. Thank you, and remember that Project 1 is due 11/10!