ok well this is what i have tried:
import greenfoot.*; // (World, Actor, GreenfootImage, Greenfoot and MouseInfo)
import java.util.List;
import java.util.ListIterator;
/**
* Write a description of class greenTank here.
*
* @author (your name)
* @version (a version number or a date)
*/
public class greenTank extends platformMover
{
/**
* Act - do whatever the greenTank wants to do. This method is called whenever
* the 'Act' or 'Run' button gets pressed in the environment.
*/
public void act()
{
turnTowardTank();
int distance = (int)(Math.random()*5)+1;
move(distance);
}
public void turnTowardTank()
{
World world = getWorld();
List<Tank> tank = world.getObjects(Tank.class);
ListIterator<Tank> iter = tank.listIterator();
if(iter.hasNext())
{
}
Tank enemy = iter.next();
int eX = enemy.getX();
int y = getY();
int x = getX();
int angle = getRotation();
if(x < eX)
{
if(angle == 180)
{
turn();
}
else if(x > eX)
{
if(angle == 0)
{
turn();
}
}
}
}
public void turn()
{
GreenfootImage img = getImage();
img.mirrorVertically();
setImage(img);
turn(180);
}
}