This is not shards but a block/shatter FX. It might get you started. :)
;
; Falling Tiles
; -------------
;
; (c) Richard Lawrence <richard@...;
; Version 1.1 (5th Jan 2001).
; Thanks to Mikkel Loekke for the "GetImage" function.
;
; This simple function takes whatever is on the backbuffer, breaks it
; up into a number of tiles and then proceeds to make them fall off
; the screen.
;
; Instructions: Run the program, hit any key (bar ESC) to make the
; picture explode. After its exploded, hit any key to quit.
;
; NOTE: If you're not running Blitz v1.35 then you'll need to convert
; the jpg file to bmp and modify the LoadBuffer command in the code!
;
; Licence: Feel free to use this in your own code. Some credit would be
; nice but its not essential.
;
; ----------------------------------------------------------------------
; These are the number of sqaures across and down the image should be
; broken up into. The higher the slower it is but the better it looks.
; Using 80 for ACROSS and 60 for DOWN is very nice but jitters slightly.
; Don't try 640 and 480 - it locked my laptop up!
Const ACROSS = 20 ; Its best if this value is divisible by 640
Const DOWN = 15 ; Its best if this value is divisible by 480
; Create a type square. This contains the location of the tile, its
; velocity and the image it will be showing.
Type square
Field x,y ; location
Field xvel,yvel ; velocity of movement
Field image ; tile image
End Type
Dim grid.square(ACROSS, DOWN)
; Set graphics mode and load image into the frontbuffer
Graphics 640,480
; NOTE! If you're not running v1.35 of Blitz then you'll need to
; covert the picture into a bmp file and edit this line!
LoadBuffer(FrontBuffer(), "BlitzLogo.bmp")
; Display the picture
WaitKey
; Make the picture fall
fall_picture()
; Wait for them to press a key
SetBuffer FrontBuffer()
Text 20,20, "Press a key to finish ..."
WaitKey
; Finish
End
; fall_picture()
; Break the screen into tiles and then make them fall off the screen
Function fall_picture()
; Set the buffer to that of the picture
SetBuffer FrontBuffer()
; Work out the size of each square
xsize = 640/ACROSS
ysize = 480/DOWN
; Loop through each square, first across then down
For i = 0 To ACROSS-1
For j = 0 To DOWN-1
; Create a new instance
grid(i,j) = New square
; Grab the image at the location on the screen
grid(i,j)\image = GetImage (i*xsize, j*ysize, (i+1)*xsize, (j+1)*ysize)
; Store its location on the screen
grid(i,j)\x = i*xsize;
grid(i,j)\y = j*ysize;
; Work out how fast and which direction the tile will drift
; from -3 (fast left) to +3 (fast right)
grid(i,j)\xvel = Rnd(6) - 3;
; Work out its velocity, negative values mean that it will
; move upwards before going down again
grid(i,j)\yvel = -Rnd(9)
Next
Next
; Set the buffer to the back one
SetBuffer BackBuffer()
; Loop through drawing each tile. If its off the screen, don't
; draw it but increase the vanished counter. When the counter
; hits ACROSS x DOWN then all tiles have gone off the screen.
While vanished <> (ACROSS * DOWN)
Cls
vanished = 0
For i = 0 To ACROSS-1
For j = 0 To DOWN-1
; Check tile is on the screen
If grid(i,j)\y < 640 Then
; Increase the y's velocity by one. This simulates
; gravity meaning that the tile will speed up
; going downwards
grid(i,j)\yvel = grid(i,j)\yvel + 1
; Update the x and y co-ordinates by adding the
; velocity values. Note xvel is not changed, the
; tiles do not change speed from left to right
grid(i,j)\y = grid(i,j)\y + grid(i,j)\yvel
grid(i,j)\x = grid(i,j)\x + grid(i,j)\xvel
; Draw it
DrawImage grid(i,j)\image, grid(i,j)\x, grid(i,j)\y
Else
; Update the vanished counter
vanished = vanished + 1
End If
Next
Next
Flip
Wend
; Free all memory up (image first then the type)
For i = 0 To ACROSS-1
For j = 0 To DOWN-1
FreeImage grid(i,j)\image
Delete grid(i,j)
Next
Next
End Function
; Grab an image from a set of co-ordinates.
; Provided by Mikkel Loekke.
Function GetImage(LIx1, LIy1, LIx2, LIy2)
; Work out width and height of the section we want
LIw=LIx2-LIx1
LIh=LIy2-LIy1
; Create a blank image of that width and height
LItempimg = CreateImage(LIw,LIh)
; Grab into this, the picture at those co-ordinates. Excessive
; picture will be clipped
GrabImage(LItempimg,LIx1,LIy1)
; Return it
Return LItempimg
End Function
L8r,