if Shape3.Top > Shape1.Top then
begin
Shape3.Top:=Shape3.Top+Shape1.Top-(Shape1.Top+10);
if Shape3.Left > Shape1.Left then
begin
Shape3.Left:=Shape3.Left+Shape1.Left-(Shape1.Left+10);
end;
if Shape3.Left < Shape1.Left then
begin
Shape3.Left:=Shape3.Left+Shape1.Left-(Shape1.Left-10);
end;
end;
if Shape3.Top < Shape1.Top then
begin
Shape3.Top:=Shape3.Top+Shape1.Top-(Shape1.Top-10);
if Shape3.Left > Shape1.Left then
begin
Shape3.Left:=Shape3.Left+Shape1.Left-(Shape1.Left+10);
end;
if Shape3.Left < Shape1.Left then
begin
Shape3.Left:=Shape3.Left+Shape1.Left-(Shape1.Left-10);
end;
end;
if Shape3.Top = Shape1.Top then
begin
if Shape3.Left = Shape1.Left then
begin
ShowMessage('Проигрыш!');
Form1.Close;
end;
end;
Несмотря на массивность код довольно простой, поэтому думаю если вы читали раздел
Уроки Delphi, то вы в нем разберетесь. Бот готов! Запускаем. Видим что бот идет к нам. Зайдем боту в тыл - он все равно идет к нам!
Игра готова! Надеюсь статья вам понравилась!