how come its starting location is on the left and it is supposed to be in the middle and move left.
mport java.awt.Color;
import info.gridworld.grid.Grid;
import info.gridworld.actor.Actor;
import info.gridworld.grid.Location;
import info.gridworld.actor.ActorWorld;
public class MoveLeftActor extends Actor
{
public void act()
{
Location loc = getLocation();
//add code here to make the actor
//move to the right
int row = loc.getRow();
int col = loc.getCol();
Location loc2 = new Location(row, col+1);
moveTo(loc2);
}
}
and u need a second one to extend the actor
import java.awt.Color;
import info.gridworld.actor.Actor;
import info.gridworld.grid.Location;
import info.gridworld.grid.BoundedGrid;
import info.gridworld.actor.ActorWorld;
public class MoveLeftActorRunner
{
public static void main(String[] args)
{
ActorWorld world = new ActorWorld();
world.add(new Location(1, 0), new Actor());
world.show();
}
}
ty if you help

New Topic/Question
Reply


MultiQuote




|