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_money=0
|
||||
plr_target={x=8,y=2}
|
||||
plr_level=4
|
||||
plr_level=1
|
||||
|
||||
levels={
|
||||
{map_start=0,map_height=8},
|
||||
@ -31,13 +31,11 @@ function reset()
|
||||
engine_power=0.1
|
||||
fuel_cons=0.005
|
||||
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
|
||||
transed_per_level=1
|
||||
cam={}
|
||||
|
||||
load_level()
|
||||
next_target()
|
||||
end
|
||||
|
||||
@ -61,11 +59,15 @@ function _update()
|
||||
if btn(➡️) then plr_engine=➡️ end
|
||||
end
|
||||
if plr_docked and btn(❎) then
|
||||
plr_docked=false
|
||||
plr_static=false
|
||||
plr_engine=⬆️
|
||||
plr_speed={x=0,y=0.5}
|
||||
sfx(4)
|
||||
if plr_win then
|
||||
make_progress()
|
||||
else
|
||||
plr_docked=false
|
||||
plr_static=false
|
||||
plr_engine=⬆️
|
||||
plr_speed={x=0,y=0.5}
|
||||
sfx(4)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
@ -123,7 +125,8 @@ function _update()
|
||||
plr_landings+=1
|
||||
if target then
|
||||
plr_money+=bonus_docked
|
||||
next_target()
|
||||
plr_transed+=1
|
||||
check_progress()
|
||||
end
|
||||
sfx(1)
|
||||
break
|
||||
@ -238,8 +241,13 @@ function _draw()
|
||||
|
||||
if plr_alive then
|
||||
if plr_docked then
|
||||
print("smooth! you docked.", 0,0,3)
|
||||
print("press ❎ to undock.", 32,60,11)
|
||||
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("press ❎ to undock.", 32,60,11)
|
||||
end
|
||||
else
|
||||
print("land gently to dock.", 0,0,3)
|
||||
end
|
||||
@ -252,6 +260,31 @@ function _draw()
|
||||
print("✽"..plr_money, fx,fy+fh+2+16,3)
|
||||
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()
|
||||
local docks={}
|
||||
for x=0,127 do
|
||||
|
Loading…
Reference in New Issue
Block a user