var x, y, b : int %the x,y coordinates for the mouse, and b for button
var pic : int := Pic.FileNew ("c:/sites/images/avatars&sigs/blademoon.jpg") %import pic
var sx, sy : int := 100 %the co-ordinates of x,y
View.Set ("Graphics:600;600,nobuttonbar,offscreenonly")
loop %loop to keep checking
Mouse.Where (x, y, b) %checking to see where the mouse is, and if the button's been clicked
Pic.Draw (pic, sx, sy, picMerge) %continuing to draw the picture
if (x > sx & x < sx + Pic.Width(pic) & y > sy & y < sy + Pic.Height(pic) & b = 1) then %check to see if the image has been clicked on
loop %loop to move the image
Mouse.Where (x, y, b) %checking if you've moved the mouse
Pic.Draw (pic, sx, sy, picMerge) %must draw the picture while moving
sx := x - Pic.Width(pic) div 2 %set the new co-ordinates of the picture to where the mouse is
sy := y - Pic.Height(pic) div 2 %same with x, but on the y axis
exit when b = 0 %exits the movement of the picture when you let go of the mouse button
View.Update
cls %clear the screen
end loop
end if
View.Update
cls %clear again..
end loop |