

This repository contains an Eclipse project with the source of GreenfootKara and all the scenarios. If you want to make adjustments to GreenfootKara or would like to report a bug, take a look at the GreenfootKara Repository on GitHub. Tip: Create the world inside the Greenfoot editor and use right-click on the world | saveWorldSetupToFile() or printWorldSetupToConsole() to save the created world. Each world must start with the following three lines: Note: If you want to use a name other than WorldSetup.txt, adjust the constant WORLD_SETUP_FILE in the KaraWorld class.Ī world setup file may contain multiple worlds. To create your own scenarios I recommend you copy an existing scenario and make changes to the WorldSetup.txt file. When the Run-button is pressed, the act()-method is called repeatedly.

This method is executed when the Act-button is pressed. The programming can be done inside the act()-method of MyKara. This way one can get accustomed with how Kara works. If you right-click on a Kara-object, all available methods are shown and can be selected with the mouse. On first contact with GreenfootKara it is helpful to only use the mouse. (Tip: by pressing the shift-key you can place multiple instances in the world without using the context menu). Objects of classes can be instantiated through a right-click, new ….() and can then be placed in the world. This only shows the Javadoc comments inside the Greenfoot editor. For this step it is recommended that they first view the class in the documentation mode. Later, the students may choose to find out how the methods were implemented in Kara itself. Thus, the complexity of Kara's methods are hidden from the students at first. But programming is always done in the class MyKara which, through inheritance, can accessed all the methods of Kara. The class Kara includes all the functionality of the ladybug Kara as seen above. The most important classes are Kara and MyKara. In Chapter 5, Kara has a few additional methods to show messages and to ask the user for input. In Chapter 4, Kara has a additional methods so that a Sokoban game can be programmed. The possibilities of Kara remain the same for all exercises, except for chapter 4 and 5. In each scenario, the world of Kara (with trees, leafs, etc.), is already prepared for each exercise. Run the setup program and follow the installation instructions.Īfter installation, any Kara-Scenario may be opened using the eenfoot file in the scenario folder.įor each exercise there is a separate scenario (see folder scenarios-chapter-1, scenarios-schapter-1-solutions, etc.). To use the Kara-Scenario Greenfoot must be installed first.

#Greenfoot code examples professional#

When used in schools, the entire GreenfootKara material will take about 16-20 lessons. This might be especially helpful if you are a teacher.
#Greenfoot code examples how to#
But often, actors change image during execution of the scenario, and then the setImage method is needed.In this article you will find background information on how to work with GreenfootKara. If an actor’s image never changes, this method is not needed at all, because any actor gets the image from the class automatically when it does not specify another image to use. The most common method to set an image for an actor is via the setImage(String filename) method. Here are some of the things I came across while writing a few scenarios that I found helpful. Still, there are a lot of things that can be done well or less well. At least if you know how to program in gerenral. Greenfoot programming is – on the whole – reasonable straight forward.
