moonbus: crash when flying out of the screen

This commit is contained in:
Dejvino 2024-08-10 08:09:42 +02:00
parent 3f5c1387c1
commit ec1def7d45

View File

@ -102,7 +102,10 @@ function _update()
-- 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})
if pc.y <= maph+1 and not plr_static then local crashed=false
if plr_pos.y<=0 or plr_pos.y>17 then
crashed=true
elseif pc.y <= maph+1 and not plr_static then
for p in all({plus(pc,clearx(unit(plr_speed,0.4))), plus(pc,cleary(unit(plr_speed,0.4)))}) do for p in all({plus(pc,clearx(unit(plr_speed,0.4))), plus(pc,cleary(unit(plr_speed,0.4)))}) do
local pmaps=0 local pmaps=0
if (p.y>=0 and p.y<=maph) then if (p.y>=0 and p.y<=maph) then
@ -124,22 +127,25 @@ function _update()
end end
sfx(1) sfx(1)
break break
elseif solid or plr_pos.y<=0 then elseif solid then
plr_speed.y*=-0.75 crashed=true
plr_speed.x*=0.5
plr_alive=false
if (dist(plr_speed) > 1) then
sfx(0)
else
plr_speed.x=0
plr_speed.y=0
plr_static=true
sfx(3)
end
break break
end end
end end
end end
if crashed then
plr_speed.y*=-0.75
plr_speed.x*=0.5
plr_alive=false
if (dist(plr_speed) > 1) then
sfx(0)
else
plr_speed.x=0
plr_speed.y=0
plr_static=true
sfx(3)
end
end
if plr_alive then if plr_alive then
telem_spd=mul(plr_speed,1) telem_spd=mul(plr_speed,1)