I've been trying to write my own sprite image grabber. Hungry Horace very kindly let me see some code of one that he did and it was most helpful, but in the interest of learning I decided to try a more basic one myself using a FOR loop and a Get Sprite command rather than just copy, paste and hope for the best.
I have an iff of a sprite sheet which has frames exactly 80 x 80. There are 8 columns and 12 rows adding up to 96 frames, but actually 93 as the last 3 frames are blank.
I wrote a piece of code which would loop 93 times (one for each frame), and each loop the two X coordinates would move right by 80 pixels from their last position. When it reached column 8 in each row, the X coordinates would reset and the two Y coordinates would move down 80 pixels. This would repeat until the last frame was reached.
I think I have everything ok but I keep getting an illegal function call at the "Get Sprite" command, so I'd be grateful if someone could tell me what I'm doing wrong.
PS, even though I didn't get it working, this is quite good fun!
Thanks.
Screen Open 3,640,960,64,Lowres
Auto View Off
Screen Hide 3
I=1
'P=0
ROWCOUNT=0
Load Iff "DH1:double dragon/sprite sheets/billy/billy 80 x 80.iff"
For C=1 To 93
' Starting point
If C=1
LX=0 : TY=0 : RX=LX+80 : BY=TY+80
End If
' Shift right every loop
If C>1 and C<94
ROWCOUNT=ROWCOUNT+1
I=I+1
LX=LX+80 : TY=TY : RX=LX+80 : BY=BY
End If
'Step down one row every 8th loop (8th frame)
If ROWCOUNT>8
LX=0 : TY=TY+80 : RX=LX+80 : BY=TY+80
ROWCOUNT=0
End If
Get Sprite 3,I,LX,TY To RX,BY
Next C