- Fade in/out de 16 colors inclosos
This commit is contained in:
87
data/fade.lua
Normal file
87
data/fade.lua
Normal file
@@ -0,0 +1,87 @@
|
|||||||
|
fade={
|
||||||
|
--table={13,15,5,3,12,5,6,7,12,9,10,16,9,13,14},
|
||||||
|
table={2,3,5,7,6,0,5,4,11,16,6,9,12,10,14,11},
|
||||||
|
pal={},
|
||||||
|
old_update=nil,
|
||||||
|
step=0,
|
||||||
|
max_steps=6,
|
||||||
|
outin=false,
|
||||||
|
|
||||||
|
init = function()
|
||||||
|
for i=1,16 do
|
||||||
|
local r,g,b=getcolor(i)
|
||||||
|
fade.pal[i]={r,g,b}
|
||||||
|
end
|
||||||
|
end,
|
||||||
|
|
||||||
|
getstep=function(num,steps)
|
||||||
|
if steps==0 or num==0 then return num end
|
||||||
|
for i=1,steps do
|
||||||
|
num=fade.table[num]
|
||||||
|
if num==0 then return num end
|
||||||
|
end
|
||||||
|
return num
|
||||||
|
end,
|
||||||
|
|
||||||
|
fadeout = function(steps)
|
||||||
|
fade.old_update=update
|
||||||
|
update=fade.update_fadeout
|
||||||
|
fade.step=0
|
||||||
|
fade.max_steps=steps or 6
|
||||||
|
end,
|
||||||
|
|
||||||
|
fadeoutin = function()
|
||||||
|
fade.old_update=update
|
||||||
|
update=fade.update_fadeout
|
||||||
|
fade.step=0
|
||||||
|
fade.outin=true
|
||||||
|
end,
|
||||||
|
|
||||||
|
update_fadeout=function()
|
||||||
|
if beat() then
|
||||||
|
for i=1,16 do
|
||||||
|
local v=fade.getstep(i,fade.step)
|
||||||
|
if v==0 then
|
||||||
|
setcolor(i,0,0,0)
|
||||||
|
else
|
||||||
|
setcolor(i,fade.pal[v][1],fade.pal[v][2],fade.pal[v][3])
|
||||||
|
end
|
||||||
|
end
|
||||||
|
fade.step=fade.step+1
|
||||||
|
if fade.step>fade.max_steps then
|
||||||
|
update = fade.old_update
|
||||||
|
if fade.outin then
|
||||||
|
fade.outin=false;
|
||||||
|
fade.fadein()
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end,
|
||||||
|
|
||||||
|
fadein = function()
|
||||||
|
fade.old_update=update
|
||||||
|
update=fade.update_fadein
|
||||||
|
fade.step=6
|
||||||
|
for i=1,16 do setcolor(i,0,0,0) end
|
||||||
|
end,
|
||||||
|
|
||||||
|
update_fadein=function()
|
||||||
|
fade.old_update()
|
||||||
|
|
||||||
|
if beat() then
|
||||||
|
for i=1,16 do
|
||||||
|
local v=fade.getstep(i,fade.step)
|
||||||
|
if v==0 then
|
||||||
|
setcolor(i,0,0,0)
|
||||||
|
else
|
||||||
|
setcolor(i,fade.pal[v][1],fade.pal[v][2],fade.pal[v][3])
|
||||||
|
end
|
||||||
|
end
|
||||||
|
fade.step=fade.step-1
|
||||||
|
if fade.step<0 then
|
||||||
|
update = fade.old_update
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
}
|
||||||
@@ -3,4 +3,4 @@ config=ja2
|
|||||||
width=160
|
width=160
|
||||||
height=144
|
height=144
|
||||||
zoom=5
|
zoom=5
|
||||||
files=wait.lua,switches.lua,scene.lua,balloon.lua,actors.lua,game.lua,mapa.lua,editor.lua,textbox.lua,menu.lua,main.lua
|
files=fade.lua,objects.lua,wait.lua,switches.lua,scene.lua,balloon.lua,actors.lua,game.lua,mapa.lua,editor.lua,textbox.lua,menu.lua,main.lua
|
||||||
|
|||||||
@@ -28,6 +28,8 @@ game={
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
})
|
})
|
||||||
|
|
||||||
|
fade.fadein()
|
||||||
end,
|
end,
|
||||||
|
|
||||||
update=function()
|
update=function()
|
||||||
|
|||||||
@@ -7,6 +7,7 @@ function _init()
|
|||||||
local pal=loadpal("tiles.gif")
|
local pal=loadpal("tiles.gif")
|
||||||
setpal(pal)
|
setpal(pal)
|
||||||
beat(6)
|
beat(6)
|
||||||
|
fade.init()
|
||||||
main_init()
|
main_init()
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user