Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Mapping screen for mouse
#3
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:

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
Reply


Messages In This Thread
Mapping screen for mouse - by PhilOfPerth - 08-07-2023, 01:52 AM
RE: Mapping screen for mouse - by commandvom - 08-07-2023, 02:32 AM
RE: Mapping screen for mouse - by mnrvovrfc - 08-07-2023, 03:36 AM
RE: Mapping screen for mouse - by mnrvovrfc - 08-07-2023, 03:51 AM
RE: Mapping screen for mouse - by PhilOfPerth - 08-07-2023, 04:14 AM
RE: Mapping screen for mouse - by SMcNeill - 08-07-2023, 07:25 AM
RE: Mapping screen for mouse - by PhilOfPerth - 08-08-2023, 06:53 AM
RE: Mapping screen for mouse - by TerryRitchie - 08-07-2023, 08:36 AM
RE: Mapping screen for mouse - by grymmjack - 08-07-2023, 02:32 PM
RE: Mapping screen for mouse - by TerryRitchie - 08-07-2023, 03:29 PM
RE: Mapping screen for mouse - by grymmjack - 08-08-2023, 12:12 AM
RE: Mapping screen for mouse - by TerryRitchie - 08-08-2023, 05:10 PM
RE: Mapping screen for mouse - by bplus - 08-07-2023, 02:36 PM
RE: Mapping screen for mouse - by TerryRitchie - 08-07-2023, 03:34 PM
RE: Mapping screen for mouse - by CharlieJV - 08-07-2023, 09:37 PM
RE: Mapping screen for mouse - by grymmjack - 08-08-2023, 12:17 AM
RE: Mapping screen for mouse - by CharlieJV - 08-08-2023, 01:53 AM
RE: Mapping screen for mouse - by grymmjack - 08-08-2023, 12:11 AM
RE: Mapping screen for mouse - by mnrvovrfc - 08-08-2023, 12:37 PM
RE: Mapping screen for mouse - by bplus - 08-07-2023, 05:44 PM
RE: Mapping screen for mouse - by justsomeguy - 08-07-2023, 07:55 PM
RE: Mapping screen for mouse - by CharlieJV - 08-07-2023, 09:35 PM
RE: Mapping screen for mouse - by grymmjack - 08-08-2023, 12:07 AM
RE: Mapping screen for mouse - by mdijkens - 08-08-2023, 10:24 AM
RE: Mapping screen for mouse - by bplus - 08-07-2023, 08:47 PM
RE: Mapping screen for mouse - by justsomeguy - 08-07-2023, 09:16 PM
RE: Mapping screen for mouse - by justsomeguy - 08-07-2023, 09:22 PM
RE: Mapping screen for mouse - by CharlieJV - 08-07-2023, 09:46 PM
RE: Mapping screen for mouse - by justsomeguy - 08-07-2023, 10:03 PM
RE: Mapping screen for mouse - by CharlieJV - 08-07-2023, 10:57 PM
RE: Mapping screen for mouse - by bplus - 08-07-2023, 11:37 PM
RE: Mapping screen for mouse - by TerryRitchie - 08-08-2023, 02:45 AM
RE: Mapping screen for mouse - by PhilOfPerth - 08-08-2023, 06:59 AM
RE: Mapping screen for mouse - by bplus - 08-08-2023, 12:25 PM
RE: Mapping screen for mouse - by mdijkens - 08-08-2023, 01:16 PM
RE: Mapping screen for mouse - by justsomeguy - 08-08-2023, 06:59 PM



Users browsing this thread: 7 Guest(s)