Introduzione. GreenFoot è uno strumento software progettato per permettere ai principianti di fare esperienza con laprogrammazione orientata. The Greenfoot Programmers’ Manual is licensed under a. Creative Commons Attribution-Non-Commercial UK: England & Wales License. Contents 1. 2. 3. 4. Opening the Code editor for a class displays all of the programming instructions for the class. Programming instructions are organized into methods in the class.

Author: JoJogami Magar
Country: Monaco
Language: English (Spanish)
Genre: Education
Published (Last): 21 June 2006
Pages: 127
PDF File Size: 9.91 Mb
ePub File Size: 6.73 Mb
ISBN: 551-5-67471-473-7
Downloads: 11328
Price: Free* [*Free Regsitration Required]
Uploader: Kigalar

There is no special function in Greenfoot to do this. The wombats and ants scenarios are distributed as examples together with Greenfoot. Siccome non sono attori non puoi inserirle nel mondo, sono fatte per essere usate come codice sorgente per gli attori. Repeat this until the class compiles without errors. The scale method takes two integers as parameters, which represent the width and height that you want the image to be.

The second possibility is to let an object change its own image as part of its programmed action. There are more background images available in the Greenfoot Image Collection on the Greenfoot web site. It takes four parameters, the first two represent the x and y co-ordinates for the start of the line, and the last two are the x and y co-ordinates of the end of the line. Greenfoot gives you many different ways to find other objects to suit many different kinds of scenarios.

This section discusses some of the characteristics of actor classes, and what to consider when writing them. This means that the point specified will almost be the bottom-left corner of the area where the text is drawn, except that the bottom of letters such as p and q will fall below that point. It is preferrable whenever the images change frequently. To fix this, we need to add code that checks whether we can move in that direction before actually greehfoot.

To mirror an image, use one of the mirrorVertically or mirrorHorizontally methods. It loops through all the pieces of food left in the pile, and for each one draws four pixels onto the image next to each other in a random position. Per utilizzare una qualsiasi delle classi di supporto devi prima scaricare il suo codice greefoot.


Greenfoot | Discuss | Programmer Manual

The background will, by default, be filled with the image by tiling the image across the world. Look at the Greenfoot Gallery to see some other scenarios. The order of objects of the same class cannot be specified. You could find Google is your friend! You have just created a wombat in Java terms: Some methods give you an manuxl.

You can also access it from within Greenfoot – use the “Greenfoot Class Documentation” menu item, from the Help menu. A text editor opens and you will see the Java source code for the Wombat class. So, if we want to do anything as part of our initialisation that needs access to the world such as create other objects in the world, or set our image depending on neighbouring objectsit cannot be done in the constructor.

Now you can close the editor. Input da tastiera There are two ways that the keyboard can be used in Greenfoot scenarios: They should not exceed the world size.

Installing on other systems The Installer for all other systems is an executable jar file. Please visit the book’s web page for more information about this new edition. The Actor geeenfoot has methods to get and set any of these. You are also prompted to select an image for the class. Create a new class.

Then we can use the two image objects to change the image repeatedly. The World class allows you to set the order in which the actors are painted on the screen, set the order in which the actors have their act method called, respond to the scenario being started and respond the the scenario being stopped.

If there is an actor which can be collided with, which the user is suposed to avoid, and which is fading out using transparency, it is a good idea to remove it from the world when the transparency gets low, but before it manyal zero. The additional fields such as x, y and rotation are inherited from Actor and are present in all Greenfoot objects. If the mouse action was over a number of actors, only the top one will return true.


If you want to paint the background programmatically you can easily do so instead of using an image file. If the distance between two actors is exactly 2, it is considered to be in range.


This relatively easy to do. However, while the scenario is stopped the user can call methods of the actors in the world form their popup menus.

The slider next to the Act and Run buttons sets the speed. For simulatons of real-world situations, such as behaviour of swarms or the workings of a machine. The installation follows a standard installation process.

Greenfoot Tutorial

If you want to do that, you have two choices: If you want smoother motion, you should use a smaller cell size. If you check the Publish source code check box then other users of the gallery will be able to download your scenario to see its source code, and play around with it on their computers however that will not affect the version on the gallery.

Circles and ovals can be drawn by calling the drawOval method, specifying the co-ordinates of the top-left corner of the area that the oval is to be drawn in, and the width and height of the oval. You can set the speed of execution using prgrammer Greenfoot.

Programmer Manual

Be aware that these method calls require more computation prograkmer the cell based methods and might slow down your program if it contains many actors. Tutorials Learn how to use Greenfoot and begin programming: The 0,0 location is in the top left of the world, and coordinates increase right x and down y. If you were drawing a line across the entire top of an image, the code would be:.

We have seen that objects in the world have methods which you can invoke via a pop-up menu. The methods discussed here are all available when sub-classing the Actor class. Sometimes it is not precise enough to use the cell location to determine collisions.