X-Git-Url: http://deadsoftware.ru/gitweb?a=blobdiff_plain;f=src%2Fgame%2Fg_phys.pas;h=1e543d4f4b31c980be889bbdad0c5088d8783a24;hb=44bf4b6ea7ee66b36c3cb86c33c180e69f7dc1ba;hp=a16abeef71f0a1341d554f97275dacf24fdb7561;hpb=722b4ecdb98bd4d51cd944030d6d44e96d76cf76;p=d2df-sdl.git diff --git a/src/game/g_phys.pas b/src/game/g_phys.pas index a16abee..1e543d4 100644 --- a/src/game/g_phys.pas +++ b/src/game/g_phys.pas @@ -1,4 +1,4 @@ -(* Copyright (C) DooM 2D:Forever Developers +(* Copyright (C) Doom 2D: Forever Developers * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -60,6 +60,7 @@ function g_Obj_CollideWater(Obj: PObj; XInc, YInc: Integer): Boolean; inline; function g_Obj_CollideLiquid(Obj: PObj; XInc, YInc: Integer): Boolean; inline; function g_Obj_CollidePanel(Obj: PObj; XInc, YInc: Integer; PanelType: Word): Boolean; inline; function g_Obj_StayOnStep(Obj: PObj): Boolean; inline; +function g_Obj_CanMoveY(Obj: PObj; YInc: Integer): Boolean; inline; procedure g_Obj_Push(Obj: PObj; VelX, VelY: Integer); inline; procedure g_Obj_PushA(Obj: PObj; Vel: Integer; Angle: SmallInt); inline; procedure g_Obj_SetSpeed(Obj: PObj; s: Integer); inline; @@ -73,7 +74,7 @@ implementation uses g_map, g_basic, Math, g_player, g_console, SysUtils, - g_sound, g_gfx, MAPDEF, g_monsters, g_game, BinEditor, utils; + g_sound, g_gfx, MAPDEF, g_monsters, g_game, utils; const @@ -90,6 +91,13 @@ begin PANEL_STEP, False); end; +function g_Obj_CanMoveY(Obj: PObj; YInc: Integer): Boolean; inline; +begin + // Åñëè øàãíóòü â ïî âåðòèêàëè, à òàì ñòåíà => øàãàòü íåëüçÿ + // Èëè åñëè øàãíóòü âíèç, à òàì ñòóïåíü => øàãàòü íåëüçÿ + Result := not(g_Obj_CollideLevel(Obj, 0, YInc) or ((YInc > 0) and g_Obj_StayOnStep(Obj))); +end; + function CollideLiquid(Obj: PObj; XInc, YInc: Integer): Boolean; inline; begin Result := g_Map_CollidePanel(Obj^.X+Obj^.Rect.X+XInc, Obj^.Y+Obj^.Rect.Y+YInc, @@ -138,7 +146,7 @@ begin for plr in gPlayers do begin if (plr = nil) then continue; - if not plr.Live then continue; + if not plr.alive then continue; with plr do begin if g_Collide(GameX+PLAYER_RECT.X, GameY+PLAYER_RECT.Y, @@ -257,7 +265,7 @@ var begin result := true; if (not g_Obj_CollideLevel(Obj, sx, -12)) and // çàáèðàåìñÿ íà 12 ïèêñåëåé âëåâî/âïðàâî - g_Obj_CollidePanel(Obj, 0, 1, PANEL_WALL or PANEL_STEP) then // òîëüêî åñëè åñòü çåìëÿ ïîä íîãàìè + (sy >= 0) and (not g_Obj_CanMoveY(Obj, sy)) then // òîëüêî åñëè åñòü çåìëÿ ïîä íîãàìè begin slope(-1); end @@ -299,9 +307,8 @@ var if Blocked(Obj, 0, sy) then st := st or MOVE_BLOCK; end; - // Åñëè øàãíóòü â ïî âåðòèêàëè, à òàì ñòåíà => øàãàòü íåëüçÿ - // Èëè åñëè øàãíóòü âíèç, à òàì ñòóïåíü => øàãàòü íåëüçÿ - if g_Obj_CollideLevel(Obj, 0, sy) or ((sy > 0) and g_Obj_StayOnStep(Obj)) then + // Åñëè øàãàòü íåëüçÿ + if not g_Obj_CanMoveY(Obj, sy) then begin if sy > 0 then st := st or MOVE_HITLAND @@ -385,7 +392,7 @@ begin } // Âûëåòåë çà íèæíþþ ãðàíèöó êàðòû? - if (Obj^.Y > gMapInfo.Height+128) then begin result := MOVE_FALLOUT; Obj.slopeUpLeft := 0; Obj.slopeFramesLeft := 0; exit; end; + if (Obj^.Y > Integer(gMapInfo.Height)+128) then begin result := MOVE_FALLOUT; Obj.slopeUpLeft := 0; Obj.slopeFramesLeft := 0; exit; end; // Ìåíÿåì ñêîðîñòü è óñêîðåíèå òîëüêî ïî ÷åòíûì êàäðàì c := (gTime mod (GAME_TICK*2) <> 0);