Creating Scenarios In Greenfoot. Greenfoot Scenarios are made up of: Greenfoot Scenarios are made up of: A World class. A World class. Actor classes.

Slides:



Advertisements
Similar presentations
Web Page Design Using Tables Here you see three examples of how tables can be used to organize your content. We call this page layout or design. You can.
Advertisements

Web Design & Development Lecture 19. Java Graphics 2.
Breakout in Greenfoot Barb Ericson
The Point Class public class Point { public double x; public double y; public Point(double x0, double y0) { x = x0; y = y0; } public double distance(Point.
Bar Graph Design. Left-side/Right-side mechanical processing creative, abstract reasoning.
CMSC 341 Building Java GUIs. 09/26/2007 CMSC 341 GUI 2 Why Java GUI Development? Course is about Data Structures, not GUIs. We are giving you the opportunity.
Chapter 8 - Creating Images and Sound Bruce Chittenden.
Chapter 2 - The First Program: Little Crab
Program: Little Crab Mr Gano.
Greenfoot Asteroids Mrs. C. Furman August 16, 2010.
Click your mouse for next slide Dreamweaver – Merging, Coloring, Fonts Now it’s time to fill your page with some more interesting stuff The first thing.
Movement. Fixed Movement setLocation (x, y) Makes the crab move to a fixed cell x,y Relative Movement The functions: getX() getY() Fetch the x and y coordinate.
IAT 800 Lab 1: Loops, Animation, and Simple User Interaction.
Histograms and Polygons Problem 24 page 42. Here I copied the data created in the other section. Notice how I put the labels. I put Frequency instead.
Games and Simulations O-O Programming in Java The Walker School
Using Dreamweaver getting started 1)Start in your “My Documents” folder 2)Create a new folder called “website” 3)Create a sub folder called “images” 4)Start.
Checkerboard Examples Top Down Design. The Problem On a checkerboard where locations are numbered similar to java coordinates, draw a rectangle using.
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.
CSE 113 Introduction to Computer Programming Lecture slides for Week 4 Monday, September 19 th, 2011 Instructor: Scott Settembre.
Karel J Robot An introduction to BlueJ and Object- Oriented Programming.
Greenfoot. Getting Started Open the Greenfoot download site: Select Greenfoot
Chapter 8 – Mouse Input, Images and Sound. Chapter 8 - Content In contrast to previous chapters, we will not build a complete scenario in this chapter.
Copyright 2008 by Pearson Education Building Java Programs Chapter 8 Lecture 8-3: Encapsulation, this reading: self-checks: #13-17 exercises:
Java is an object oriented programming language In this model of programming all entities are objects that have methods and fields Methods perform tasks.
Floor Plans in Microsoft Excel Models for the 21 st Century Architect/Engineer By: Mrs. Guenther.
Graphic User Interface. Graphic User Interface (GUI) Most of us interact with computers using GUIs. GUIs are visual representations of the actions you.
Creating Greenfoot Backgrounds. GIMP: GIMP: is a software graphics editor is a software graphics editor is similar to Adobe Photoshop – but FREE. is similar.
Lesson 3: Arrays and Loops. Arrays Arrays are like collections of variables Picture mailboxes all lined up in a row, or storage holes in a shelf – You.
4.3.1 Non-void Methods Parameters are largely one-way communication.  Shared instances variables is one way to accomplish this. calling codemethod parameter.
Inheritance CSI 1101 Nour El Kadri. OOP  We have seen that object-oriented programming (OOP) helps organizing and maintaining large software systems.
Lesson 2: Reading a program. Remember: from yesterday We learned about… Precise language is needed to program Actors and Classes Methods – step by step.
1 Layer up to keep warm… A short tutorial on the usage of layers.
Double click here to add event title Double click here to add event date Double click here to add event time Double click here to add event location.
Introduction To Greenfoot
© 2006 Pearson Addison-Wesley. All rights reserved Non-void Methods Parameters are largely one-way communication.  Shared instances variables is.
IOT POLY ENGINEERING 2-19 November 29, 2010 Your drawing space is 10” wide by 7 ¼” high. Calculate the horizontal starting point and the vertical starting.
How to create a basic game in Scratch. The Scratch Stage The Scratch stage is 480 pixels wide and 360 pixels high x increasesx decreases.
Chapter 2 – The Little Crab Program:. Little Crab Scenario Inheritance: The Arrows Denote Hierarchy Crab is an Animal Animal is an Actor Therefore, It.
Greenfoot Workshop Bobby - Snake.
Print out your name blocks! (15 points). Create a new “idw”
CompSci 4 Java 4 Apr 14, 2009 Prof. Susan Rodger.
Loops. About the Midterm Exam.. Exam on March 12 Monday (tentatively) Review on March 5.
Chapter 4 - Finishing the Crab Game
Working On-Line Module 4 People's Resource Center Barry Glicklich Last updated 27 March 2012Working On-Line (BG)1.
Click on this icon to start animation At the end of animation, ‘right click’ and select ‘end show’. Animation frame 1 of 32 To hasten the speed of animation,
Chapter 10: Creating Images and Sound
GUI’s.
Chapter 4 - Finishing the Crab Game
Chapter 5 – Making Music: An On-Screen Piano (Part 1 – Using Loops)
Inheritance ITI1121 Nour El Kadri.
Barb Ericson Georgia Institute of Technology June 2007
Introduction to Object-oriented Program Design
Computation as an Expressive Medium
CS 106A, Lecture 12 More Graphics
UBC 2016 Why Coding?.
Factoring to Solve Quadratic Equations
DREAMWEAVER MX 2004 Chapter 3 Working with Tables
Calculate Area with grid lines no grid lines. Calculate Area with grid lines no grid lines.
Breakout in Greenfoot Barb Ericson
Calculate Area with grid lines no grid lines. Calculate Area with grid lines no grid lines.
Methods, Data and Data Types
Use an Internet Browser
An Example of Inheritance
YOUR text YOUR text YOUR text YOUR text
Building Java Programs
CSS Boxes CS 1150 Fall 2016.
Cascading Style Sheets
WJEC GCSE Computer Science
Chapter 11 Inheritance and Encapsulation and Polymorphism
Introduction to Computer Science and Object-Oriented Programming
Presentation transcript:

