It is currently Sun May 19, 2013 1:39 am

All times are UTC + 1 hour




Post new topic Reply to topic  [ 9 posts ] 
Author Message
 Post subject: AnimateSprite3D for Windows Mac and Linux
PostPosted: Sun Jul 24, 2011 7:33 am 
Offline
Addict
Addict
User avatar

Joined: Sun Apr 27, 2003 8:12 am
Posts: 1620
Location: USA
Here's a small procedure for animating Sprite3D. Download zip file for an example. ;)

DOWNLOAD EXAMPLE

Code:
Structure Sprite3DCalculations
  Animate.l
  Loop.l
  LoopStart.l
EndStructure

Procedure AnimateSprite3D(Sprite3D, SpriteNumberFrom, SpriteNumberTo, FpsDelay) ;FpsDelay must have a value of 1 or higher in order to playback fps accurately

  Static Dim Sprites3D.Sprite3DCalculations(99) ;99 can be change to however many AnimatedSprite3D's you want to use
 
  If Sprites3D(Sprite3D)\LoopStart = 0 ;as it should when first started
      Sprites3D(Sprite3D)\Loop = FpsDelay ;we make sure we start the first sprite frame without delay or error
      Sprites3D(Sprite3D)\LoopStart = 1 ;then we kill it as this is only needed to start with
  EndIf
 
  If Sprites3D(Sprite3D)\Loop = FpsDelay ;if true we change to the next sprite frame
 
    If Sprites3D(Sprite3D)\Animate = (SpriteNumberTo - SpriteNumberFrom) +1 ;if the last sprite frame is used we need to restart from the first sprite frame
        Sprites3D(Sprite3D)\Animate = 0 ;reset Animate back to 0
    EndIf
   
      CreateSprite3D(Sprite3D, SpriteNumberFrom + Sprites3D(Sprite3D)\Animate) ;this keeps updating the sprite frames with the same Sprite3D
   
      Sprites3D(Sprite3D)\Animate +1 ;getting ready for the next sprite frame
     
      Sprites3D(Sprite3D)\Loop = 1 ;restart the FpsDelay loop
     
    Else
     
      Sprites3D(Sprite3D)\Loop +1 ;if the loop doesn't = FpsDelay we add +1 until it does
     
   EndIf
   
EndProcedure

_________________
AMD 64 4000+ / 1GB PC2700 / WIN XP Home SP3 / Nvidia GT220 x16 512MB / M-Audio Revolution 5.1
Macbook Air 11.6" - 2010 / OS X 10.8

http://www.posemotion.com
http://www.flashpulse.com


Last edited by J. Baker on Wed Jul 27, 2011 9:54 am, edited 9 times in total.

Top
 Profile  
 
 Post subject: Re: AnimateSprite3D for Windows Mac and Linux
PostPosted: Sun Jul 24, 2011 9:26 am 
Offline
Addict
Addict
User avatar

Joined: Sun Apr 27, 2003 8:12 am
Posts: 1620
Location: USA
EDIT: Removed this code as its no longer needed.

_________________
AMD 64 4000+ / 1GB PC2700 / WIN XP Home SP3 / Nvidia GT220 x16 512MB / M-Audio Revolution 5.1
Macbook Air 11.6" - 2010 / OS X 10.8

http://www.posemotion.com
http://www.flashpulse.com


Last edited by J. Baker on Sun Jul 24, 2011 7:53 pm, edited 1 time in total.

Top
 Profile  
 
 Post subject: Re: AnimateSprite3D for Windows Mac and Linux
PostPosted: Sun Jul 24, 2011 10:28 am 
Offline
Addict
Addict
User avatar

Joined: Sun Apr 27, 2003 8:12 am
Posts: 1620
Location: USA
EDIT: removed comments as they pertained to the old procedure.

_________________
AMD 64 4000+ / 1GB PC2700 / WIN XP Home SP3 / Nvidia GT220 x16 512MB / M-Audio Revolution 5.1
Macbook Air 11.6" - 2010 / OS X 10.8

http://www.posemotion.com
http://www.flashpulse.com


Last edited by J. Baker on Sun Jul 24, 2011 7:58 pm, edited 1 time in total.

Top
 Profile  
 
 Post subject: Re: AnimateSprite3D for Windows Mac and Linux
PostPosted: Sun Jul 24, 2011 10:53 am 
Offline
Addict
Addict
User avatar

Joined: Thu Aug 07, 2003 7:01 pm
Posts: 2853
Location: United Kingdom
Thanks for this. :)

