X-Git-Url: http://deadsoftware.ru/gitweb?a=blobdiff_plain;f=src%2Fgame%2Fg_basic.pas;h=a5790239f616380501b8e33b29ce7a19d0d7954d;hb=5b1aa7467400740cf8ee0fef8206580a3584eed4;hp=98cebcce846067023ff07b3fa558f1c9ddba0797;hpb=1b0f87b9a64f04be222df8d8d2de059cb139c98d;p=d2df-sdl.git diff --git a/src/game/g_basic.pas b/src/game/g_basic.pas index 98cebcc..a579023 100644 --- a/src/game/g_basic.pas +++ b/src/game/g_basic.pas @@ -48,7 +48,7 @@ function g_CollideAround(X1, Y1: Integer; Width1, Height1: Word; X2, Y2: Integer; Width2, Height2: Word): Boolean; function g_CollidePlayer(X, Y: Integer; Width, Height: Word): Boolean; function g_PatchLength(X1, Y1, X2, Y2: Integer): Word; -function g_TraceVector(X1, Y1, X2, Y2: Integer): Boolean; +function g_TraceVector(X1, Y1, X2, Y2: Integer): Boolean; // `true`: no wall hit function g_GetAcidHit(X, Y: Integer; Width, Height: Word): Byte; function g_Look(a, b: PObj; d: TDirection): Boolean; procedure IncMax(var A: Integer; B, Max: Integer); overload; @@ -142,15 +142,21 @@ begin end; end; + function g_TraceVector(X1, Y1, X2, Y2: Integer): Boolean; var + wallHitX: Integer = 0; + wallHitY: Integer = 0; +(* i: Integer; dx, dy: Integer; Xerr, Yerr, d: LongWord; incX, incY: Integer; x, y: Integer; +*) begin - Result := False; + (* + result := False; Assert(gCollideMap <> nil, 'g_TraceVector: gCollideMap = nil'); @@ -193,8 +199,22 @@ begin end; Result := True; + *) + + result := false; + if g_Map_traceToNearestWall(x1, y1, x2, y2, @wallHitX, @wallHitY) then + begin + // check distance + //result := ((wallHitX-x1)*(wallHitX-x1)+(wallHitY-y1)*(wallHitY-y1) > (x2-x1)*(x2-x1)+(y2-y1)*(y2-y1)); + result := false; + end + else + begin + result := true; // no obstacles + end; end; + function g_CreateUID(UIDType: Byte): Word; var ok: Boolean;