I'll throw out this kind of suggestion:
Code:
if GetKeyState(VK_LEFT) < 0 then
begin
if not Blurp.testForWall(Blurp.X-4,Blurp.Y) then
begin
Blurp.X:=Blurp.X-4;
AdSpriteEngine.X:=AdSpriteEngine.X+4;
end;
end;
if GetKeyState(VK_RIGHT) < 0 then
begin
if not Blurp.testForWall(Blurp.X+4+Blurp.Image.Width,Blurp.Y) then
begin
Blurp.X:=Blurp.X+4;
AdSpriteEngine.X:=AdSpriteEngine.X-4;
end;
end;
if GetKeyState(VK_UP) < 0 then
begin
if not Blurp.testForWall(Blurp.X,Blurp.Y-4) then
begin
Blurp.Y:=Blurp.Y-4;
AdSpriteEngine.Y:=AdSpriteEngine.Y+4;
end;
end;
if GetKeyState(VK_DOWN) < 0 then
begin
if not Blurp.testForWall(Blurp.X,Blurp.Y+4+Blurp.Image.Height) then
begin
Blurp.Y:=Blurp.Y+4;
AdSpriteEngine.Y:=AdSpriteEngine.Y-4;
end;
end;
Code:
function TBlurp.testForWall(pointX,pointY:single):boolean;
var tilenr: integer;
begin
tilenr:=TileInfo[trunc(pointX) div 64, trunc(pointY) div 64].tilenr;
case tilenr of
2: result:=true;
else result:=false;
end;
end;
Bookmarks