Quote: "IF mouseX <= 500 AND >= 645 AND mouseY"
...is definitely appropriate and urged usage.
to further your
best practice dbpro habits, you should only call
mousex() /
mousey()
once during each iteration of your menu routine and store them as variabes for later checks:
set window on
set window position (desktop width() - 640)/2, (desktop height() - 480)/2 `center window
rem generate 128x32 buttons for menu
`blue button
cls rgb (128,128,0)
get image 1, 0,0,128,32,1
cls rgb (255,255,0)
get image 11,0,0,128,32,1
`green button
cls rgb(0,128,0)
get image 2, 0,0,128,32,1
cls rgb(0,255,0)
get image 12,0,0,128,32,1
`red button
cls rgb(128,0,0)
get image 3, 0,0,128,32,1
cls rgb(255,0,0)
get image 13,0,0,128,32,1
cls rgb(0,0,0)
do
mx = mousex() : my = mousey() `capture mouse coords ONCE for use this loop
for x = 1 to 3
if mx => 0 and mx < 128 and my => (x*32) and my < (x*32)+ 32
paste image x+10, 0, x*32,1
else
paste image x, 0, x*32,1
endif
next x
loop
the reason behind the practice is that the mouse can move/be repositioned
during a
single loop/iteration which
could cause inaccuracies/ill-effects.
ie, in the basic menu routine above, imagine if the mouse y-position changes between button checks
within the for/next loop, then, technically, 2 of the buttons
could be active at once =
you won't necessarily notice this in such a short piece of code as processing it is a breeze for your system but imagine a seriously-complex, lengthy routine combined with everything else that
could be going on in a fully-developed application/game... i've experienced it myself, as have many others here and, without accounting for it, it's a tough "bug" to track down.
edit: cleaned code up a little
Virtual Nomad @ California, USA . DBPro V7.5
AMD Phenomâ„¢ X4 9750 Quad-Core @ 2.4 GHz . 8 GB PC2-6400 RAM
ATI Radeon HD 3650 @ 512 MB . Vista Home Premium 64 Bit