I'm struggling with a school project, and I need some help.
How exactly do you make something move 1 forward, 2 back, 3 forward, 4 back, etc. until you "find" the object placed on the track? Currently I have a direction variable set to 1 if facing EAST (0 degrees), and -1 if facing WEST (180 degrees). I just can't figure out how to code the actor to move the way I want it to.
{ int direction = getRotation(); int n = 0; /** * Act - do whatever the Robot wants to do. This method is called whenever * the 'Act' or 'Run' button gets pressed in the environment. */ public void act() { } public void directionFace() { if (direction == 0) { n = 1; } else if (direction == 180) { n = -1; } } public void distance() { }