summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: fde5f98)
raw | patch | inline | side by side (parent: fde5f98)
author | DeaDDooMER <deaddoomer@deadsoftware.ru> | |
Wed, 8 Mar 2017 10:22:20 +0000 (13:22 +0300) | ||
committer | DeaDDooMER <deaddoomer@deadsoftware.ru> | |
Wed, 8 Mar 2017 10:22:20 +0000 (13:22 +0300) |
src/mobs.pas | patch | blob | history | |
src/player.mpsrc | patch | blob | history |
diff --git a/src/mobs.pas b/src/mobs.pas
index 95815db35f60c894ba81fd5da88288eb5f65968a..4899980faad7dd40f79c6aa86bac25798a8f3481 100644 (file)
--- a/src/mobs.pas
+++ b/src/mobs.pas
setPosi(1, i);\r
end;\r
\r
- function testSolid(i, vector:integer):boolean;\r
+ function testSolid(i, vector : integer) : boolean;\r
var\r
- x, y:integer;\r
+ x, y : integer;\r
begin\r
- y:=((getY(i)+getH(i)))/16-1;\r
+ y := (getY(i) + getH(i)) / 16 - 1;\r
\r
- if vector<0 then\r
- begin\r
- x:=(getX(i)/16)-1;\r
- end;\r
- else\r
- if vector>0 then\r
- begin\r
- x:=((getX(i)+getW(i))/16){+1};\r
- end;\r
+ if vector > 0 then\r
+ x := (getX(i) + getW(i) / 2 + 16 / 2) / 16;\r
else\r
- x:=((getX(i)+getW(i)/2)/16);\r
+ x := (getX(i) + getW(i) / 2 - 16 / 2) / 16;\r
\r
- testSolid:=phy.isSolid(x, y, getVX(i), getVY(i));\r
+ testSolid := phy.isSolid(x, y, getVX(i), getVY(i));\r
+ end;\r
+\r
+ function collideWithPlayer(i : integer) : boolean;\r
+ begin\r
+ collideWithPlayer := CollTwoObj(getX(i), getY(i), getW(i), getH(i), player.getX, player.getY, player.getW, player.getH);\r
+ end;\r
+\r
+ function canBite(i : integer) : boolean;\r
+ begin\r
+ canBite := collideWithPlayer(i);\r
end;\r
\r
- procedure updateZloyAiAnim(i:integer);\r
+ procedure updateZloyAiAnim(i : integer);\r
const\r
DEL=1;\r
var\r
mob_anim[i, 3]:=a_f;\r
end;\r
\r
- procedure updateZloyAi(i:integer);\r
+ procedure updateZloyAi(i : integer);\r
+ var\r
+ vector : integer;\r
begin\r
- if player.getX<getX(i) then\r
+ if player.getX < getX(i) then\r
begin\r
goLeft(i);\r
- updateZloyAiAnim(i);\r
- if testSolid(i, -1) then\r
- goUp(i);\r
- end;\r
- else\r
- if player.getX>getX(i) then\r
- begin\r
- goRight(i);\r
- updateZloyAiAnim(i);\r
- if testSolid(i, 1) then\r
- goUp(i);\r
+ vector := -1;\r
end;\r
+ else if player.getX > getX(i) then\r
+ begin\r
+ goRight(i);\r
+ vector := 1;\r
+ end;\r
+\r
+ if vector <> 0 then\r
+ begin\r
+ updateZloyAiAnim(i);\r
+ if testSolid(i, vector) then\r
+ goUp(i);\r
+ end;\r
+\r
+ if collideWithPlayer(i) then\r
+ player.biteIt(1, vector);\r
end;\r
\r
- procedure update;//Обновление логики\r
+ procedure update;\r
var\r
i, _type, ai:integer;\r
begin\r
diff --git a/src/player.mpsrc b/src/player.mpsrc
index 3e9f3615fa11a8ab31a9689f3e72f84f85439607..1891939e113195d38530b4fb149d2a35378a3c43 100644 (file)
--- a/src/player.mpsrc
+++ b/src/player.mpsrc
procedure cancelAnim(anim:integer);\r
\r
procedure dropItem(item, sum:integer);\r
+ procedure biteIt(hp : integer; vector : integer);\r
\r
procedure calcPhysics;\r
\r
DrawImage(PlayerHand[posi, animHand], x-6-camx, y+8-camy);\r
end;\r
\r
+ procedure biteIt(damage : integer; vector : integer);\r
+ begin\r
+ hp := hp - damage;\r
+ end;\r
+\r
procedure loadPhy;\r
begin\r
phy.loadObject(getX, getY, getW, getH, getVelX, getVelY, getJmp);\r