% A small program to demonstrate how the mouse works. % This procedure draws crosshairs centred at (x,y) in a particular colour. procedure drawCrossHairs(x, y : int, colour : int) const delta := 5 drawline(max(1,x-delta), y, min(maxx, x+delta), y, colour) drawline(x, max(1,y-delta), x, min(maxy, y+delta), colour) end drawCrossHairs var oldx, oldy : int var x, y, buttonNum, buttonUpDown : int var firstTime : boolean := true % Initialize the mouse. buttonchoose("onebutton") loop % Wait for a button click. buttonwait("downup", x, y, buttonNum, buttonUpDown) % Erase old crosshairs, if present. if not firstTime then % Erase old crosshairs drawCrossHairs(oldx, oldy, White) end if firstTime := false % Draw crosshairs at new position and record the position. drawCrossHairs(x, y, Black) oldx := x oldy := y end loop