'🔶 — DECLARATIONS —
STRUCTURE select_color
x1%
y1%
x2%
y2%
END STRUCTURE
scw% = 160 : sch% = 40
DIM this_color(0 TO 15) AS select_color
DIM xpos_now%, ypos_now%
DEFDV MouseInBounds% = ( _MOUSEY >= 0 ) _
AND ( _MOUSEY < sch%) _
AND ( _MOUSEX >= 0) _
AND ( _MOUSEX < scw%)
'🔶 — 🏁🏁🏁 MAIN PROGRAM 🏁🏁🏁 —
SCREEN _NEWIMAGE(scw%, sch%, 12)
GOSUB ➔SetupColors
DO
IF _MOUSEBUTTON AND MouseInBounds% THEN
WHILE _MOUSEBUTTON : WEND
IF MouseInBounds% THEN _
xpos_now% = _MOUSEX : _
ypos_now% = _MOUSEY : _
GOSUB ➔HandleColorChosen
END IF
LOOP
END
'🔶 — SUBROUTINES —
➔SetupColors:
FOR this_row = 0 TO 1 : FOR this_col = 0 TO 7
index = ( this_row * 8 ) + this_col
this_color(index).x1% = this_col * 20
this_color(index).y1% = this_row * 20
this_color(index).x2% = this_color(index).x1% + 20
this_color(index).y2% = this_color(index).y1% + 19
LINE _
( this_color(index).x1%, this_color(index).y1% ) _
- ( this_color(index).x2%, this_color(index).y2% ), _
index, BF
NEXT this_col : NEXT this_row
RETURN
➔HandleColorChosen:
FOR index = 0 to 15
IF xpos_now% >= this_color(index).x1% _
AND xpos_now% <= this_color(index).x2% _
AND ypos_now% >= this_color(index).y1% _
AND ypos_now% <= this_color(index).y2% _
THEN _ALERT("color: " + index) : RETURN
NEXT index
RETURN