Einzelnen Beitrag anzeigen

mimi

Registriert seit: 1. Dez 2002
Ort: Oldenburg(Oldenburg)
2.008 Beiträge
 
FreePascal / Lazarus
 
#11

Re: Collisionserknnung:problem

  Alt 6. Feb 2005, 12:34
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;
Michael Springwald
MFG
Michael Springwald,
Bitte nur Deutsche Links angeben Danke (benutzte überwiegend Lazarus)
  Mit Zitat antworten Zitat