From 720e05f1b37cb3755232d52f7514eff468f04160 Mon Sep 17 00:00:00 2001 From: Stas'M Date: Sun, 27 Jan 2019 15:45:16 +0300 Subject: [PATCH] GFX: Properly check for lift direction http://doom2d.org/forum/viewtopic.php?f=36&t=2597 --- src/game/g_gfx.pas | 52 +++++++++++++++++++++++----------------------- 1 file changed, 26 insertions(+), 26 deletions(-) diff --git a/src/game/g_gfx.pas b/src/game/g_gfx.pas index e92f369..64b62e8 100644 --- a/src/game/g_gfx.pas +++ b/src/game/g_gfx.pas @@ -337,35 +337,35 @@ var r: Integer; begin pan := g_Map_PanelAtPoint(x, y, GridTagLift); - result := (pan <> nil); + result := (pan <> nil) and WordBool(pan.PanelType and (PANEL_LIFTUP or PANEL_LIFTDOWN or PANEL_LIFTLEFT or PANEL_LIFTRIGHT)); r := Random(3); if result then begin - if ((pan.PanelType and PANEL_LIFTUP) <> 0) then - begin - if (velY > -1-r) then velY -= 0.8; - if (abs(velX) > 0.1) then velX -= velX/10.0; - velX += (Random-Random)*0.2; - accelY := 0.15; - end - else if ((pan.PanelType and PANEL_LIFTDOWN) <> 0) then - begin - if (velY < 1+r) then velY += 0.8; - accelY := 0.15; - end - else if ((pan.PanelType and PANEL_LIFTLEFT) <> 0) then - begin - if (velX > -8-r) then velX -= (8+r) div 2; - accelY := 0.15; - end - else if ((pan.PanelType and PANEL_LIFTRIGHT) <> 0) then - begin - if (velX < 8+r) then velX += (8+r) div 2; - accelY := 0.15; - end - else - begin - result := false; + case pan.LiftType of + LIFTTYPE_UP: + begin + if (velY > -1-r) then velY -= 0.8; + if (abs(velX) > 0.1) then velX -= velX/10.0; + velX += (Random-Random)*0.2; + accelY := 0.15; + end; + LIFTTYPE_DOWN: + begin + if (velY < 1+r) then velY += 0.8; + accelY := 0.15; + end; + LIFTTYPE_LEFT: + begin + if (velX > -8-r) then velX -= (8+r) div 2; + accelY := 0.15; + end; + LIFTTYPE_RIGHT: + begin + if (velX < 8+r) then velX += (8+r) div 2; + accelY := 0.15; + end; + else + result := false; end; // awake if result and (state = TPartState.Sleeping) then state := TPartState.Normal; -- 2.29.2