Einzelnen Beitrag anzeigen

Blup

Registriert seit: 7. Aug 2008
Ort: Brandenburg
1.429 Beiträge
 
Delphi 10.4 Sydney
 
#3

Re: Auto durch Labyrinth fahren lassen

  Alt 23. Feb 2010, 13:51
Vieleicht solltest du dich erst einmal mit einem Ball statt des Autos begnügen und die Steuerung zum Beispiel über Tasten selbst übernehmen.

Hier soll wohl ermittelt werden, ob in der entsprechenden Richtung ein Hindernis ist.
if image1.Canvas.Pixels[shape_auto.Left+i,shape_auto.Top+j-100+(autobreite div 2)]<>0 then So könnte es vieleicht funktionieren:
Delphi-Quellcode:
for i := -1 to 1 do
begin
  // ??? x := shape_auto.Left + i;
  case i of
    -1: x := shape_auto.Left - 1;
     1: x := shape_auto.Left + shape_auto.Width + 1;
  else x := shape_auto.Left + (shape_auto.Width div 2); // Mittelpunkt;
  end;

  for j := -1 to 1 do
  begin
    // ??? y := shape_auto.Top+j-100+(autobreite div 2);
    case j of
      -1: y := shape_auto.Top - 1;
       1: y := shape_auto.Top + shape_auto.Height + 1;
    else y := shape_auto.Top + (shape_auto.Height div 2); // Mittelpunkt;
    end;

    if image1.Canvas.Pixels[x, y] <> 0 then
Falls das Image nicht das gesamte Formular füllt, muss Point(x,y) noch in Koordinaten des Images umgerechnet werden.
  Mit Zitat antworten Zitat