DEADSOFTWARE

render: separate item logic and drawing
[d2df-sdl.git] / src / game / opengl / r_items.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_items;
18 interface
20 procedure r_Items_Draw;
21 procedure r_Items_DrawDrop;
23 implementation
25 uses
26 SysUtils, Classes, Math,
27 e_graphics,
28 MAPDEF,
29 g_basic, g_game,
30 g_items
31 ;
33 procedure itemsDrawInternal (dropflag: Boolean);
34 var
35 i, fX, fY: Integer;
36 it: PItem;
37 begin
38 if (ggItems = nil) then exit;
40 for i := 0 to High(ggItems) do
41 begin
42 it := @ggItems[i];
43 if (not it.used) or (it.ItemType = ITEM_NONE) then continue; // just in case
44 if not it.alive then continue;
45 if (it.dropped <> dropflag) then continue;
47 with it^ do
48 begin
49 if g_Collide(Obj.X, Obj.Y, Obj.Rect.Width, Obj.Rect.Height, sX, sY, sWidth, sHeight) then
50 begin
51 Obj.lerp(gLerpFactor, fX, fY);
52 if (Animation = nil) then
53 begin
54 e_Draw(gItemsTexturesID[ItemType], fX, fY, 0, true, false);
55 end
56 else
57 begin
58 Animation.Draw(fX, fY, TMirrorType.None);
59 end;
61 if g_debug_Frames then
62 begin
63 e_DrawQuad(Obj.X+Obj.Rect.X,
64 Obj.Y+Obj.Rect.Y,
65 Obj.X+Obj.Rect.X+Obj.Rect.Width-1,
66 Obj.Y+Obj.Rect.Y+Obj.Rect.Height-1,
67 0, 255, 0);
68 end;
69 end;
70 end;
71 end;
72 end;
74 procedure r_Items_Draw;
75 begin
76 itemsDrawInternal(false);
77 end;
79 procedure r_Items_DrawDrop;
80 begin
81 itemsDrawInternal(true);
82 end;
84 end.