Delphi-PRAXiS
Seite 2 von 2     12   

Delphi-PRAXiS (https://www.delphipraxis.net/forum.php)
-   Multimedia (https://www.delphipraxis.net/16-multimedia/)
-   -   Delphi Collisionserknnung:problem (https://www.delphipraxis.net/37144-collisionserknnung-problem.html)

mimi 6. Feb 2005 12:34

Re: Collisionserknnung:problem
 
ja habe ich so sieht die funktion in wirklichkeit aus:
Delphi-Quellcode:
function TGame.GetObj(x,y,w,h,s:Integer):TObjTyp;
var
  i:Integer;
begin
  result.WRechts:=False;
  result.WLings:=False;
  result.WOben:=False;
  result.WUnten:=False;

  result.Typ:=None;
  result.index:=None;
  result.f:=False;

  for i:=0 to High(obj.walls) do begin
    // Rechts
    if (x+w+s > obj.walls[i].x) and (y > obj.walls[i].y) and (x+w+s < obj.walls[i].x+obj.walls[i].w) and (y < obj.walls[i].y+obj.walls[i].h) then
      result.WRechts:=True;

    // Lings
    if (x-s > obj.walls[i].x) and
       (y > obj.walls[i].y) and
       (x-s < obj.walls[i].x+obj.walls[i].w) and
       (y < obj.walls[i].y+obj.walls[i].h) then
      result.WLings:=True;

    // Unten
    if (x > obj.walls[i].x) and (y+h+1 >obj.walls[i].y) and(x < obj.walls[i].x+obj.walls[i].w) and (y+h+1< obj.walls[i].y+obj.walls[i].h) then
      result.WUnten:=True;

    // Oben
    if (x > obj.walls[i].x) and (y > obj.walls[i].y) and(x < obj.walls[i].x+obj.walls[i].w) and (y<obj.walls[i].y+obj.walls[i].h ) then
      result.WOben:=True

  end;
end;


Alle Zeitangaben in WEZ +1. Es ist jetzt 10:16 Uhr.
Seite 2 von 2     12   

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
LinkBacks Enabled by vBSEO © 2011, Crawlability, Inc.
Delphi-PRAXiS (c) 2002 - 2023 by Daniel R. Wolf, 2024-2025 by Thomas Breitkreuz