Advertisement
Guest User

Untitled

a guest
May 22nd, 2018
72
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.02 KB | None | 0 0
  1. import greenfoot.*; // (World, Actor, GreenfootImage, Greenfoot and MouseInfo)
  2.  
  3. /**
  4. * Write a description of class Boo here.
  5. *
  6. * @author (your name)
  7. * @version (a version number or a date)
  8. */
  9. public class Boo extends Actor
  10. {
  11. /**
  12. * Act - do whatever the Boo wants to do. This method is called whenever
  13. * the 'Act' or 'Run' button gets pressed in the environment.
  14. */
  15. public void act()
  16. {
  17. move(10);
  18. hitDetection();
  19. if(isAtEdge())
  20. {
  21. int turnOne = (int) (Math.random()*100);
  22. turn(turnOne + 1);
  23. move(10);
  24. }
  25.  
  26. }
  27.  
  28. public void hitDetection()
  29. {
  30. Actor Mario = getOneIntersectingObject(Mario.class);
  31.  
  32. if(Mario != null)
  33. {
  34. getWorld().removeObject(Mario);
  35. }
  36. Actor Fireball = getOneIntersectingObject(Fireball.class);
  37. if(Fireball != null)
  38. {
  39. getWorld().removeObject(Fireball);
  40. }
  41. }
  42. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement