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,7 +127,13 @@ function _update()
end end
sfx(1) sfx(1)
break break
elseif solid or plr_pos.y<=0 then elseif solid then
crashed=true
break
end
end
end
if crashed then
plr_speed.y*=-0.75 plr_speed.y*=-0.75
plr_speed.x*=0.5 plr_speed.x*=0.5
plr_alive=false plr_alive=false
@ -136,9 +145,6 @@ function _update()
plr_static=true plr_static=true
sfx(3) sfx(3)
end end
break
end
end
end end
if plr_alive then if plr_alive then