I suggest a code inversion to remove a 1 frame delay
the code has
I suggest
With the final code being
the code has
Function DragImage() While MouseDown(1) Cls DrawImage img,imgx,imgy DrawImage mouse,MouseX(),MouseY() imgx = MouseX() + distx imgy = MouseY() + disty Flip Wend End Function
I suggest
Function DragImage() While MouseDown(1) Cls imgx = MouseX() + distx imgy = MouseY() + disty DrawImage img,imgx,imgy DrawImage mouse,MouseX(),MouseY() Flip Wend End Function
With the final code being
Graphics 800,600,16,2 AutoMidHandle True HidePointer() Global mouse = CreateImage(10,10) Global img = CreateImage(100,20) Global imgx = 100 Global imgy = 100 Global distx = 0 Global disty = 0 SetBuffer ImageBuffer(mouse) Color 100,100,100 Rect 0,0,10,10,1 SetBuffer ImageBuffer(img) Color 100,0,0 Rect 0,0,100,20,1 SetBuffer BackBuffer() While Not KeyHit(1) Cls DrawImage img,imgx,imgy DrawImage mouse,MouseX(),MouseY() If ImagesCollide(mouse,MouseX(),MouseY(),0,img,imgx,imgy,0) distx = imgx - MouseX() disty = imgy - MouseY() DragImage() EndIf Flip Wend Function DragImage() While MouseDown(1) Cls imgx = MouseX() + distx imgy = MouseY() + disty DrawImage img,imgx,imgy DrawImage mouse,MouseX(),MouseY() Flip Wend End Function