December 03, 2020, 08:06:47 PM

Author Topic: [bmx] Simple Lightning for Max by IKG [ 1+ years ago ]  (Read 819 times)

Offline BlitzBot

  • Jr. Member
  • **
  • Posts: 1
[bmx] Simple Lightning for Max by IKG [ 1+ years ago ]
« on: June 29, 2017, 12:28:43 AM »
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
  1. 'Written by David Schwartz - http://www.devdave.net
  2. Graphics 640,480,0
  3. SetColor 255,255,255
  4.  
  5. Global newpixelx = 0
  6. Global pixelx = 240
  7. Global pixely = 0
  8. Global pixelmove = 0
  9.  
  10. Repeat
  11.  
  12. If KeyHit(key_space) Then newpixelx = Rand(0,640)
  13.  
  14. CreateBolt()
  15.  
  16. Flip;Cls
  17.  
  18. Until KeyHit(key_escape)
  19.  
  20. Function CreateBolt()
  21. pixelx = newpixelx
  22. pixely = 0
  23.         For i=1 To 480
  24.                 pixelmove = Rand(-1,1)
  25.                 pixelx = pixelx - pixelmove    
  26.                 pixelmove = Rand(-1,1)
  27.                 pixelx = pixelx + pixelmove
  28.                 pixely = pixely + 1
  29.                 Plot pixelx,pixely
  30.         Next
  31. 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.
Code: [Select]
'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


 

SimplePortal 2.3.6 © 2008-2014, SimplePortal