Advertisement
Guest User

Untitled

a guest
Apr 23rd, 2019
93
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.39 KB | None | 0 0
  1. local fireBlocks = {}
  2. local tilesize = 8
  3. local numberWidthBlocks = math.floor(ScrW() / tilesize)
  4. local numberHeightBlocks = 48 -- means all the 36 colors with a little more space to remaining flames
  5. local offsetY = ScrH() - (numberHeightBlocks * tilesize)
  6.  
  7. local colorLookup = {
  8. Color(7,7,7),
  9. Color(31,7,7),
  10. Color(47,15,7),
  11. Color(71,15,7),
  12. Color(87,23,7),
  13. Color(103,31,7),
  14. Color(119,31,7),
  15. Color(143,39,7),
  16. Color(159,47,7),
  17. Color(175,63,7),
  18. Color(191,71,7),
  19. Color(199,71,7),
  20. Color(223,79,7),
  21. Color(223,87,7),
  22. Color(223,87,7),
  23. Color(215,95,7),
  24. Color(215,95,7),
  25. Color(215,103,15),
  26. Color(207,111,15),
  27. Color(207,119,15),
  28. Color(207,127,15),
  29. Color(207,135,23),
  30. Color(199,135,23),
  31. Color(199,143,23),
  32. Color(199,151,31),
  33. Color(191,159,31),
  34. Color(191,159,31),
  35. Color(191,167,39),
  36. Color(191,167,39),
  37. Color(191,175,47),
  38. Color(183,175,47),
  39. Color(183,183,47),
  40. Color(183,183,55),
  41. Color(207,207,111),
  42. Color(223,223,159),
  43. Color(239,239,199),
  44. Color(255,255,25),
  45. }
  46.  
  47. for i,v in ipairs(colorLookup) do
  48. v.a = (i/#colorLookup) * 255
  49. end
  50.  
  51. for line = 1,numberHeightBlocks do
  52. table.insert(fireBlocks, {})
  53.  
  54. local yValue = (line - 1) * tilesize + offsetY
  55. for col = 1,numberWidthBlocks do
  56. if line < numberHeightBlocks - 1 then
  57. table.insert(fireBlocks[line], {x = (col-1) * tilesize, y = yValue, color = 1})
  58. else
  59. table.insert(fireBlocks[line], {x = (col-1) * tilesize, y = yValue, color = 36})
  60. end
  61. end
  62. end
  63.  
  64. local function draw()
  65. for line, cols in ipairs(fireBlocks) do
  66. for _, block in ipairs(cols) do
  67. surface.SetDrawColor(colorLookup[block.color])
  68. surface.DrawRect(block.x, block.y, tilesize, tilesize)
  69. end
  70. end
  71. end
  72.  
  73. local nextUpdate = 0
  74.  
  75. local function update()
  76.  
  77. if nextUpdate > RealTime() then
  78. return
  79. end
  80.  
  81. nextUpdate = RealTime() + 1/16
  82.  
  83. for line = 1,numberHeightBlocks - 1 do
  84. for col = 2,numberWidthBlocks - 1 do
  85. local windDirection = math.random()
  86. local decay = math.floor(math.random() * 3)
  87. local collumn_To_Apply = col
  88. if windDirection < 0.2 then
  89. collumn_To_Apply = (col - 1)
  90. elseif windDirection > 0.8 then
  91. collumn_To_Apply = (col + 1)
  92. end
  93. if fireBlocks[line+1][col].color - decay > 1 then
  94. fireBlocks[line][collumn_To_Apply].color = fireBlocks[line+1][col].color - decay
  95. else
  96. fireBlocks[line][collumn_To_Apply].color = 1
  97. end
  98. end
  99. end
  100. end
  101.  
  102. hook.Add("HUDPaint", "doom", draw)
  103. hook.Add("Think", "doom", update)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement