[bmx] Simple Lightning for Max by IKG [ 1+ years ago ]

Started by BlitzBot, June 29, 2017, 00:28:43

Previous topic - Next topic

BlitzBot

Title : Simple Lightning for Max
Author : IKG
Posted : 1+ years ago

Description : Press your space-bar to change where the lightning is generated.

Code :
Code (blitzmax) Select
'Written by David Schwartz - http://www.devdave.net
Graphics 640,480,0
SetColor 255,255,255

Global newpixelx = 0
Global pixelx = 240
Global pixely = 0
Global pixelmove = 0

Repeat

If KeyHit(key_space) Then newpixelx = Rand(0,640)

CreateBolt()

Flip;Cls

Until KeyHit(key_escape)

Function CreateBolt()
pixelx = newpixelx
pixely = 0
For i=1 To 480
pixelmove = Rand(-1,1)
pixelx = pixelx - pixelmove
pixelmove = Rand(-1,1)
pixelx = pixelx + pixelmove
pixely = pixely + 1
Plot pixelx,pixely
Next
End Function


Comments :


IKG(Posted 1+ years ago)

 Would have added a "glow" to it if I knew how. Tried messing around with ALPHABLEND and SetAlpha, but failed.


Azathoth(Posted 1+ years ago)

 If you use DrawLine you can set the width to make it look thicker.


IKG(Posted 1+ years ago)

 Actually, I like its width as it is. The only thing I would add now is a glow that most lightning bolts have ;)


Calibrator(Posted 1+ years ago)

 I added a blue glow and changed some other things.After pressing SPACE the bolt stays on screen to get a better impression of it. Press SPACE again for anotheror ESCAPE to leave.
'Written by David Schwartz - <a href="http://www.devdave.net/" target="_blank">http://www.devdave.net</a>
'Modified by Calibrator, 2010-06-06
'
Global ResX = 800
Global ResY = 600


Function CreateBolt()

Local pixelmove
Local pixelx
Local pixely

pixelx = Rand(0,ResX)
pixely = 0

For i=1 To ResY
pixelmove = Rand(-1,1)
pixelx = pixelx - pixelmove
pixelmove = Rand(-1,1)
pixelx = pixelx + pixelmove
pixely = pixely + 1

SetColor 0,0,128
Plot pixelx-2,pixely

SetColor 0,0,192
Plot pixelx-1,pixely

SetColor 225,225,255
Plot pixelx,pixely

SetColor 0,0,192
Plot pixelx+1,pixely

SetColor 0,0,128
Plot pixelx+2,pixely
Next
End Function


Graphics ResX,ResY,0

While Not (KeyHit(KEY_ESCAPE) Or AppTerminate())

If KeyHit(KEY_SPACE)
Cls
CreateBolt()
Flip
EndIf

Wend