From: DeaDDooMER Date: Sun, 16 Jan 2022 19:28:16 +0000 (+0300) Subject: render: player punch TAnimation -> TAnimationState X-Git-Url: http://deadsoftware.ru/gitweb?a=commitdiff_plain;h=1443e95fdfcecd289bb2801121198caad9ecd039;p=d2df-sdl.git render: player punch TAnimation -> TAnimationState --- diff --git a/src/game/g_game.pas b/src/game/g_game.pas index 48b713c..539cf2c 100644 --- a/src/game/g_game.pas +++ b/src/game/g_game.pas @@ -2472,12 +2472,6 @@ begin end; end; - g_Frames_CreateWAD(nil, 'FRAMES_PUNCH', GameWAD+':WEAPONS\PUNCH', 64, 64, 4, False); - g_Frames_CreateWAD(nil, 'FRAMES_PUNCH_UP', GameWAD+':WEAPONS\PUNCH_UP', 64, 64, 4, False); - g_Frames_CreateWAD(nil, 'FRAMES_PUNCH_DN', GameWAD+':WEAPONS\PUNCH_DN', 64, 64, 4, False); - g_Frames_CreateWAD(nil, 'FRAMES_PUNCH_BERSERK', GameWAD+':WEAPONS\PUNCHB', 64, 64, 4, False); - g_Frames_CreateWAD(nil, 'FRAMES_PUNCH_BERSERK_UP', GameWAD+':WEAPONS\PUNCHB_UP', 64, 64, 4, False); - g_Frames_CreateWAD(nil, 'FRAMES_PUNCH_BERSERK_DN', GameWAD+':WEAPONS\PUNCHB_DN', 64, 64, 4, False); g_Sound_CreateWADEx('SOUND_GAME_TELEPORT', GameWAD+':SOUNDS\TELEPORT'); g_Sound_CreateWADEx('SOUND_GAME_NOTELEPORT', GameWAD+':SOUNDS\NOTELEPORT'); g_Sound_CreateWADEx('SOUND_GAME_SECRET', GameWAD+':SOUNDS\SECRET'); @@ -2614,12 +2608,6 @@ begin g_Texture_Delete('TEXTURE_PLAYER_BLUEFLAG_D'); g_Texture_Delete('TEXTURE_PLAYER_TALKBUBBLE'); g_Texture_Delete('TEXTURE_PLAYER_INVULPENTA'); - g_Frames_DeleteByName('FRAMES_PUNCH'); - g_Frames_DeleteByName('FRAMES_PUNCH_UP'); - g_Frames_DeleteByName('FRAMES_PUNCH_DN'); - g_Frames_DeleteByName('FRAMES_PUNCH_BERSERK'); - g_Frames_DeleteByName('FRAMES_PUNCH_BERSERK_UP'); - g_Frames_DeleteByName('FRAMES_PUNCH_BERSERK_DN'); g_Sound_Delete('SOUND_GAME_TELEPORT'); g_Sound_Delete('SOUND_GAME_NOTELEPORT'); g_Sound_Delete('SOUND_GAME_SECRET'); diff --git a/src/game/g_player.pas b/src/game/g_player.pas index 7c73eb7..5478180 100644 --- a/src/game/g_player.pas +++ b/src/game/g_player.pas @@ -191,7 +191,7 @@ type FSavedStateNum: Integer; FModel: TPlayerModel; - FPunchAnim: TAnimation; + FPunchAnim: TAnimationState; FActionPrior: Byte; FActionAnim: Byte; FActionForce: Boolean; @@ -403,7 +403,7 @@ type property Berserk: Integer read FBerserk; property Pain: Integer read FPain; property Pickup: Integer read FPickup; - property PunchAnim: TAnimation read FPunchAnim write FPunchAnim; + property PunchAnim: TAnimationState read FPunchAnim write FPunchAnim; property SpawnInvul: Integer read FSpawnInvul; property Ghost: Boolean read FGhost; @@ -2123,6 +2123,8 @@ begin FNetTime := 0; FWaitForFirstSpawn := false; + FPunchAnim := TAnimationState.Create(False, 1, 4); + FPunchAnim.Disable; resetWeaponQueue(); end; @@ -2269,31 +2271,15 @@ begin FJetSoundOn.Free(); FJetSoundOff.Free(); FModel.Free(); - if FPunchAnim <> nil then - FPunchAnim.Free(); + FPunchAnim.Free(); inherited; end; procedure TPlayer.DoPunch(); -var - id: DWORD; - st: String; begin - if FPunchAnim <> nil then begin - FPunchAnim.reset(); - FPunchAnim.Free; - FPunchAnim := nil; - end; - st := 'FRAMES_PUNCH'; - if R_BERSERK in FRulez then - st := st + '_BERSERK'; - if FKeys[KEY_UP].Pressed then - st := st + '_UP' - else if FKeys[KEY_DOWN].Pressed then - st := st + '_DN'; - g_Frames_Get(id, st); - FPunchAnim := TAnimation.Create(id, False, 1); + FPunchAnim.Reset; + FPunchAnim.Enable; end; procedure TPlayer.Fire(); @@ -4295,8 +4281,10 @@ begin FLoss := 0; end; - if FAlive and (FPunchAnim <> nil) then - FPunchAnim.Update(); + if FAlive then + FPunchAnim.Update; + if FPunchAnim.played then + FPunchAnim.Disable; if FAlive and (gFly or FJetpack) then FlySmoke(); diff --git a/src/game/opengl/r_player.pas b/src/game/opengl/r_player.pas index 28eaf3d..8b25eb4 100644 --- a/src/game/opengl/r_player.pas +++ b/src/game/opengl/r_player.pas @@ -19,6 +19,9 @@ interface uses g_player, g_base; // TPlayer, TRGB + procedure r_Player_Load; + procedure r_Player_Free; + procedure r_Player_DrawAll; procedure r_Player_DrawDebug (p: TPlayer); procedure r_Player_DrawHealth; @@ -49,6 +52,29 @@ implementation r_playermodel, r_graphics, r_animations, r_textures, r_items ; + var + PunchFrames: array [Boolean, 0..2] of DWORD; + + procedure r_Player_Load; + begin + g_Frames_CreateWAD(@PunchFrames[False, 0], 'FRAMES_PUNCH', GameWAD + ':WEAPONS\PUNCH', 64, 64, 4, False); + g_Frames_CreateWAD(@PunchFrames[False, 1], 'FRAMES_PUNCH_UP', GameWAD + ':WEAPONS\PUNCH_UP', 64, 64, 4, False); + g_Frames_CreateWAD(@PunchFrames[False, 2], 'FRAMES_PUNCH_DN', GameWAD + ':WEAPONS\PUNCH_DN', 64, 64, 4, False); + g_Frames_CreateWAD(@PunchFrames[True, 0], 'FRAMES_PUNCH_BERSERK', GameWAD + ':WEAPONS\PUNCHB', 64, 64, 4, False); + g_Frames_CreateWAD(@PunchFrames[True, 1], 'FRAMES_PUNCH_BERSERK_UP', GameWAD + ':WEAPONS\PUNCHB_UP', 64, 64, 4, False); + g_Frames_CreateWAD(@PunchFrames[True, 2], 'FRAMES_PUNCH_BERSERK_DN', GameWAD + ':WEAPONS\PUNCHB_DN', 64, 64, 4, False); + end; + + procedure r_Player_Free; + begin + g_Frames_DeleteByName('FRAMES_PUNCH'); + g_Frames_DeleteByName('FRAMES_PUNCH_UP'); + g_Frames_DeleteByName('FRAMES_PUNCH_DN'); + g_Frames_DeleteByName('FRAMES_PUNCH_BERSERK'); + g_Frames_DeleteByName('FRAMES_PUNCH_BERSERK_UP'); + g_Frames_DeleteByName('FRAMES_PUNCH_BERSERK_DN'); + end; + procedure r_Player_DrawAll; var i: Integer; begin @@ -305,14 +331,12 @@ begin else Mirror := TMirrorType.Horizontal; - if p.PunchAnim <> nil then + if p.PunchAnim.enabled then begin - r_Animation_Draw(p.PunchAnim, fX + IfThen(p.Direction = TDirection.D_LEFT, 15 - p.Obj.Rect.X, p.Obj.Rect.X - 15), fY + fSlope + p.Obj.Rect.Y - 11, Mirror); - if p.PunchAnim.played then - begin - p.PunchAnim.Free; - p.PunchAnim := nil; - end; + if p.FKeys[KEY_DOWN].Pressed then ID := PunchFrames[R_BERSERK in p.FRulez, 2] + else if p.FKeys[KEY_UP].Pressed then ID := PunchFrames[R_BERSERK in p.FRulez, 1] + else ID := PunchFrames[R_BERSERK in p.FRulez, 0]; + r_AnimationState_Draw(ID, p.PunchAnim, fX + IfThen(p.Direction = TDirection.D_LEFT, 15 - p.Obj.Rect.X, p.Obj.Rect.X - 15), fY + fSlope + p.Obj.Rect.Y - 11, Mirror); end; if (p.FMegaRulez[MR_INVUL] > gTime) and ((gPlayerDrawn <> p) or (p.SpawnInvul >= gTime)) then diff --git a/src/game/opengl/r_render.pas b/src/game/opengl/r_render.pas index 50e5892..b6bb016 100644 --- a/src/game/opengl/r_render.pas +++ b/src/game/opengl/r_render.pas @@ -37,7 +37,7 @@ implementation e_log, g_system, g_game, g_options, g_console, r_window, r_graphics, r_console, r_playermodel, - r_weapons, r_items, r_gfx, r_monsters, r_map + r_weapons, r_items, r_gfx, r_monsters, r_map, r_player ; var @@ -78,6 +78,7 @@ implementation procedure r_Render_Load; begin + r_Player_Load; r_Map_Load; r_PlayerModel_Load; r_Monsters_Load; @@ -94,6 +95,7 @@ implementation r_Monsters_Free; r_PlayerModel_Free; r_Map_Free; + r_Player_Free; end; procedure r_Render_Initialize;