Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import greenfoot.*; // (World, Actor, GreenfootImage, Greenfoot and MouseInfo)
- /**
- * Write a description of class Boo here.
- *
- * @author (your name)
- * @version (a version number or a date)
- */
- public class Boo extends Actor
- {
- /**
- * Act - do whatever the Boo wants to do. This method is called whenever
- * the 'Act' or 'Run' button gets pressed in the environment.
- */
- public void act()
- {
- move(10);
- hitDetection();
- if(isAtEdge())
- {
- int turnOne = (int) (Math.random()*100);
- turn(turnOne + 1);
- move(10);
- }
- }
- public void hitDetection()
- {
- Actor Mario = getOneIntersectingObject(Mario.class);
- if(Mario != null)
- {
- getWorld().removeObject(Mario);
- }
- Actor Fireball = getOneIntersectingObject(Fireball.class);
- if(Fireball != null)
- {
- getWorld().removeObject(Fireball);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement