Here is some easy functions:
(attached media is freeware by me made with eye candy plugins.)
Rem Project: billBoards
Rem Created: 03.06.2006 19:36:47
Rem ***** Main Source File *****
AutoCam Off
Sync On : Sync Rate 60
GOSUB lblr_setSprites
make object plain 100, 1000, 1000
color object 100, 0
xrotate object 100, 270
Position Camera 0, 10, 0
Do
imagesFire1 = loopAniSprite3D(aniSprFire1, 4, aniImgFire1, imagesFire1)
imagesFire2 = loopAniSprite3D(aniSprFire2, 4, aniImgFire2, imagesFire2)
imagesSmoke = loopAniSprite3D(aniSprSmoke, 4, aniImgSmoke, imagesSmoke)
mmx = mousemovex() : mmy = mousemovey()
ax# = wrapvalue(ax# + mmy)
ay# = wrapvalue(ay# + mmx)
rotate camera ax#, ay#, 0.0
if mouseclick()=1 then move camera 1
if mouseclick()=2 then move camera -1
text 0, 0, "Screen Fps: "+str$(screen fps())
text 0, 14, "Static: "+str$(statistic(1))
Sync
Loop
lblr_setSprites:
`first 10 is total of images
`second 60 is the total of animated images (max animated images is 60)
DIM aniImg(10,60) As Integer
`first 10 is total of real sprites
`second 10 is the total of instanced sprites (max instances is 10)
DIM aniSpr3D(10,10) As Integer
REM IMAGES
aniImgFire1 = createAniImage("fire28.png", 8)
aniImgFire2 = createAniImage("fire8.png", 8)
aniImgSmoke = createAniImage("smoke8.png", 8)
REM BILLBOARDS
aniSprFire1 = createAniSprite3D()
aniSprFire2 = createAniSprite3D()
aniSprSmoke = createAniSprite3D()
REM INSTANCE BILLBOARDS
`first fire animation
instantAniSprite3D(aniSprFire1, 1, 16, 32, 0.0, 16.0, 0, 0)
instantAniSprite3D(aniSprFire1, 2, 16, 32, 0.0, 0.0, 50, 1)
instantAniSprite3D(aniSprFire1, 3, 16, 64, 0.0, 0.0, 100, 1)
instantAniSprite3D(aniSprFire1, 4, 16, 32, 0.0, 0.0, 150, 1)
`second fire animation
instantAniSprite3D(aniSprFire2, 1, 32, 128, 50.0, 0.0, 0, 1)
instantAniSprite3D(aniSprFire2, 2, 16, 32, 50.0, 0.0, 50, 1)
instantAniSprite3D(aniSprFire2, 3, 16, 32, 50.0, 0.0, 100, 1)
instantAniSprite3D(aniSprFire2, 4, 16, 32, 50.0, 0.0, 150, 1)
`smoke animation
instantAniSprite3D(aniSprSmoke, 1, 32, 64, -50.0, 0.0, 0, 1)
instantAniSprite3D(aniSprSmoke, 2, 16, 32, -50.0, 0.0, 50, 1)
instantAniSprite3D(aniSprSmoke, 3, 16, 32, -50.0, 0.0, 100, 1)
instantAniSprite3D(aniSprSmoke, 4, 16, 32, -50.0, 0.0, 150, 1)
RETURN
`>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
`str is strip file name
`noi is number of images in strip file
`RETURNS: array number holder
`NOT: Dont forget to change aniImg() Array to suit array counts
Function createAniImage(str As String, noi As Integer)
Repeat
inc img
Until aniImg(img,1) = 0
bmp = freeBitmap()
Load Bitmap str, 1
bmpW = bitmap Width(1)
bmpH = bitmap Height(1)
bmpN = bmpW / noi
Set Current Bitmap 1
For i = 1 To noi
aniImg(img,i) = freeImage()
Get Image aniImg(img,i), (i*bmpN)-bmpN, 0, (i*bmpN), bmpH
Next i
Set CUrrent Bitmap 0
Delete Bitmap 1
EndFunction img
`<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
`>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
`x, y, z are coordinates to create sprite (CHANGE THE EXPLANATION)
`RETURNS: array number holder
`NOT: Dont forget to change aniSpr3D() Array to suit array counts
Function createAniSprite3D()
Repeat
inc spr
Until aniSpr3D(spr,0) = 0
aniSpr3D(spr,0) = freeObject()
Make Object Plain aniSpr3D(spr,0), 100, 100
Ghost Object On aniSpr3D(spr,0), 0
Disable Object zWrite aniSpr3D(spr,0)
Position Object aniSpr3D(spr,0), 0.0, 0.0, 0.0
Set Object Light aniSpr3D(spr,0), 0
Hide Object aniSpr3D(spr,0)
EndFunction spr
`<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
`>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
`n1 is source sprite
`n2 is instant sprite
`w, h are sizes of instance sprite
`x, y, z are coordinates of instance sprite
`offset Is boolean, if = 1 then offset bottom of sprite with y coordinate else dont
`RETURNS: nothing
`NOT: Dont forget to change aniSpr3D() Array to suit array counts
Function instantAniSprite3D(n1 As Integer, n2 As Integer, w As Integer, h As Integer, x As Float, y As Float, z As Float, offset As Boolean)
aniSpr3D(n1,n2) = freeObject()
Instance Object aniSpr3D(n1,n2), aniSpr3D(n1, 0)
Scale Object aniSpr3D(n1,n2), w, h, 100
If offset = 1
Position Object aniSpr3D(n1,n2), x, y+Object Size Y(aniSpr3D(n1,n2),0)/100.0*h/2.0, z
Else
Position Object aniSpr3D(n1,n2), x, y, z
EndIf
EndFunction
`<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
`>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
`n1 is source sprite
`n2 is instant sprite count
`img is the image array number
`i is the fake global variable, dont mess with it
Function loopAniSprite3D(n1 As Integer, n2 As Integer, img As Integer, i As Integer)
For instance = 1 To n2
Point Object aniSpr3D(n1,instance), Camera Position X(), Object Position Y(aniSpr3D(n1,instance)), Camera Position Z()
Next instance
Texture Object aniSpr3D(n1,0), aniImg(img,int(i/5))
Inc i
If i > 40 Then i = 5
EndFunction i
`<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
lbl_functionsFree:
`>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
Function freeDll()
Repeat
Inc i
Until DLL Exist(i) = 0
EndFunction i
`<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
`>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
Function freeMemblock()
Repeat
Inc i
Until MemBlock Exist(i) = 0
EndFunction i
`<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
`>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
Function freeObject()
Repeat
Inc i
Until Object Exist(i) = 0
EndFunction i
`<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
`>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
Function freeSound()
Repeat
Inc i
Until Sound Exist(i) = 0
EndFunction i
`<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
`>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
Function freeMusic()
Repeat
Inc i
Until Music Exist(i) = 0
EndFunction i
`<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
`>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
Function freeAnimation()
Repeat
Inc i
Until Animation Exist(i) = 0
EndFunction i
`<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
`>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
Function freeBitmap()
Repeat
Inc i
Until Bitmap Exist(i) = 0
EndFunction i
`<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
`>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
Function freeEffect()
Repeat
Inc i
Until Effect Exist(i) = 0
EndFunction i
`<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
`>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
Function freeImage()
Repeat
Inc i
Until Image Exist(i) = 0
EndFunction i
`<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
`>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
Function freeLight()
Repeat
Inc i
Until Light Exist(i) = 0
EndFunction i
`<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
`>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
Function freeLimb()
Repeat
Inc i
Until Limb Exist(i,i) = 0
EndFunction i
`<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
`>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
Function freeMatrix()
Repeat
Inc i
Until Matrix Exist(i) = 0
EndFunction i
`<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
`>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
Function freeMesh()
Repeat
Inc i
Until Mesh Exist(i) = 0
EndFunction i
`<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
`>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
Function freePixelshader()
Repeat
Inc i
Until Pixel Shader Exist(i) = 0
EndFunction i
`<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
`>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
Function freeParticles()
Repeat
Inc i
Until Particles Exist(i) = 0
EndFunction i
`<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
`>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
Function freeSprite()
Repeat
Inc i
Until Sprite Exist(i) = 0
EndFunction i
`<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
`>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
Function freeTerrain()
Repeat
Inc i
Until Terrain Exist(i) = 0
EndFunction i
`<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
`>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
Function freeVertexshader()
Repeat
Inc i
Until Vertex Shader Exist(i) = 0
EndFunction i
`<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
`>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
Function freeFile()
Repeat
Inc i
Until File Open(i) = 0
EndFunction i
`<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<