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}
20 uses MAPDEF
; // ITEM_MAX
22 procedure r_Items_Load
;
23 procedure r_Items_Free
;
24 procedure r_Items_Draw
;
25 procedure r_Items_DrawDrop
;
26 procedure r_Items_Update
;
31 SysUtils
, Classes
, Math
,
32 r_graphics
, r_animations
, r_textures
,
33 g_base
, g_basic
, g_game
, g_options
, g_textures
,
38 items
: Array [0..ITEM_MAX
] of record
43 procedure LoadItem (i
: Integer; name
: String; w
, h
, delay
, n
: Integer; backanim
: Boolean);
45 g_Frames_CreateWAD(@items
[i
].id
, '', GameWAD
+ ':TEXTURES\' + name
, w
, h
, n
, backanim
);
46 if backanim
then n
:= n
* 2 - 2;
47 items
[i
].anim
:= TAnimState
.Create(True, delay
, n
);
50 procedure r_Items_Load
;
53 // i name w h d n backanim
54 LoadItem(ITEM_NONE
, 'NOTEXTURE', 16, 16, 0, 1, False);
55 LoadItem(ITEM_MEDKIT_SMALL
, 'MED1', 16, 16, 0, 1, False);
56 LoadItem(ITEM_MEDKIT_LARGE
, 'MED2', 32, 32, 0, 1, False);
57 LoadItem(ITEM_MEDKIT_BLACK
, 'BMED', 32, 32, 0, 1, False);
58 LoadItem(ITEM_ARMOR_GREEN
, 'ARMORGREEN', 32, 16, 20, 3, True);
59 LoadItem(ITEM_ARMOR_BLUE
, 'ARMORBLUE', 32, 16, 20, 3, True);
60 LoadItem(ITEM_SPHERE_BLUE
, 'SBLUE', 32, 32, 15, 4, True);
61 LoadItem(ITEM_SPHERE_WHITE
, 'SWHITE', 32, 32, 20, 4, True);
62 LoadItem(ITEM_SUIT
, 'SUIT', 32, 64, 0, 1, False);
63 LoadItem(ITEM_OXYGEN
, 'OXYGEN', 16, 32, 0, 1, False);
64 LoadItem(ITEM_INVUL
, 'INVUL', 32, 32, 20, 4, True);
65 LoadItem(ITEM_WEAPON_SAW
, 'SAW', 64, 32, 0, 1, False);
66 LoadItem(ITEM_WEAPON_SHOTGUN1
, 'SHOTGUN1', 64, 16, 0, 1, False);
67 LoadItem(ITEM_WEAPON_SHOTGUN2
, 'SHOTGUN2', 64, 16, 0, 1, False);
68 LoadItem(ITEM_WEAPON_CHAINGUN
, 'MGUN', 64, 16, 0, 1, False);
69 LoadItem(ITEM_WEAPON_ROCKETLAUNCHER
, 'RLAUNCHER', 64, 16, 0, 1, False);
70 LoadItem(ITEM_WEAPON_PLASMA
, 'PGUN', 64, 16, 0, 1, False);
71 LoadItem(ITEM_WEAPON_BFG
, 'BFG', 64, 64, 0, 1, False);
72 LoadItem(ITEM_WEAPON_SUPERPULEMET
, 'SPULEMET', 64, 16, 0, 1, False);
73 LoadItem(ITEM_AMMO_BULLETS
, 'CLIP', 16, 16, 0, 1, False);
74 LoadItem(ITEM_AMMO_BULLETS_BOX
, 'AMMO', 32, 16, 0, 1, False);
75 LoadItem(ITEM_AMMO_SHELLS
, 'SHELL1', 16, 8, 0, 1, False);
76 LoadItem(ITEM_AMMO_SHELLS_BOX
, 'SHELL2', 32, 16, 0, 1, False);
77 LoadItem(ITEM_AMMO_ROCKET
, 'ROCKET', 16, 32, 0, 1, False);
78 LoadItem(ITEM_AMMO_ROCKET_BOX
, 'ROCKETS', 64, 32, 0, 1, False);
79 LoadItem(ITEM_AMMO_CELL
, 'CELL', 16, 16, 0, 1, False);
80 LoadItem(ITEM_AMMO_CELL_BIG
, 'CELL2', 32, 32, 0, 1, False);
81 LoadItem(ITEM_AMMO_BACKPACK
, 'BPACK', 32, 32, 0, 1, False);
82 LoadItem(ITEM_KEY_RED
, 'KEYR', 16, 16, 0, 1, False);
83 LoadItem(ITEM_KEY_GREEN
, 'KEYG', 16, 16, 0, 1, False);
84 LoadItem(ITEM_KEY_BLUE
, 'KEYB', 16, 16, 0, 1, False);
85 LoadItem(ITEM_WEAPON_KASTET
, 'KASTET', 64, 32, 0, 1, False);
86 LoadItem(ITEM_WEAPON_PISTOL
, 'PISTOL', 64, 16, 0, 1, False);
87 LoadItem(ITEM_BOTTLE
, 'BOTTLE', 64, 32, 20, 4, True);
88 LoadItem(ITEM_HELMET
, 'HELMET', 64, 16, 20, 4, True);
89 LoadItem(ITEM_JETPACK
, 'JETPACK', 96, 32, 15, 3, True);
90 LoadItem(ITEM_INVIS
, 'INVIS', 128, 32, 20, 4, True);
91 LoadItem(ITEM_WEAPON_FLAMETHROWER
, 'FLAMETHROWER', 64, 32, 0, 1, False);
92 LoadItem(ITEM_AMMO_FUELCAN
, 'FUELCAN', 16, 32, 0, 1, False);
94 // fill with NOTEXURE forgotten item
95 for i
:= ITEM_AMMO_FUELCAN
+ 1 to ITEM_MAX
do
96 LoadItem(i
,'NOTEXTURE', 16, 16, 0, 1, False);
99 g_Frames_CreateWAD(nil, 'FRAMES_ITEM_BLUESPHERE', GameWAD
+':TEXTURES\SBLUE', 32, 32, 4, True);
100 g_Frames_CreateWAD(nil, 'FRAMES_ITEM_WHITESPHERE', GameWAD
+':TEXTURES\SWHITE', 32, 32, 4, True);
101 g_Frames_CreateWAD(nil, 'FRAMES_ITEM_ARMORGREEN', GameWAD
+':TEXTURES\ARMORGREEN', 32, 16, 3, True);
102 g_Frames_CreateWAD(nil, 'FRAMES_ITEM_ARMORBLUE', GameWAD
+':TEXTURES\ARMORBLUE', 32, 16, 3, True);
103 g_Frames_CreateWAD(nil, 'FRAMES_ITEM_JETPACK', GameWAD
+':TEXTURES\JETPACK', 32, 32, 3, True);
104 g_Frames_CreateWAD(nil, 'FRAMES_ITEM_INVUL', GameWAD
+':TEXTURES\INVUL', 32, 32, 4, True);
105 g_Frames_CreateWAD(nil, 'FRAMES_ITEM_INVIS', GameWAD
+':TEXTURES\INVIS', 32, 32, 4, True);
106 g_Frames_CreateWAD(nil, 'FRAMES_ITEM_RESPAWN', GameWAD
+':TEXTURES\ITEMRESPAWN', 32, 32, 5, True);
107 g_Frames_CreateWAD(nil, 'FRAMES_ITEM_BOTTLE', GameWAD
+':TEXTURES\BOTTLE', 16, 32, 4, True);
108 g_Frames_CreateWAD(nil, 'FRAMES_ITEM_HELMET', GameWAD
+':TEXTURES\HELMET', 16, 16, 4, True);
109 g_Frames_CreateWAD(nil, 'FRAMES_FLAG_RED', GameWAD
+':TEXTURES\FLAGRED', 64, 64, 5, False);
110 g_Frames_CreateWAD(nil, 'FRAMES_FLAG_BLUE', GameWAD
+':TEXTURES\FLAGBLUE', 64, 64, 5, False);
111 g_Frames_CreateWAD(nil, 'FRAMES_FLAG_DOM', GameWAD
+':TEXTURES\FLAGDOM', 64, 64, 5, False);
112 g_Texture_CreateWADEx('ITEM_MEDKIT_SMALL', GameWAD
+':TEXTURES\MED1');
113 g_Texture_CreateWADEx('ITEM_MEDKIT_LARGE', GameWAD
+':TEXTURES\MED2');
114 g_Texture_CreateWADEx('ITEM_WEAPON_SAW', GameWAD
+':TEXTURES\SAW');
115 g_Texture_CreateWADEx('ITEM_WEAPON_PISTOL', GameWAD
+':TEXTURES\PISTOL');
116 g_Texture_CreateWADEx('ITEM_WEAPON_KASTET', GameWAD
+':TEXTURES\KASTET');
117 g_Texture_CreateWADEx('ITEM_WEAPON_SHOTGUN1', GameWAD
+':TEXTURES\SHOTGUN1');
118 g_Texture_CreateWADEx('ITEM_WEAPON_SHOTGUN2', GameWAD
+':TEXTURES\SHOTGUN2');
119 g_Texture_CreateWADEx('ITEM_WEAPON_CHAINGUN', GameWAD
+':TEXTURES\MGUN');
120 g_Texture_CreateWADEx('ITEM_WEAPON_ROCKETLAUNCHER', GameWAD
+':TEXTURES\RLAUNCHER');
121 g_Texture_CreateWADEx('ITEM_WEAPON_PLASMA', GameWAD
+':TEXTURES\PGUN');
122 g_Texture_CreateWADEx('ITEM_WEAPON_BFG', GameWAD
+':TEXTURES\BFG');
123 g_Texture_CreateWADEx('ITEM_WEAPON_SUPERPULEMET', GameWAD
+':TEXTURES\SPULEMET');
124 g_Texture_CreateWADEx('ITEM_WEAPON_FLAMETHROWER', GameWAD
+':TEXTURES\FLAMETHROWER');
125 g_Texture_CreateWADEx('ITEM_AMMO_BULLETS', GameWAD
+':TEXTURES\CLIP');
126 g_Texture_CreateWADEx('ITEM_AMMO_BULLETS_BOX', GameWAD
+':TEXTURES\AMMO');
127 g_Texture_CreateWADEx('ITEM_AMMO_SHELLS', GameWAD
+':TEXTURES\SHELL1');
128 g_Texture_CreateWADEx('ITEM_AMMO_SHELLS_BOX', GameWAD
+':TEXTURES\SHELL2');
129 g_Texture_CreateWADEx('ITEM_AMMO_ROCKET', GameWAD
+':TEXTURES\ROCKET');
130 g_Texture_CreateWADEx('ITEM_AMMO_ROCKET_BOX', GameWAD
+':TEXTURES\ROCKETS');
131 g_Texture_CreateWADEx('ITEM_AMMO_CELL', GameWAD
+':TEXTURES\CELL');
132 g_Texture_CreateWADEx('ITEM_AMMO_CELL_BIG', GameWAD
+':TEXTURES\CELL2');
133 g_Texture_CreateWADEx('ITEM_AMMO_FUELCAN', GameWAD
+':TEXTURES\FUELCAN');
134 g_Texture_CreateWADEx('ITEM_AMMO_BACKPACK', GameWAD
+':TEXTURES\BPACK');
135 g_Texture_CreateWADEx('ITEM_KEY_RED', GameWAD
+':TEXTURES\KEYR');
136 g_Texture_CreateWADEx('ITEM_KEY_GREEN', GameWAD
+':TEXTURES\KEYG');
137 g_Texture_CreateWADEx('ITEM_KEY_BLUE', GameWAD
+':TEXTURES\KEYB');
138 g_Texture_CreateWADEx('ITEM_OXYGEN', GameWAD
+':TEXTURES\OXYGEN');
139 g_Texture_CreateWADEx('ITEM_SUIT', GameWAD
+':TEXTURES\SUIT');
140 g_Texture_CreateWADEx('ITEM_WEAPON_KASTET', GameWAD
+':TEXTURES\KASTET');
141 g_Texture_CreateWADEx('ITEM_MEDKIT_BLACK', GameWAD
+':TEXTURES\BMED');
144 procedure r_Items_Free
;
147 for i
:= 0 to ITEM_MAX
do
148 g_Frames_DeleteByID(items
[i
].id
);
151 procedure itemsDrawInternal (dropflag
: Boolean);
156 if (ggItems
= nil) then exit
;
158 for i
:= 0 to High(ggItems
) do
161 if (not it
.used
) or (it
.ItemType
= ITEM_NONE
) then continue
; // just in case
162 if not it
.alive
then continue
;
163 if (it
.dropped
<> dropflag
) then continue
;
167 if g_Collide(Obj
.X
, Obj
.Y
, Obj
.Rect
.Width
, Obj
.Rect
.Height
, sX
, sY
, sWidth
, sHeight
) then
169 Obj
.lerp(gLerpFactor
, fX
, fY
);
171 r_AnimState_Draw(items
[it
.ItemType
].id
, items
[it
.ItemType
].anim
, fX
, fY
, 0, TMirrorType
.None
, False);
173 if g_debug_Frames
then
175 e_DrawQuad(Obj
.X
+Obj
.Rect
.X
,
177 Obj
.X
+Obj
.Rect
.X
+Obj
.Rect
.Width
-1,
178 Obj
.Y
+Obj
.Rect
.Y
+Obj
.Rect
.Height
-1,
186 procedure r_Items_Draw
;
188 itemsDrawInternal(false);
191 procedure r_Items_DrawDrop
;
193 itemsDrawInternal(true);
196 procedure r_Items_Update
;
199 for i
:= 0 to ITEM_MAX
do
200 items
[i
].anim
.Update
;