-
-
Save amiantos/4ee1ac79a49f971da92a2edc9fee15ad to your computer and use it in GitHub Desktop.
back of beyond screen transition effect
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function change_mode(int) | |
local modes={ | |
{menu_init,menu_update,menu_draw}, | |
{ow_init,ow_update,ow_draw}, | |
{shmup_init,shmup_update,shmup_draw}, | |
{gameover_init,gameover_update,gameover_draw} | |
} | |
second_swipe=false | |
next_init=modes[int][1] | |
next_update=modes[int][2] | |
next_draw=modes[int][3] | |
next_init() | |
next_update() | |
transition_init() | |
end | |
function transition_init() | |
clr_lines={} | |
t_stars={} | |
for i=1,128 do | |
local x=127+rnd(128) | |
add(clr_lines,{ | |
x=x, | |
o_x=x, | |
y=i, | |
}) | |
local z=flr(rnd(4)) | |
add(t_stars,{ | |
x=ceil(rnd(128)), | |
y=i, | |
col=star_cols[z+1], | |
spd=5-z | |
}) | |
end | |
if debug_mode then | |
next_init() | |
_update=next_update | |
_draw=next_draw | |
else | |
_update=transition_update | |
_draw=transition_draw | |
end | |
end | |
function transition_update() end | |
function transition_draw() | |
camera() | |
if second_swipe then | |
if (next_update==ow_update) update_camera() | |
next_draw() | |
end | |
local finished=true | |
for i=1,128 do | |
local clr_line=clr_lines[i] | |
local star=t_stars[i] | |
star.x-=star.spd | |
clr_line.x-=10 | |
if (clr_line.x>=0) finished=false | |
if (star.x<0) star.x=128 | |
if second_swipe then | |
line(0,clr_line.y,clr_line.x,clr_line.y,0) | |
if (star.x<clr_line.x) pset(star.x,star.y,star.col) | |
else | |
line(clr_line.x,clr_line.y,127,clr_line.y,0) | |
if (star.x>clr_line.x) pset(star.x,star.y,star.col) | |
end | |
end | |
if finished and not second_swipe then | |
second_swipe=true | |
for clr_line in all(clr_lines) do | |
clr_line.x=clr_line.o_x | |
end | |
elseif finished then | |
next_update() | |
_update=next_update | |
_draw=next_draw | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment