This week only. Pastebin PRO Accounts Christmas Special! Don't miss out!Want more features on Pastebin? Sign Up, it's FREE!
Guest

Untitled

By: a guest on Jan 24th, 2014  |  syntax: None  |  size: 1.31 KB  |  views: 36  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. import greenfoot.*;    
  2.    
  3. public class MyWorld extends World    
  4. {    
  5.     public int a = 0;  
  6.     private int threshold = 100; //increase to make the time until a random thing is added longer...    
  7.     private int thresholdWave = 3; //increase to make the time until a random thing is added longer...  
  8.     Counter counter = new Counter();
  9.  
  10.         /**
  11.      * Creates a world with the size of 1100x500 cells, where every cell is just 1 pixel
  12.      */  
  13.      
  14.     public MyWorld()  
  15.     {      
  16.         super(1100, 500,1);  
  17.         addObject(counter, 50, 25);  
  18.          
  19.     }  
  20.      
  21. public void act()    
  22.     {    
  23.          a++;    
  24.         if(a == threshold)    
  25.         {  
  26.            RandomPlacement();  
  27.             a = 0;    
  28.         }    
  29.     }    
  30.     public void RandomPlacement()    
  31.     {      
  32.         int x = Greenfoot.getRandomNumber(getWidth());    
  33.         int y = 10;    
  34.     addObject (new Rock(counter),x,y);  
  35.     }  
  36.     {  
  37.     if (Greenfoot.mouseClicked(this)){ // Hvis der er trykket med musen på objektet sker følgende  
  38.          
  39.             int x= Greenfoot.getRandomNumber (getWidth());//generer tilfældigt nummer  
  40.             int y= Greenfoot.getRandomNumber (getHeight());//generer tilfældigt nummer  
  41.              
  42.              
  43.         }  
  44. }  
  45. }
clone this paste RAW Paste Data