Might want to put a _LIMIT statement to "guard" the big loop. Otherwise this program is going to take over the entire CPU. :O
Also just after the LINE and PRINT statements for the mouse buttons, put a _DISPLAY if the LINE statements are constantly erasing the central area of the program. People get easily irritated with screen flickering even in simple programs.
THIS IS HOW I FIXED IT:
Also just after the LINE and PRINT statements for the mouse buttons, put a _DISPLAY if the LINE statements are constantly erasing the central area of the program. People get easily irritated with screen flickering even in simple programs.
THIS IS HOW I FIXED IT:
Code: (Select All)
DIM updscreen AS _BYTE
DIM mousesector(10, 5) AS INTEGER
mousesector(1, 1) = 1 'xi
mousesector(1, 2) = 1 'yi
mousesector(1, 3) = 320 'xf
mousesector(1, 4) = 480 'yf
mousesector(1, 5) = 1 'option selected
mousesector(2, 1) = 321 'xi
mousesector(2, 2) = 1 'yi
mousesector(2, 3) = 639 'xf
mousesector(2, 4) = 480 'yf
mousesector(2, 5) = 2 'option selected
SCREEN 12
LINE (99, 9)-(601, 401), 7, BF
LINE (101, 11)-(599, 399), 8, BF
tm$ = " Column = ### Row = ### Button1 = ## Button2 = ## Button3 = ##"
LOCATE 29, 20: PRINT "LeftButton = draw - RightButton = Erase";
DO
_LIMIT 1000
updscreen = 0
K$ = INKEY$
DO WHILE _MOUSEINPUT
X = _MOUSEX: Y = _MOUSEY
IF X > 100 AND X < 600 AND PX > 100 AND PX < 600 THEN
IF Y > 10 AND Y < 400 AND PY > 10 AND PY < 400 THEN
IF _MOUSEBUTTON(1) THEN LINE (PX, PY)-(X, Y), 15 : updscreen = 1
IF _MOUSEBUTTON(2) THEN LINE (101, 11)-(599, 399), 8, BF : updscreen = 1
END IF
END IF
PX = X: PY = Y
IF updscreen THEN
LOCATE 27, 10: PRINT USING tm$; X; Y; _MOUSEBUTTON(1); _MOUSEBUTTON(2); _MOUSEBUTTON(3)
_DISPLAY
updscreen = 0
END IF
LOOP
'---------------------- code detecting sector --------------
IF _MOUSEBUTTON(1) THEN
FOR i = 1 TO 2
IF X > mousesector(i, 1) AND Y > mousesector(i, 2) AND X < mousesector(i, 3) AND Y < mousesector(i, 4) THEN
OptionSelected = mousesector(i, 5)
LOCATE 28, 19: PRINT "OPTION SELECTED: "; OptionSelected
updscreen = 1
END IF
NEXT
END IF
'----------------- end code -------------
IF updscreen THEN _DISPLAY
LOOP UNTIL K$ = CHR$(27)
SYSTEM