' ' Provides sprite wrappers routines ' ' $Id$ ' Strict Import noddybox.vector Type TSprite Field x:Float Field y:Float Field v:TVector ' These fields are private ' Field img:TImage Field frames:Int Field pong:Int Field fr:Int Field colmask:Int Field aninmove:Int Field animspeed:Int Field animframe:Int Field animframeinc:Int Function Create:TSprite(i:TImage,anim_speed:Int,ping_pong:Int,anim_with_delta:Int,col_mask:Int) Local s:TSprite=New TSprite s.img=i s.frames=i.frames.length-1 s.fr=0 s.colmask=col_mask s.animframe=0 s.animframeinc=1 s.pong=ping_pong s.aninmove=anim_with_delta s.animspeed=anim_speed s.v=TVector.Create(0,0,0) s.x=0 s.y=0 s.v.x=0 s.v.y=0 Return s End Function Method ChangeAnim(anim_speed:Int,ping_pong:Int,anim_with_delta:Int) pong=ping_pong aninmove=anim_with_delta animspeed=anim_speed End Method Method ChangeImage(i:TImage,col_mask) img=i frames=i.frames.length-1 colmask=col_mask animframe=0 animframeinc=1 End Method Method Update() x:+v.x y:+v.y DrawImage(img,x,y,animframe) If (colmask<>0) CollideImage(img,x,y,animframe,0,colmask,Self) EndIf fr:+1 If (frames>0 And ((Not aninmove) Or v.x<>0 Or v.y<>0)) If (fr>animspeed) fr=0 animframe:+animframeinc If (pong) If (animframe=0 Or animframe=frames) animframeinc=-animframeinc EndIf Else If (animframe>frames) animframe=0 EndIf EndIf EndIf EndIf End Method End Type