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}
22 R_GFX_FLAME_WIDTH = 32;
23 R_GFX_FLAME_HEIGHT = 32;
24 R_GFX_SMOKE_WIDTH = 32;
25 R_GFX_SMOKE_HEIGHT = 32;
31 procedure r_GFX_Update
;
33 procedure r_GFX_OnceAnim (AnimType
, X
, Y
: Integer);
38 {$INCLUDE ../nogl/noGLuses.inc}
39 SysUtils
, Classes
, Math
,
41 g_base
, r_graphics
, g_options
, r_animations
,
51 Animation
: TAnimationState
;
55 OnceAnims
: array of TOnceAnim
= nil;
56 gfxFrames
: array [0..R_GFX_LAST
] of DWORD
;
60 g_Frames_CreateWAD(nil, 'FRAMES_TELEPORT', GameWAD
+':TEXTURES\TELEPORT', 64, 64, 10, False);
61 g_Frames_Get(gfxFrames
[R_GFX_TELEPORT
], 'FRAMES_TELEPORT');
62 g_Frames_Get(gfxFrames
[R_GFX_FLAME
], 'FRAMES_FLAME');
63 g_Frames_Get(gfxFrames
[R_GFX_EXPLODE_ROCKET
], 'FRAMES_EXPLODE_ROCKET');
64 g_Frames_Get(gfxFrames
[R_GFX_EXPLODE_BFG
], 'FRAMES_EXPLODE_BFG');
65 g_Frames_Get(gfxFrames
[R_GFX_BFG_HIT
], 'FRAMES_BFGHIT');
66 g_Frames_Get(gfxFrames
[R_GFX_FIRE
], 'FRAMES_FIRE');
67 g_Frames_Get(gfxFrames
[R_GFX_ITEM_RESPAWN
], 'FRAMES_ITEM_RESPAWN');
68 g_Frames_Get(gfxFrames
[R_GFX_SMOKE
], 'FRAMES_SMOKE');
69 g_Frames_Get(gfxFrames
[R_GFX_EXPLODE_SKELFIRE
], 'FRAMES_EXPLODE_SKELFIRE');
70 g_Frames_Get(gfxFrames
[R_GFX_EXPLODE_PLASMA
], 'FRAMES_EXPLODE_PLASMA');
71 g_Frames_Get(gfxFrames
[R_GFX_EXPLODE_BSPFIRE
], 'FRAMES_EXPLODE_BSPFIRE');
72 g_Frames_Get(gfxFrames
[R_GFX_EXPLODE_IMPFIRE
], 'FRAMES_EXPLODE_IMPFIRE');
73 g_Frames_Get(gfxFrames
[R_GFX_EXPLODE_CACOFIRE
], 'FRAMES_EXPLODE_CACOFIRE');
74 g_Frames_Get(gfxFrames
[R_GFX_EXPLODE_BARONFIRE
], 'FRAMES_EXPLODE_BARONFIRE');
80 g_Frames_DeleteByName('FRAMES_TELEPORT');
81 if OnceAnims
<> nil then
83 for a
:= 0 to High(OnceAnims
) do
84 OnceAnims
[a
].Animation
.Free();
89 function FindOnceAnim (): DWORD
;
92 if OnceAnims
<> nil then
93 for i
:= 0 to High(OnceAnims
) do
94 if OnceAnims
[i
].Animation
= nil then
99 if OnceAnims
= nil then
101 SetLength(OnceAnims
, 16);
106 Result
:= High(OnceAnims
) + 1;
107 SetLength(OnceAnims
, Length(OnceAnims
) + 16);
111 procedure r_GFX_OnceAnim (AnimType
, x
, y
: Integer);
112 var find_id
: DWORD
; a
: TAnimationState
;
114 if not gpart_dbg_enabled
then exit
;
115 find_id
:= FindOnceAnim();
117 R_GFX_NONE
: a
:= nil;
118 R_GFX_TELEPORT
: a
:= TAnimationState
.Create(false, 6, 10); // !!! speed can be 3
121 AnimType
:= R_GFX_TELEPORT
;
122 a
:= TAnimationState
.Create(false, 3, 10);
124 R_GFX_FLAME
: a
:= TAnimationState
.Create(false, 3, 11);
127 AnimType
:= R_GFX_FLAME
;
128 a
:= TAnimationState
.Create(false, 2 + Random(2), 10);
130 R_GFX_EXPLODE_ROCKET
: a
:= TAnimationState
.Create(false, 6, 6);
131 R_GFX_EXPLODE_BFG
: a
:= TAnimationState
.Create(false, 6, 6);
132 R_GFX_BFG_HIT
: a
:= TAnimationState
.Create(false, 4, 4);
133 R_GFX_FIRE
: a
:= TAnimationState
.Create(false, 4, 8); // !!! speed can be random
134 R_GFX_ITEM_RESPAWN
: a
:= TAnimationState
.Create(false, 4, 5);
135 R_GFX_SMOKE
: a
:= TAnimationState
.Create(false, 3, 10);
138 AnimType
:= R_GFX_SMOKE
;
139 a
:= TAnimationState
.Create(false, 3, 10);
142 R_GFX_EXPLODE_SKELFIRE
: a
:= TAnimationState
.Create(false, 8, 3);
143 R_GFX_EXPLODE_PLASMA
: a
:= TAnimationState
.Create(false, 3, 4);
144 R_GFX_EXPLODE_BSPFIRE
: a
:= TAnimationState
.Create(false, 3, 5);
145 R_GFX_EXPLODE_IMPFIRE
: a
:= TAnimationState
.Create(false, 6, 3);
146 R_GFX_EXPLODE_CACOFIRE
: a
:= TAnimationState
.Create(false, 6, 3);
147 R_GFX_EXPLODE_BARONFIRE
: a
:= TAnimationState
.Create(false, 6, 3);
152 OnceAnims
[find_id
].AnimType
:= AnimType
;
153 OnceAnims
[find_id
].Animation
:= a
;
154 // OnceAnims[find_id].Animation.Blending := Anim.Blending;
155 // OnceAnims[find_id].Animation.alpha := Anim.alpha;
156 OnceAnims
[find_id
].x
:= x
;
157 OnceAnims
[find_id
].y
:= y
;
160 procedure r_GFX_Update
;
163 if OnceAnims
<> nil then
165 for a
:= 0 to High(OnceAnims
) do
167 if OnceAnims
[a
].Animation
<> nil then
169 OnceAnims
[a
].oldx
:= OnceAnims
[a
].x
;
170 OnceAnims
[a
].oldy
:= OnceAnims
[a
].y
;
171 case OnceAnims
[a
].AnimType
of
172 R_GFX_FLAME
, R_GFX_SMOKE
: (*ONCEANIM_SMOKE:*)
174 if Random(3) = 0 then
175 OnceAnims
[a
].x
:= OnceAnims
[a
].x
-1+Random(3);
176 if Random(2) = 0 then
177 OnceAnims
[a
].y
:= OnceAnims
[a
].y
-Random(2);
180 if OnceAnims
[a
].Animation
.Played
then
182 OnceAnims
[a
].Animation
.Free();
183 OnceAnims
[a
].Animation
:= nil;
186 OnceAnims
[a
].Animation
.Update();
192 procedure r_GFX_Draw
;
194 a
, len
, fx
, fy
: Integer;
196 if not gpart_dbg_enabled
then exit
;
198 if (Particles
<> nil) then
200 glDisable(GL_TEXTURE_2D
);
201 if (g_dbg_scale
< 0.6) then glPointSize(1)
202 else if (g_dbg_scale
> 1.3) then glPointSize(g_dbg_scale
+1)
204 glDisable(GL_POINT_SMOOTH
);
207 glBlendFunc(GL_SRC_ALPHA
, GL_ONE_MINUS_SRC_ALPHA
);
211 len
:= High(Particles
);
216 if not alive
then continue
;
217 if (x
>= sX
) and (y
>= sY
) and (x
<= sX
+sWidth
) and (sY
<= sY
+sHeight
) then
219 fx
:= nlerp(oldx
, x
, gLerpFactor
);
220 fy
:= nlerp(oldy
, y
, gLerpFactor
);
221 glColor4ub(red
, green
, blue
, alpha
);
222 glVertex2f(fx
+0.37, fy
+0.37);
232 if (OnceAnims
<> nil) then
234 len
:= High(OnceAnims
);
237 if (OnceAnims
[a
].Animation
<> nil) then
241 fx
:= nlerp(oldx
, x
, gLerpFactor
);
242 fy
:= nlerp(oldy
, y
, gLerpFactor
);
243 r_AnimationState_Draw(gfxFrames
[AnimType
], Animation
, x
, y
, TMirrorType
.None
);