summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: d52e9d7)
raw | patch | inline | side by side (parent: d52e9d7)
author | DeaDDooMER <deaddoomer@deadsoftware.ru> | |
Tue, 21 Feb 2023 15:48:56 +0000 (18:48 +0300) | ||
committer | DeaDDooMER <deaddoomer@deadsoftware.ru> | |
Fri, 9 Jun 2023 09:19:25 +0000 (12:19 +0300) |
diff --git a/src/game/g_panel.pas b/src/game/g_panel.pas
index 2681f1d43ec1e40e7b50712e0f3f7a5183c3c0ed..275c57b0f03640ef576c6bd3b02cf74e1234bee9 100644 (file)
--- a/src/game/g_panel.pas
+++ b/src/game/g_panel.pas
property oldY: Integer read FOldY;
property oldWidth: Word read FOldW;
property oldHeight: Word read FOldH;
+ property oldMovingActive: Boolean read mOldMovingActive write mOldMovingActive;
property panelType: Word read FPanelType write FPanelType;
property enabled: Boolean read FEnabled write FEnabled;
property door: Boolean read FDoor write FDoor;
diff --git a/src/game/g_phys.pas b/src/game/g_phys.pas
index 3ff102b6e00b3220b8ce658b4cc7666726468820..2695eb7e67d9452212b2420da3d65b22177d6ebd 100644 (file)
--- a/src/game/g_phys.pas
+++ b/src/game/g_phys.pas
slopeFramesLeft: Integer; // frames left to go
// for frame interpolation
oldX, oldY: Integer;
- procedure lerp(t: Single; out fX, fY: Integer);
end;
const
const
SmoothSlopeFrames = 4;
-procedure TObj.lerp(t: Single; out fX, fY: Integer);
-begin
- fX := nlerp(oldX, X, t);
- fY := nlerp(oldY, Y, t);
-end;
-
function g_Obj_StayOnStep(Obj: PObj): Boolean; inline;
begin
Result := not g_Map_CollidePanel(Obj^.X+Obj^.Rect.X, Obj^.Y+Obj^.Rect.Y+Obj^.Rect.Height-1,
index 331988249b287a83355b7df4e07a522875e6ef15..42102bb75ad4dd8ca1f3e7e04c66b88d0e387e29 100644 (file)
interface
- uses r_textures, r_fonts, g_player, g_phys;
+ uses r_textures, r_fonts, g_player, g_phys, g_panel;
type
TBasePoint = (
function r_Common_TimeToStr (t: LongWord): AnsiString;
- procedure r_Common_GetObjectPos (const obj: TObj; out x, y: Integer);
+ procedure r_Common_GetPanelPos (const p: TPanel; out x, y, w, h: Integer);
+ procedure r_Common_GetObjectPos (constref obj: TObj; out x, y: Integer);
procedure r_Common_GetPlayerPos (const p: TPlayer; out x, y: Integer);
procedure r_Common_GetCameraPos (const p: TPlayer; center: Boolean; out x, y: Integer);
function r_Common_GetPosByUID (uid: WORD; out obj: TObj; out x, y: Integer): Boolean;
FreeMem(temp)
end;
- procedure r_Common_GetObjectPos (const obj: TObj; out x, y: Integer);
- var fx, fy: Integer;
+ procedure r_Common_GetPanelPos (const p: TPanel; out x, y, w, h: Integer);
begin
- obj.Lerp(gLerpFactor, fx, fy);
- x := fx;
- y := fy + obj.slopeUpLeft;
+ ASSERT(p <> nil);
+ if p.OldMovingActive then
+ begin
+ x := nlerp(p.oldX, p.x, gLerpFactor);
+ y := nlerp(p.oldY, p.y, gLerpFactor);
+ w := nlerp(p.oldWidth, p.width, gLerpFactor);
+ h := nlerp(p.oldHeight, p.height, gLerpFactor);
+ end
+ else
+ begin
+ x := p.x;
+ y := p.y;
+ w := p.width;
+ h := p.height;
+ end;
+ end;
+
+ procedure r_Common_GetObjectPos (constref obj: TObj; out x, y: Integer);
+ begin
+ x := nlerp(obj.oldx, obj.x, gLerpFactor);
+ y := nlerp(obj.oldy, obj.y, gLerpFactor) + obj.slopeUpLeft;
end;
procedure r_Common_GetPlayerPos (const p: TPlayer; out x, y: Integer);
- var fx, fy, fSlope: Integer;
begin
ASSERT(p <> nil);
- p.obj.Lerp(gLerpFactor, fx, fy);
- fSlope := nlerp(p.SlopeOld, p.obj.slopeUpLeft, gLerpFactor);
- x := fx;
- y := fy + fSlope;
+ x := nlerp(p.obj.oldx, p.obj.x, gLerpFactor);
+ y := nlerp(p.obj.oldy + p.SlopeOld, p.obj.y + p.obj.slopeUpLeft, gLerpFactor);
end;
{$IFDEF ENABLE_CORPSES}
index 371b13db5ac8810e30444257144ad501c272054e..992d8687a3194d9c15d5dc17b98f7773001117d7 100644 (file)
end;
procedure r_Map_DrawPanel (p: TPanel);
- var Texture, spec: Integer; t: TGLMultiTexture; count, frame: LongInt; a: TAnimInfo;
+ var Texture, x, y, w, h: Integer; t: TGLMultiTexture; count, frame: LongInt; a: TAnimInfo;
begin
ASSERT(p <> nil);
ASSERT(p.FCurTexture >= -1); (* p.FCurTexture = -1 -> invisible texture *)
if p.FCurTexture >= 0 then
begin
+ r_Common_GetPanelPos(p, x, y, w, h);
ASSERT(p.FCurTexture <= High(p.TextureIDs));
Texture := p.TextureIDs[p.FCurTexture].Texture;
ASSERT(Texture >= -1); (* Texture = -1 -> texture not found *)
a.loop := p.AnimLoop;
g_Anim_GetFrameByTime(a, (gTime - p.AnimTime) DIV GAME_TICK, count, frame);
end;
- r_Draw_TextureRepeat(t.GetTexture(frame), p.x, p.y, p.width, p.height, false, 255, 255, 255, 255 - p.alpha, p.blending);
+ r_Draw_TextureRepeat(t.GetTexture(frame), x, y, w, h, false, 255, 255, 255, 255 - p.alpha, p.blending);
end
else if RenTextures[Texture].spec = 0 then
begin
- r_Draw_TextureRepeat(nil, p.x, p.y, p.width, p.height, false, 255, 255, 255, 255, false);
+ r_Draw_TextureRepeat(nil, x, y, w, h, false, 255, 255, 255, 255, false);
end;
case RenTextures[Texture].spec of
- TEXTURE_SPECIAL_WATER: r_Draw_Filter(p.x, p.y, p.x + p.width, p.y + p.height, 0, 0, 255, 255);
- TEXTURE_SPECIAL_ACID1: r_Draw_Filter(p.x, p.y, p.x + p.width, p.y + p.height, 0, 230, 0, 255);
- TEXTURE_SPECIAL_ACID2: r_Draw_Filter(p.x, p.y, p.x + p.width, p.y + p.height, 230, 0, 0, 255);
+ TEXTURE_SPECIAL_WATER: r_Draw_Filter(x, y, x + w, y + h, 0, 0, 255, 255);
+ TEXTURE_SPECIAL_ACID1: r_Draw_Filter(x, y, x + w, y + h, 0, 230, 0, 255);
+ TEXTURE_SPECIAL_ACID2: r_Draw_Filter(x, y, x + w, y + h, 230, 0, 0, 255);
end;
end
else
begin
- r_Draw_TextureRepeat(nil, p.x, p.y, p.width, p.height, false, 255, 255, 255, 255, false);
+ r_Draw_TextureRepeat(nil, x, y, w, h, false, 255, 255, 255, 255, false);
end;
end;
end;