...is not a function, array, macro or linked list

TailBite specific forum

Moderators: gnozal, ABBKlaus, lexvictory

lexvictory
Addict
Addict
Posts: 1027
Joined: Sun May 15, 2005 5:15 am
Location: Australia
Contact:

Post by lexvictory »

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
Demonio Ardente

Currently managing Linux & OS X Tailbite
OS X TailBite now up to date with Windows!
User avatar
J. Baker
Addict
Addict
Posts: 2178
Joined: Sun Apr 27, 2003 8:12 am
Location: USA
Contact:

Post by J. Baker »

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
www.posemotion.com

PureBasic Tools for OS X: PureMonitor, plist Tool, Data Maker & App Chef

Mac: 10.13.6 / 1.4GHz Core 2 Duo / 2GB DDR3 / Nvidia 320M
PC: Win 7 / AMD 64 4000+ / 3GB DDR / Nvidia 720GT


Even the vine knows it surroundings but the man with eyes does not.
Post Reply