Here's some commented code for ya:
rem this represents the sprite position
cx = rnd(640)
cy = rnd(480)
bullet_speed# = 6
sync on
sync rate 60
do
cls
rem randomly position the sprite
if spacekey()
cx = rnd(640)
cy = rnd(480)
endif
rem if left click
if mouseclick() = 1 and flag = 0
flag = 1
shoot = 1
rem get angle from sprite to the mouse
a# = atanfull(mousex()-cx, mousey()-cy)
rem form a direction vector
dx# = sin(a#)
dy# = cos(a#)
rem starting bullet position (start from the sprite)
bx# = cx
by# = cy
endif
if mouseclick() = 0 then flag = 0
rem if bullet was fired and/or active
if shoot = 1
rem update bullet position
bx# = bx# + dx#*bullet_speed#
by# = by# + dy#*bullet_speed#
rem stop moving bullet if hits mouse
rem simple distance formula: A^2 + B^2 = C^2
if (bx#-mousex())^2 + (by#-mousey())^2 <= 256
shoot = 0
endif
rem stop moving bullet if of screen
if bx# < 0 or bx# > screen width() or by# < 0 or by# > screen height()
shoot = 0
endif
rem show the bullet
ink rgb(255,0,0),0
circle bx#, by#, 4
endif
rem the sprite
ink rgb(0,255,0),0
circle cx, cy, 20
rem the mouse
ink rgb(255,255,0),0
circle mousex(), mousey(), 16
sync
loop