Uses 2d circle commands instead HowDo's sprites. Obviously, his can have a fancier looking gui.
#constant BUTTON_RADIUS = 4
type MyValue
a as integer
b as dword
c as string
endtype
type radioButton
groupID as integer
x as integer
y as integer
state as integer
value as MyValue
endtype
dim buttons(0) as radioButton
stuff as MyValue
addButton(1,56,35,stuff)
addButton(1,36,35,stuff)
addButton(1,16,35,stuff)
addButton(2,56,135,stuff)
addButton(2,36,135,stuff)
addButton(2,16,135,stuff)
repeat
cls
click_buttons()
draw_buttons()
until spacekey()
function addButton(group as integer, x as integer, y as integer, values as MyValue)
array insert at top buttons()
buttons(0).groupID = group
buttons(0).x = x
buttons(0).y = y
buttons(0).state = 0
buttons(0).value = values
endfunction
function draw_buttons()
for i = 0 to array count(buttons())-1
circle buttons(i).x,buttons(i).y,BUTTON_RADIUS
if buttons(i).state = 1 then circle buttons(i).x,buttons(i).y,1
next i
endfunction
function click_buttons()
_MC = mouseclick()
for i = 0 to array count(buttons())-1
if _MC = 1
if (mousex()-buttons(i).x)^2 + (mousey()-buttons(i).y)^2 <= BUTTON_RADIUS*BUTTON_RADIUS
buttons(i).state = 1
rem change state to off for all other buttons in THIS(selected button's) group
for j = 0 to array count(buttons())-1
if j <> i
if buttons(j).groupID = buttons(i).groupID then buttons(j).state = 0
endif
next j
rem exit early (cause you can only click 1 button at a time)
exitfunction
endif
endif
next i
endfunction
rem unfortunately, you cannot return a UDT from a function and therefore
rem we are stuck using a global variable to get the data we need
function getSelectedValue(group as integer)
for i = 0 to array count(buttons())-1
if buttons(i).groupID = group
if buttons(i).state = 1 then returnedValue = buttons(i).value : exitfunction
endif
next i
endfunction
PETA - People for the Eating of Tasty Animals
