Posted By

joswald on 01/29/11


Tagged

greenfoot


Versions (?)

Click Instruction Panel


 / Published in: Java
 

  1. import greenfoot.*; // (Actor, World, Greenfoot, GreenfootImage)
  2.  
  3. public class CrabWorld extends World
  4. {
  5. Panel p;
  6. /**
  7.   * Create the crab world (the beach). Our world has a size
  8.   * of 560x560 cells, where every cell is just 1 pixel.
  9.   */
  10.  
  11. public CrabWorld()
  12. {
  13. super(560, 560, 1);
  14. p = new Panel();
  15. addObject( p, 280, 280 );
  16. }
  17.  
  18. /**
  19.   * Add objects to the world
  20.   */
  21. public void populate()
  22. {
  23. // add your objects in this method
  24. }
  25.  
  26. public void act()
  27. {
  28. super.act();
  29. if( p != null )
  30. {
  31. if( Greenfoot.mouseClicked( p ) )
  32. {
  33. removeObject( p );
  34. p = null;
  35. populate();
  36. }
  37. }
  38. }
  39.  
  40. }

Report this snippet  

You need to login to post a comment.