afdadd97d76198e4f20e8ebfaabe35ea02262811
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
,
52 Animation
: TAnimState
;
56 OnceAnims
: array of TOnceAnim
= nil;
57 gfxFrames
: array [0..R_GFX_LAST
] of DWORD
;
61 g_Frames_CreateWAD(nil, 'FRAMES_TELEPORT', GameWAD
+':TEXTURES\TELEPORT', 64, 64, 10, False);
62 g_Frames_Get(gfxFrames
[R_GFX_TELEPORT
], 'FRAMES_TELEPORT');
63 g_Frames_Get(gfxFrames
[R_GFX_FLAME
], 'FRAMES_FLAME');
64 g_Frames_Get(gfxFrames
[R_GFX_EXPLODE_ROCKET
], 'FRAMES_EXPLODE_ROCKET');
65 g_Frames_Get(gfxFrames
[R_GFX_EXPLODE_BFG
], 'FRAMES_EXPLODE_BFG');
66 g_Frames_Get(gfxFrames
[R_GFX_BFG_HIT
], 'FRAMES_BFGHIT');
67 g_Frames_Get(gfxFrames
[R_GFX_FIRE
], 'FRAMES_FIRE');
68 g_Frames_Get(gfxFrames
[R_GFX_ITEM_RESPAWN
], 'FRAMES_ITEM_RESPAWN');
69 g_Frames_Get(gfxFrames
[R_GFX_SMOKE
], 'FRAMES_SMOKE');
70 g_Frames_Get(gfxFrames
[R_GFX_EXPLODE_SKELFIRE
], 'FRAMES_EXPLODE_SKELFIRE');
71 g_Frames_Get(gfxFrames
[R_GFX_EXPLODE_PLASMA
], 'FRAMES_EXPLODE_PLASMA');
72 g_Frames_Get(gfxFrames
[R_GFX_EXPLODE_BSPFIRE
], 'FRAMES_EXPLODE_BSPFIRE');
73 g_Frames_Get(gfxFrames
[R_GFX_EXPLODE_IMPFIRE
], 'FRAMES_EXPLODE_IMPFIRE');
74 g_Frames_Get(gfxFrames
[R_GFX_EXPLODE_CACOFIRE
], 'FRAMES_EXPLODE_CACOFIRE');
75 g_Frames_Get(gfxFrames
[R_GFX_EXPLODE_BARONFIRE
], 'FRAMES_EXPLODE_BARONFIRE');
80 g_Frames_DeleteByName('FRAMES_TELEPORT');
84 function FindOnceAnim (): DWORD
;
87 if OnceAnims
<> nil then
88 for i
:= 0 to High(OnceAnims
) do
89 if OnceAnims
[i
].Animation
.IsInvalid() then
94 if OnceAnims
= nil then
96 SetLength(OnceAnims
, 16);
101 Result
:= High(OnceAnims
) + 1;
102 SetLength(OnceAnims
, Length(OnceAnims
) + 16);
106 procedure r_GFX_OnceAnim (AnimType
, x
, y
: Integer);
107 var find_id
: DWORD
; a
: TAnimState
; alpha
: Byte;
109 if not gpart_dbg_enabled
then exit
;
110 find_id
:= FindOnceAnim();
113 R_GFX_NONE
: a
:= TAnimState
.Create(false, 0, 0);
114 R_GFX_TELEPORT
: a
:= TAnimState
.Create(false, 6, 10);
117 AnimType
:= R_GFX_TELEPORT
;
118 a
:= TAnimState
.Create(false, 3, 10);
120 R_GFX_FLAME
: a
:= TAnimState
.Create(false, 3, 11);
123 AnimType
:= R_GFX_FLAME
;
124 a
:= TAnimState
.Create(false, 2 + Random(2), 10);
126 R_GFX_EXPLODE_ROCKET
: a
:= TAnimState
.Create(false, 6, 6);
127 R_GFX_EXPLODE_BFG
: a
:= TAnimState
.Create(false, 6, 6);
128 R_GFX_BFG_HIT
: a
:= TAnimState
.Create(false, 4, 4);
129 R_GFX_FIRE
: a
:= TAnimState
.Create(false, 4, 8); // !!! TODO: random speed
130 R_GFX_ITEM_RESPAWN
: a
:= TAnimState
.Create(false, 4, 5);
131 R_GFX_SMOKE
: a
:= TAnimState
.Create(false, 3, 10);
134 AnimType
:= R_GFX_SMOKE
;
135 a
:= TAnimState
.Create(false, 3, 10);
138 R_GFX_EXPLODE_SKELFIRE
: a
:= TAnimState
.Create(false, 8, 3);
139 R_GFX_EXPLODE_PLASMA
: a
:= TAnimState
.Create(false, 3, 4);
140 R_GFX_EXPLODE_BSPFIRE
: a
:= TAnimState
.Create(false, 3, 5);
141 R_GFX_EXPLODE_IMPFIRE
: a
:= TAnimState
.Create(false, 6, 3);
142 R_GFX_EXPLODE_CACOFIRE
: a
:= TAnimState
.Create(false, 6, 3);
143 R_GFX_EXPLODE_BARONFIRE
: a
:= TAnimState
.Create(false, 6, 3);
145 a
:= TAnimState
.Create(false, 0, 0);
146 raise Exception
.Create('invalid anim type');
148 OnceAnims
[find_id
].AnimType
:= AnimType
;
149 OnceAnims
[find_id
].Alpha
:= alpha
;
150 OnceAnims
[find_id
].Animation
:= a
;
151 OnceAnims
[find_id
].Animation
.Reset();
152 OnceAnims
[find_id
].Animation
.Enable();
153 OnceAnims
[find_id
].x
:= x
;
154 OnceAnims
[find_id
].y
:= y
;
157 procedure r_GFX_Update
;
160 if OnceAnims
<> nil then
162 for a
:= 0 to High(OnceAnims
) do
164 if OnceAnims
[a
].Animation
.IsValid() then
166 OnceAnims
[a
].oldx
:= OnceAnims
[a
].x
;
167 OnceAnims
[a
].oldy
:= OnceAnims
[a
].y
;
168 case OnceAnims
[a
].AnimType
of
169 R_GFX_FLAME
, R_GFX_SMOKE
: (*ONCEANIM_SMOKE:*)
171 if Random(3) = 0 then
172 OnceAnims
[a
].x
:= OnceAnims
[a
].x
-1+Random(3);
173 if Random(2) = 0 then
174 OnceAnims
[a
].y
:= OnceAnims
[a
].y
-Random(2);
177 if OnceAnims
[a
].Animation
.Played
then
178 OnceAnims
[a
].Animation
.Invalidate()
180 OnceAnims
[a
].Animation
.Update();
186 procedure r_GFX_Draw
;
188 a
, len
, fx
, fy
: Integer;
190 if not gpart_dbg_enabled
then exit
;
192 if (Particles
<> nil) then
194 glDisable(GL_TEXTURE_2D
);
195 if (g_dbg_scale
< 0.6) then glPointSize(1)
196 else if (g_dbg_scale
> 1.3) then glPointSize(g_dbg_scale
+1)
198 glDisable(GL_POINT_SMOOTH
);
201 glBlendFunc(GL_SRC_ALPHA
, GL_ONE_MINUS_SRC_ALPHA
);
205 len
:= High(Particles
);
210 if not alive
then continue
;
211 if (x
>= sX
) and (y
>= sY
) and (x
<= sX
+sWidth
) and (sY
<= sY
+sHeight
) then
213 fx
:= nlerp(oldx
, x
, gLerpFactor
);
214 fy
:= nlerp(oldy
, y
, gLerpFactor
);
215 glColor4ub(red
, green
, blue
, alpha
);
216 glVertex2f(fx
+0.37, fy
+0.37);
226 if (OnceAnims
<> nil) then
228 len
:= High(OnceAnims
);
231 if OnceAnims
[a
].Animation
.IsValid() then
235 fx
:= nlerp(oldx
, x
, gLerpFactor
);
236 fy
:= nlerp(oldy
, y
, gLerpFactor
);
237 r_AnimState_Draw(gfxFrames
[AnimType
], Animation
, x
, y
, Alpha
, TMirrorType
.None
, False);