I have made an approach to a pointer-trail composed by lines, or sprites, as a snake, or as the way the gradius konami's game for its "option" selection.
Well, much better than my explanations, just see the behaviour of my approach to understand it:
Code: Select all
Structure Vector3D
x.f:y.f:z.f:m.f
color.l
EndStructure
Global puntero.Vector3D,punterodelta.Vector3D,SCREENWIDTH.u=GetSystemMetrics_(#SM_CXSCREEN),SCREENHEIGHT.u=GetSystemMetrics_(#SM_CYSCREEN),bitplanes.a=32,puntero\x=SCREENWIDTH/2,puntero\y=SCREENHEIGHT/2
Global wind.Vector3D:wind\x=0:wind\y=0
InitMouse():InitSprite():InitKeyboard()
OpenScreen(SCREENWIDTH,SCREENHEIGHT,bitplanes,title$)
Global NewList estela_puntero.Vector3D()
#maxlenstela=10
#colorestelapuntero=$0FABE5
#lenestela=7
MouseLocate(puntero\x,puntero\y)
For a.u=1 To #maxlenstela
AddElement(estela_puntero()):estela_puntero()\color=#colorestelapuntero
Next
Repeat
ClearScreen(RGB(5,8,9)):ExamineKeyboard():ExamineMouse()
punterodelta\x=MouseDeltaX():punterodelta\y=MouseDeltaY()
puntero\x=MouseX():puntero\y=MouseY()
If FirstElement(estela_puntero()); And (punterodelta\x Or punterodelta\y)
estela_puntero()\x=#lenestela*(-punterodelta\x+wind\x):estela_puntero()\y=#lenestela*(-punterodelta\y+wind\y)
If LastElement(estela_puntero())
*p.Vector3D=@estela_puntero()
While PreviousElement(estela_puntero())
CopyMemory(@estela_puntero(),*p,SizeOf(Vector3D))
*p=@estela_puntero()
Wend
EndIf
EndIf
StartDrawing(ScreenOutput())
prev.Vector3D\x=puntero\x:prev.Vector3D\y=puntero\y
ForEach estela_puntero()
Circle(prev\x+estela_puntero()\x,prev\y+estela_puntero()\y,8,estela_puntero()\color)
Line(prev\x,prev\y,estela_puntero()\x,estela_puntero()\y,estela_puntero()\color)
prev\x+estela_puntero()\x:prev\y+estela_puntero()\y
Next
Circle(puntero\x,puntero\y,14,$C01177)
StopDrawing()
FlipBuffers():Delay(15)
Until KeyboardPushed(#PB_Key_Escape)
CloseScreen()
Thanks in advance!