This site requires JavaScript, please enable it in your browser!
Greenfoot back
Parrybo
Parrybo wrote ...

2013/5/19

Crab+Lobster Game for School: Lobster Problem

Parrybo Parrybo

2013/5/19

#
My crab, in my case Nyan Cat ignores the enemies if it gets touched. Nothing happens it's like the lobsters are just moving Images. But it works with the non-moving enemies if it touches them the game stops as expected. What's wrong with my Lobsters do you got any ideas? Here is the code of my Lobsters,Crab and a non-moving enemie. Some words are german. ^^ That's the Lobsters
  public void act() 
    { move(-7);  
        if (atWorldEdge()){ 
        turn (17) ; }
       int Zufallz = Greenfoot.getRandomNumber (100); 
       if (Greenfoot.getRandomNumber (100)<5) if (Zufallz <5) { turn (45); turn (45) ; } }   
  
    public void LookForCrab()
    { if (canSee(Crab.class))
        { eat(Crab.class);
            Greenfoot.stop () ;
        }

    }
Thats's the Crab/Nyan Cats:
        
   public void LookForLobster () 
   { if (canSee (Lobster.class)) {
       Actor Lobster=sees (Actor.class) ;
       GreenfootSound ton=new GreenfootSound ("smb_mariodie.wav") ;
       ton.play () ;
       Greenfoot.stop () ; }
   
   
    }
And the one of the non-moving object which is the same but works:
 public void lookForEvilShroom ()
    {  if (canSee(EvilShroom.class)){
        Actor EvilShroom=sees (Actor.class); 
        GreenfootSound ton=new GreenfootSound ("smb_mariodie.wav") ;
       ton.play () ;
      EvilShroom.setLocation( Greenfoot.getRandomNumber (450 ), Greenfoot.getRandomNumber (450)); 
      Greenfoot.stop () ; }
    
    
    }
You need to login to post a reply.