Quote: "Grog, do you think you and show me an example of sprites in a array... I have never messed around with them so im tryin to understand them by looking at the actual thing...
Thank you"
Np. Arrays are real easy once you get used to them.
The basic arrays are one dimensional (like "dim Text$(5)" which is 6 strings... 0 to 5) but you can add numbers to hold more data (like "dim Text$(9,5)" which is 10 sets of 6 strings for each set). Arrays can be used in many, many ways.
This code snip creates 20 sprites and moves them down the screen at different speeds ( because each sprite has it's own timer() and delay ):
` Make 20 Images
for t=1 to 20
ink rgb(rnd(255),rnd(255),rnd(255)),0
box 0,0,32,24
ink rgb(255,255,255),0
center text 15,5,str$(t)
get image t,0,0,32,24,1
next t
` Dimensionalize the array (20 sprites 5 integers of data)
dim Spr(19,4)
` Define the array
for t=0 to 19
Spr(t,0)=t+1 :` Sprite/Image Number
Spr(t,1)=rnd(640) :` X Coordinate
Spr(t,2)=rnd(480) :` Y Coordinate
Spr(t,3)=timer() :` Timer
Spr(t,4)=rnd(100) :` Timer Delay
next t
do
for t=0 to 19
` Show Sprite
sprite Spr(t,0),Spr(t,1),Spr(t,2),Spr(t,0)
` Increase y based on timer in Spr(t,3) and delay in Spr(t,4)
if Spr(t,2)<=480 and timer()>Spr(t,3)+Spr(t,4)
` Increase the y coordinate
Spr(t,2)=Spr(t,2)+1
` Reset the timer
Spr(t,3)=timer()
endif
next t
loop