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 procedure r_Monsters_Draw
;
21 procedure r_Monsters_DrawHealth
;
26 SysUtils
, Classes
, Math
,
27 r_graphics
, g_options
, r_animations
,
29 g_base
, g_basic
, g_game
, g_phys
,
33 procedure r_Monsters_Draw (constref monster
: TMonster
);
34 var m
: TMirrorType
; dx
, dy
, c
, fX
, fY
: Integer; o
: TObj
;
38 //e_CharFont_Print(gMenuSmallFont, Obj.X + Obj.Rect.X, Obj.Y + Obj.Rect.Y, 'TYPE: ' + IntToStr(MonsterType));
39 //e_CharFont_Print(gMenuSmallFont, Obj.X + Obj.Rect.X, Obj.Y + Obj.Rect.Y + 16, 'STATE: ' + IntToStr(MonsterState));
41 Obj
.lerp(gLerpFactor
, fX
, fY
);
43 // Если колдун стреляет, то рисуем огонь:
44 if MonsterType
= MONSTER_VILE
then
45 if MonsterState
= MONSTATE_SHOOT
then
46 if GetPos(MonsterTargetUID
, @o
) then
47 r_Animation_Draw(VileFireAnim
, o
.X
+ o
.Rect
.X
+ (o
.Rect
.Width
div 2) - 32, o
.Y
+ o
.Rect
.Y
+ o
.Rect
.Height
- 128, TMirrorType
.None
);
49 // Не в области рисования не ресуем:
51 if (g_dbg_scale
= 1.0) then
53 if not g_Collide(Obj
.X
+ Obj
.Rect
.X
, Obj
.Y
+ Obj
.Rect
.Y
, Obj
.Rect
.Width
, Obj
.Rect
.Height
, sX
- 128, sY
- 128, sWidth
+ 256, sHeight
+ 256) then
57 // Эти монстры, умирая, не оставляют трупов:
58 if MonsterState
= MONSTATE_DEAD
then
60 MONSTER_BARREL
, MONSTER_SOUL
, MONSTER_PAIN
: Exit
;
63 // Есть что рисовать при текущем поведении:
64 if DirAnim
[MonsterAnim
, GameDirection
] <> nil then
66 // Если нет левой анимации или она совпадает с правой => отражаем правую:
67 if (GameDirection
= TDirection
.D_LEFT
) and ((not MONSTER_ANIMTABLE
[MonsterType
].LeftAnim
) or (DirAnim
[MonsterAnim
, TDirection
.D_LEFT
].FramesID
= DirAnim
[MonsterAnim
, TDirection
.D_RIGHT
].FramesID
)) and (MonsterType
<> MONSTER_BARREL
) then
68 m
:= TMirrorType
.Horizontal
70 m
:= TMirrorType
.None
;
72 // Левая анимация => меняем смещение относительно центра:
73 if (GameDirection
= TDirection
.D_LEFT
) and (MonsterType
<> MONSTER_BARREL
) then
75 dx
:= MONSTER_ANIMTABLE
[MonsterType
].AnimDeltaLeft
[MonsterAnim
].X
;
76 dy
:= MONSTER_ANIMTABLE
[MonsterType
].AnimDeltaLeft
[MonsterAnim
].Y
;
78 if m
= TMirrorType
.Horizontal
then
80 // Нет отдельной левой анимации
81 // Расстояние от края текстуры до края визуального положения объекта на текстуре:
82 c
:= (MONSTERTABLE
[MonsterType
].Rect
.X
- dx
) + MONSTERTABLE
[MonsterType
].Rect
.Width
;
83 // Расстояние от края хит бокса до края визуального положения объекта на текстуре:
84 dx
:= DirAnim
[MonsterAnim
, GameDirection
].Width
- c
- MONSTERTABLE
[MonsterType
].Rect
.X
;
85 // Т.к. двигать текстуру нужно будет в противоположном направлении:
87 // Это значит: dX := -frameWidth - animDeltaX + hitX + hitWidth + hitX
90 else // Правая анимация
92 dx
:= MONSTER_ANIMTABLE
[MonsterType
].AnimDeltaRight
[MonsterAnim
].X
;
93 dy
:= MONSTER_ANIMTABLE
[MonsterType
].AnimDeltaRight
[MonsterAnim
].Y
;
96 r_Animation_Draw(DirAnim
[MonsterAnim
, GameDirection
], fX
+ dx
, fY
+ dy
, m
);
99 if g_debug_Frames
then
101 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);
106 procedure r_Monsters_Draw
;
109 if gMonsters
<> nil then
110 for a
:= 0 to High(gMonsters
) do
111 if (gMonsters
[a
] <> nil) then r_Monsters_Draw(gMonsters
[a
]);
114 procedure r_Monsters_DrawHealth
;
115 var a
: Integer; fW
, fH
: Byte;
117 if gMonsters
= nil then Exit
;
118 e_TextureFontGetSize(gStdFont
, fW
, fH
);
119 for a
:= 0 to High(gMonsters
) do
121 if gMonsters
[a
] <> nil then
123 e_TextureFontPrint(gMonsters
[a
].Obj
.X
+ gMonsters
[a
].Obj
.Rect
.X
,
124 gMonsters
[a
].Obj
.Y
+ gMonsters
[a
].Obj
.Rect
.Y
+ gMonsters
[a
].Obj
.Rect
.Height
- fH
,
125 IntToStr(gMonsters
[a
].MonsterHealth
), gStdFont
);