Add Lua cartridge for Doom fire
This commit is contained in:
parent
cfc6a1b105
commit
ddbe443f92
80
doom_fire.lua
Normal file
80
doom_fire.lua
Normal file
|
@ -0,0 +1,80 @@
|
|||
-- title: Doom Fire
|
||||
-- author: Fabien Freling
|
||||
-- desc: short description
|
||||
-- script: lua
|
||||
|
||||
t=0
|
||||
width=240
|
||||
height=136
|
||||
base={}
|
||||
-- init with black
|
||||
for i=1,width*height do
|
||||
base[i] = 0
|
||||
end
|
||||
for i=width*(height-1),width*height do
|
||||
base[i] = 15
|
||||
end
|
||||
cls(0)
|
||||
|
||||
function display()
|
||||
for y=1,height do
|
||||
for x=1,width do
|
||||
pix(x, y, base[x+y*width])
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
function dofire()
|
||||
for x=1,width do
|
||||
for y=0,height-2 do
|
||||
spreadfire(x, y)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
function spreadfire(x, y)
|
||||
local rand = math.random(0, 3) -- [0,3]
|
||||
local delta = rand & 1
|
||||
local side = -rand+1 -- [-2,1]
|
||||
if x+side < 1 then side=0 end
|
||||
if x+side > width then side=0 end
|
||||
local dst=(x+side) + y*width
|
||||
local src=x + (y+1)*width
|
||||
base[dst] = base[src] - delta
|
||||
if base[dst] < 0 then base[dst]=0 end
|
||||
end
|
||||
|
||||
function TIC()
|
||||
display()
|
||||
-- slow down fire
|
||||
if t % 2 == 0 then
|
||||
dofire()
|
||||
end
|
||||
t=t+1
|
||||
end
|
||||
|
||||
-- <TILES>
|
||||
-- 001:efffffffff222222f8888888f8222222f8fffffff8ff0ffff8ff0ffff8ff0fff
|
||||
-- 002:fffffeee2222ffee88880fee22280feefff80fff0ff80f0f0ff80f0f0ff80f0f
|
||||
-- 003:efffffffff222222f8888888f8222222f8fffffff8fffffff8ff0ffff8ff0fff
|
||||
-- 004:fffffeee2222ffee88880fee22280feefff80ffffff80f0f0ff80f0f0ff80f0f
|
||||
-- 017:f8fffffff8888888f888f888f8888ffff8888888f2222222ff000fffefffffef
|
||||
-- 018:fff800ff88880ffef8880fee88880fee88880fee2222ffee000ffeeeffffeeee
|
||||
-- 019:f8fffffff8888888f888f888f8888ffff8888888f2222222ff000fffefffffef
|
||||
-- 020:fff800ff88880ffef8880fee88880fee88880fee2222ffee000ffeeeffffeeee
|
||||
-- </TILES>
|
||||
|
||||
-- <WAVES>
|
||||
-- 000:00000000ffffffff00000000ffffffff
|
||||
-- 001:0123456789abcdeffedcba9876543210
|
||||
-- 002:0123456789abcdef0123456789abcdef
|
||||
-- </WAVES>
|
||||
|
||||
-- <SFX>
|
||||
-- 000:000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000304000000000
|
||||
-- </SFX>
|
||||
|
||||
-- <PALETTE>
|
||||
-- 000:140c1c4424345d403c794a4eb23030d62424fa0000e6690cee6d10d2a12cceaa40caa13cd2aa40e6c271dad45effffff
|
||||
-- </PALETTE>
|
||||
|
Loading…
Reference in a new issue