moonbus: level transitions through menu

This commit is contained in:
Dejvino 2024-08-10 16:07:42 +02:00
parent 4a30d9f522
commit 62b85fa0f2

View File

@ -5,19 +5,9 @@ __lua__
-- by Dejvino -- by Dejvino
function reset() function reset()
plr_alive=true
plr_win=false
plr_docked=false
plr_pos={x=5,y=8}
plr_speed={x=0.5,y=0}
plr_static=false
plr_engine=-1
plr_fuel=1
plr_landings=0
plr_transed=0
plr_money=0 plr_money=0
plr_target={x=8,y=2}
plr_level=1 plr_level=1
plr_target={}
levels={ levels={
{map_start=0,map_height=8}, {map_start=0,map_height=8},
@ -30,16 +20,46 @@ function reset()
flag_start=1 flag_start=1
flag_dock=7 flag_dock=7
telem_spd={} cam={}
load_level()
menuitem(1, "Next level", function()
plr_win=true
make_progress()
end)
menuitem(2, "Prev level", function()
plr_win=true
plr_level-=2
make_progress()
end)
end
function load_level()
plr_alive=true
plr_win=false
plr_docked=false
plr_speed={x=0,y=0.5}
plr_static=false
plr_engine=-1
plr_fuel=1
plr_landings=0
plr_transed=0
local maplevel=levels[plr_level]
mapy=maplevel.map_start
maph=maplevel.map_height
gravity=maplevel.gravity or 0.01
engine_power=0.1 engine_power=0.1
fuel_cons=0.005 fuel_cons=0.005
land_speed_limit=1 land_speed_limit=1
bonus_docked=1 bonus_docked=1
transed_per_level=1 transed_per_level=1
cam={}
load_level() plr_pos=find_random_point_by_flag(1)
telem_spd={}
next_target() next_target()
end end
@ -50,7 +70,7 @@ end
function _update() function _update()
debug_points={} debug_points={}
if not plr_alive and btn(❎) then if not plr_alive and btn(❎) then
reset() load_level()
end end
-- controlls -- controlls
@ -267,16 +287,17 @@ function _draw()
print("press ❎ to reset.", 32,60,11) print("press ❎ to reset.", 32,60,11)
end end
print("⌂"..plr_landings, fx,fy+fh+2+0,3) print("⌂"..plr_landings, fx,fy+fh+2+0,3)
print("웃"..plr_transed, fx,fy+fh+2+8,3) print("웃"..plr_transed.."/"..transed_per_level, fx,fy+fh+2+8,3)
print("✽"..plr_money, fx,fy+fh+2+16,3) print("✽"..plr_money, fx,fy+fh+2+16,3)
print("lvl "..plr_level, fx+20,fy+fh+2+16,3)
end end
function get_new_level() function get_new_level()
return min(flr(plr_transed/transed_per_level)+1,#levels) return max(1,min(#levels,plr_level + 1))
end end
function check_progress() function check_progress()
if (plr_level!=get_new_level()) then if plr_transed >= transed_per_level then
plr_win=true plr_win=true
end end
end end
@ -288,15 +309,6 @@ function make_progress()
next_target() next_target()
end 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
plr_pos=find_random_point_by_flag(1)
end
function find_random_point_by_flag(f) function find_random_point_by_flag(f)
local pts={} local pts={}
for x=0,127 do for x=0,127 do
@ -392,40 +404,40 @@ function limit(val,lim)
return val return val
end end
__gfx__ __gfx__
000000000000000000000000000000000000aa000000000050000005000000000000000000000000000000000000000000000000000000000000000000000000 000000000000000000000000000000000000aa00000000005000000500000000000b300000000000000000000000000000000000000000000000000000000000
00a9a90000a9a90000a9a90000a9a90000a9000000a9a90000000000000000000000000000000000000000000000000000000000000000000000000000000000 00a9a90000a9a90000a9a90000a9a90000a9000000a9a90000000000000000000033330000000000000000000000000000000000000000000000000000000000
00111100001111000011110000111100000100000011110000000000000000000000000000000000000000000000000000000000000000000000000000000000 001111000011110000111100001111000001000000111100000000000000000000b3430000000000000000000000000000000000000000000000000000000000
01111110011111100111111001111110010010100111111000000000000000000000000000000000000000000000000000000000000000000000000000000000 01111110011111100111111001111110010010100111111000000000000000000035bb3000000000000000000000000000000000000000000000000000000000
0a9999400a9999400a9999400a9999400a9990400a77654000000000000000000000000000000000000000000000000000000000000000000000000000000000 0a9999400a9999400a9999400a9999400a9990400a776540000000000000000003b3433000000000000000000800009000000000000000000000000000000000
5a9999458a9999455a9999455a999948000909555a7c564500000000000000000000000000000000000000000000000000000000000000000000000000000000 5a9999458a9999455a9999455a999948000909555a7c564500000000000000000b343b30000b3000000000000a0000a000000000000000000000000000000000
59494445894944455949444559494448594904405967154500000000000000000000000000000000000000000000000000000000000000000000000000000000 5949444589494445594944455949444859490440596715450000000000000000b3b4533300b3b300030303000400004000000000000000000000000000000000
0055550000555500008888000055550050555500007c560050000005000000000000000000000000000000000000000000000000000000000000000000000000 0055550000555500008888000055550050555500007c5600500000050000000000045000000b3000033003030400004000000000000000000000000000000000
66566665000000000000000560000000d8ddddbd0000000000566660000000000000000000000000000000000000000000000000000000000000000000000000 66566665000000000000000560000000d8ddddbd0000000000566660000000000003333333333333333330007766776600000000000000000000000000000000
666666660000000000000006660000005d7c56d50000000006666666000000000000000000000000000000000000000000000000000000000000000000000000 666666660000000000000006660000005d7c56d5000000000666666600000000003d3343433d3343433d33007665766500000000000000000000000000000000
56666657000000000000005756600000566715570000000006666657000000000000000000000000000000000000000000000000000000000000000000000000 56666657000000000000005756600000566715570000000006666657000000000434465354344653543446505446545400000000000000000000000000000000
66756666000000000000066666750000667c56660000000066756666000000000000000000000000000000000000000000000000000000000000000000000000 66756666000000000000066666750000667c5666000000006675666600000000444454d4444454d4444454d4446454d400000000000000000000000000000000
66666666000000000000666666666000666715660000000066666666000000000000000000000000000000000000000000000000000000000000000000000000 66666666000000000000666666666000666715660000000066666666000000000644444446444444464444404444444400000000000000000000000000000000
66666665006600000006666566666600667c55650000000066666665000000000000000000000000000000000000000000000000000000000000000000000000 66666665006600000006666566666600667c5565000000006666666500000000d4454445d4454445d4454445d454544500000000000000000000000000000000
65666657076567600066665765666650656556570000000065666650000000000000000000000000000000000000000000000000000000000000000000000000 65666657076567600066665765666650656556570000000065666650000000005444445454444454544444505444545400000000000000000000000000000000
67656666666666566765666667656666666566660000000007656600000000000000000000000000000000000000000000000000000000000000000000000000 67656666666666566765666667656666666566660000000007656600000000000445464444454644444546404654564400000000000000000000000000000000
00000007777777777d8ddbd770000000065666656656666000000000000000000000000000000000000000000000000000000000000000000000000000000000 00000007777777777d8ddbd77000000006566665665666600000000000000000454445444544454445444544000000000000000eeeeeeeeee000000000000000
000000767676767676dddd7665000000006666666666660000000000000000000000000000000000000000000000000000000000000000000000000000000000 000000767676767676dddd766500000000666666666666000000000000000000044d4446444d4446444d44400000000000000088888888888200000000000000
00000077666666666661166665000000000666575666600000000000000000000000000000000000000000000000000000000000000000000000000000000000 00000077666666666661166665000000000666575666600000000000000000005444465454444654544446540000000000000e22222222222220000000000000
0000007661116116616d161655000000000066666675000000000000000000000000000000000000000000000000000000000000000000000000000000000000 0000007661116116616d16165500000000006666667500000000000000000000444454d4444454d4444454d00000000000008888888888888882000000000000
000000776d161dd66d166dd665000000000006666660000000000000000000000000000000000000000000000000000000000000000000000000000000000000 000000776d161dd66d166dd6650000000000066666600000000000000000000004444444464444444644440000000000000e2222222222222222200000000000
00000076666666666666666655000000000000656600000000000000000000000000000000000000000000000000000000000000000000000000000000000000 000000766666666666666666550000000000006566000000000000000000000000454445d4454445d44544450000000000888888888888888888820000000000
00000076656565656565656565000000000000076000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 0000007665656565656565656500000000000007600000000000000000000000544444545444445454444450000000000e222222222222222222222000000000
00000005555555555555555550000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 00000005555555555555555550000000000000000000000000000000000000000445464444454644444546400000000088888888888888888888888200000000
6460000677c000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 6460000677c000000000000000000000000000000000000000000000000000004544454445444544454445440000000054444544544445445444454400000000
545646666611cc000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 545646666611cc00000000000000000000000000000000000000000000000000444d4446444de446444dbb460000000055455555555555555545555500000000
6555456661d111500000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 6555456661d1115000000000000000000000000000000000000000000000000054464654544e8854544b3314000000004444544444c414d44445444400000000
5455556661dd15650000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 5455556661dd1565000000000000000000000000000000000000000000000000446554d4444882d4444411d40000000055555545555554555555555500000000
65554566666656550000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 65554566666656550000000000000000000000000000000000000000000000004465144446442644464444440000000045444444444445444444444400000000
54555566666565550000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 5455556666656555000000000000000000000000000000000000000000000000d4414445d4464445d44544450000000055545555555455555545554500000000
55511166565655500000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 555111665656555000000000000000000000000000000000000000000000000054444454544445445444445400000000444445444414d5144445d54400000000
11100006555555000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 11100006555555000000000000000000000000000000000000000000000000004445464444454644444546440000000054554555545555555545554500000000
__gff__ __gff__
0000000000000200000000000000000001000000810001000000000000000000000181000000000000000000000000000101000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 0000000000000200010000000000000001000000810001000101018100000000000181000000000001010100000100000101000000000000010101000101010000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
__map__ __map__
0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
@ -436,14 +448,14 @@ __map__
0012101013000000000000121010101000000000000000000000000000000012101010101013000000000000000000000000000000000000000000000000000011000000000000000000000020212123202123000000000000000000110000121010130000000000000000202122101300000000000000000000000012101300 0012101013000000000000121010101000000000000000000000000000000012101010101013000000000000000000000000000000000000000000000000000011000000000000000000000020212123202123000000000000000000110000121010130000000000000000202122101300000000000000000000000012101300
1210101010130000000012101010101011001100000000110000000000121010101010101010130011000000000012141300000000000000000000000000001110130000000000000000000020212121212123000000000011001210101010101010101300001100000000202121101013000012101300000000001210101013 1210101010130000000012101010101011001100000000110000000000121010101010101010130011000000000012141300000000000000000000000000001110130000000000000000000020212121212123000000000011001210101010101010101300001100000000202121101013000012101300000000001210101013
1010101010101010141010101010101010101010101010101010141010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010141010101010101010101010101010101010101010101010101010101010101010101010101010101010101010212221101010101010 1010101010101010141010101010101010101010101010101010141010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010141010101010101010101010101010101010101010101010101010101010101010101010101010101010101010212221101010101010
0000000000000000000012102221212123000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
0000000000000000111210102121212123000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
0000000000002021212121212110000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
0000000000002021211021101010000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 0000000000000000000000000000000000000000000b09000000000000003d3d191a00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
0000000000000000001021212121230000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 000000060000000000080a090000000000000000181b1a000000000000000000282a00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
0000000600000000121021102123000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 0000000b000008091829292a00000000080a090a28392a002c2d2e0000000000282a00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
0000000000111112101010100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 08000a1b091819192929392a0a0a0a181919191929292a0a3c3d3e0a0a091b08282a00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
1010101410101010101010101010101010101010141010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010 1919191919192929392929291919192929292929292929292929292929382929292929291010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010
0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001600000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001600000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000016000000000000000000000000000000000000001600000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 0000000000000000000000000000000016000000000000000000000000000000000000001600000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000121413000000000000000000160000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000121413000000000000000000160000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000