DEADSOFTWARE

fb5e612f1c63e144ce5d9ed0f2ca33edca16ff51
[d2df-sdl.git] / src / game / opengl / r_weapons.pas
1 (* Copyright (C) Doom 2D: Forever Developers
2 *
3 * This program is free software: you can redistribute it and/or modify
4 * it under the terms of the GNU General Public License as published by
5 * the Free Software Foundation, version 3 of the License ONLY.
6 *
7 * This program is distributed in the hope that it will be useful,
8 * but WITHOUT ANY WARRANTY; without even the implied warranty of
9 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
10 * GNU General Public License for more details.
11 *
12 * You should have received a copy of the GNU General Public License
13 * along with this program. If not, see <http://www.gnu.org/licenses/>.
14 *)
15 {$INCLUDE ../../shared/a_modes.inc}
16 unit r_weapons;
18 interface
20 procedure r_Weapon_Load;
21 procedure r_Weapon_Free;
22 procedure r_Weapon_Draw;
24 implementation
26 uses
27 SysUtils, Classes, Math,
28 MAPDEF,
29 r_graphics, r_animations, r_textures,
30 g_base, g_basic, g_game, g_options,
31 g_weapons
32 ;
34 var
35 ShotTexture, ShotFrames: array [WEAPON_KASTET..WEAPON_SKEL_FIRE] of DWORD;
37 procedure r_Weapon_Load;
38 begin
39 g_Texture_CreateWADEx('TEXTURE_WEAPON_ROCKET', GameWAD+':TEXTURES\BROCKET');
40 g_Frames_CreateWAD(nil, 'FRAMES_WEAPON_SKELFIRE', GameWAD+':TEXTURES\BSKELFIRE', 64, 16, 2);
41 g_Frames_CreateWAD(nil, 'FRAMES_WEAPON_BFG', GameWAD+':TEXTURES\BBFG', 64, 64, 2);
42 g_Frames_CreateWAD(nil, 'FRAMES_WEAPON_PLASMA', GameWAD+':TEXTURES\BPLASMA', 16, 16, 2);
43 g_Frames_CreateWAD(nil, 'FRAMES_WEAPON_IMPFIRE', GameWAD+':TEXTURES\BIMPFIRE', 16, 16, 2);
44 g_Frames_CreateWAD(nil, 'FRAMES_WEAPON_BSPFIRE', GameWAD+':TEXTURES\BBSPFIRE', 16, 16, 2);
45 g_Frames_CreateWAD(nil, 'FRAMES_WEAPON_CACOFIRE', GameWAD+':TEXTURES\BCACOFIRE', 16, 16, 2);
46 g_Frames_CreateWAD(nil, 'FRAMES_WEAPON_BARONFIRE', GameWAD+':TEXTURES\BBARONFIRE', 64, 16, 2);
47 g_Frames_CreateWAD(nil, 'FRAMES_WEAPON_MANCUBFIRE', GameWAD+':TEXTURES\BMANCUBFIRE', 64, 32, 2);
48 g_Frames_CreateWAD(nil, 'FRAMES_EXPLODE_ROCKET', GameWAD+':TEXTURES\EROCKET', 128, 128, 6);
49 g_Frames_CreateWAD(nil, 'FRAMES_EXPLODE_SKELFIRE', GameWAD+':TEXTURES\ESKELFIRE', 64, 64, 3);
50 g_Frames_CreateWAD(nil, 'FRAMES_EXPLODE_BFG', GameWAD+':TEXTURES\EBFG', 128, 128, 6);
51 g_Frames_CreateWAD(nil, 'FRAMES_EXPLODE_IMPFIRE', GameWAD+':TEXTURES\EIMPFIRE', 64, 64, 3);
52 g_Frames_CreateWAD(nil, 'FRAMES_BFGHIT', GameWAD+':TEXTURES\BFGHIT', 64, 64, 4);
53 g_Frames_CreateWAD(nil, 'FRAMES_FIRE', GameWAD+':TEXTURES\FIRE', 64, 128, 8);
54 g_Frames_CreateWAD(nil, 'FRAMES_FLAME', GameWAD+':TEXTURES\FLAME', 32, 32, 11);
55 g_Frames_CreateWAD(nil, 'FRAMES_EXPLODE_PLASMA', GameWAD+':TEXTURES\EPLASMA', 32, 32, 4, True);
56 g_Frames_CreateWAD(nil, 'FRAMES_EXPLODE_BSPFIRE', GameWAD+':TEXTURES\EBSPFIRE', 32, 32, 5);
57 g_Frames_CreateWAD(nil, 'FRAMES_EXPLODE_CACOFIRE', GameWAD+':TEXTURES\ECACOFIRE', 64, 64, 3);
58 g_Frames_CreateWAD(nil, 'FRAMES_EXPLODE_BARONFIRE', GameWAD+':TEXTURES\EBARONFIRE', 64, 64, 3);
59 g_Frames_CreateWAD(nil, 'FRAMES_SMOKE', GameWAD+':TEXTURES\SMOKE', 32, 32, 10, False);
61 g_Texture_CreateWADEx('TEXTURE_SHELL_BULLET', GameWAD+':TEXTURES\EBULLET');
62 g_Texture_CreateWADEx('TEXTURE_SHELL_SHELL', GameWAD+':TEXTURES\ESHELL');
64 (* WEAPON_ROCKETLAUNCHER *)
65 g_Texture_Get('TEXTURE_WEAPON_ROCKET', ShotTexture[WEAPON_ROCKETLAUNCHER]);
67 (* WEAPON_PLASMA *)
68 g_Frames_Get(ShotFrames[WEAPON_PLASMA], 'FRAMES_WEAPON_PLASMA');
69 // Animation := TAnimation.Create(FramesID, True, 5);
71 (* WEAPON_BFG *)
72 g_Frames_Get(ShotFrames[WEAPON_BFG], 'FRAMES_WEAPON_BFG');
73 // Animation := TAnimation.Create(FramesID, True, 6);
75 (* WEAPON_FLAMETHROWER *)
76 //g_Frames_Get(ShotTexture[WEAPON_FLAMETHROWER], 'FRAMES_FLAME');
77 //g_Frames_Get(ShotFrames[WEAPON_FLAMETHROWER], 'FRAMES_FLAME');
79 (* WEAPON_IMP_FIRE *)
80 g_Frames_Get(ShotFrames[WEAPON_IMP_FIRE], 'FRAMES_WEAPON_IMPFIRE');
81 // Animation := TAnimation.Create(FramesID, True, 4);
83 (* WEAPON_CACO_FIRE *)
84 g_Frames_Get(ShotFrames[WEAPON_CACO_FIRE], 'FRAMES_WEAPON_CACOFIRE');
85 // Animation := TAnimation.Create(FramesID, True, 4);
87 (* WEAPON_MANCUB_FIRE *)
88 g_Frames_Get(ShotFrames[WEAPON_MANCUB_FIRE], 'FRAMES_WEAPON_MANCUBFIRE');
89 // Animation := TAnimation.Create(FramesID, True, 4);
91 (* WEAPON_BARON_FIRE *)
92 g_Frames_Get(ShotFrames[WEAPON_BARON_FIRE], 'FRAMES_WEAPON_BARONFIRE');
93 // Animation := TAnimation.Create(FramesID, True, 4);
95 (* WEAPON_BSP_FIRE *)
96 g_Frames_Get(ShotFrames[WEAPON_BSP_FIRE], 'FRAMES_WEAPON_BSPFIRE');
97 // Animation := TAnimation.Create(FramesID, True, 4);
99 (* WEAPON_SKEL_FIRE *)
100 g_Frames_Get(ShotFrames[WEAPON_SKEL_FIRE], 'FRAMES_WEAPON_SKELFIRE');
101 // Animation := TAnimation.Create(FramesID, True, 5);
102 end;
104 procedure r_Weapon_Free;
105 begin
106 g_Texture_Delete('TEXTURE_WEAPON_ROCKET');
107 g_Frames_DeleteByName('FRAMES_WEAPON_BFG');
108 g_Frames_DeleteByName('FRAMES_WEAPON_PLASMA');
109 g_Frames_DeleteByName('FRAMES_WEAPON_IMPFIRE');
110 g_Frames_DeleteByName('FRAMES_WEAPON_BSPFIRE');
111 g_Frames_DeleteByName('FRAMES_WEAPON_CACOFIRE');
112 g_Frames_DeleteByName('FRAMES_WEAPON_MANCUBFIRE');
113 g_Frames_DeleteByName('FRAMES_EXPLODE_ROCKET');
114 g_Frames_DeleteByName('FRAMES_EXPLODE_BFG');
115 g_Frames_DeleteByName('FRAMES_EXPLODE_IMPFIRE');
116 g_Frames_DeleteByName('FRAMES_BFGHIT');
117 g_Frames_DeleteByName('FRAMES_FIRE');
118 g_Frames_DeleteByName('FRAMES_EXPLODE_PLASMA');
119 g_Frames_DeleteByName('FRAMES_EXPLODE_BSPFIRE');
120 g_Frames_DeleteByName('FRAMES_EXPLODE_CACOFIRE');
121 g_Frames_DeleteByName('FRAMES_SMOKE');
122 g_Frames_DeleteByName('FRAMES_WEAPON_BARONFIRE');
123 g_Frames_DeleteByName('FRAMES_EXPLODE_BARONFIRE');
124 end;
126 procedure r_Weapon_Draw;
127 var i, fX, fY, xx, yy: Integer; a: SmallInt; p: TDFPoint;
128 begin
129 if Shots = nil then
130 Exit;
132 for i := 0 to High(Shots) do
133 begin
134 if Shots[i].ShotType <> 0 then
135 begin
136 with Shots[i] do
137 begin
138 if Shots[i].ShotType in [WEAPON_ROCKETLAUNCHER, WEAPON_BARON_FIRE, WEAPON_MANCUB_FIRE, WEAPON_SKEL_FIRE] then
139 a := -GetAngle2(Obj.Vel.X, Obj.Vel.Y)
140 else
141 a := 0;
143 Obj.lerp(gLerpFactor, fX, fY);
144 p.X := Obj.Rect.Width div 2;
145 p.Y := Obj.Rect.Height div 2;
147 if Animation <> nil then
148 begin
149 if Shots[i].ShotType in [WEAPON_BARON_FIRE, WEAPON_MANCUB_FIRE, WEAPON_SKEL_FIRE] then
150 r_AnimationState_DrawEx(ShotFrames[Shots[i].ShotType], Animation, fX, fY, 0, TMirrorType.None, False, p, a)
151 else
152 r_AnimationState_Draw(ShotFrames[Shots[i].ShotType], Animation, fX, fY, 0, TMirrorType.None, False);
153 end
154 else if ShotTexture[Shots[i].ShotType] <> 0 then
155 begin
156 if (Shots[i].ShotType = WEAPON_ROCKETLAUNCHER) then
157 e_DrawAdv(ShotTexture[Shots[i].ShotType], fX, fY, 0, True, False, a, @p, TMirrorType.None)
158 else if (Shots[i].ShotType <> WEAPON_FLAMETHROWER) then
159 e_Draw(ShotTexture[Shots[i].ShotType], fX, fY, 0, True, False);
160 end;
162 if g_debug_Frames then
163 begin
164 xx := Obj.X + Obj.Rect.X;
165 yy := Obj.Y + Obj.Rect.Y;
166 e_DrawQuad(xx, yy, xx + Obj.Rect.Width - 1, yy + Obj.Rect.Height - 1, 0, 255, 0);
167 end
168 end
169 end
170 end
171 end;
173 end.