public class NxtRobot
extends LegoRobot
Class that represents a simulated NXT robot brick. Parts (e.g. motors, sensors) may
be assembled into the robot to make it doing the desired job. Each instance
creates its own square playground (501 x 501 pixels). Some initial conditions may be modified by
calling static methods of the class NxtContext in a static block. A typical example
is:
import ch.aplu.nxtsim.*;
public class Example
{
static
{
NxtContext.setStartPosition(100, 100);
NxtContext.setStartDirection(45);
}
public Example()
{
LegoRobot robot = new LegoRobot();
Gear gear = new Gear();
robot.addPart(gear);
gear.forward(5000);
robot.exit();
}
public static void main(String[] args)
{
new Example();
}
}
In principle you may remove the static header and use the program unmodified
for the real NXT robot using the NxtJLib or NxtJLibA library (see www.aplu.ch/nxt).
Because LegoRobot extends Actor all public methods of Actor are exposed. Some
of them are overridden. All sprite images are loaded from subdirectory "sprites"
of the application folder or, if not found there, from _sprites of the distribution JAR.
For backward compatibility with pre-EV3 programs.