Results 1 to 10 of 31

Thread: Collission detection on level ( source Travels doc + some other examples)

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #11
    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;
    Last edited by User137; 16-08-2011 at 03:58 PM. Reason: trunc

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •