4 procedure loadObject(_x
, _y
, _w
, _h
, _velx
, _vely
:integer; _jmp
:boolean);
6 function isSolid(x
, y
, velx
, vely
:integer):boolean;
8 function mapCollType(_type
, x
, y
, w
, h
:integer):boolean;
10 function CollTwoObj(x1
,y1
,w1
,h1
,x2
,y2
,w2
,h2
:integer):boolean;
12 procedure jumpObj(vel
:integer);
13 procedure calc(gravity
:boolean);
15 function getX
:integer;
16 function getY
:integer;
17 function getVelX
:integer;
18 function getVelY
:integer;
19 function getJmp
:boolean;
21 function canSeeObj(x1
, y1
, x2
, y2
:integer):boolean;
24 uses items_store
, maps
, vars
;
29 x
, y
, w
, h
, velx
, vely
:integer;
32 function CollTwoObj(x1
,y1
,w1
,h1
,x2
,y2
,w2
,h2
:integer):boolean;
34 if (x1
+w1
>x2
) and (x1
<x2
+w2
) and (y1
+h1
>y2
) and (y1
<y2
+h2
) then
38 procedure loadObject(_x
, _y
, _w
, _h
, _velx
, _vely
:integer; _jmp
:boolean);
49 function mapBoundCheck(x
, y
: Integer) : Boolean;
51 mapBoundCheck
:= (x
< 0) or (x
> MAP_W
* TILE_SIZE
);
54 function onMapObjectCheck(x
, y
, w
, h
: Integer) : Boolean;
56 onMapObjectCheck
:= mapBoundCheck(x
, y
) or mapBoundCheck(x
+ w
, y
+ h
);
59 function isSolid(x
, y
, velx
, vely
:integer):boolean;
61 isSolid
:= getBlockColl(getMap(x
, y
)) <> 0;
64 function mapColl(x
, y
, w
, h
, velx
, vely
:integer):boolean;
67 minx
, miny
, maxx
, maxy
:integer;
69 if onMapObjectCheck(x
, y
, w
, h
) then
75 minx
:=x
div TILE_SIZE
;
76 miny
:=y
div TILE_SIZE
;
77 maxx
:=(x
+w
-1) div TILE_SIZE
;
78 maxy
:=(y
+h
-1) div TILE_SIZE
;
79 for i
:=minx
to maxx
do
80 for j
:=miny
to maxy
do
82 if isSolid(i
, j
, velx
, vely
) then
90 function canSeeObj(x1
, y1
, x2
, y2
:integer):boolean;
92 deltax
, deltay
:integer;
94 error
, error2
:integer;
114 error
:=deltaX
-deltaY
;
116 while((x1
<>x2
) or (y1
<>y2
)) do
118 if isSolid(x1
, y1
, 0, 0) then
122 if error2
>-deltaY
then
128 if error2
<deltaX
then
137 function mapCollType(_type
, x
, y
, w
, h
:integer):boolean;
140 minx
, miny
, maxx
, maxy
:integer;
142 minx
:=x
div TILE_SIZE
;
143 miny
:=y
div TILE_SIZE
;
144 maxx
:=(x
+w
-1) div TILE_SIZE
;
145 maxy
:=(y
+h
-1) div TILE_SIZE
;
146 for i
:=minx
to maxx
do
147 for j
:=miny
to maxy
do
149 if getMap(i
, j
)=_type
then
157 procedure calcGravity
;
162 if vely
>MAX_VELY
then
171 if mapColl(x
, y
, w
, h
, velx
, vely
) then
180 for i
:=1 to abs(vely
) do
183 if mapColl(x
, y
, w
, h
, velx
, vely
) then
193 function fixVYup
:boolean;
196 (mapCollType(49, x
, y
, w
, h
) or
197 mapCollType(103, x
, y
, w
, h
) or
198 mapCollType(108, x
, y
, w
, h
)) then
202 (mapCollType(50, x
, y
, w
, h
) or
203 mapCollType(51, x
, y
, w
, h
)) then
212 (mapCollType(49, x
, y
, w
, h
) or
213 mapCollType(103, x
, y
, w
, h
)) then
217 (mapCollType(50, x
, y
, w
, h
) or
218 mapCollType(51, x
, y
, w
, h
)) then
222 procedure jumpObj(vel
:integer);
240 if mapColl(x
, y
, w
, h
, velx
, vely
) then
249 for i
:=1 to abs(velx
) do //there for-downto-do have a bug!
252 if mapColl(x
, y
, w
, h
, velx
, vely
) then
275 if mapColl(x
, y
, w
, h
, velx
, vely
) then
284 for i
:=1 to abs(vely
) do //there for-downto-do have a bug!
287 if mapColl(x
, y
, w
, h
, velx
, vely
) then
302 function getX
:integer;
307 function getY
:integer;
312 function getVelX
:integer;
317 function getVelY
:integer;
322 function getJmp
:boolean;
327 procedure calc(gravity
:boolean);