Advertisement
Guest User

Untitled

a guest
Jan 24th, 2014
154
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.31 KB | None | 0 0
  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. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement