moonbus: level transitions based on score
This commit is contained in:
parent
ec1def7d45
commit
c5c565832d
45
moonbus.p8
45
moonbus.p8
@ -17,7 +17,7 @@ function reset()
|
|||||||
plr_transed=0
|
plr_transed=0
|
||||||
plr_money=0
|
plr_money=0
|
||||||
plr_target={x=8,y=2}
|
plr_target={x=8,y=2}
|
||||||
plr_level=4
|
plr_level=1
|
||||||
|
|
||||||
levels={
|
levels={
|
||||||
{map_start=0,map_height=8},
|
{map_start=0,map_height=8},
|
||||||
@ -31,13 +31,11 @@ function reset()
|
|||||||
engine_power=0.1
|
engine_power=0.1
|
||||||
fuel_cons=0.005
|
fuel_cons=0.005
|
||||||
land_speed_limit=1
|
land_speed_limit=1
|
||||||
local maplevel=levels[plr_level]
|
|
||||||
mapy=maplevel.map_start
|
|
||||||
maph=maplevel.map_height
|
|
||||||
gravity=maplevel.gravity or 0.01
|
|
||||||
bonus_docked=1
|
bonus_docked=1
|
||||||
|
transed_per_level=1
|
||||||
cam={}
|
cam={}
|
||||||
|
|
||||||
|
load_level()
|
||||||
next_target()
|
next_target()
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -61,6 +59,9 @@ function _update()
|
|||||||
if btn(➡️) then plr_engine=➡️ end
|
if btn(➡️) then plr_engine=➡️ end
|
||||||
end
|
end
|
||||||
if plr_docked and btn(❎) then
|
if plr_docked and btn(❎) then
|
||||||
|
if plr_win then
|
||||||
|
make_progress()
|
||||||
|
else
|
||||||
plr_docked=false
|
plr_docked=false
|
||||||
plr_static=false
|
plr_static=false
|
||||||
plr_engine=⬆️
|
plr_engine=⬆️
|
||||||
@ -68,6 +69,7 @@ function _update()
|
|||||||
sfx(4)
|
sfx(4)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
end
|
||||||
|
|
||||||
-- engine
|
-- engine
|
||||||
if plr_engine==⬆️ then
|
if plr_engine==⬆️ then
|
||||||
@ -123,7 +125,8 @@ function _update()
|
|||||||
plr_landings+=1
|
plr_landings+=1
|
||||||
if target then
|
if target then
|
||||||
plr_money+=bonus_docked
|
plr_money+=bonus_docked
|
||||||
next_target()
|
plr_transed+=1
|
||||||
|
check_progress()
|
||||||
end
|
end
|
||||||
sfx(1)
|
sfx(1)
|
||||||
break
|
break
|
||||||
@ -238,8 +241,13 @@ function _draw()
|
|||||||
|
|
||||||
if plr_alive then
|
if plr_alive then
|
||||||
if plr_docked then
|
if plr_docked then
|
||||||
|
if plr_win then
|
||||||
|
print("wohoo! level complete.", 0,0,3)
|
||||||
|
print("press ❎ to advance.", 32,60,11)
|
||||||
|
else
|
||||||
print("smooth! you docked.", 0,0,3)
|
print("smooth! you docked.", 0,0,3)
|
||||||
print("press ❎ to undock.", 32,60,11)
|
print("press ❎ to undock.", 32,60,11)
|
||||||
|
end
|
||||||
else
|
else
|
||||||
print("land gently to dock.", 0,0,3)
|
print("land gently to dock.", 0,0,3)
|
||||||
end
|
end
|
||||||
@ -252,6 +260,31 @@ function _draw()
|
|||||||
print("✽"..plr_money, fx,fy+fh+2+16,3)
|
print("✽"..plr_money, fx,fy+fh+2+16,3)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
function get_new_level()
|
||||||
|
return flr(plr_transed/transed_per_level)+1
|
||||||
|
end
|
||||||
|
|
||||||
|
function check_progress()
|
||||||
|
if (plr_level!=get_new_level()) then
|
||||||
|
plr_win=true
|
||||||
|
end
|
||||||
|
end
|
||||||
|
function make_progress()
|
||||||
|
if (plr_win) then
|
||||||
|
plr_level=get_new_level()
|
||||||
|
load_level()
|
||||||
|
end
|
||||||
|
next_target()
|
||||||
|
end
|
||||||
|
|
||||||
|
function load_level(lvl)
|
||||||
|
local maplevel=levels[plr_level]
|
||||||
|
mapy=maplevel.map_start
|
||||||
|
maph=maplevel.map_height
|
||||||
|
gravity=maplevel.gravity or 0.01
|
||||||
|
plr_win=false
|
||||||
|
end
|
||||||
|
|
||||||
function next_target()
|
function next_target()
|
||||||
local docks={}
|
local docks={}
|
||||||
for x=0,127 do
|
for x=0,127 do
|
||||||
|
Loading…
Reference in New Issue
Block a user