Grafico e audio del TouchSensor premuto

import javax.microedition.lcdui.Graphics;

import lejos.nxt.Button;
import lejos.nxt.SensorPort;
import lejos.nxt.Sound;
import lejos.nxt.TouchSensor;
import lejos.util.Delay;

public class Line {

	public static void main(String[] args) {

		Graphics g = new Graphics();
		TouchSensor ts = new TouchSensor(SensorPort.S1);
		int x = 0;
		int y1 = 32, y2 = 32;

		do {
			g.setColor(1);
			g.drawLine(x, 0, x, 63);

			g.setColor(0);
			if (ts.isPressed()) {
				y2 = 22;
				Sound.beep();
			} else
				y2 = 32;

			g.drawLine(x, y1, x, y2);
			y1 = y2;
			x++;

			if (x == 100)
				x = 0;

			Delay.msDelay(100);
		} while (!Button.ESCAPE.isDown());

	}
}