import greenfoot.*; // (World, Actor, GreenfootImage, Greenfoot and MouseInfo)
/**
* Write a description of class Projectile here.
*
* @author
* @version (a version number or a date)
*/
public class Projectile extends Mover
{
/**
* Act - do whatever the Projectile wants to do. This method is called whenever
* the 'Act' or 'Run' button gets pressed in the environment.
*/
int speed = 10;
int timer=23;
public void eat(Class clss)
{
Actor actor = getOneObjectAtOffset(0, 0, clss);
if(actor != null) {
getWorld().removeObject(actor);
}
}
public boolean canSee(Class clss)
{
Actor actor = getOneObjectAtOffset(0, 0, clss);
return actor != null;
}
public Projectile()
{
getImage().scale(30,30);
}
public void act()
{
// turnToMouse();
setLocation(getX()-10,getY());
if(timer>0){timer--;}
if(timer==0){getWorld().removeObject(this);}
lookForZombie1();
}
public void turnToMouse()
{
turnTowards(Greenfoot.getMouseInfo().getX(), Greenfoot.getMouseInfo().getY());
}
public void lookForZombie1()
{
if ( canSee(Zombie1.class) )
{
eat(Zombie1.class);
}
}
}