Quote: "Is there anything current on sprite animations from a sprite sheet. I may benefit from an indepth (but not too complicated) tutorial on that. In theory i thought you load up an image, then do something like work out how big each frame is within the big image, then break it up using some sort of grab command then paste it out as an when needed."
Yes, your theory on how sprite sheets are loaded is right but you can do it the hard way (all yourself) or the easy way with the CREATE ANIMATED SPRITE command. The following code snips (Hard/Easy) do exactly the same thing (animating 10 frames that change every 100 milliseconds).
The Hard Way:
You load the image as a bitmap (so the user can't see it) and grab each frame as a separate image. To animate it you create a TIMER() and show the SPRITE but change it's image number when the TIMER() is up to animate.
sync rate 0
sync on
hide mouse
` Load the sprite sheet
load bitmap "GrogMegaSprite.png",1
` Set the starting image number
CImage=100
` Grab the images
for x=0 to 460 step 51
get image CImage,x,y,x+50,y+52,1
inc CImage
next x
` Change to the main view screen
set current bitmap 0
` Set the starting image number and timer
CImage=100:tim=timer()
do
` Show the sprite
sprite 1,mousex(),mousey(),CImage
` Check if 100 milliseconds are up
if timer()>tim+100
` Change to the next frame
inc CImage
` Check if the last frame has been shown and reset to first frame
if CImage=110 then CImage=100
` Reset timer
tim=timer()
endif
sync
loop
The Easy Way:
You use CREATE ANIMATED SPRITE which tells Darkbasic how many frames are in the image so it cuts the image perfectly. Show the SPRITE and play the sprite to animate.
sync rate 0
sync on
hide mouse
` Load the sprite sheet into an animated sprite
create animated sprite 1,"GrogMegaSprite.png",10,1,1
do
` Show the sprite
sprite 1,mousex(),mousey(),1
` Play the sprite (frames 1 to 10 cycling every 100 milliseconds)
play sprite 1,1,10,100
sync
loop
When Darkbasic Pro sees the CREATE ANIMATED SPRITE command it takes the image size horizontally (in this case 510) and the number of frames across (10) and divides the two numbers to get the horizontal size of each frame (510/10 = 51). It then does the same thing vertically (Image size 52 divided by frames down 1 = 52). So the attached image is going to automatically be 10 images cut up in 51x52 size.
To stop the blue screen all you do is add a screen sized PASTE IMAGE as a background.
sync rate 0
sync on
hide mouse
` Make random number picking more random
randomize timer()
` Load the sprite sheet into an animated sprite
create animated sprite 1,"GrogMegaSprite.png",10,1,1
` Make a background image
for t=1 to 2000
` Pick a random color
ink rgb(rnd(255),rnd(255),rnd(255)),0
` Make a random line
line rnd(screen width()),rnd(screen height()),rnd(screen width()),rnd(screen height())
next t
` Grab the background (use 1 as a texture flag to avoid blurring the image)
get image 2,0,0,screen width(),screen height(),1
do
` Show the background
paste image 2,0,0
` Show the sprite
sprite 1,mousex(),mousey(),1
` Play the sprite
play sprite 1,1,10,100
sync
loop