From: DeaDDooMER Date: Tue, 8 Jun 2021 02:44:59 +0000 (+0300) Subject: render: separate weapon shots logic and drawing X-Git-Url: http://deadsoftware.ru/gitweb?p=d2df-sdl.git;a=commitdiff_plain;h=17a3d3f944849de3be0b3fae36c935367648a179 render: separate weapon shots logic and drawing --- diff --git a/src/game/Doom2DF.lpr b/src/game/Doom2DF.lpr index dc00629..caa2955 100644 --- a/src/game/Doom2DF.lpr +++ b/src/game/Doom2DF.lpr @@ -160,6 +160,7 @@ uses r_map in 'opengl/r_map.pas', r_monsters in 'opengl/r_monsters.pas', r_panel in 'opengl/r_panel.pas', + r_weapons in 'opengl/r_weapons.pas', {$IFDEF USE_FMOD} fmod in '../lib/FMOD/fmod.pas', diff --git a/src/game/g_weapons.pas b/src/game/g_weapons.pas index 32fc8f6..c94282d 100644 --- a/src/game/g_weapons.pas +++ b/src/game/g_weapons.pas @@ -74,7 +74,6 @@ function g_Weapon_Explode(X, Y: Integer; rad: Integer; SpawnerUID: Word): Boolea procedure g_Weapon_BFG9000(X, Y: Integer; SpawnerUID: Word); procedure g_Weapon_PreUpdate(); procedure g_Weapon_Update(); -procedure g_Weapon_Draw(); function g_Weapon_Danger(UID: Word; X, Y: Integer; Width, Height: Word; Time: Byte): Boolean; procedure g_Weapon_DestroyShot(I: Integer; X, Y: Integer; Loud: Boolean = True); @@ -2544,59 +2543,6 @@ begin end; end; -procedure g_Weapon_Draw(); -var - i, fX, fY: Integer; - a: SmallInt; - p: TDFPoint; -begin - if Shots = nil then - Exit; - - for i := 0 to High(Shots) do - if Shots[i].ShotType <> 0 then - with Shots[i] do - begin - if (Shots[i].ShotType = WEAPON_ROCKETLAUNCHER) or - (Shots[i].ShotType = WEAPON_BARON_FIRE) or - (Shots[i].ShotType = WEAPON_MANCUB_FIRE) or - (Shots[i].ShotType = WEAPON_SKEL_FIRE) then - a := -GetAngle2(Obj.Vel.X, Obj.Vel.Y) - else - a := 0; - - Obj.lerp(gLerpFactor, fX, fY); - p.X := Obj.Rect.Width div 2; - p.Y := Obj.Rect.Height div 2; - - if Animation <> nil then - begin - if (Shots[i].ShotType = WEAPON_BARON_FIRE) or - (Shots[i].ShotType = WEAPON_MANCUB_FIRE) or - (Shots[i].ShotType = WEAPON_SKEL_FIRE) then - Animation.DrawEx(fX, fY, TMirrorType.None, p, a) - else - Animation.Draw(fX, fY, TMirrorType.None); - end - else if TextureID <> 0 then - begin - if (Shots[i].ShotType = WEAPON_ROCKETLAUNCHER) then - e_DrawAdv(TextureID, fX, fY, 0, True, False, a, @p, TMirrorType.None) - else if (Shots[i].ShotType <> WEAPON_FLAMETHROWER) then - e_Draw(TextureID, fX, fY, 0, True, False); - end; - - if g_debug_Frames then - begin - e_DrawQuad(Obj.X+Obj.Rect.X, - Obj.Y+Obj.Rect.Y, - Obj.X+Obj.Rect.X+Obj.Rect.Width-1, - Obj.Y+Obj.Rect.Y+Obj.Rect.Height-1, - 0, 255, 0); - end; - end; -end; - function g_Weapon_Danger(UID: Word; X, Y: Integer; Width, Height: Word; Time: Byte): Boolean; var a: Integer; diff --git a/src/game/opengl/r_game.pas b/src/game/opengl/r_game.pas index 090f674..c3577cc 100644 --- a/src/game/opengl/r_game.pas +++ b/src/game/opengl/r_game.pas @@ -32,7 +32,7 @@ implementation g_textures, e_input, e_sound, g_language, g_console, g_menu, g_triggers, g_player, g_options, g_monsters, g_map, g_panel, g_window, g_items, g_weapons, g_gfx, g_phys, g_net, g_gui, g_netmaster, - g_game, r_console, r_gfx, r_items, r_map, r_panel, r_monsters + g_game, r_console, r_gfx, r_items, r_map, r_panel, r_monsters, r_weapons ; var @@ -1239,7 +1239,7 @@ begin drawPanelType('*back', PANEL_BACK, g_rlayer_back); drawPanelType('*step', PANEL_STEP, g_rlayer_step); drawOther('items', @r_Items_Draw); - drawOther('weapons', @g_Weapon_Draw); + drawOther('weapons', @r_Weapon_Draw); drawOther('shells', @g_Player_DrawShells); drawOther('drawall', @g_Player_DrawAll); drawOther('corpses', @g_Player_DrawCorpses); diff --git a/src/game/opengl/r_weapons.pas b/src/game/opengl/r_weapons.pas new file mode 100644 index 0000000..3b1f085 --- /dev/null +++ b/src/game/opengl/r_weapons.pas @@ -0,0 +1,79 @@ +(* Copyright (C) Doom 2D: Forever Developers + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, version 3 of the License ONLY. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + *) +{$INCLUDE ../../shared/a_modes.inc} +unit r_weapons; + +interface + + procedure r_Weapon_Draw; + +implementation + + uses + SysUtils, Classes, Math, + MAPDEF, + e_graphics, + g_basic, g_game, + g_weapons + ; + + procedure r_Weapon_Draw; + var i, fX, fY, xx, yy: Integer; a: SmallInt; p: TDFPoint; + begin + if Shots = nil then + Exit; + + for i := 0 to High(Shots) do + begin + if Shots[i].ShotType <> 0 then + begin + with Shots[i] do + begin + if Shots[i].ShotType in [WEAPON_ROCKETLAUNCHER, WEAPON_BARON_FIRE, WEAPON_MANCUB_FIRE, WEAPON_SKEL_FIRE] then + a := -GetAngle2(Obj.Vel.X, Obj.Vel.Y) + else + a := 0; + + Obj.lerp(gLerpFactor, fX, fY); + p.X := Obj.Rect.Width div 2; + p.Y := Obj.Rect.Height div 2; + + if Animation <> nil then + begin + if Shots[i].ShotType in [WEAPON_BARON_FIRE, WEAPON_MANCUB_FIRE, WEAPON_SKEL_FIRE] then + Animation.DrawEx(fX, fY, TMirrorType.None, p, a) + else + Animation.Draw(fX, fY, TMirrorType.None); + end + else if TextureID <> 0 then + begin + if (Shots[i].ShotType = WEAPON_ROCKETLAUNCHER) then + e_DrawAdv(TextureID, fX, fY, 0, True, False, a, @p, TMirrorType.None) + else if (Shots[i].ShotType <> WEAPON_FLAMETHROWER) then + e_Draw(TextureID, fX, fY, 0, True, False); + end; + + if g_debug_Frames then + begin + xx := Obj.X + Obj.Rect.X; + yy := Obj.Y + Obj.Rect.Y; + e_DrawQuad(xx, yy, xx + Obj.Rect.Width - 1, yy + Obj.Rect.Height - 1, 0, 255, 0); + end + end + end + end + end; + +end.