lexvictory wrote:J. Baker wrote:It will be needed to animate more then one sprite. I'll have to come up with another method.
You would have the same effect using static; calling the function with different params doesn't change the location of the static variable used...
Global does work on arrays if that's what you're thinking
First, I would like to thank you for helping.
Also, I just tried the following code which does compile to a working lib but doesn't work with multiple sprites yet, as I removed
Static. Still working on it.
Code: Select all
Structure SpriteCalculations
FramesPerColumn.l
LoopFrames.l
DivXStart.l
MulXStart.l
MinXStart.l
DivXEnd.l
MulXEnd.l
MinXEnd.l
XEnd.l
YEnd.l
XStart.l
YStart.l
Loop.l
EndStructure
ProcedureDLL AnimateSprite(Sprite, ClipWidth, ClipHeight, FramesPerRow, NumberOfFrames, StartFrame, EndFrame, FpsDelay)
Global Dim Sprites.SpriteCalculations(99)
Sprites(Sprite)\FramesPerColumn = Round((NumberOfFrames / FramesPerRow), #PB_Round_Up)
Sprites(Sprite)\LoopFrames + 1
If Sprites(Sprite)\LoopFrames > EndFrame
Sprites(Sprite)\LoopFrames = StartFrame
EndIf
If Sprites(Sprite)\LoopFrames = StartFrame
Sprites(Sprite)\DivXStart = Round(StartFrame / FramesPerRow, #PB_Round_Down)
Sprites(Sprite)\MulXStart = Sprites(Sprite)\DivXStart * FramesPerRow
Sprites(Sprite)\MinXStart = StartFrame - Sprites(Sprite)\MulXStart
Sprites(Sprite)\XStart = (Sprites(Sprite)\MinXStart * ClipWidth) - ClipWidth
If Sprites(Sprite)\XStart < 0
Sprites(Sprite)\XStart = 0
EndIf
Sprites(Sprite)\YStart = (Round(StartFrame / Sprites(Sprite)\FramesPerColumn, #PB_Round_Up) * ClipHeight) - ClipHeight
EndIf
Sprites(Sprite)\DivXEnd = Round(StartFrame / FramesPerRow, #PB_Round_Down)
Sprites(Sprite)\MulXEnd = Sprites(Sprite)\DivXEnd * FramesPerRow
Sprites(Sprite)\MinXEnd = StartFrame - Sprites(Sprite)\MulXEnd
Sprites(Sprite)\XEnd = (Sprites(Sprite)\MinXend * ClipWidth) - ClipWidth
Sprites(Sprite)\YEnd = (Round(StartFrame / Sprites(Sprite)\FramesPerColumn, #PB_Round_Up) * ClipHeight) - ClipHeight
ClipSprite(Sprite, Sprites(Sprite)\XStart, Sprites(Sprite)\YStart, ClipWidth, ClipHeight)
If Sprites(Sprite)\Loop > FpsDelay
Sprites(Sprite)\XStart + ClipWidth
If Sprites(Sprite)\XStart = ClipWidth * FramesPerRow
Sprites(Sprite)\YStart + ClipHeight
Sprites(Sprite)\DivXStart = Round(StartFrame / FramesPerRow, #PB_Round_Down)
Sprites(Sprite)\MulXStart = Sprites(Sprite)\DivXStart * FramesPerRow
Sprites(Sprite)\MinXStart = StartFrame - Sprites(Sprite)\MulXStart
Sprites(Sprite)\XStart = (Sprites(Sprite)\MinXStart * ClipWidth) - ClipWidth
If Sprites(Sprite)\XStart < 0
Sprites(Sprite)\XStart = 0
EndIf
EndIf
Sprites(Sprite)\Loop = 1
If Sprites(Sprite)\XStart = Sprites(Sprite)\XEnd And Sprites(Sprite)\YStart = Sprites(Sprite)\YEnd
Sprites(Sprite)\LoopFrames = StartFrame - 1
EndIf
Else
Sprites(Sprite)\LoopFrames - 1
Sprites(Sprite)\Loop + 1
EndIf
EndProcedure