March 05, 2021, 07:46:41 AM

Author Topic: [bb] Bullets with trails by SillyPutty [ 1+ years ago ]  (Read 413 times)

Offline BlitzBot

[bb] Bullets with trails by SillyPutty [ 1+ years ago ]
« on: June 29, 2017, 12:28:40 AM »
Title : Bullets with trails
Author : SillyPutty
Posted : 1+ years ago

Description : shooting bullets with trails, ala Crimsonland

Code :
Code: BlitzBasic
  1. Strict
  2.  
  3. Framework brl.glmax2d
  4. Import brl.graphics
  5. Import brl.linkedlist
  6. SetGraphicsDriver GLMax2DDriver()
  7. AppTitle = "Bullet Test - by Erick 'Deux' Grove"
  8.  
  9. Graphics 800,600,0
  10.  
  11.  
  12.  
  13. AutoMidHandle True
  14.  
  15. Global bulletimage:TImage = CreateImage(16,16,DynamicImage|MaskedImage)
  16. Global bulletList:TList
  17.  
  18. Type bullet
  19. Field x#
  20. Field y#
  21. Field origin_x#
  22. Field origin_y#
  23. Field scale_factor#
  24. Field alpha_factor#
  25.  
  26. Field life#
  27. Method draw()
  28. SetColor 200,125,125
  29. DrawRect x,y+(scale_factor*5),3,5
  30. SetScale 1,scale_factor
  31. SetColor 100,100,100
  32. SetAlpha alpha_factor
  33. DrawRect origin_x,origin_y,3,5
  34. SetScale 1,1
  35. SetAlpha 1
  36. End Method
  37.  
  38. Method update()
  39. y:-1
  40. life:-1
  41. scale_factor:-3
  42. alpha_factor:-0.03
  43.  
  44. If(alpha_factor <0) ListRemove bulletList,Self
  45. End Method
  46.  
  47. End Type
  48.  
  49. bulletList = CreateList()
  50.  
  51. Cls
  52. SetColor 200,200,200
  53. DrawRect 0,0,3,10
  54. GrabImage bulletimage,0,0
  55.  
  56. SetBlend(alphablend)
  57.  
  58. Function UpdateBullets()
  59.  
  60. For Local b:bullet = EachIn bulletList
  61. b.Draw()
  62. b.Update()
  63.  
  64. Next
  65.  
  66. End Function
  67.  
  68. While Not KeyDown(KEY_ESCAPE)
  69.  
  70. SetScale 1,1
  71. SetAlpha 1
  72. If KeyHit(KEY_SPACE)
  73. Local mybullet:bullet = New bullet
  74. mybullet.life = 100
  75. mybullet.alpha_factor=1
  76. mybullet.x = MouseX()
  77. mybullet.y = MouseY()
  78. myBullet.origin_x = mybullet.x
  79. myBullet.origin_y = mybullet.y
  80.  
  81. bulletList.addLast(mybullet)
  82. End If
  83.  
  84. UpdateBullets()
  85.  
  86. Flip
  87. Cls
  88. Wend
  89.  
  90. FlushMem
  91. End


Comments :


SillyPutty(Posted 1+ years ago)

 btw, this is bmax code, i dont see how i can edit this entry to move it to the bmx filter.


clownhunter(Posted 1+ years ago)

 You need to get rid of FlushMem.


kfprimm(Posted 1+ years ago)

 this was posted a year ago...


 

SimplePortal 2.3.6 © 2008-2014, SimplePortal