summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 89a9309)
raw | patch | inline | side by side (parent: 89a9309)
author | DeaDDooMER <deaddoomer@deadsoftware.ru> | |
Wed, 8 Mar 2017 10:47:21 +0000 (13:47 +0300) | ||
committer | DeaDDooMER <deaddoomer@deadsoftware.ru> | |
Wed, 8 Mar 2017 10:47:21 +0000 (13:47 +0300) |
src/phy.pas | patch | blob | history |
diff --git a/src/phy.pas b/src/phy.pas
index 648ca346c76ad438da34143fde58198475dd497b..431f18034826a9fc28e56ff6b1c9cedc39e0a947 100644 (file)
--- a/src/phy.pas
+++ b/src/phy.pas
function canSeeObj(x1, y1, x2, y2:integer):boolean;\r
\r
implementation\r
- uses items_store, maps;\r
+ uses items_store, maps, vars;\r
const\r
MAX_VELY=32;\r
TILE_SIZE=16;\r
jmp:=_jmp;\r
end;\r
\r
+ function mapBoundCheck(x, y : Integer) : Boolean;\r
+ begin\r
+ mapBoundCheck := (x < 0) or (x > MAP_W * TILE_SIZE);\r
+ end;\r
+\r
+ function onMapObjectCheck(x, y, w, h : Integer) : Boolean;\r
+ begin\r
+ onMapObjectCheck := mapBoundCheck(x, y) or mapBoundCheck(x + w, y + h);\r
+ end;\r
+\r
function isSolid(x, y, velx, vely:integer):boolean;\r
- begin\r
- if getBlockColl(getMap(x, y))<>0 then\r
- isSolid:=true;\r
- end;\r
+ begin\r
+ isSolid := getBlockColl(getMap(x, y)) <> 0;\r
+ end;\r
\r
function mapColl(x, y, w, h, velx, vely:integer):boolean;\r
- var\r
- i, j:integer;\r
- minx, miny, maxx, maxy:integer;\r
- begin\r
- minx:=x div TILE_SIZE;\r
- miny:=y div TILE_SIZE;\r
- maxx:=(x+w-1) div TILE_SIZE;\r
- maxy:=(y+h-1) div TILE_SIZE;\r
- for i:=minx to maxx do\r
- for j:=miny to maxy do\r
- begin\r
- if isSolid(i, j, velx, vely) then\r
- begin\r
- mapColl:=true;\r
- exit;\r
- end;\r
- end;\r
- end;\r
+ var\r
+ i, j:integer;\r
+ minx, miny, maxx, maxy:integer;\r
+ begin\r
+ if onMapObjectCheck(x, y, w, h) then\r
+ begin\r
+ mapColl := true;\r
+ exit;\r
+ end;\r
+\r
+ minx:=x div TILE_SIZE;\r
+ miny:=y div TILE_SIZE;\r
+ maxx:=(x+w-1) div TILE_SIZE;\r
+ maxy:=(y+h-1) div TILE_SIZE;\r
+ for i:=minx to maxx do\r
+ for j:=miny to maxy do\r
+ begin\r
+ if isSolid(i, j, velx, vely) then\r
+ begin\r
+ mapColl:=true;\r
+ exit;\r
+ end;\r
+ end;\r
+ end;\r
\r
function canSeeObj(x1, y1, x2, y2:integer):boolean;\r
var\r