My moving enemies can't kill the player i dont no why because it works with non-moving enemies.
It's like my enemies are just empty images moving around. But my non-moving enemies are like obstacles and the game stops when my player touches them.
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 () ;
}
}
public void LookForLobster ()
{ if (canSee (Lobster.class)) { Greenfoot.playSound("smb_mariodie.wav");
Greenfoot.stop(); }
}
} 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 () ; }
}import greenfoot.*; // (World, Actor, GreenfootImage, and Greenfoot)
/**
* This class defines a crab. Crabs live on the beach.
*/
public class Crab extends Animal
{
private GreenfootImage image1;
private GreenfootImage image2;
int zaehler;
public Crab()
{
zaehler=0;
}
public void act()
{
if (atWorldEdge()){
turn (17) ; }
if (Greenfoot.isKeyDown ("w") ){
move (10) ; }
if (Greenfoot.isKeyDown ("s") ) {
move (-10) ; }
if (Greenfoot.isKeyDown ("d") ) {
turn (10) ; }
if (Greenfoot.isKeyDown ("a") ) {
turn (-10) ; }
lookForWorm () ;
lookForPowerUP () ;
lookForEvilShroom () ;
}
public void lookForWorm ()
{ if (canSee(Worm.class)){
Actor wurm=sees (Actor.class);
GreenfootSound ton=new GreenfootSound ("cat_meow_x.wav") ;
ton.play () ;
wurm.setLocation( Greenfoot.getRandomNumber (450 ), Greenfoot.getRandomNumber (450));
zaehler =zaehler+1 ;
CrabWorld welt=(CrabWorld) getWorld();
Label l =welt.getLabel();
l.setText("Punkte: "+zaehler);
}
}
public void lookForPowerUP ()
{ if (canSee(PowerUP.class)){
Actor PowerUP=sees (Actor.class);
GreenfootSound ton=new GreenfootSound ("smb_powerup.wav") ;
ton.play () ;
PowerUP.setLocation( Greenfoot.getRandomNumber (450 ), Greenfoot.getRandomNumber (450));
zaehler =zaehler+10 ;
CrabWorld welt=(CrabWorld) getWorld();
Label l =welt.getLabel();
l.setText("Punkte: "+zaehler); }
}
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 () ; }
}
public void LookForLobster ()
{ if (canSee (Lobster.class)) { Greenfoot.playSound("smb_mariodie.wav");
Greenfoot.stop(); }
}
}
import greenfoot.*; // (World, Actor, GreenfootImage, Greenfoot and MouseInfo)
/**
* Write a description of class Lobster here.
*
* @author (your name)
* @version (a version number or a date)
*/
public class Lobster extends Animal
{
/**
* Act - do whatever the Lobster wants to do. This method is called whenever
* the 'Act' or 'Run' button gets pressed in the environment.
*/
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 () ;
}
}
}