summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 720e05f)
raw | patch | inline | side by side (parent: 720e05f)
author | Stas'M <x86corez@gmail.com> | |
Sun, 27 Jan 2019 19:45:33 +0000 (22:45 +0300) | ||
committer | Stas'M <x86corez@gmail.com> | |
Sun, 27 Jan 2019 19:45:33 +0000 (22:45 +0300) |
http://doom2d.org/forum/viewtopic.php?t=2586&f=36
src/game/g_gfx.pas | patch | blob | history | |
src/game/g_map.pas | patch | blob | history |
diff --git a/src/game/g_gfx.pas b/src/game/g_gfx.pas
index 64b62e8d7682fdbc14f270b7dd01dc4c2645f3a6..476f658d15175b28e911ee8b60e2dca69b6bcd0a 100644 (file)
--- a/src/game/g_gfx.pas
+++ b/src/game/g_gfx.pas
ex: Integer;
begin
if (not force) and (ceilingY <> Unknown) then exit;
- if (nil = g_Map_traceToNearest(x, y, x, g_Map_MinY, GridTagObstacle, @ex, @ceilingY)) then
+ if (nil = g_Map_traceToNearest(x, y, x, g_Map_MinY, GridTagSolid, @ex, @ceilingY)) then
begin
ceilingY := g_Map_MinY-2;
end;
pan: TPanel;
dx, dy: SmallInt;
ex, ey: Integer;
- checkEnv, inAir: Boolean;
+ checkEnv, inAir, inStep: Boolean;
floorJustTraced: Boolean;
{$IF DEFINED(D2F_DEBUG_FALL_MPLAT)}
oldFloorY: Integer;
if (dx <> 0) then
begin
// has some horizontal velocity
- pan := g_Map_traceToNearest(x, y, x+dx, y+dy, GridTagObstacle, @ex, @ey);
+ inStep := False;
+ pan := g_Map_traceToNearest(x, y, x+dx, y+dy, GridTagSolid, @ex, @ey);
+ if (pan = nil) and (dy >= 0) then
+ begin
+ // do not stuck inside step
+ if g_Map_traceToNearest(x, y, x, y, GridTagStep, nil, nil) = nil then
+ // check for step panel below
+ pan := g_Map_traceToNearest(x, y, x, y+dy, GridTagStep, nil, @ey);
+ inStep := pan <> nil;
+ if inStep then
+ begin
+ // stick to panel edges
+ if ex < pan.X then
+ ex := pan.X
+ else if ex > pan.X + pan.Width - 1 then
+ ex := pan.X + pan.Width - 1;
+ end;
+ end;
checkEnv := (x <> ex);
x := ex;
y := ey;
end;
if (pan <> nil) then
begin
- // we stuck
- // the only case when we can have both ceiling and wall is corner; stick to wall in this case
- // check if we stuck to a wall
- if (dx < 0) then dx := -1 else dx := 1;
- if (g_Map_PanelAtPoint(x+dx, y, GridTagObstacle) <> nil) then
- begin
- // stuck to a wall
- stickToWall(dx);
- end
+ if inStep then
+ stickToWall(dx)
else
begin
- // stuck to a ceiling
- stickToCeiling();
+ // we stuck
+ // the only case when we can have both ceiling and wall is corner; stick to wall in this case
+ // check if we stuck to a wall
+ if (dx < 0) then dx := -1 else dx := 1;
+ if (g_Map_PanelAtPoint(x+dx, y, GridTagSolid) <> nil) then
+ begin
+ // stuck to a wall
+ stickToWall(dx);
+ end
+ else
+ begin
+ // stuck to a ceiling
+ stickToCeiling();
+ end;
end;
end;
end
if (x < g_Map_MinX) or (y < g_Map_MinY) or (x > g_Map_MaxX) or (y > g_Map_MaxY) then continue;
// in what environment we are starting in?
- pan := g_Map_PanelAtPoint(x, y, (GridTagObstacle or GridTagLiquid));
+ pan := g_Map_PanelAtPoint(x, y, (GridTagSolid or GridTagLiquid));
if (pan <> nil) then
begin
// either in a wall, or in a liquid
- if ((pan.tag and GridTagObstacle) <> 0) then continue; // don't spawn in walls
+ if ((pan.tag and GridTagSolid) <> 0) then continue; // don't spawn in walls
env := TEnvType.ELiquid;
end
else
if (dx <> 0) then
begin
// has some horizontal velocity
- pan := g_Map_traceToNearest(x, y, x+dx, y+dy, (GridTagObstacle or GridTagLiquid), @ex, @ey);
+ pan := g_Map_traceToNearest(x, y, x+dx, y+dy, (GridTagSolid or GridTagLiquid), @ex, @ey);
if (x <> ex) then begin floorY := Unknown; ceilingY := Unknown; end; // dunno yet
x := ex;
y := ey;
if (x < g_Map_MinX) or (y < g_Map_MinY) or (x > g_Map_MaxX) or (y > g_Map_MaxY) then continue;
// in what environment we are starting in?
- pan := g_Map_PanelAtPoint(x, y, (GridTagObstacle or GridTagLiquid));
+ pan := g_Map_PanelAtPoint(x, y, (GridTagSolid or GridTagLiquid));
if (pan <> nil) then
begin
// either in a wall, or in a liquid
- //if ((pan.tag and GridTagObstacle) <> 0) then continue; // don't spawn in walls
+ //if ((pan.tag and GridTagSolid) <> 0) then continue; // don't spawn in walls
//env := TEnvType.ELiquid;
continue;
end
if (x < g_Map_MinX) or (y < g_Map_MinY) or (x > g_Map_MaxX) or (y > g_Map_MaxY) then continue;
// in what environment we are starting in?
- pan := g_Map_PanelAtPoint(x, y, (GridTagObstacle or GridTagLiquid));
+ pan := g_Map_PanelAtPoint(x, y, (GridTagSolid or GridTagLiquid));
if (pan <> nil) then
begin
// either in a wall, or in a liquid
- //if ((pan.tag and GridTagObstacle) <> 0) then continue; // don't spawn in walls
+ //if ((pan.tag and GridTagSolid) <> 0) then continue; // don't spawn in walls
//env := TEnvType.ELiquid;
continue;
end
diff --git a/src/game/g_map.pas b/src/game/g_map.pas
index fef17e0bde166a76136071daefde8f9907c31dd9..be752f804f2116d93fb88ea8be5a251586225726 100644 (file)
--- a/src/game/g_map.pas
+++ b/src/game/g_map.pas
GridTagLift = 1 shl 8; // gLifts
GridTagBlockMon = 1 shl 9; // gBlockMon
+ GridTagSolid = (GridTagWall or GridTagDoor);
GridTagObstacle = (GridTagStep or GridTagWall or GridTagDoor);
GridTagLiquid = (GridTagAcid1 or GridTagAcid2 or GridTagWater);