GLBasic forum

Codesnippets => Code Snippets => Topic started by: Devlin on 2007-Feb-12

Title: Something I wrote to help me animate my stuff
Post by: Devlin on 2007-Feb-12
Dunno if there's something better out there, but all that stuff about timers and stuff just confused me silly...

Code: (glbasic) [Select]
//
// Add this to your main loop :
// counter=counter+1
//
// Function AnimSprite (idlo,idhi,delay,x,y)
// Animates a string of sprite id's
//
// idlo  : Id of beginning of animation
// idhi  : Id of end of animation
// delay : Delay(Recommended value : 10 (may vary per machine, need to improve on this somehow))
// x     : X position of animation
// y     : Y position of animation
FUNCTION animsprite: idlo , idhi , delay , x , y
// local variables : idlo , idhi , delay , x , y

IF frame < idlo
frame = idlo
ENDIF

IF counter = delay
counter=0
frame=frame+1
ENDIF

IF frame > idhi
frame = idlo
ENDIF

SPRITE frame,x,y
ENDFUNCTION //animsprite
//
EDIT : I've fixed another bug :)
Title: Something I wrote to help me animate my stuff
Post by: Kitty Hello on 2007-Feb-12
Cool. I should start packing these stuff into the manual as well.