From ae9f71c24837ae555baef3eaf8ebe06152cfe9e0 Mon Sep 17 00:00:00 2001 From: DeaDDooMER Date: Mon, 17 Jan 2022 19:35:32 +0300 Subject: [PATCH] render: load shell textures in render --- src/game/g_player.pas | 15 +--------- src/game/g_weapons.pas | 3 -- src/game/opengl/r_player.pas | 56 +++++++++++++++++++++++------------- 3 files changed, 37 insertions(+), 37 deletions(-) diff --git a/src/game/g_player.pas b/src/game/g_player.pas index 7f65163..8aa0a7d 100644 --- a/src/game/g_player.pas +++ b/src/game/g_player.pas @@ -539,12 +539,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; @@ -1538,33 +1536,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 a5114e1..fc53928 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 93f1b23..650aa22 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 -- 2.29.2