From: DeaDDooMER Date: Mon, 17 Jan 2022 16:35:32 +0000 (+0300) Subject: render: load shell textures in render X-Git-Url: http://deadsoftware.ru/gitweb?a=commitdiff_plain;h=0de0c814aedf27fc6374f50b2ce57db780d37c8e;p=d2df-sdl.git render: load shell textures in render --- diff --git a/src/game/g_player.pas b/src/game/g_player.pas index e7f3fee..070ca33 100644 --- a/src/game/g_player.pas +++ b/src/game/g_player.pas @@ -520,12 +520,10 @@ type PShell = ^TShell; TShell = record - SpriteID: DWORD; - alive: Boolean; + alive: Boolean; SType: Byte; RAngle: Integer; Timeout: Cardinal; - CX, CY: Integer; Obj: TObj; procedure getMapBox (out x, y, w, h: Integer); inline; @@ -1576,33 +1574,22 @@ begin end; procedure g_Player_CreateShell(fX, fY, dX, dY: Integer; T: Byte); -var - SID: DWORD; begin if (gShells = nil) or (Length(gShells) = 0) then Exit; with gShells[CurrentShell] do begin - SpriteID := 0; g_Obj_Init(@Obj); Obj.Rect.X := 0; Obj.Rect.Y := 0; if T = SHELL_BULLET then begin - if g_Texture_Get('TEXTURE_SHELL_BULLET', SID) then - SpriteID := SID; - CX := 2; - CY := 1; Obj.Rect.Width := 4; Obj.Rect.Height := 2; end else begin - if g_Texture_Get('TEXTURE_SHELL_SHELL', SID) then - SpriteID := SID; - CX := 4; - CY := 2; Obj.Rect.Width := 7; Obj.Rect.Height := 3; end; diff --git a/src/game/g_weapons.pas b/src/game/g_weapons.pas index 2f157ab..1ffbdf6 100644 --- a/src/game/g_weapons.pas +++ b/src/game/g_weapons.pas @@ -1137,9 +1137,6 @@ begin g_Sound_CreateWADEx('SOUND_PLAYER_SHELL1', GameWAD+':SOUNDS\SHELL1'); g_Sound_CreateWADEx('SOUND_PLAYER_SHELL2', GameWAD+':SOUNDS\SHELL2'); - g_Texture_CreateWADEx('TEXTURE_SHELL_BULLET', GameWAD+':TEXTURES\EBULLET'); - g_Texture_CreateWADEx('TEXTURE_SHELL_SHELL', GameWAD+':TEXTURES\ESHELL'); - //wgunMonHash := hashNewIntInt(); wgunHitHeap := TBinaryHeapHitTimes.Create(); end; diff --git a/src/game/opengl/r_player.pas b/src/game/opengl/r_player.pas index 1e5dec0..6d87a18 100644 --- a/src/game/opengl/r_player.pas +++ b/src/game/opengl/r_player.pas @@ -52,6 +52,8 @@ implementation var PunchFrames: array [Boolean, 0..2] of DWORD; + BulletTexture: DWORD; + ShellTexture: DWORD; procedure r_Player_Load; begin @@ -61,6 +63,10 @@ implementation 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; @@ -140,27 +146,37 @@ end; 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