import greenfoot.*; // (World, Actor, GreenfootImage, Greenfoot and MouseInfo)
import java.util.ArrayList; //ArrayList
/**
* Write a description of class Bomber_Dog here.
*
* @author (your name)
* @version (a version number or a date)
*/
public class Bomber_Dog extends Actor
{
int speed = 5;
int value = 0;
public void act()
{
barrierDetection();
obstacleDetection();
wallDetection();
checkKeys();
}
public void checkKeys()
{
if (Greenfoot.isKeyDown("w"))
{
setLocation(getX(), getY() - speed);
}
if (Greenfoot.isKeyDown("s"))
{
setLocation(getX(), getY() + speed);
}
if (Greenfoot.isKeyDown("a"))
{
setLocation(getX()- speed, getY());
}
if (Greenfoot.isKeyDown("d"))
{
setLocation(getX() + speed, getY());
}
}
public void barrierDetection()
{
Actor a = getOneIntersectingObject(Barrier.class);
if(a != null)
{
setLocation(getX()-5, getY()-5);
}
}
public void obstacleDetection()
{
Actor a = getOneIntersectingObject(Obstacle.class);
if(a != null)
{
setLocation(getX()-5, getY()-5);
}
}
public void wallDetection()
{
int x = getX();
int y = getY();
Actor a = getOneIntersectingObject(Wall.class);
if(a != null)
{
setLocation(x,y);
}
}
}

