News:

PlayBASIC2DLL V0.99 Revision I Commercial Edition released! - Convert PlayBASIC programs to super fast Machine Code. 

Main Menu

Help sprite

Started by Emicrania, November 27, 2009, 11:32:24 AM

Previous topic - Next topic

Emicrania

Hi!
I'm a totally newby and i'm having problems to understand how to animate sprites. For example i got the frames of every single movement  but i don't know how to put them together in Playbasic... how to substitute a circle (of the scrolling tutorial) with my animations? I read the tutorials but still seems very complicated to me...

kevin

#1
 Well, in order to help you,  we need more information.  Otherwise if somebody writes an example, then it most probably won't do exactly what you need.  So can you show what have you've got so far ?

How are the animation frames arranged on the picture(s) ??  if they're ordered in evenly spaced installments, then you might be able to just use the    Frame Sheet Animation Lib

If they're not, then you'll need to break up the frames manually.   But without seeing the animation I can't tell. 

Also see -> Introduction to Animation


Emicrania

The animation is the same of my avatar! Is ripped from super castlevania IV. I got the frames separated. Anyway i must read the tutorial.

kevin


So the Animation is currently a GIF animation ?   If so, you'll need to extract the frames before you can load it..


LemonWizard

Quote from: Emicrania on November 27, 2009, 12:10:04 PM
The animation is the same of my avatar! Is ripped from super castlevania IV. I got the frames separated. Anyway i must read the tutorial.

If you have the frames seperated you have to load each frame as a seperate image. Then, you have to increment which frame is drawn, and draw it in the same place as the previous frame, and then continue animating until you get to the next frame. Then, you have to change the frame back to the first one. And do it again. This is simpler than you think.

rename the images "frame" and put a number in front of them.

put them in the same folder as your project.

Then type in this code

SETFPS 30 ;use this to control the frame rate
frames=5 ;change this values for how many files you have
dim sprite(frames)
for temp=1 to frames
sprite(temp)=loadnewfximage("Frame"+str$(temp)+str$(.bmp)")
;(the file extension has to be the same as the files you have)
next temp
fcount=1
maxfcount=frames
rendertoscreen ;change it so that all images and direct draw are done on the screen
main:
drawimage sprite(fcount), 100, 100, 0
fcount=fcount+1 ; this line changes the frame to the next one
if fcount >maxfcount then fcount=1 ;wrap the value between the total number of frames, and 1



sync ;you should sync the screen before clearing it only once per loop
cls rgb(0,0,0) ;clear the screen ;you should clear the screen once per loop if you are drawing animations
goto main ;this is the only thing you really should change. you could change this to do loop but I like it better this way.
;this is roughly the only goto statement you'll ever see ME use.. hehe