moonbus: level transitions based on score
This commit is contained in:
parent
ec1def7d45
commit
c5c565832d
59
moonbus.p8
59
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,11 +59,15 @@ 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
|
||||||
plr_docked=false
|
if plr_win then
|
||||||
plr_static=false
|
make_progress()
|
||||||
plr_engine=⬆️
|
else
|
||||||
plr_speed={x=0,y=0.5}
|
plr_docked=false
|
||||||
sfx(4)
|
plr_static=false
|
||||||
|
plr_engine=⬆️
|
||||||
|
plr_speed={x=0,y=0.5}
|
||||||
|
sfx(4)
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -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
|
||||||
print("smooth! you docked.", 0,0,3)
|
if plr_win then
|
||||||
print("press ❎ to undock.", 32,60,11)
|
print("wohoo! level complete.", 0,0,3)
|
||||||
|
print("press ❎ to advance.", 32,60,11)
|
||||||
|
else
|
||||||
|
print("smooth! you docked.", 0,0,3)
|
||||||
|
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