moonbus: particles

This commit is contained in:
Dejvino 2024-08-11 21:45:40 +02:00
parent 937bee80c8
commit 1f54a2f8f3

View File

@ -62,6 +62,8 @@ function load_level()
plr_pos=find_random_point_by_flag(1) plr_pos=find_random_point_by_flag(1)
telem_spd={} telem_spd={}
particles={}
next_target() next_target()
end end
@ -128,6 +130,7 @@ function _update()
if plr_engine != -1 then if plr_engine != -1 then
sfx(2,2) sfx(2,2)
plr_fuel=max(0,min(1,plr_fuel-fuel_cons)) plr_fuel=max(0,min(1,plr_fuel-fuel_cons))
generate_particle(plr_pos)
else else
sfx(-1,2) sfx(-1,2)
end end
@ -157,6 +160,14 @@ function _update()
plr_speed.y-=gravity plr_speed.y-=gravity
end end
-- particles
for i,part in pairs(particles) do
part.spd.y-=gravity/5
move(part.p,part.spd,0.1)
part.age=max(0,part.age)+1
if (part.age >= part.limit) then del(particles,part) end
end
-- crash detection -- crash detection
local pc=plus(plr_pos,{x=0.5,y=-0.5}) local pc=plus(plr_pos,{x=0.5,y=-0.5})
local crashed=false local crashed=false
@ -196,8 +207,10 @@ function _update()
plr_speed.x*=0.5 plr_speed.x*=0.5
plr_alive=false plr_alive=false
if (dist(plr_speed) > 1) then if (dist(plr_speed) > 1) then
for i=1,10 do generate_particle() end
sfx(0) sfx(0)
else else
for i=1,20 do generate_particle() end
plr_speed.x=0 plr_speed.x=0
plr_speed.y=0 plr_speed.y=0
plr_static=true plr_static=true
@ -258,6 +271,14 @@ function _draw()
pset(px,py,8) pset(px,py,8)
end end
for part in all(particles) do
local p=part.p
local px,py=to_scrn(p)
--pset(px,py,ttl > 10 and 8 or 5)
circ(px,py,cos(part.age/20)*0.6+1.5,part.age < 10 and 8 or (part.age < part.limit/2 and 5 or 1))
end
print(#particles, 32,50,11)
-- target -- target
if plr_alive then if plr_alive then
local tg={x=plr_target.x,y=plr_target.y} local tg={x=plr_target.x,y=plr_target.y}
@ -384,6 +405,15 @@ function next_target()
plr_target={x=mp.x,y=maph-mp.y+1} plr_target={x=mp.x,y=maph-mp.y+1}
end end
function generate_particle()
add(particles,{
p=plus(plus(plr_pos,{x=0.25,y=-0.85}),{x=rnd(),y=rnd()},0.5),
spd=plus(mul({x=rnd(2)-1,y=rnd(2)-1},0.1),mul(plr_speed,rnd(0.5))),
age=rnd(20),
limit=80+flr(rnd(40))
})
end
function to_scrn(p) function to_scrn(p)
local x=p.x*8 local x=p.x*8
local y=128-p.y*8 local y=128-p.y*8
@ -415,6 +445,7 @@ function cleary(p)
} }
end end
function mul(p,a) function mul(p,a)
a=a or 1
return { return {
x=p.x*a, x=p.x*a,
y=p.y*a y=p.y*a
@ -446,38 +477,38 @@ function limit(val,lim)
return val return val
end end
__gfx__ __gfx__
000000000000000000000000000000000000aa00000000005000000500000000000b300000000000000000000000000000000000000000000000000000000000 000000000000000000000000000000000000aa000000000050000005000000009009f00000000000000000000000000000000000000000000000000000000000
00a9a90000a9a90000a9a90000a9a90000a9000000a9a90000000000000000000033330000000000000000000000000000000000000000000000000000000000 00a9a90000a9a90000a9a90000a9a90000a9000000a9a90000000000000000009ffff99f00000000000000000000000000000000000000000000000000000000
001111000011110000111100001111000001000000111100000000000000000000b3430000000000000000000000000000000000000000000000000000000000 0011110000111100001111000011110000010000001111000000000000000000099fe9f000000000000000000000000000000000000000000000000000000000
01111110011111100111111001111110010010100111111000000000000000000035bb3000000000000000000000000000000000000000000000000000000000 0111111001111110011111100111111001001010011111100000000000000000009d99f000000000000000000000000000000000000000000000000000000000
0a9999400a9999400a9999400a9999400a9990400a776540000000000000000003b3433000000000000000000800009000000000000000000000000000000000 0a9999400a9999400a9999400a9999400a9990400a77654000000000000000000f9fe0f90000000000000000d000000d00000000000000000000000000000000
5a9999458a9999455a9999455a999948000909555a7c564500000000000000000b343b30000b3000000000000a0000a000000000000000000000000000000000 5a9999458a9999455a9999455a999948000909555a7c56450000000000000000099ef999000a9000000000000d0000d000000000000000000000000000000000
5949444589494445594944455949444859490440596715450000000000000000b3b4533300b3b300030303000400004000000000000000000000000000000000 59494445894944455949444559494448594904405967154500000000000000009ffed0f000a9a900090a09000e0000e000000000000000000000000000000000
0055550000555500008888000055550050555500007c5600500000050000000000045000000b3000033003030400004000000000000000000000000000000000 0055550000555500008888000055550050555500007c560050000005000000000f0ed000000a90000990090a0e0000e000000000000000000000000000000000
66566665000000000000000560000000d8ddddbd0000000000566660000000000003333333333333333330007766776600000000000000000000000000000000 66566665000000000000000560000000d8ddddbd000000000056666000000000000dddddddddddddddddd0007766776600000000000000000000000000000000
666666660000000000000006660000005d7c56d5000000000666666600000000003d3343433d3343433d33007665766500000000000000000000000000000000 666666660000000000000006660000005d7c56d500000000066666660000000000dddd2d2ddddd2d2ddddd007665766500000000000000000000000000000000
56666657000000000000005756600000566715570000000006666657000000000434465354344653543446505446545400000000000000000000000000000000 566666570000000000000057566000005667155700000000066666570000000002d2265d52d2265d52d226505226525200000000000000000000000000000000
66756666000000000000066666750000667c5666000000006675666600000000444454d4444454d4444454d4446454d400000000000000000000000000000000 66756666000000000000066666750000667c5666000000006675666600000000222252d2222252d2222252d2226252d200000000000000000000000000000000
66666666000000000000666666666000666715660000000066666666000000000644444446444444464444404444444400000000000000000000000000000000 66666666000000000000666666666000666715660000000066666666000000000622222226222222262222202222222200000000000000000000000000000000
66666665006600000006666566666600667c5565000000006666666500000000d4454445d4454445d4454445d454544500000000000000000000000000000000 66666665006600000006666566666600667c5565000000006666666500000000d2252225d2252225d2252225d252522500000000000000000000000000000000
65666657076567600066665765666650656556570000000065666650000000005444445454444454544444505444545400000000000000000000000000000000 65666657076567600066665765666650656556570000000065666650000000005222225252222252522222505222525200000000000000000000000000000000
67656666666666566765666667656666666566660000000007656600000000000445464444454644444546404654564400000000000000000000000000000000 67656666666666566765666667656666666566660000000007656600000000000225262222252622222526202652562200000000000000000000000000000000
00000007777777777d8ddbd77000000006566665665666600000000000000000454445444544454445444544000000000000000eeeeeeeeee000000000000000 00000007777777777d8ddbd770000000065666656656666000000000000000002522252225222522252225220000000000000007777777777000000000000000
000000767676767676dddd766500000000666666666666000000000000000000044d4446444d4446444d44400000000000000088888888888200000000000000 000000767676767676dddd766500000000666666666666000000000000000000022d2226222d2226222d2220000000000000007f979797979200000000000000
00000077666666666661166665000000000666575666600000000000000000005444465454444654544446540000000000000e22222222222220000000000000 000000776666666666611666650000000006665756666000000000000000000052222652522226525222265200000000000007f77f797f792f20000000000000
0000007661116116616d16165500000000006666667500000000000000000000444454d4444454d4444454d00000000000008888888888888882000000000000 0000007661116116616d16165500000000006666667500000000000000000000222252d2222252d2222252d00000000000007f7ffffffffff2f2000000000000
000000776d161dd66d166dd6650000000000066666600000000000000000000004444444464444444644440000000000000e2222222222222222200000000000 000000776d161dd66d166dd66500000000000666666000000000000000000000022222222622222226222200000000000007979f9f9f9f9f9f2f200000000000
000000766666666666666666550000000000006566000000000000000000000000454445d4454445d44544450000000000888888888888888888820000000000 000000766666666666666666550000000000006566000000000000000000000000252225d2252225d225222500000000007f79fff9fff9fff9f2f20000000000
0000007665656565656565656500000000000007600000000000000000000000544444545444445454444450000000000e222222222222222222222000000000 00000076656565656565656565000000000000076000000000000000000000005222225252222252522222500000000007f7ffffffffffffffff2f2000000000
00000005555555555555555550000000000000000000000000000000000000000445464444454644444546400000000088888888888888888888888200000000 0000000555555555555555555000000000000000000000000000000000000000022526222225262222252620000000007f7f9f9f9f9f9f9f9f9f929200000000
6460000677c000000000000000000000000000000000000000000000000000004544454445444544454445440000000054444544544445445444454400000000 6460000677c0000000000000000000000000000000000000000000000000000025222522252225222522252200000000deeeedeedeeeedeedeeeedee00000000
545646666611cc00000000000000000000000000000000000000000000000000444d4446444de446444dbb460000000055455555555555555545555500000000 545646666611cc00000000000000000000000000000000000000000000000000222d2226222de226222dbb2600000000dddddddddddddddddddddddd00000000
6555456661d1115000000000000000000000000000000000000000000000000054464654544e8854544b3314000000004444544444c414d44445444400000000 6555456661d1115000000000000000000000000000000000000000000000000052262652522e8852522b331200000000e5eede5eee11d11eee11d11e00000000
5455556661dd1565000000000000000000000000000000000000000000000000446554d4444882d4444411d40000000055555545555554555555555500000000 5455556661dd1565000000000000000000000000000000000000000000000000226552d2222882d2222211d200000000dddddddddddddddddddddddd00000000
65554566666656550000000000000000000000000000000000000000000000004465144446442644464444440000000045444444444445444444444400000000 655545666666565500000000000000000000000000000000000000000000000022651222262226222622222200000000edee5eeeed11e11eed11e11e00000000
5455556666656555000000000000000000000000000000000000000000000000d4414445d4464445d44544450000000055545555555455555545554500000000 5455556666656555000000000000000000000000000000000000000000000000d2212225d2262225d225222500000000dddddddddddddddddddddddd00000000
555111665656555000000000000000000000000000000000000000000000000054444454544445445444445400000000444445444414d5144445d54400000000 555111665656555000000000000000000000000000000000000000000000000052222252522225225222225200000000ee5eed5eee11d11eeee666ee00000000
11100006555555000000000000000000000000000000000000000000000000004445464444454644444546440000000054554555545555555545554500000000 111000065555550000000000000000000000000000000000000000000000000022252622222526222225262200000000dddddddddddddddddd65556d00000000
00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
@ -704,7 +735,7 @@ __label__
67656666676566666765666667656666676566666765666667656666676566666765666667656666676566666765666667656666676566666765666667656666 67656666676566666765666667656666676566666765666667656666676566666765666667656666676566666765666667656666676566666765666667656666
__gff__ __gff__
0000000000000200010000000000000001000000810001000101018100000000000181000000000001010100000100000101000000000000010101000101010000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 0000000000000200010000000000000001000000810001000101018100000000000181000000000001010100010101000101000000000000010101000101010000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
__map__ __map__
0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
@ -718,27 +749,27 @@ __map__
0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000b09000000000000003d3d191a00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 0000000000000000000000000000000000000000000b0900000000000000000000000000000000000000000000000900000000000000000a080000000000000000000000080a00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
000000060000000000080a090000000000000000181b1a000000000000000000282a00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 000000060000000000080a090000000000000000181b1a000000000000000000080a000000000000000000000018191b1a000000000018191a00000000000a0a00000a1819192d2e0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000900
0000000b000008091829292a00000000080a090a28392a002c2d2e0000000000282a00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 0000000b000008091829292a00000000080a090a28392a002c2d2e0000000000282a0000000000000000000000283e3d2a080000000028292a000000181919191919192929293d3d00000000000000000000000000000000000000000000000000000000000018191a00000000002c2d2e000000000000000000000008181a09
08000a1b091819192929392a0a0a0a181919191929292a0a3c3d3e0a0a091b08282a00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 08000a1b091819192929392a0a0a0a181919191929292a0a3c3d3e0a0a091b08282a000008000a00090800001819191919191a000000283a2a080000282929293a29293929293c3e0000090800000a000809000000090a08000a080000000a08000a181a00002838291a00080b003e3c3d080a080a0a08080a0a080a1829381a
1919191919192929392929291919192929292929292929292929292929382929292929291010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010 191919191919292939292929191919292929292929292929292929292938292929292929292929292929292929292929292929292929292929292929293a29292929392929292929291b292929292929292929292929292929292929292929292929292929292929292929291b29292929292929292929292929292929292929
0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001600000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001600000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000016000000000000000000000000000000000000001600000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 0000000000000000000000000000000016000000000000000000000000000000000000001600000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000121413000000000000000000160000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000121413000000000000000000160000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
0000000000001100000000000000000000000600000016000000000030223100000000000000000000003022212300000000000000101010000000000016000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 0000000000001100000000000000000000000000000016000000000030223100000000000000000000003022212300000000000000101010000000000016000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
0000000000121013000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000241025000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 0000000000121000000000000000000000000600000000000000000000000000000000000000000000000000000000000000000000241025000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
1300000000162500000000001100000020212223000000000000000000000000000000000000302121222300000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 0000000000162500000000001100000030212231000000000000000000000000000000000000302121222300000000000000000000000000000000000000160000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
1013000000000000000000121013000000000000000000000016000000000000000000000000302121213100000000000000160000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 0000000000000000000000121013000000000000000000000016000000000000000000000000302121213100000000000000160000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
1010130000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 0000000000000000000000101010000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
0000160000000000000000241025000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000160000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 0000000000110000000000000000000000001100000000000000160000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 0000000012101600000000000000000000121013000011000000000000000000000000001100110000000011000000000000000000000000001100000000111100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 0011001210102500000000000000000012101010131210130000000000110000000000202121212300202121212300000000000000000000121000000000101013000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 0010101010100000002021212300001210101010101021212223000012102123000020212121212300202121212123000000001100000012102500000000241010000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 1210101010101300122121212123121010101010101021212123111210212123000012212121211300122121212113000000121013001210102021230000121010130000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 1010101010101014101010101010101010101010101010101010101010101010101010101010101014101010101010101010101010101010101010101410101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010
1010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010
__sfx__ __sfx__
000400002c2501f250132503365036660396503764035630316202f6202c620246201d6101b6101b61019610126100e61010610116100c6000d6000e6000c6000a60007600016000060000000000000000000000 000400002c2501f250132503365036660396503764035630316202f6202c620246201d6101b6101b61019610126100e61010610116100c6000d6000e6000c6000a60007600016000060000000000000000000000
010800003d0202d0203d0203d61421620216201d6101c6101a6150000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 010800003d0202d0203d0203d61421620216201d6101c6101a6150000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000