summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 3e9b43c)
raw | patch | inline | side by side (parent: 3e9b43c)
author | DeaDDooMER <deaddoomer@deadsoftware.ru> | |
Mon, 7 Jun 2021 17:52:39 +0000 (20:52 +0300) | ||
committer | DeaDDooMER <deaddoomer@deadsoftware.ru> | |
Fri, 9 Jun 2023 07:41:07 +0000 (10:41 +0300) |
src/game/Doom2DF.lpr | patch | blob | history | |
src/game/g_items.pas | patch | blob | history | |
src/game/opengl/r_game.pas | patch | blob | history | |
src/game/opengl/r_items.pas | [new file with mode: 0644] | patch | blob |
diff --git a/src/game/Doom2DF.lpr b/src/game/Doom2DF.lpr
index adbf20556266cf7651dc6d74d098e89e863269b3..a23adf686d22769219fadce121ba1fc98b72c234 100644 (file)
--- a/src/game/Doom2DF.lpr
+++ b/src/game/Doom2DF.lpr
r_console in 'opengl/r_console.pas',
r_game in 'opengl/r_game.pas',
r_gfx in 'opengl/r_gfx.pas',
+ r_items in 'opengl/r_items.pas',
{$IFDEF USE_FMOD}
fmod in '../lib/FMOD/fmod.pas',
diff --git a/src/game/g_items.pas b/src/game/g_items.pas
index a69ceaaf811bd9f84f5b07ec41b0e6e2fcf11537..23c10df8aadc7d3a1e45197991f8f0317a5bb1a2 100644 (file)
--- a/src/game/g_items.pas
+++ b/src/game/g_items.pas
procedure getMapBox (out x, y, w, h: Integer); inline;
procedure moveBy (dx, dy: Integer); inline;
+ property used: Boolean read slotIsUsed;
property myid: Integer read arrIdx;
end;
procedure g_Items_SetDrop (ID: DWORD);
procedure g_Items_PreUpdate();
procedure g_Items_Update();
-procedure g_Items_Draw();
-procedure g_Items_DrawDrop();
procedure g_Items_Pick(ID: DWORD);
procedure g_Items_Remove(ID: DWORD);
procedure g_Items_SaveState (st: TStream);
gItemsTexturesID: Array [1..ITEM_MAX] of DWORD;
gMaxDist: Integer = 1; // for sounds
+ var (* private state *)
+ ggItems: Array of TItem = nil;
+
implementation
uses
Math,
- g_basic, e_graphics, g_sound, g_main, g_gfx, g_map,
+ g_basic, g_sound, g_main, g_gfx, g_map,
g_game, g_triggers, g_console, g_player, g_net, g_netmsg,
e_log,
g_grid, binheap, idpool, utils, xstreams;
-
-var
- ggItems: Array of TItem = nil;
-
-
// ////////////////////////////////////////////////////////////////////////// //
var
freeIds: TIdPool = nil;
end;
end;
-
-procedure itemsDrawInternal (dropflag: Boolean);
-var
- i, fX, fY: Integer;
- it: PItem;
-begin
- if (ggItems = nil) then exit;
-
- for i := 0 to High(ggItems) do
- begin
- it := @ggItems[i];
- if (not it.slotIsUsed) or (it.ItemType = ITEM_NONE) then continue; // just in case
- if not it.alive then continue;
- if (it.dropped <> dropflag) then continue;
-
- with it^ do
- begin
- if g_Collide(Obj.X, Obj.Y, Obj.Rect.Width, Obj.Rect.Height, sX, sY, sWidth, sHeight) then
- begin
- Obj.lerp(gLerpFactor, fX, fY);
- if (Animation = nil) then
- begin
- e_Draw(gItemsTexturesID[ItemType], fX, fY, 0, true, false);
- end
- else
- begin
- Animation.Draw(fX, fY, TMirrorType.None);
- end;
-
- if g_debug_Frames then
- begin
- e_DrawQuad(Obj.X+Obj.Rect.X,
- Obj.Y+Obj.Rect.Y,
- Obj.X+Obj.Rect.X+Obj.Rect.Width-1,
- Obj.Y+Obj.Rect.Y+Obj.Rect.Height-1,
- 0, 255, 0);
- end;
- end;
- end;
- end;
-end;
-
-
-procedure g_Items_Draw ();
-begin
- itemsDrawInternal(false);
-end;
-
-procedure g_Items_DrawDrop ();
-begin
- itemsDrawInternal(true);
-end;
-
-
procedure g_Items_SetDrop (ID: DWORD);
begin
if (ID < Length(ggItems)) then
index 974731147b2cb0911748877183820fcd92be8e4f..79d4b2ece9fa7f22848eaaf06c81d1751c7d10d8 100644 (file)
g_textures, e_input, e_sound,
g_language, g_console, g_menu, g_triggers, g_player, g_options, g_monsters, g_map, g_panel, g_window,
g_items, g_weapons, g_gfx, g_phys, g_net, g_gui, g_netmaster,
- g_game, r_console, r_gfx
+ g_game, r_console, r_gfx, r_items
;
var
drawPanelType('*back', PANEL_BACK, g_rlayer_back);
drawPanelType('*step', PANEL_STEP, g_rlayer_step);
- drawOther('items', @g_Items_Draw);
+ drawOther('items', @r_Items_Draw);
drawOther('weapons', @g_Weapon_Draw);
drawOther('shells', @g_Player_DrawShells);
drawOther('drawall', @g_Player_DrawAll);
drawOther('corpses', @g_Player_DrawCorpses);
drawPanelType('*wall', PANEL_WALL, g_rlayer_wall);
drawOther('monsters', @g_Monsters_Draw);
- drawOther('itemdrop', @g_Items_DrawDrop);
+ drawOther('itemdrop', @r_Items_DrawDrop);
drawPanelType('*door', PANEL_CLOSEDOOR, g_rlayer_door);
drawOther('gfx', @r_GFX_Draw);
drawOther('flags', @g_Map_DrawFlags);
diff --git a/src/game/opengl/r_items.pas b/src/game/opengl/r_items.pas
--- /dev/null
@@ -0,0 +1,84 @@
+(* Copyright (C) Doom 2D: Forever Developers
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, version 3 of the License ONLY.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ *)
+{$INCLUDE ../shared/a_modes.inc}
+unit r_items;
+
+interface
+
+ procedure r_Items_Draw;
+ procedure r_Items_DrawDrop;
+
+implementation
+
+ uses
+ SysUtils, Classes, Math,
+ e_graphics,
+ MAPDEF,
+ g_basic, g_game,
+ g_items
+ ;
+
+procedure itemsDrawInternal (dropflag: Boolean);
+var
+ i, fX, fY: Integer;
+ it: PItem;
+begin
+ if (ggItems = nil) then exit;
+
+ for i := 0 to High(ggItems) do
+ begin
+ it := @ggItems[i];
+ if (not it.used) or (it.ItemType = ITEM_NONE) then continue; // just in case
+ if not it.alive then continue;
+ if (it.dropped <> dropflag) then continue;
+
+ with it^ do
+ begin
+ if g_Collide(Obj.X, Obj.Y, Obj.Rect.Width, Obj.Rect.Height, sX, sY, sWidth, sHeight) then
+ begin
+ Obj.lerp(gLerpFactor, fX, fY);
+ if (Animation = nil) then
+ begin
+ e_Draw(gItemsTexturesID[ItemType], fX, fY, 0, true, false);
+ end
+ else
+ begin
+ Animation.Draw(fX, fY, TMirrorType.None);
+ end;
+
+ if g_debug_Frames then
+ begin
+ e_DrawQuad(Obj.X+Obj.Rect.X,
+ Obj.Y+Obj.Rect.Y,
+ Obj.X+Obj.Rect.X+Obj.Rect.Width-1,
+ Obj.Y+Obj.Rect.Y+Obj.Rect.Height-1,
+ 0, 255, 0);
+ end;
+ end;
+ end;
+ end;
+end;
+
+procedure r_Items_Draw;
+begin
+ itemsDrawInternal(false);
+end;
+
+procedure r_Items_DrawDrop;
+begin
+ itemsDrawInternal(true);
+end;
+
+end.