1 (* Copyright (C) Doom 2D: Forever Developers
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.
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.
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/>.
15 {$INCLUDE ../../shared/a_modes.inc}
24 R_GFX_EXPLODE_ROCKET
= 3;
25 R_GFX_EXPLODE_BFG
= 4;
28 R_GFX_ITEM_RESPAWN
= 7;
30 R_GFX_EXPLODE_SKELFIRE
= 9;
31 R_GFX_EXPLODE_PLASMA
= 10;
32 R_GFX_EXPLODE_BSPFIRE
= 11;
33 R_GFX_EXPLODE_IMPFIRE
= 12;
34 R_GFX_EXPLODE_CACOFIRE
= 13;
35 R_GFX_EXPLODE_BARONFIRE
= 14;
36 R_GFX_TELEPORT_FAST
= 15;
37 R_GFX_SMOKE_TRANS
= 16;
38 R_GFX_FLAME_RAND
= 17;
41 R_GFX_FLAME_WIDTH
= 32;
42 R_GFX_FLAME_HEIGHT
= 32;
43 R_GFX_SMOKE_WIDTH
= 32;
44 R_GFX_SMOKE_HEIGHT
= 32;
49 procedure r_GFX_Update
;
51 procedure r_GFX_OnceAnim (AnimType
, X
, Y
: Integer);
56 {$INCLUDE ../nogl/noGLuses.inc}
57 SysUtils
, Classes
, Math
,
59 g_base
, r_graphics
, g_options
, r_animations
,
69 Animation
: TAnimationState
;
73 OnceAnims
: array of TOnceAnim
= nil;
74 gfxFrames
: array [0..R_GFX_LAST
] of DWORD
;
78 g_Frames_CreateWAD(nil, 'FRAMES_TELEPORT', GameWAD
+':TEXTURES\TELEPORT', 64, 64, 10, False);
79 g_Frames_Get(gfxFrames
[R_GFX_TELEPORT
], 'FRAMES_TELEPORT');
80 g_Frames_Get(gfxFrames
[R_GFX_FLAME
], 'FRAMES_FLAME');
81 g_Frames_Get(gfxFrames
[R_GFX_EXPLODE_ROCKET
], 'FRAMES_EXPLODE_ROCKET');
82 g_Frames_Get(gfxFrames
[R_GFX_EXPLODE_BFG
], 'FRAMES_EXPLODE_BFG');
83 g_Frames_Get(gfxFrames
[R_GFX_BFG_HIT
], 'FRAMES_BFGHIT');
84 g_Frames_Get(gfxFrames
[R_GFX_FIRE
], 'FRAMES_FIRE');
85 g_Frames_Get(gfxFrames
[R_GFX_ITEM_RESPAWN
], 'FRAMES_ITEM_RESPAWN');
86 g_Frames_Get(gfxFrames
[R_GFX_SMOKE
], 'FRAMES_SMOKE');
87 g_Frames_Get(gfxFrames
[R_GFX_EXPLODE_SKELFIRE
], 'FRAMES_EXPLODE_SKELFIRE');
88 g_Frames_Get(gfxFrames
[R_GFX_EXPLODE_PLASMA
], 'FRAMES_EXPLODE_PLASMA');
89 g_Frames_Get(gfxFrames
[R_GFX_EXPLODE_BSPFIRE
], 'FRAMES_EXPLODE_BSPFIRE');
90 g_Frames_Get(gfxFrames
[R_GFX_EXPLODE_IMPFIRE
], 'FRAMES_EXPLODE_IMPFIRE');
91 g_Frames_Get(gfxFrames
[R_GFX_EXPLODE_CACOFIRE
], 'FRAMES_EXPLODE_CACOFIRE');
92 g_Frames_Get(gfxFrames
[R_GFX_EXPLODE_BARONFIRE
], 'FRAMES_EXPLODE_BARONFIRE');
98 g_Frames_DeleteByName('FRAMES_TELEPORT');
99 if OnceAnims
<> nil then
101 for a
:= 0 to High(OnceAnims
) do
102 OnceAnims
[a
].Animation
.Free();
107 function FindOnceAnim (): DWORD
;
110 if OnceAnims
<> nil then
111 for i
:= 0 to High(OnceAnims
) do
112 if OnceAnims
[i
].Animation
= nil then
117 if OnceAnims
= nil then
119 SetLength(OnceAnims
, 16);
124 Result
:= High(OnceAnims
) + 1;
125 SetLength(OnceAnims
, Length(OnceAnims
) + 16);
129 procedure r_GFX_OnceAnim (AnimType
, x
, y
: Integer);
130 var find_id
: DWORD
; a
: TAnimationState
;
132 if not gpart_dbg_enabled
then exit
;
133 find_id
:= FindOnceAnim();
135 R_GFX_NONE
: a
:= nil;
136 R_GFX_TELEPORT
: a
:= TAnimationState
.Create(false, 6, 10); // !!! speed can be 3
139 AnimType
:= R_GFX_TELEPORT
;
140 a
:= TAnimationState
.Create(false, 3, 10);
142 R_GFX_FLAME
: a
:= TAnimationState
.Create(false, 3, 11);
145 AnimType
:= R_GFX_FLAME
;
146 a
:= TAnimationState
.Create(false, 2 + Random(2), 10);
148 R_GFX_EXPLODE_ROCKET
: a
:= TAnimationState
.Create(false, 6, 6);
149 R_GFX_EXPLODE_BFG
: a
:= TAnimationState
.Create(false, 6, 6);
150 R_GFX_BFG_HIT
: a
:= TAnimationState
.Create(false, 4, 4);
151 R_GFX_FIRE
: a
:= TAnimationState
.Create(false, 4, 8); // !!! speed can be random
152 R_GFX_ITEM_RESPAWN
: a
:= TAnimationState
.Create(false, 4, 5);
153 R_GFX_SMOKE
: a
:= TAnimationState
.Create(false, 3, 10);
156 AnimType
:= R_GFX_SMOKE
;
157 a
:= TAnimationState
.Create(false, 3, 10);
160 R_GFX_EXPLODE_SKELFIRE
: a
:= TAnimationState
.Create(false, 8, 3);
161 R_GFX_EXPLODE_PLASMA
: a
:= TAnimationState
.Create(false, 3, 4);
162 R_GFX_EXPLODE_BSPFIRE
: a
:= TAnimationState
.Create(false, 3, 5);
163 R_GFX_EXPLODE_IMPFIRE
: a
:= TAnimationState
.Create(false, 6, 3);
164 R_GFX_EXPLODE_CACOFIRE
: a
:= TAnimationState
.Create(false, 6, 3);
165 R_GFX_EXPLODE_BARONFIRE
: a
:= TAnimationState
.Create(false, 6, 3);
170 OnceAnims
[find_id
].AnimType
:= AnimType
;
171 OnceAnims
[find_id
].Animation
:= a
;
172 // OnceAnims[find_id].Animation.Blending := Anim.Blending;
173 // OnceAnims[find_id].Animation.alpha := Anim.alpha;
174 OnceAnims
[find_id
].x
:= x
;
175 OnceAnims
[find_id
].y
:= y
;
178 procedure r_GFX_Update
;
181 if OnceAnims
<> nil then
183 for a
:= 0 to High(OnceAnims
) do
185 if OnceAnims
[a
].Animation
<> nil then
187 OnceAnims
[a
].oldx
:= OnceAnims
[a
].x
;
188 OnceAnims
[a
].oldy
:= OnceAnims
[a
].y
;
189 case OnceAnims
[a
].AnimType
of
190 R_GFX_FLAME
, R_GFX_SMOKE
: (*ONCEANIM_SMOKE:*)
192 if Random(3) = 0 then
193 OnceAnims
[a
].x
:= OnceAnims
[a
].x
-1+Random(3);
194 if Random(2) = 0 then
195 OnceAnims
[a
].y
:= OnceAnims
[a
].y
-Random(2);
198 if OnceAnims
[a
].Animation
.Played
then
200 OnceAnims
[a
].Animation
.Free();
201 OnceAnims
[a
].Animation
:= nil;
204 OnceAnims
[a
].Animation
.Update();
210 procedure r_GFX_Draw
;
212 a
, len
, fx
, fy
: Integer;
214 if not gpart_dbg_enabled
then exit
;
216 if (Particles
<> nil) then
218 glDisable(GL_TEXTURE_2D
);
219 if (g_dbg_scale
< 0.6) then glPointSize(1)
220 else if (g_dbg_scale
> 1.3) then glPointSize(g_dbg_scale
+1)
222 glDisable(GL_POINT_SMOOTH
);
225 glBlendFunc(GL_SRC_ALPHA
, GL_ONE_MINUS_SRC_ALPHA
);
229 len
:= High(Particles
);
234 if not alive
then continue
;
235 if (x
>= sX
) and (y
>= sY
) and (x
<= sX
+sWidth
) and (sY
<= sY
+sHeight
) then
237 fx
:= nlerp(oldx
, x
, gLerpFactor
);
238 fy
:= nlerp(oldy
, y
, gLerpFactor
);
239 glColor4ub(red
, green
, blue
, alpha
);
240 glVertex2f(fx
+0.37, fy
+0.37);
250 if (OnceAnims
<> nil) then
252 len
:= High(OnceAnims
);
255 if (OnceAnims
[a
].Animation
<> nil) then
259 fx
:= nlerp(oldx
, x
, gLerpFactor
);
260 fy
:= nlerp(oldy
, y
, gLerpFactor
);
261 r_AnimationState_Draw(gfxFrames
[AnimType
], Animation
, x
, y
, TMirrorType
.None
);