/ Published in: Java
Expand |
Embed | Plain Text
Copy this code and paste it in your HTML
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); 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(); } } } }