a9447d5925afaea6ebe8b40b65c9aeb00418952b
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 g_playermodel
; // TPlayerModel
22 procedure r_PlayerModel_Initialize
;
23 procedure r_PlayerModel_Finalize
;
24 procedure r_PlayerModel_Draw (pm
: TPlayerModel
; X
, Y
: Integer; Alpha
: Byte = 0);
29 SysUtils
, Classes
, Math
,
32 g_basic
, g_map
, g_weapons
, g_textures
, g_main
36 WeapNames
: Array [WP_FIRST
+ 1..WP_LAST
] of String = ('csaw', 'hgun', 'sg', 'ssg', 'mgun', 'rkt', 'plz', 'bfg', 'spl', 'flm');
39 WeaponID
: Array [WP_FIRST
+ 1..WP_LAST
, W_POS_NORMAL
..W_POS_DOWN
, W_ACT_NORMAL
..W_ACT_FIRE
] of DWORD
;
41 procedure r_PlayerModel_Initialize
;
45 for a
:= WP_FIRST
+ 1 to WP_LAST
do
47 g_Texture_CreateWAD(WeaponID
[a
][W_POS_NORMAL
][W_ACT_NORMAL
], GameWAD
+':WEAPONS\'+UpperCase(WeapNames
[a
]));
48 g_Texture_CreateWAD(WeaponID
[a
][W_POS_NORMAL
][W_ACT_FIRE
], GameWAD
+':WEAPONS\'+UpperCase(WeapNames
[a
])+'_FIRE');
49 g_Texture_CreateWAD(WeaponID
[a
][W_POS_UP
][W_ACT_NORMAL
], GameWAD
+':WEAPONS\'+UpperCase(WeapNames
[a
])+'_UP');
50 g_Texture_CreateWAD(WeaponID
[a
][W_POS_UP
][W_ACT_FIRE
], GameWAD
+':WEAPONS\'+UpperCase(WeapNames
[a
])+'_UP_FIRE');
51 g_Texture_CreateWAD(WeaponID
[a
][W_POS_DOWN
][W_ACT_NORMAL
], GameWAD
+':WEAPONS\'+UpperCase(WeapNames
[a
])+'_DN');
52 g_Texture_CreateWAD(WeaponID
[a
][W_POS_DOWN
][W_ACT_FIRE
], GameWAD
+':WEAPONS\'+UpperCase(WeapNames
[a
])+'_DN_FIRE');
56 procedure r_PlayerModel_Finalize
;
59 for a
:= WP_FIRST
+ 1 to WP_LAST
do
60 for b
:= W_POS_NORMAL
to W_POS_DOWN
do
61 for c
:= W_ACT_NORMAL
to W_ACT_FIRE
do
62 e_DeleteTexture(WeaponID
[a
][b
][c
])
65 procedure r_PlayerModel_Draw (pm
: TPlayerModel
; X
, Y
: Integer; Alpha
: Byte = 0);
72 if pm
.Direction
= TDirection
.D_LEFT
then
73 Mirror
:= TMirrorType
.None
75 Mirror
:= TMirrorType
.Horizontal
;
77 if (pm
.Flag
<> FLAG_NONE
) and (pm
.FlagAnim
<> nil) and (not (pm
.CurrentAnimation
in [A_DIE1
, A_DIE2
])) then
79 p
.X
:= IfThen(pm
.Direction
= TDirection
.D_LEFT
, FLAG_BASEPOINT
.X
, 64 - FLAG_BASEPOINT
.X
);
80 p
.Y
:= FLAG_BASEPOINT
.Y
;
82 pm
.FlagAnim
.DrawEx(X
+IfThen(pm
.Direction
= TDirection
.D_LEFT
, pm
.FlagPoint
.X
-1, 2*FLAG_BASEPOINT
.X
-pm
.FlagPoint
.X
+1)-FLAG_BASEPOINT
.X
,
83 Y
+pm
.FlagPoint
.Y
-FLAG_BASEPOINT
.Y
+1, Mirror
, p
,
84 IfThen(pm
.Direction
= TDirection
.D_RIGHT
, pm
.FlagAngle
, -pm
.FlagAngle
));
88 if pm
.Direction
= TDirection
.D_RIGHT
then
89 Mirror
:= TMirrorType
.None
91 Mirror
:= TMirrorType
.Horizontal
;
93 if pm
.DrawWeapon
and (not (pm
.CurrentAnimation
in [A_DIE1
, A_DIE2
, A_PAIN
])) and (pm
.CurrentWeapon
in [WP_FIRST
+ 1..WP_LAST
]) then
95 if pm
.CurrentAnimation
in [A_SEEUP
, A_ATTACKUP
] then
98 if pm
.CurrentAnimation
in [A_SEEDOWN
, A_ATTACKDOWN
] then
103 if (pm
.CurrentAnimation
in [A_ATTACK
, A_ATTACKUP
, A_ATTACKDOWN
]) or pm
.Fire
then
109 e_Draw(WeaponID
[pm
.CurrentWeapon
][pos
][act
],
110 X
+ pm
.WeaponPoints
[pm
.CurrentWeapon
, pm
.CurrentAnimation
, pm
.Direction
,
111 pm
.Anim
[TDirection
.D_RIGHT
][pm
.CurrentAnimation
].CurrentFrame
].X
,
112 Y
+ pm
.WeaponPoints
[pm
.CurrentWeapon
, pm
.CurrentAnimation
, pm
.Direction
,
113 pm
.Anim
[TDirection
.D_RIGHT
][pm
.CurrentAnimation
].CurrentFrame
].Y
,
114 0, True, False, Mirror
);
118 if (pm
.Direction
= TDirection
.D_LEFT
) and (pm
.Anim
[TDirection
.D_LEFT
][pm
.CurrentAnimation
] <> nil) then
120 pm
.Anim
[TDirection
.D_LEFT
][pm
.CurrentAnimation
].Alpha
:= Alpha
;
121 pm
.Anim
[TDirection
.D_LEFT
][pm
.CurrentAnimation
].Draw(X
, Y
, TMirrorType
.None
);
125 pm
.Anim
[TDirection
.D_RIGHT
][pm
.CurrentAnimation
].Alpha
:= Alpha
;
126 pm
.Anim
[TDirection
.D_RIGHT
][pm
.CurrentAnimation
].Draw(X
, Y
, Mirror
);
130 e_Colors
:= pm
.Color
;
132 if (pm
.Direction
= TDirection
.D_LEFT
) and (pm
.MaskAnim
[TDirection
.D_LEFT
][pm
.CurrentAnimation
] <> nil) then
134 pm
.MaskAnim
[TDirection
.D_LEFT
][pm
.CurrentAnimation
].Alpha
:= Alpha
;
135 pm
.MaskAnim
[TDirection
.D_LEFT
][pm
.CurrentAnimation
].Draw(X
, Y
, TMirrorType
.None
);
139 pm
.MaskAnim
[TDirection
.D_RIGHT
][pm
.CurrentAnimation
].Alpha
:= Alpha
;
140 pm
.MaskAnim
[TDirection
.D_RIGHT
][pm
.CurrentAnimation
].Draw(X
, Y
, Mirror
);