_________________
http://www.SinisterSoft.com <- My Business website
http://www.ReportComplete.com and http://www.ReportPlus.co.uk <- School end of term reports system


Top
 Profile  
 
 Post subject: Re: AnimateSprite3D for Windows Mac and Linux
PostPosted: Sun Jul 24, 2011 7:57 pm 
Offline
Addict
Addict
User avatar

Joined: Sun Apr 27, 2003 8:12 am
Posts: 1620
Location: USA
Ok, new procedure updated on the first post. It now includes the FpsDelay within it. So if your games fps is 60 and your AnimateSprite3D is 15 fps, you would just put a 4 as the FpsDelay value. I'm sure you get it. ;)

_________________
AMD 64 4000+ / 1GB PC2700 / WIN XP Home SP3 / Nvidia GT220 x16 512MB / M-Audio Revolution 5.1
Macbook Air 11.6" - 2010 / OS X 10.8

http://www.posemotion.com
http://www.flashpulse.com


Top
 Profile  
 
 Post subject: Re: AnimateSprite3D for Windows Mac and Linux
PostPosted: Sun Jul 24, 2011 8:11 pm 
Offline
Addict
Addict
User avatar

Joined: Sun Apr 27, 2003 8:12 am
Posts: 1620
Location: USA
DoubleDutch wrote:
Thanks for this. :)

Your welcome! ;)

_________________
AMD 64 4000+ / 1GB PC2700 / WIN XP Home SP3 / Nvidia GT220 x16 512MB / M-Audio Revolution 5.1
Macbook Air 11.6" - 2010 / OS X 10.8

http://www.posemotion.com
http://www.flashpulse.com


Top
 Profile  
 
 Post subject: Re: AnimateSprite3D for Windows Mac and Linux
PostPosted: Mon Jul 25, 2011 12:36 am 
Offline
Addict
Addict
User avatar

Joined: Sun Apr 27, 2003 8:12 am
Posts: 1620
Location: USA
Ok, small code change. FpsDelay must have a value of 1 or higher. As no frame starts at 0 because it doesn't exist. Otherwise a delay of 4 would have actually been 5. I updated the code above and the download example. ;)

_________________
AMD 64 4000+ / 1GB PC2700 / WIN XP Home SP3 / Nvidia GT220 x16 512MB / M-Audio Revolution 5.1
Macbook Air 11.6" - 2010 / OS X 10.8

http://www.posemotion.com
http://www.flashpulse.com


Top
 Profile  
 
 Post subject: Re: AnimateSprite3D for Windows Mac and Linux
PostPosted: Wed Jul 27, 2011 9:57 am 
Offline
Addict
Addict
User avatar

Joined: Sun Apr 27, 2003 8:12 am
Posts: 1620
Location: USA
Ok, I made a big mistake of only testing this with sprite numbers from 1 to 15. I wasn't even thinking like if sprite numbers 31 to 45 or something were used. But the code has been fixed and I added better comments. My apologies. ;)

_________________
AMD 64 4000+ / 1GB PC2700 / WIN XP Home SP3 / Nvidia GT220 x16 512MB / M-Audio Revolution 5.1
Macbook Air 11.6" - 2010 / OS X 10.8

http://www.posemotion.com
http://www.flashpulse.com


Top
 Profile  
 
 Post subject: Re: AnimateSprite3D for Windows Mac and Linux
PostPosted: Fri Jul 29, 2011 8:50 am 
Offline
Addict
Addict
User avatar

Joined: Sun Apr 27, 2003 8:12 am
Posts: 1620
Location: USA
Here's another example with a smaller procedure but you add your own delays in the repeat section. ;)

Will work with the same images in the download example from above.

Code:
Structure Sprite3DCalculations
  Animate.l
EndStructure

Procedure AnimateSprite3D(Sprite, SpriteNumberFrom, SpriteNumberTo)

  Static Dim Sprites3D.Sprite3DCalculations(99)
 
    If Sprites3D(Sprite)\Animate = (SpriteNumberTo - SpriteNumberFrom) +1
      Sprites3D(Sprite)\Animate = SpriteNumberFrom -1
    EndIf
 
      Sprites3D(Sprite)\Animate +1
   
    CreateSprite3D(Sprite, Sprites3D(Sprite)\Animate)
   
EndProcedure

If InitKeyboard() = 0
   MessageRequester("Error!", "Keyboard system can not be initialized.", 0)
  End
EndIf

If InitSprite() = 0
   MessageRequester("Error!", "Sprite system can not be initialized.", 0)
  End
