Main Menu

Animation with bmp strips

Started by Cor, December 01, 2004, 07:42:23 AM

Previous topic - Next topic

Cor

How to display a strip image bmp file which consists of e.g. 8 x 64x64 images onto the screen, and sequential play the images.

gr.
Cor de Visser
Author of Super Guitar Chord Finder
http://www.ready4music.com
http://www.chordplanet.com

kevin

#1
Animation is still on the back burner, haven't decided on the best way to implement it..  In the mean time, what i normally do, is load an image and grab the frames from it as a set of images and store them in array.  

So this means that the user drives animation of the sprite, not the engine.    One of the reasons why, is that animation on it's own is only part of  the issue. If the sprite is auto animated it can be really tedious to sequence it movement.   I've always  preferred to building in a more robust Animation/Movement system.. but all in time..

This function loads a image strip/page to an array.  The array will contain the image of indexs are the load.. the number of frames is stored in index 0 of the array


PlayBASIC Code: [Select]
Function Load_Anim(AnimFrames(),File$,Frames,FrameWidth,FrameHeight,TransparentColour) 
Index=GetFreeImage()
LoadImage file$,Index

width=GetImageWidth(index)
height=GetImageHeight(index)

Dim AnimFrames(Frames)
AnimFrames(0)=Frames

For lp=1 To frames
RenderToImage Index
FreeImage=GetFreeImage()
AnimFrames(lp)=FreeImage
GetImage FreeImage,Xpos,Ypos,Xpos+Framewidth,Ypos+FrameHeight
ImageMaskColour FreeImage,TransparentColour
Xpos=Xpos+Framewidth
If Xpos=>width Then Xpos=0: Ypos=Ypos+FRameHeight
Next
RenderToScreen
DeleteImage index
EndFunction






  See PlayBASIC Documentation  - Frame Sheet Animations




Cor

Kevin,

Could you please make a working example of this including a bitmap image

gr.

cor

QuoteAnimation is still on the back burner, haven't decided on the best way to implement it..  In the mean time, what i normally do, is load an image and grab the frames from it as a set of images and store them in array. 

So this means that the user drives animation of the sprite, not the engine.    One of the reasons why, is that animation on it's own is only part of  the issue. If the sprite is auto animated it can be really tedious to sequence it movement.   I've always  preferred to building in a more robust Animation/Movement system.. but all in time..

This function loads a image strip/page to an array.  The array will contain the image of indexs are the load.. the number of frames is stored in index 0 of the array

Function Load_Anim(AnimFrames(),File$,Frames,FrameWidth,FrameHeight,TransparentColour)
 Index=GetFreeImage()
 LoadImage file$,Index  
 
 width=GetImageWidth(index)
 height=GetImageHeight(index)

 Dim AnimFrames(Frames)
 AnimFrames(0)=Frames

 For lp=1 To frames
  RenderToImage Index
  FreeImage=GetFreeImage()
  AnimFrames(lp)=FreeImage
  GetImage FreeImage,Xpos,Ypos,Xpos+Framewidth,Ypos+FrameHeight
  ImageMaskColour FreeImage,TransparentColour
  Xpos=Xpos+Framewidth
  If Xpos=>width Then Xpos=0: Ypos=Ypos+FRameHeight
 Next
 RenderToScreen
 DeleteImage index
EndFunction


Cor de Visser
Author of Super Guitar Chord Finder
http://www.ready4music.com
http://www.chordplanet.com

kevin

i posted an example in the source code forum bellow