Return to Snippet

Revision: 40295
at January 29, 2011 00:59 by joswald


Initial Code
import greenfoot.*;  // (Actor, World, Greenfoot, GreenfootImage)

public class CrabWorld extends World
{
    Panel p;
    /**
     * Create the crab world (the beach). Our world has a size 
     * of 560x560 cells, where every cell is just 1 pixel.
     */

    public CrabWorld() 
    {
        super(560, 560, 1);
        p = new Panel();
        addObject( p, 280, 280 );
    }

    /**
     * Add objects to the world
     */    
    public void populate()
    {
        // add your objects in this method
    }
    
    public void act()
    {
        super.act();
        if( p != null )
        {
            if( Greenfoot.mouseClicked( p ) )
            {
                removeObject( p );
                p = null;
                populate();
            }
        }
    }
        
}

Initial URL


Initial Description


Initial Title
Click Instruction Panel

Initial Tags


Initial Language
Java