Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ' Flame test #2 by Conexion
- ' With assistance from ##Freebasic
- ' Extra help: Mysoft
- #Include "fbgfx.bi"
- Randomize , 1
- Const fpsLimit = 60
- Const pi = 3.14159265 'Shouldn't need any more than that
- Dim As Integer ScrW = 800, ScrH = 600
- Dim As UByte CharH = 8, CharW = 8
- ScreenRes ScrW, ScrH, 8, , fb.gfx_high_priority
- 'Set up the pallete
- 'xPal is the counter
- 'bPal adds extra blue/brightness
- Dim As UByte xPal = 255 'Set it so when xPal +=1 happens, you get 0
- Dim As UByte bPal = 0
- Dim As Integer fadewhite = 170
- Do
- xPal += 1
- If xPal < 64 Then
- Palette xPal, xPal*4, xPal, 0
- Else
- If xPal > 192 Then
- bPal += 4
- end If
- Palette xPal, 255, xPal, bPal
- end if
- Loop Until xPal = 255
- /'Palette test
- For iii As Integer = 0 To 255
- Line (iii*2.5+10, 15)-(iii*2.5+30, 40), iii, bf
- Dim As Integer ir, ig, ib
- Palette Get iii, ir, ig, ib
- Next
- '/
- 'Set up the Image Buffer
- Dim As fb.image Ptr ImgBuff = ImageCreate(ScrW, (ScrH + 4) / 2)
- 'Spinner Variables
- Dim As Integer spnRadius = 80
- Dim As Integer spnDegrees = 11 ' Degrees Clockwise
- Dim As Single spnOldX, spnOldY, spnX, spnY = spnRadius
- Dim As Single spnAngle = spnDegrees * -0.017453 'Degrees to Rads
- Dim As Integer spnVX = ScrW / 2, spnVY = ScrH / 4 ' Center the Spinner
- 'Precalculate the distance to each pixel we need to average
- Dim As Integer calcDL = ScrW - 1
- Dim As Integer calcD = ScrW
- Dim As Integer calcDR = ScrW + 1
- Dim As Integer calcDD = ScrW Shl 2
- 'Adjust this to adjust the fire trail
- Dim As Single fTrail = 1 / 4.2
- 'Fire trail variables
- Dim As Integer fX, fY, fZ, fColor
- ' FPS Vars
- Dim As Integer fpsX, fpsY, fps, fpsNew, fpsSeconds
- fpsX = (ScrW - len(fps)*CharW)
- fpsY = (ScrH - CharH) - 24
- Dim As Double fpsStart
- Dim As Integer fpslSleep
- Dim As Double fpslStart
- Dim As Double fpslV = 1.0 / fpsLimit
- Do
- ' Start our timer
- fpslStart = Timer
- ScreenLock
- ' Lets get the spinner down first!
- spnOldX = spnX
- spnOldY = spnY
- ' Calculate the rotation coordinates
- spnX = (spnOldX * Cos(spnAngle)) + (spnOldY * Sin(spnAngle))
- spnY = (spnOldY * Cos(spnAngle)) - (spnOldX * Sin(spnAngle))
- ' Draw it, translated "V" distance. Also, half the arc/shape
- ' for when we stretch the image on the Y-axis.
- Circle ImgBuff, (spnX + spnVX, spnY / 2 + spnVY), 8, 255,,,.5
- ' The Screen Buffer
- Dim As UByte Ptr ScrBuff = ScreenPtr
- ' The pixel part of ImgBuff
- Dim As UByte Ptr ImgPix = Cast( UByte Ptr, Cast( UByte Ptr, ImgBuff ) + SizeOf(FB.IMAGE) )
- ' Random dots on the bottom line
- Dim As UByte Ptr BotLine = ImgPix
- BotLine += ScrW * CInt((ScrH-2)/2)
- For ranLine As Integer = 0 To ScrW
- BotLine[ranLine] = (Rnd * 255)
- Next
- ' Output FPS with a shadow
- Draw String ImgBuff, (fpsX - 1, (fpsY - 1) / 2), Str(fps), 0
- Draw String ImgBuff, (fpsX - 1, (fpsY + 1) / 2), Str(fps), 0
- Draw String ImgBuff, (fpsX + 1, (fpsY - 1) / 2), Str(fps), 0
- Draw String ImgBuff, (fpsX + 1, (fpsY + 1) / 2), Str(fps), 0
- Draw String ImgBuff, (fpsX, fpsY / 2), Str(fpsNew), 254
- ' Filter Time!
- ' Fire is calculated by adding the 3 pixels touching the bottom of any pixel
- ' As well as one pixel two pixels down, then finding the average.
- ' fX, fY, fZ, fColor
- 'Dim As Integer calcDL = ScrW - 1
- 'Dim As Integer calcD = ScrW
- 'Dim As Integer calcDR = ScrW + 1
- 'Dim As Integer calcDD = ScrW Shl 2
- Dim As UByte Ptr fT = ImgPix
- For fY = 0 To (ScrH/2) - 1
- For fX = 0 To ScrW - 1
- fColor = (fT[calcDL] + fT[calcD] + fT[calcDR] + fT[calcDD]) * fTrail
- *fT = fColor
- fT += 1
- Next
- Next
- ' Draw ImgBuff at 2*Y
- for PY as integer = 0 to (Scrh/2)-1
- for PX as integer = 0 to ScrW-1
- *ScrBuff = *ImgPix
- ScrBuff[ScrW] = *ImgPix
- ScrBuff += 1: ImgPix += 1
- next
- scrbuff += ScrW
- Next
- ScreenUnLock
- ' Adjust for our FPS limit
- fpslSleep = CInt((fpslStart + fpslV - Timer) * 1000.0)
- If fpslSleep > 1 Then
- Sleep fpslSleep, 1
- Else
- 'Let's not be a memory hog
- Sleep 1
- end If
- ' Calculate actual FPS
- fps += 1
- 'fpsStart + 1 = One second going by
- If fpsStart + 1 < Timer Then
- fpsNew = fps
- fps = 0
- fpsSeconds += 1
- fpsStart = Timer
- end If
- Loop Until InKey <> ""
- ImageDestroy(ImgBuff)
- End
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement