summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: a6a2a42)
raw | patch | inline | side by side (parent: a6a2a42)
author | DeaDDooMER <deaddoomer@deadsoftware.ru> | |
Mon, 7 Jun 2021 17:52:39 +0000 (20:52 +0300) | ||
committer | DeaDDooMER <deaddoomer@deadsoftware.ru> | |
Tue, 29 Jun 2021 09:51:11 +0000 (12:51 +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 87b41f84c59d98061329483828812f1d08fdcdbb..bec1c219b15a4f119489624e4609290ce3b708c6 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 7331242b7672c3675c54be4b14d630736dfbbd95..02c8b5fc86dc50e62410e335f7fa0eb61aafea48 100644 (file)
--- a/src/game/g_items.pas
+++ b/src/game/g_items.pas
procedure positionChanged (); //WARNING! call this after monster position was changed, or coldet will not work right!
+ 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 d2ead67c0117c15fc2483501c54765c954dc973c..aa13e6bccfd4af398f3d86c32d779ea0a19b9d00 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.