EndIf

If InitSprite3D() = 0
   MessageRequester("Error!", "Sprite3D system can't be initialized.", 0)
  End
EndIf

UsePNGImageDecoder()

If OpenScreen(1280, 720, 32, "Sprite3D Animated", #PB_Screen_SmartSynchronization)
 
  CatchSprite(1, ?Pic1, #PB_Sprite_Texture | #PB_Sprite_AlphaBlending)
  CatchSprite(2, ?Pic2, #PB_Sprite_Texture | #PB_Sprite_AlphaBlending)
  CatchSprite(3, ?Pic3, #PB_Sprite_Texture | #PB_Sprite_AlphaBlending)
  CatchSprite(4, ?Pic4, #PB_Sprite_Texture | #PB_Sprite_AlphaBlending)
  CatchSprite(5, ?Pic5, #PB_Sprite_Texture | #PB_Sprite_AlphaBlending)
  CatchSprite(6, ?Pic6, #PB_Sprite_Texture | #PB_Sprite_AlphaBlending)
  CatchSprite(7, ?Pic7, #PB_Sprite_Texture | #PB_Sprite_AlphaBlending)
  CatchSprite(8, ?Pic8, #PB_Sprite_Texture | #PB_Sprite_AlphaBlending)
  CatchSprite(9, ?Pic9, #PB_Sprite_Texture | #PB_Sprite_AlphaBlending)
  CatchSprite(10, ?Pic10, #PB_Sprite_Texture | #PB_Sprite_AlphaBlending)
  CatchSprite(11, ?Pic11, #PB_Sprite_Texture | #PB_Sprite_AlphaBlending)
  CatchSprite(12, ?Pic12, #PB_Sprite_Texture | #PB_Sprite_AlphaBlending)
  CatchSprite(13, ?Pic13, #PB_Sprite_Texture | #PB_Sprite_AlphaBlending)
  CatchSprite(14, ?Pic14, #PB_Sprite_Texture | #PB_Sprite_AlphaBlending)
  CatchSprite(15, ?Pic15, #PB_Sprite_Texture | #PB_Sprite_AlphaBlending)
 
  Sprite3DAniDelay = 4
  ImageSize = 256
 
  Repeat
   
   SetFrameRate(60)
   FlipBuffers()
   ClearScreen(RGB(0,0,0))
   
   Start3D()
    If Sprite3DAniDelay = 4 ;added a delay since the animation is only 15 fps.
      AnimateSprite3D(1, 1, 15)
      Sprite3DAniDelay = 0
    EndIf
     Sprite3DAniDelay +1
      ZoomSprite3D(1, ImageSize +zoom.d, ImageSize +zoom.d)
     DisplaySprite3D(1, 32, 32)
    Stop3D() 
   
    If ImageSize +zoom.d < 512
     zoom.d +0.5
    EndIf
   
   ExamineKeyboard()
   
  Until KeyboardPushed(#PB_Key_Escape)
 
 Else
  MessageRequester("Error!", "Can not open a 1280x720 - 32 bit screen.", 0)
EndIf

End

DataSection
  Pic1: IncludeBinary "images/star00001.png"
  Pic2: IncludeBinary "images/star00002.png"
  Pic3: IncludeBinary "images/star00003.png"
  Pic4: IncludeBinary "images/star00004.png"
  Pic5: IncludeBinary "images/star00005.png"
  Pic6: IncludeBinary "images/star00006.png"
  Pic7: IncludeBinary "images/star00007.png"
  Pic8: IncludeBinary "images/star00008.png"
  Pic9: IncludeBinary "images/star00009.png"
  Pic10: IncludeBinary "images/star00010.png"
  Pic11: IncludeBinary "images/star00011.png"
  Pic12: IncludeBinary "images/star00012.png"
  Pic13: IncludeBinary "images/star00013.png"
  Pic14: IncludeBinary "images/star00014.png"
  Pic15: IncludeBinary "images/star00015.png"
EndDataSection

_________________
AMD 64 4000+ / 1GB PC2700 / WIN XP Home SP3 / Nvidia GT220 x16 512MB / M-Audio Revolution 5.1
Macbook Air 11.6" - 2010 / OS X 10.8

http://www.posemotion.com
http://www.flashpulse.com


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 9 posts ] 

All times are UTC + 1 hour


Who is online

Users browsing this forum: No registered users and 0 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
Jump to:  

 


Powered by phpBB © 2008 phpBB Group
subSilver+ theme by Canver Software, sponsor Sanal Modifiye