Hello,
Basically, you need 2 things:
1. A timer of some sort to wait for the click
2. The screen position and dimensions of the square
The code that follows has the idea. It uses 2 subroutines (blocks of code that can be jumped to and returned from) to control the drawing and placement of the square. The Subroutines are basically psuedocode so you will have to put in the "real" code to get them to work.
set display mode 800,600,16
sync on
sync rate 60
rem first thing, place your square and get it's screen position
gosub _place_square
do
rem set up a timer that waits 5 seconds
tim=timer()
while timer() - tim < 5000
rem check for click
if mouseclick()=1
rem you clicked in time so now check if you are within the image
mx=mousex() : my=mousey()
if mouse_within(mx,my,x1,y1,x2,y2)=1
rem if it's true, jump to points routine
gosub _get_points
exit : rem exit while loop
endif
endif
rem redraw the image on screen
gosub _draw_square
sync
endwhile
rem place the square randomly on screen again
gosub _place_square
sync
loop
_place_square:
rem this subroutine holds the code to place the square on the
rem screen and to get the screen position and assign x1,y1,x2,y2
cls
` x1 = random screen x value
` x2 = x1 + x size of square
` y1 = random screen y value
` y2 = y1 + y size of square
rem draw the image at it's new location
gosub _draw_image
return
`=========================================================
_draw_square:
rem draw the image at the coordinates you got from _place_square
` paste image num, x1, y1
return
`=========================================================
_get_points:
rem score
inc points
return
`=========================================================
mouse_within(mx,my,x1,y1,x2,y2)
result=0
if mx>=x1
if mx<=x2
if my>=y1
if my<=y2
result=1
endif
endif
endif
endif
return result
_place_square gets the new screen position of the square whenever you want to change it's location.
_draw_square draws the image with the new coordinates created by _place_square.
In the main loop, there is a While Endwhile loop that checks if a certain amount of time has passed (5 secs). If you click the LEFT button of the mouse, the next check is to see if the click occurs within the screen dimensions that were set up when _place_square was last called. If it was, and it was within the 5 secs, then it jumps to the _get_points routine and increases the points, exits out of the While loop and then chooses another screen location for the block.
The framework is there, it's up to you to fill in the blanks.
And just an extra note, random screen positions can be gotten using the rnd() command and the screen sizes:
randomx = rnd(screen width())
randomy = rnd(screen height())
Enjoy your day.