Author Topic: How do you make Bones Man in rows?  (Read 847 times)

0 Members and 1 Guest are viewing this topic.

Offline Hotshot

  • DBF Aficionado
  • ******
  • Posts: 2114
  • Karma: 91
    • View Profile
How do you make Bones Man in rows?
« on: November 03, 2012 »
I have try to make 5 Bones man in rows but they all stuck in one Bones Man  ::)

Code: [Select]
; setup our Screen Width and Height here for easier tracking
#ScreenWidth  = 640
#ScreenHeight = 480

; Initialize the sprite and keyboard systems and a 640x480, 16-bit screen
If InitSprite() = 0 Or InitKeyboard() = 0 Or OpenScreen(#ScreenWidth,#ScreenHeight,16,"App Title") = 0
   MessageRequester("Error!", "Unable to Initialize Environment", #PB_MessageRequester_Ok)
   End
EndIf

; Use the PNG decoder for image loads.
UsePNGImageDecoder()

; load in the sprite
LoadSprite(0,"Bone_1.png")
LoadSprite(1,"Bone_2.png")
LoadSprite(2,"Bone_3.png")


Structure Bone_Man
    X.w           ; track the X position Man
    Y.w           ; track the Y position Man
    Frame.b       ; track the frame we're using in the Man animation
    FrameTimer.b  ; time between frame changes?
    LastChanged.l ; last frame change time?
EndStructure

; setup a list of Man
NewList Man.Bone_Man()

; create a bunch of instances Man
For BCounter = 0 To 5
    If AddElement(Man()) <> 0
       Man()\X = Man()\X *10                     ; TRYING to Split up Bones Men in each distance :(
       Man()\Frame = Random(1)
       Man()\FrameTimer = Random(100) + 30
       Man()\LastChanged = ElapsedMilliseconds()
    Else
       MessageRequester("Error!", "Unable to allocate memory for new element", #PB_MessageRequester_Ok)
       End
    EndIf
Next

Repeat
      ClearScreen(0)

      ; get the current time for processing
      Current_Time = ElapsedMilliseconds()
   
      ForEach Man()
         ; show our sprite (using transparency)
         DisplayTransparentSprite(Man()\Frame,Man()\X,Man()\Y)
     
      ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
      ; Finally let's update the frame
      ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
     
      ; has sufficient time elapsed to change the frame on this Man?
      If Current_Time > Man()\LastChanged + Man()\FrameTimer
         ;if we're on Frame 0, move to 1
         If Man()\Frame = 0
            Man()\Frame = 1
         Else
            ; otherwise move to 0
            Man()\Frame = 0
         EndIf
         ; make sure to reset the LastChanged time!
         Man()\LastChanged = Current_Time
      EndIf
   Next   
 
   FlipBuffers()
   
   ExamineKeyboard()
Until KeyboardReleased(#PB_Key_All)

End

Offline Hotshot

  • DBF Aficionado
  • ******
  • Posts: 2114
  • Karma: 91
    • View Profile
Re: How do you make Bones Man in rows?
« Reply #1 on: November 03, 2012 »
I got the Animations Working :D