X-Git-Url: http://deadsoftware.ru/gitweb?a=blobdiff_plain;f=src%2Fgame%2Fopengl%2Fr_player.pas;h=6d87a18ce5afe35df3f83b35c699966a1a9e5011;hb=0de0c814aedf27fc6374f50b2ce57db780d37c8e;hp=faff88b0a63cdd2a576af72e10f28b483e539901;hpb=3af68bc5a306b013ddb2a04c24543b6ec6e288af;p=d2df-sdl.git diff --git a/src/game/opengl/r_player.pas b/src/game/opengl/r_player.pas index faff88b..6d87a18 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; @@ -35,8 +38,6 @@ interface procedure r_Player_DrawPain (p: TPlayer); procedure r_Player_DrawPickup (p: TPlayer); - procedure r_Player_DrawCorpse (p: TCorpse); - implementation uses @@ -46,9 +47,38 @@ implementation {$IFDEF ENABLE_HOLMES} g_holmes, {$ENDIF} - r_playermodel, r_graphics, r_animations, r_textures + r_playermodel, r_graphics, r_animations, r_textures, r_items, r_game, r_map ; + var + PunchFrames: array [Boolean, 0..2] of DWORD; + BulletTexture: DWORD; + ShellTexture: 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); + g_Texture_CreateWADEx('TEXTURE_SHELL_BULLET', GameWAD + ':TEXTURES\EBULLET'); + g_Texture_CreateWADEx('TEXTURE_SHELL_SHELL', GameWAD + ':TEXTURES\ESHELL'); + g_Texture_Get('TEXTURE_SHELL_BULLET', BulletTexture); + g_Texture_Get('TEXTURE_SHELL_SHELL', ShellTexture); + 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 @@ -97,60 +127,56 @@ begin end; end; -procedure r_Player_DrawCorpses; -var - i, fX, fY: Integer; - a: TDFPoint; -begin - if gGibs <> nil then - for i := 0 to High(gGibs) do - if gGibs[i].alive then - with gGibs[i] do - begin - if not g_Obj_Collide(sX, sY, sWidth, sHeight, @Obj) then - Continue; - - Obj.lerp(gLerpFactor, fX, fY); - - a.X := Obj.Rect.X+(Obj.Rect.Width div 2); - a.y := Obj.Rect.Y+(Obj.Rect.Height div 2); - - e_DrawAdv(ID, fX, fY, 0, True, False, RAngle, @a, TMirrorType.None); - - e_Colors := Color; - e_DrawAdv(MaskID, fX, fY, 0, True, False, RAngle, @a, TMirrorType.None); - e_Colors.R := 255; - e_Colors.G := 255; - e_Colors.B := 255; - end; + procedure r_Player_DrawCorpse (p: TCorpse); + var fX, fY: Integer; + begin + if (p.State <> CORPSE_STATE_REMOVEME) and (p.Model <> nil) then + begin + p.Obj.lerp(gLerpFactor, fX, fY); + r_PlayerModel_Draw(p.Model, fX, fY) + end + end; - if gCorpses <> nil then - for i := 0 to High(gCorpses) do - if gCorpses[i] <> nil then - r_Player_DrawCorpse(gCorpses[i]) -end; + procedure r_Player_DrawCorpses; + var i: Integer; + begin + if gCorpses <> nil then + for i := 0 to High(gCorpses) do + if gCorpses[i] <> nil then + r_Player_DrawCorpse(gCorpses[i]) + end; -procedure r_Player_DrawShells; -var - i, fX, fY: Integer; - a: TDFPoint; -begin - if gShells <> nil then - for i := 0 to High(gShells) do - if gShells[i].alive then - with gShells[i] do + procedure r_Player_DrawShells; + var i, fX, fY: Integer; a: TDFPoint; TextureID: DWORD = DWORD(-1); + begin + if gShells <> nil then + begin + for i := 0 to High(gShells) do + begin + if gShells[i].alive and g_Obj_Collide(sX, sY, sWidth, sHeight, @gShells[i].Obj) then begin - if not g_Obj_Collide(sX, sY, sWidth, sHeight, @Obj) then - Continue; - - Obj.lerp(gLerpFactor, fX, fY); - - a.X := CX; - a.Y := CY; - - e_DrawAdv(SpriteID, fX, fY, 0, True, False, RAngle, @a, TMirrorType.None); - end; -end; + gShells[i].Obj.lerp(gLerpFactor, fX, fY); + case gShells[i].SType of + SHELL_BULLET: + begin + TextureID := BulletTexture; + a.X := 2; + a.Y := 1; + end; + SHELL_SHELL, SHELL_DBLSHELL: + begin + TextureID := ShellTexture; + a.X := 4; + a.Y := 2; + end + else + Assert(false) + end; + e_DrawAdv(TextureID, fX, fY, 0, True, False, gShells[i].RAngle, @a, TMirrorType.None); + end + end + end + end; procedure r_Player_DrawIndicator (p: TPlayer; Color: TRGB); var @@ -329,14 +355,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 @@ -785,26 +809,4 @@ begin e_DrawFillQuad(0, 0, gPlayerScreenSize.X-1, gPlayerScreenSize.Y-1, 150, 200, 150, 255-h*50); end; -procedure r_Player_DrawCorpse (p: TCorpse); -var - fX, fY: Integer; -begin - if p.State = CORPSE_STATE_REMOVEME then - Exit; - - p.Obj.lerp(gLerpFactor, fX, fY); - - if p.Animation <> nil then - r_Animation_Draw(p.Animation, fX, fY, TMirrorType.None); - - if p.AnimationMask <> nil then - begin - e_Colors := p.Color; - r_Animation_Draw(p.AnimationMask, fX, fY, TMirrorType.None); - e_Colors.R := 255; - e_Colors.G := 255; - e_Colors.B := 255; - end; -end; - end.