Creating Scenarios In Greenfoot

Greenfoot Scenarios are made up of: Greenfoot Scenarios are made up of: A World class. A World class. Actor classes. Actor classes. To add these in a new scenario: To add these in a new scenario: Right click on the World class or Actor class Right click on the World class or Actor class Select “New Subclass” Select “New Subclass”

Select the background you want (for a World) or the icon your want (for an Actor) Select the background you want (for a World) or the icon your want (for an Actor)

Greenfoot Worlds are composed of a grid. Greenfoot Worlds are composed of a grid. Grids are composed of cells. For example, this grid is 3 cells by 4 cells. Grids are composed of cells. For example, this grid is 3 cells by 4 cells. The cells in Greenfoot are all square. The cells in Greenfoot are all square.

To define the properties of a World’s grid, you put the following in the World’s constructor: To define the properties of a World’s grid, you put the following in the World’s constructor: super(10, 5, 10); The World is 10 cells wide. The World is 5 cells high. Each cell is 10 pixels by 10 pixels.

super(10, 5, 10); super(10, 5, 10);

If your cells are really big, the animation for your actors will look choppy. The actors are going from one cell to the next. If your cells are really big, the animation for your actors will look choppy. The actors are going from one cell to the next.

The solution to get rid of the choppy animation is to shrink the cell size. The solution to get rid of the choppy animation is to shrink the cell size. super(10, 5, 1); The World is 10 cells wide. The World is 5 cells high. Each cell is 1 pixel by 1 pixel.

super(10, 5, 10); super(10, 5, 10); Notice that the world is now smaller because our cell size is smaller. We need to adjust the dimensions of the world to account for the smaller cell size.

Let’s double the width and height of the world’s cells: Let’s double the width and height of the world’s cells: super(20, 10, 1); super(20, 10, 1); The World is now 20 cells wide. The World is now 10 cells high. Each cell is 1 pixel by 1 pixel.

super(20, 10, 1); super(20, 10, 1);  Now our animation should be smoother.

super(20, 10, 1); super(20, 10, 1);  Now our animation should be smoother.

super(20, 10, 1); super(20, 10, 1);  Now our animation should be smoother.

The World subclass that you create has access to the World class’ methods. The World subclass that you create has access to the World class’ methods. One important method is addObject( ) One important method is addObject( ) addObject( ) addObject( ) To automatically create an Actor method in the world when your World class is initialized use this method. To automatically create an Actor method in the world when your World class is initialized use this method. Syntax: addObject(greenfoot.Actor object, int x, int y) Syntax: addObject(greenfoot.Actor object, int x, int y)addObject Ex: addObject(new Ladybug( ), 7, 3); Ex: addObject(new Ladybug( ), 7, 3);

addObject(new Ladybug( ), 7, 3);  The Ladybug will be created here. addObject(new Ladybug( ), 7, 3);  The Ladybug will be created here.  You have probably noticed that Java’s y axis starts at the top left!

The Actor subclass (Ladybug) that you create has access to the Actor class’ methods. The Actor subclass (Ladybug) that you create has access to the Actor class’ methods. One important method is setLocation( ) One important method is setLocation( ) setLocation( ) setLocation( ) To send an Actor object to a location in the grid you use this method. To send an Actor object to a location in the grid you use this method. Syntax: setLocation(int x, int y) Syntax: setLocation(int x, int y)setLocation Ex: setLocation(2, 4); Ex: setLocation(2, 4);

setLocation(2, 4);  The Ladybug will be sent here. setLocation(2, 4);  The Ladybug will be sent here.

The Actor class also has “get axis” methods that return the location of the object. The Actor class also has “get axis” methods that return the location of the object. getX( ) getX( ) getY( ) getY( ) To make the Actor object move forward use these methods with the setLocation method inside the Act method: To make the Actor object move forward use these methods with the setLocation method inside the Act method: Ex: setLocation(getX( ) + 1, getY( )); Ex: setLocation(getX( ) + 1, getY( ));