From c1152dcbbe15bcdb9848b99137475f6ec201ead4 Mon Sep 17 00:00:00 2001 From: DeaDDooMER Date: Sun, 16 Jan 2022 20:05:24 +0300 Subject: [PATCH] render: remove flag animation from player model state --- src/game/Doom2DF.lpr | 1 + src/game/g_playermodel.pas | 40 +++-------------------- src/game/opengl/r_playermodel.pas | 53 +++++++++++++++++++++++++++---- src/game/opengl/r_render.pas | 10 ++++++ 4 files changed, 62 insertions(+), 42 deletions(-) diff --git a/src/game/Doom2DF.lpr b/src/game/Doom2DF.lpr index 12b9efd..275c6f3 100644 --- a/src/game/Doom2DF.lpr +++ b/src/game/Doom2DF.lpr @@ -233,6 +233,7 @@ begin if (NetMode = NET_SERVER) then g_Net_Host_Update() else if (NetMode = NET_CLIENT) then g_Net_Client_Update(); // think + r_Render_Update; g_Game_Update(); // server: send any accumulated outgoing data to clients if NetMode = NET_SERVER then g_Net_Flush(); diff --git a/src/game/g_playermodel.pas b/src/game/g_playermodel.pas index 8ffb589..51dd6c0 100644 --- a/src/game/g_playermodel.pas +++ b/src/game/g_playermodel.pas @@ -113,9 +113,6 @@ type FSlopSound: Byte; FCurrentWeapon: Byte; FFlag: Byte; - FFlagPoint: TDFPoint; - FFlagAngle: SmallInt; - FFlagAnim: TAnimation; // !!! TAnimationState FFire: Boolean; FFireCounter: Byte; FID: Integer; @@ -141,17 +138,10 @@ type public property Color: TRGB read FColor write FColor; - property AnimState: TAnimationState read FAnimState; property CurrentAnimation: Byte read FCurrentAnimation; - property CurrentWeapon: Byte read FCurrentWeapon; - property Flag: Byte read FFlag; - property FlagAnim: TAnimation read FFlagAnim; - property FlagAngle: SmallInt read FFlagAngle; - property FlagPoint: TDFPoint read FFlagPoint; - property ID: Integer read FID; end; @@ -661,13 +651,8 @@ begin Result.FPainSounds := PainSounds; Result.FDieSounds := DieSounds; Result.FSlopSound := SlopSound; - - Result.FFlagPoint := FlagPoint; - Result.FFlagAngle := FlagAngle; Result.FID := a; - Result.ChangeAnimation(A_STAND, True); - Break; end; end; @@ -906,27 +891,14 @@ begin FFireCounter := 0 end; -procedure TPlayerModel.SetFlag(Flag: Byte); -var - tid: DWORD; -begin - FFlag := Flag; - - FFlagAnim.Free(); - FFlagAnim := nil; - - case Flag of - FLAG_RED: g_Frames_Get(tid, 'FRAMES_FLAG_RED'); - FLAG_BLUE: g_Frames_Get(tid, 'FRAMES_FLAG_BLUE'); - else Exit; + procedure TPlayerModel.SetFlag (Flag: Byte); + begin + FFlag := Flag end; - FFlagAnim := TAnimation.Create(tid, True, 8); -end; - - procedure TPlayerModel.SetWeapon(Weapon: Byte); + procedure TPlayerModel.SetWeapon (Weapon: Byte); begin - FCurrentWeapon := Weapon; + FCurrentWeapon := Weapon end; function TPlayerModel.GetBlood (): TModelBlood; @@ -943,8 +915,6 @@ end; begin if FAnimState <> nil then FAnimState.Update; - if FFlagAnim <> nil then - FFlagAnim.Update; if FFireCounter > 0 then Dec(FFireCounter) else diff --git a/src/game/opengl/r_playermodel.pas b/src/game/opengl/r_playermodel.pas index 1602f23..b90ed05 100644 --- a/src/game/opengl/r_playermodel.pas +++ b/src/game/opengl/r_playermodel.pas @@ -19,8 +19,11 @@ interface uses g_playermodel; // TPlayerModel + procedure r_PlayerModel_Initialize; + procedure r_PlayerModel_Finalize; procedure r_PlayerModel_Load; procedure r_PlayerModel_Free; + procedure r_PlayerModel_Update; procedure r_PlayerModel_Draw (pm: TPlayerModel; X, Y: Integer; Alpha: Byte = 0); implementation @@ -30,7 +33,7 @@ implementation MAPDEF, utils, ImagingTypes, Imaging, ImagingUtility, r_graphics, g_options, r_animations, r_textures, - g_base, g_basic, g_map, g_weapons + g_base, g_basic, g_map, g_weapons, g_textures ; const @@ -48,6 +51,20 @@ implementation mask: DWORD; end; end; + RedFlagFrames: DWORD; + BlueFlagFrames: DWORD; + FlagAnimState: TAnimationState; + + procedure r_PlayerModel_Initialize; + begin + FlagAnimState := TAnimationState.Create(True, 8, 5); + end; + + procedure r_PlayerModel_Finalize; + begin + FlagAnimState.Free; + FlagAnimState := nil; + end; procedure ExtAnimFromBaseAnim(MName: String; AIdx: Integer); const @@ -82,6 +99,8 @@ implementation procedure r_PlayerModel_Load; var ID1, ID2: DWORD; i, a, b: Integer; prefix, aname: String; begin + g_Frames_CreateWAD(@RedFlagFrames, 'FRAMES_FLAG_RED', GameWAD + ':TEXTURES\FLAGRED', 64, 64, 5, False); + g_Frames_CreateWAD(@BlueFlagFrames, 'FRAMES_FLAG_BLUE', GameWAD + ':TEXTURES\FLAGBLUE', 64, 64, 5, False); for a := WP_FIRST + 1 to WP_LAST do begin g_Texture_CreateWAD(WeaponID[a][W_POS_NORMAL][W_ACT_NORMAL], GameWAD+':WEAPONS\'+UpperCase(WeapNames[a])); @@ -134,6 +153,8 @@ implementation procedure r_PlayerModel_Free; var i, a, b, c: Integer; begin + e_DeleteTexture(RedFlagFrames); + e_DeleteTexture(BlueFlagFrames); if PlayerModelsArray = nil then Exit; for i := 0 to High(PlayerModelsArray) do begin @@ -164,12 +185,18 @@ implementation e_DeleteTexture(WeaponID[a][b][c]) end; + procedure r_PlayerModel_Update; + begin + FlagAnimState.Update + end; + procedure r_PlayerModel_Draw (pm: TPlayerModel; X, Y: Integer; Alpha: Byte = 0); var Mirror: TMirrorType; pos, act: Byte; - p: TDFPoint; + fp, p: TDFPoint; FramesID: DWORD; + fa: Integer; begin // Флаги: if pm.Direction = TDirection.D_LEFT then @@ -177,14 +204,26 @@ begin else Mirror := TMirrorType.Horizontal; - if (pm.Flag <> FLAG_NONE) and (pm.FlagAnim <> nil) and (not (pm.CurrentAnimation in [A_DIE1, A_DIE2])) then + FramesID := 0; + case pm.Flag of + FLAG_RED: FramesID := RedFlagFrames; + FLAG_BLUE: FramesID := BlueFlagFrames; + end; + if (FramesID <> 0) and (not (pm.CurrentAnimation in [A_DIE1, A_DIE2])) then begin + fp := PlayerModelsArray[pm.id].FlagPoint; + fa := PlayerModelsArray[pm.id].FlagAngle; p.X := IfThen(pm.Direction = TDirection.D_LEFT, FLAG_BASEPOINT.X, 64 - FLAG_BASEPOINT.X); p.Y := FLAG_BASEPOINT.Y; - - r_Animation_DrawEx(pm.FlagAnim, X+IfThen(pm.Direction = TDirection.D_LEFT, pm.FlagPoint.X-1, 2*FLAG_BASEPOINT.X-pm.FlagPoint.X+1)-FLAG_BASEPOINT.X, - Y+pm.FlagPoint.Y-FLAG_BASEPOINT.Y+1, Mirror, p, - IfThen(pm.Direction = TDirection.D_RIGHT, pm.FlagAngle, -pm.FlagAngle)); + r_AnimationState_DrawEx( + FramesID, + FlagAnimState, + X + IfThen(pm.Direction = TDirection.D_LEFT, fp.X - 1, 2 * FLAG_BASEPOINT.X - fp.X + 1) - FLAG_BASEPOINT.X, + Y + fp.Y - FLAG_BASEPOINT.Y + 1, + Mirror, + p, + IfThen(pm.Direction = TDirection.D_RIGHT, fa, -fa) + ); end; // Оружие: diff --git a/src/game/opengl/r_render.pas b/src/game/opengl/r_render.pas index 5deccdb..b26d0ec 100644 --- a/src/game/opengl/r_render.pas +++ b/src/game/opengl/r_render.pas @@ -19,11 +19,14 @@ interface procedure r_Render_Initialize; procedure r_Render_Finalize; + procedure r_Render_Resize (w, h: Integer); procedure r_Render_Load; procedure r_Render_Free; + procedure r_Render_Update; + procedure r_Render_Apply; implementation @@ -98,14 +101,21 @@ implementation LoadGL; r_Window_Initialize; r_Console_Init; + r_PlayerModel_Initialize; end; procedure r_Render_Finalize; begin + r_PlayerModel_Finalize; FreeGL; e_ReleaseEngine end; + procedure r_Render_Update; + begin + r_PlayerModel_Update; + end; + procedure r_Render_Resize (w, h: Integer); begin LoadGL; -- 2.29.2