b41c8e3b7ff82cfcc4eda09aa5e8cbb6f7f2895b
11 hp
, hunger
, air
: integer;
18 function GetX
: integer;
19 function GetY
: integer;
20 function GetW
: integer;
21 function GetH
: integer;
22 procedure SetX(val
: integer);
23 procedure SetY(val
: integer);
25 procedure LoadSkin(str
, path
: string);
27 procedure Draw(camx
, camy
: integer);
28 procedure PlayAnim(anim
: integer);
29 procedure CancelAnim(anim
: integer);
31 procedure DropItem(item
, sum
: integer);
32 procedure BiteIt(hp
: integer; vector
: integer);
34 procedure CalcPhysics
;
45 uses func
, phy
, vars
, Canvas
, drop
, items
, jsr75i
, inv
;
58 playerBody
: array [0..1] of image
;
59 playerHand
: array [0..1, 0..3] of image
;
60 playerLegs
: array [0..1, 0..2] of image
;
61 animHand
, animLegs
, animDelay
:integer;
63 procedure SetX(val
: integer);
68 procedure SetY(val
: integer);
73 function GetX
: integer;
78 function GetY
: integer;
83 function GetW
: integer;
88 function GetH
: integer;
93 procedure SetVelX(val
: integer);
98 procedure SetVelY(val
: integer);
103 function GetVelX
: integer;
108 function GetVelY
: integer;
113 procedure SetJmp(val
: boolean);
118 function GetJmp
: boolean;
123 procedure DropItem(item
, sum
: integer);
125 if posi
= POSI_LEFT
then Drop
.Create(item
, sum
, GetX
- 8, GetY
);
126 else Drop
.Create(item
, sum
, GetX
+ GetW
, GetY
);
129 procedure LoadSkin(str
, path
:string);
134 im
:= ld_tex(str
, path
, 'mobs/');
135 playerBody
[POSI_LEFT
] := rotate_image_from_image(im
, 0, 0, 8, 20, 0);
136 playerBody
[POSI_RIGHT
] := rotate_image_from_image(im
, 8, 0, 8, 20, 0);
137 playerHand
[POSI_LEFT
, 0] := rotate_image_from_image(im
, 40, 0, 4, 12, 0);
138 playerHand
[POSI_RIGHT
, 0] := rotate_image_from_image(im
, 44, 0, 4, 12, 0);
139 for i
:= 1 to 3 do begin
140 playerHand
[POSI_LEFT
, i
] := rotate_image_from_image(im
, 16, (i
- 1) * 6, 12, 6, 0);
141 playerHand
[POSI_RIGHT
, i
] := rotate_image_from_image(im
, 28, (i
- 1) * 6, 12, 6, 0);
143 for i
:=0 to 2 do begin
144 playerLegs
[POSI_LEFT
, i
] := rotate_image_from_image(im
, i
* 12, 20, 12, 12, 0);
145 playerLegs
[POSI_RIGHT
, i
] := rotate_image_from_image(im
, 36 + i
* 12, 20, 12, 12, 0);
154 for i
:= 0 to 1 do begin
155 playerBody
[i
] := nullimg
;
156 for j
:=0 to 3 do playerHand
[i
, j
] := nullimg
;
157 for j
:=0 to 2 do playerLegs
[i
, j
] := nullimg
;
161 procedure PlayAnim(anim
: integer);
163 if anim
= ANIM_HAND
then begin
164 animHand
:= animHand
+ 1;
165 if animHand
> 3 then animHand
:=1;
166 end else if anim
= ANIM_LEGS
then begin
167 if animDelay
= 0 then begin
168 animLegs
:= animLegs
+ 1;
169 if animLegs
> 2 then animLegs
:= 0;
171 animDelay
:=animDelay
+1;
172 if animDelay
> PLAYER_ANIM_DEL
then animDelay
:= 0;
176 procedure CancelAnim(anim
: integer);
178 if anim
= ANIM_HAND
then animHand
:= 0;
179 else if anim
= ANIM_LEGS
then animLegs
:= 0;
182 procedure Draw(camx
, camy
: integer);
188 DrawImage(playerBody
[posi
], x
- camx
, y
- camy
);
189 DrawImage(playerLegs
[posi
, animLegs
], x
- 2 - camx
, y
+ 20 - camy
);
191 if animHand
= 0 then DrawSmallItem(Inv
.GetItem(invslot
), x
- camx
, y
+ 14 - camy
);
192 else if posi
= POSI_RIGHT
then DrawSmallItem(Inv
.GetItem(invslot
), x
+ 10 - camx
, y
+ 5 - camy
+ animHand
);
193 else if posi
= POSI_LEFT
then DrawSmallItem(Inv
.GetItem(invslot
), x
- 10 - camx
, y
+ 5 - camy
+ animHand
);
195 if (animHand
= 0) or (posi
= POSI_RIGHT
) then DrawImage(playerHand
[posi
, animHand
], x
+ 2 - camx
, y
+ 8 - camy
);
196 else DrawImage(playerHand
[posi
, animHand
], x
- 6 - camx
, y
+ 8 - camy
);
199 procedure BiteIt(damage
: integer; vector
: integer);
202 velx
:= velx
+ vector
;
207 Phy
.SetObject(GetX
, GetY
, GetW
, GetH
, GetVelX
, GetVelY
, GetJmp
);
219 procedure CalcPhysics
;
229 if (vel
> 0) and (Phy
.GetGCV
- vel
< -10) then BiteIt(vel
- 10, Random(5) - 2);
235 SetVelY(-PLAYER_SPEED
);
238 Phy
.Jump(jumpVelocity
);
245 if fly
then SetVelY(PLAYER_SPEED
);
250 SetVelX(-PLAYER_SPEED
);
252 if not fly
then PlayAnim(ANIM_LEGS
);
257 SetVelX(PLAYER_SPEED
);
259 if not fly
then playAnim(ANIM_LEGS
);
264 i
, maxd
, sum
: integer;
267 for i
:= 0 to maxd
do if Drop
.IsNull(i
) = false then begin
268 if Phy
.IntersectRects(GetX
, GetY
, GetW
, GetH
, Drop
.GetX(i
), Drop
.GetY(i
), Drop
.GetW
, Drop
.GetH
) then begin
269 sum
:=inv
.giveItem(drop
.getItem(i
), drop
.getSum(i
));