Sayfayı Yazdır | Pencereyi Kapat

araba sorun

Nereden Yazdırıldığı: Clomosy | Forum
Kategori: Genel Programlama
Forum Adı: Genel İşlemler
Forum Tanımlaması: TRObject dili ile programlama yaparken karşılaşılan genel işlemler
URL: https://forum.clomosy.com.tr/forum_posts.asp?TID=566
Tarih: 06 Ocak 2025 Saat 14:02
Program Versiyonu: Web Wiz Forums 12.07 - https://www.webwizforums.com


Konu: araba sorun
Mesajı Yazan: ibrahimethem
Konu: araba sorun
Mesaj Tarihi: 24 Ağustos 2023 Saat 09:48
Var
  MyForm:TclGameForm;
  rightbutton, leftbutton : TClProButton;
  araba,engel1img,engelimg,engel2img: TClProImage;
  GameTimer,Timer,GameTimer1,GameTimer2,GameTimer3:TClTimer;
  b: Boolean;

Procedure Proc4OnGameTimer;
Const 
  engel2imgSpeed = -10;
begin
  engel2img.Align:= alNone; 
  engel2img.Top := engel2img.Top - engel2imgSpeed;//yukarı yön
  
  if (engel2img.Left + engel2img.Width) > TForm(MyForm).ClientWidth then  // sağ kenar kontrolü
    engel2img.Left := TForm(MyForm).ClientWidth - engel2img.Width;
  
  if (engel2img.Left) < 0 then // sol kenar kontrolü
    engel2img.Left := 0;
  
  if (engel2img.Top + engel2img.Height) > TForm(MyForm).ClientHeight then  // Alt sınır kontrolü
  begin
    engel2img.Top := TForm(MyForm).ClientHeight - engel2img.Height;
    engel2img.Top := 0;
    engel2img.Left:= clMath.generateRandom(150,250);
  end;
  
  if engel2img then
    GameTimer.Enabled:= True;
end;

Procedure Proc2OnGameTimer;
Const 
  engel1imgSpeed= -10;
begin
  engel1img.Align := alNone; 
  engel1img.Top := engel1img.Top - engel1imgSpeed;//yukarı yön
  
  if (engel1img.Left + engel1img.Width) > TForm(MyForm).ClientWidth then  // sağ kenar kontrolü
    engel1img.Left := TForm(MyForm).ClientWidth - engel1img.Width;
  
  if (engel1img.Left) < 0 then // sol kenar kontrolü
    engel1img.Left := 0;
    
  if (engel1img.Top + engel1img.Height) > TForm(MyForm).ClientHeight then  // Alt sınır kontrolü
  begin
    engel1img.Top := TForm(MyForm).ClientHeight - engel1img.Height;
    engel1img.Top := 0;
    engel1img.Left:= clMath.generateRandom(50,150);
  end;
  
  if engel1img then
    GameTimer.Enabled:= True;
end;

Procedure Proc3OnGameTimer;
Const 
  engelimgSpeed = -10;
begin
  engelimg.Align := alNone; 
  engelimg.Top := engelimg.Top - engelimgSpeed;//yukarı yön

  if (engelimg.Left + engelimg.Width) > TForm(MyForm).ClientWidth then  // sağ kenar kontrolü
    engelimg.Left := TForm(MyForm).ClientWidth - engelimg.Width;

  if (engelimg.Left) < 0 then // sol kenar kontrolü
    engelimg.Left := 0;

  if (engelimg.Top + engelimg.Height) > TForm(MyForm).ClientHeight then  // Alt sınır kontrolü
  begin
    engelimg.Top := TForm(MyForm).ClientHeight - engelimg.Height;
    engelimg.Top := 0;
    engelimg.Left:= clMath.generateRandom(0,100);
  end;

  if engelimg then
    GameTimer.Enabled:= True;
end;

procedure SetImage3;
begin
  engel2img := MyForm.AddNewProImage(MyForm,'engel2img');
  clComponent.SetupComponent(engel2img,'{"Width":75, "Height":150, "Align":"None",
  "ImgUrl":"https://i.hizliresim.com/io5ymz8.png", "Left": 60, "Top": 0}');
end;

procedure SetImage2;
begin
  engel1img := MyForm.AddNewProImage(MyForm,'engel1img');
  clComponent.SetupComponent(engel1img,'{"Width":75, "Height":150, "Align":"None",
  "ImgUrl":"https://i.hizliresim.com/p1uujvb.png", "Left": 0, "Top": 30}');
end;

procedure SetImage1;
begin
  engelimg:= MyForm.AddNewProImage(MyForm,'engelimg');
  clComponent.SetupComponent(engelimg,'{"Width":75, "Height":150, "Align":"None",
  "ImgUrl":"https://i.hizliresim.com/rr72hin.png", "Left": 30, "Top": 10}');
end;

Function Max(in1,in2: Integer): Integer; begin

  if in1 >= in2 then
    Result:= in1
  else
    Result:= in2;
End;

Function Min(in1,in2: Integer): Integer; begin

  if in1 <= in2 then
    Result:= in1
  else
    Result:= in2;
End;

// Change background
Procedure Proc1OnGameTimer; begin

  if b then
    MyForm.SetFormBGImage('c4gxsvt.png')
  else
    MyForm.SetFormBGImage('anhjtzn.png');
  
  b:= not b;
End;

Procedure ProcOnGameTimer;
Const 
  arabaSpeed = 0;
Var
  intersect_area,intersect_x1, intersect_y1, intersect_x2, intersect_y2: Integer;
  b: Boolean;
begin
  araba.Top := araba.Top - arabaSpeed;//Yukarı yön
  
  if (araba.Left + araba.Width) > TForm(MyForm).ClientWidth then  // sağ kenar kontrolü
    araba.Left := TForm(MyForm).ClientWidth - araba.Width;
  
  if (araba.Left) < 0 then // sol kenar kontrolü
    araba.Left := 0;
  
  if (araba.Top + araba.Height) > TForm(MyForm).ClientHeight then  // alt sınıt  kontrolü
    araba.Top := TForm(MyForm).ClientHeight - araba.Height;
  
  if araba then
  GameTimer.Enabled := True;
  
  b:= False;
  
  {Engel}
  intersect_x1:= max(araba.Left, engelimg.Left);
  intersect_y1:= max(araba.Top, engelimg.Top);
  intersect_x2:= min(araba.Left+araba.Width, engelimg.Left+engelimg.Width);
  intersect_y2:= min(araba.Top+araba.Height, engelimg.Top+engelimg.Height);
  intersect_area:= (intersect_x2 - intersect_x1) * (intersect_y2 - intersect_y1);
  
  b:= b or (intersect_area > 0) and (araba.Top < engelimg.Top+engelimg.Height);

  {/Engel}
  
  {Engel1}
  intersect_x1:= max(araba.Left, engel1img.Left);
  intersect_y1:= max(araba.Top, engel1img.Top);
  intersect_x2:= min(araba.Left+araba.Width, engel1img.Left+engel1img.Width);
  intersect_y2:= min(araba.Top+araba.Height, engel1img.Top+engel1img.Height);
  intersect_area:= (intersect_x2 - intersect_x1) * (intersect_y2 - intersect_y1);
  
  b:= b or (intersect_area > 0) and (araba.Top < engel1img.Top+engel1img.Height);
  {/Engel1}
  
  {Engel2}
  intersect_x1:= max(araba.Left, engel2img.Left);
  intersect_y1:= max(araba.Top, engel2img.Top);
  intersect_x2:= min(araba.Left+araba.Width, engel2img.Left+engel2img.Width);
  intersect_y2:= min(araba.Top+araba.Height, engel2img.Top+engel2img.Height);
  intersect_area:= (intersect_x2 - intersect_x1) * (intersect_y2 - intersect_y1);
   
  b:= b or (intersect_area > 0) and (araba.Top < engel2img.Top+engel2img.Height);
  {/Engel2}
  
  
  if b then
  Begin
    ShowMessage('Engele dokunuldu');
    engelimg.Top:= 1;
    engel1img.Top:= 1;
    engel2img.Top:= 1;
  End;
end; 

procedure rightbuttonOnClick;
Begin
  araba.Align := alNone;
  araba.Left:= araba.Left +25;
end;
 
procedure leftbuttonOnClick;
Begin
  araba.Align := alNone;
  araba.Left:= araba.Left -25;
end;

procedure SetImage;
begin
  araba := MyForm.AddNewProImage(MyForm,'araba');
  clComponent.SetupComponent(araba,'{"MarginBottom":-450,"Width" :75, "Height":150,
 "ImgUrl":"https://1.bp.blogspot.com/-eLqVU9iD9EM/WsoJrp3VRaI/AAAAAAAABjo/QH1WGuxqG1Y24swMOrKAZUZzSl8ScXXWgCLcBGAs/s1600/araba.png", "ImgFit":"yes"}');
end;

begin
  b:= False;
  MyForm := TclGameForm.Create(Self);
  MyForm.AddGameAssetFromUrl('https://i.hizliresim.com/c4gxsvt.png');
  MyForm.AddGameAssetFromUrl('https://i.hizliresim.com/anhjtzn.png');
  
  
  rightbutton := MyForm.AddNewProButton(MyForm,'rightbutton','');
  clComponent.SetupComponent(rightbutton,'{"caption":" ", "MarginBottom":-700, "Width" :200,"MarginLeft":275, 
  "Height":70,"RoundHeight":2,
  "RoundWidth":2}');
  MyForm.SetImage(rightbutton,'https://i.hizliresim.com/rctnzmd.png'); 
  MyForm.AddNewEvent(rightbutton,tbeOnClick,'rightbuttonOnClick');
  
  
  
  leftbutton := MyForm.AddNewProButton(MyForm,'leftbutton','');
  clComponent.SetupComponent(leftbutton,'{"caption":" ",  "MarginBottom":-700,  "Width" :200,"MarginRight":300, 
  "Height":70,"RoundHeight":2,
  "RoundWidth":2}');
  MyForm.SetImage(leftbutton,'https://i.hizliresim.com/t73pt83.png'); 
  MyForm.AddNewEvent(leftbutton,tbeOnClick,'leftbuttonOnClick');
  
  Timer:= MyForm.AddNewTimer(MyForm,'timer',100);
  Timer.Enabled:= True;  
  MyForm.AddNewEvent(Timer,tbeOnTimer,'Proc1OnGameTimer');
  
  GameTimer:= MyForm.AddNewTimer(MyForm,'GameTimer',1000);
  GameTimer.Interval := 100;
  GameTimer.Enabled := True;
  MyForm.AddNewEvent(GameTimer,tbeOnTimer,'ProcOnGameTimer');
  
  GameTimer2:= MyForm.AddNewTimer(MyForm,'GameTimer2',1000);
  GameTimer2.Interval := 100;
  GameTimer2.Enabled := True;
  MyForm.AddNewEvent(GameTimer2,tbeOnTimer,'Proc2OnGameTimer');
  
  GameTimer1:= MyForm.AddNewTimer(MyForm,'GameTimer1',1000);
  GameTimer1.Interval := 100;
  GameTimer1.Enabled := True;
  MyForm.AddNewEvent(GameTimer1,tbeOnTimer,'Proc3OnGameTimer');
  
  GameTimer3:= MyForm.AddNewTimer(MyForm,'GameTimer3',1000);
  GameTimer3.Interval := 100;
  GameTimer3.Enabled := True;
  MyForm.AddNewEvent(GameTimer3,tbeOnTimer,'Proc4OnGameTimer');

  SetImage3;
  SetImage2;
  SetImage1;
  SetImage;
  MyForm.Run;
end;
Sınır kontrollerini yapmama rağmen engelde gelen arabalar bazen üst üste bazen ise yoldan çıkmış halde geliyor sebebi nedir acaba ?



Cevaplar:
Mesajı Yazan: Alforce
Mesaj Tarihi: 24 Ağustos 2023 Saat 11:24
Bu nasıl:

{Engel}
  intersect_x1:= max(araba.Left, engelimg.Left);
  intersect_y1:= max(araba.Top, engelimg.Top);
  intersect_x2:= min(araba.Left+araba.Width, engelimg.Left+engelimg.Width);
  intersect_y2:= min(araba.Top+araba.Height, engelimg.Top+engelimg.Height);
  intersect_area:= (intersect_x2 - intersect_x1) * (intersect_y2 - intersect_y1);
  
  b:= b or (intersect_area > 0) and (araba.Top < engelimg.Top+engelimg.Height) and (not (araba.Top + araba.Height < engelimg.Top));

  {/Engel}
  
  {Engel1}
  intersect_x1:= max(araba.Left, engel1img.Left);
  intersect_y1:= max(araba.Top, engel1img.Top);
  intersect_x2:= min(araba.Left+araba.Width, engel1img.Left+engel1img.Width);
  intersect_y2:= min(araba.Top+araba.Height, engel1img.Top+engel1img.Height);
  intersect_area:= (intersect_x2 - intersect_x1) * (intersect_y2 - intersect_y1);
  
  b:= b or (intersect_area > 0) and (araba.Top < engel1img.Top+engel1img.Height) and (not (araba.Top + araba.Height < engel1img.Top));
  {/Engel1}
  
  {Engel2}
  intersect_x1:= max(araba.Left, engel2img.Left);
  intersect_y1:= max(araba.Top, engel2img.Top);
  intersect_x2:= min(araba.Left+araba.Width, engel2img.Left+engel2img.Width);
  intersect_y2:= min(araba.Top+araba.Height, engel2img.Top+engel2img.Height);
  intersect_area:= (intersect_x2 - intersect_x1) * (intersect_y2 - intersect_y1);
   
  b:= b or (intersect_area > 0) and (araba.Top < engel2img.Top+engel2img.Height) and (not (araba.Top + araba.Height < engel2img.Top));
  {/Engel2}

150. satırdan sonraki mofiye.


Mesajı Yazan: ibrahimethem
Mesaj Tarihi: 24 Ağustos 2023 Saat 12:58
Değiştirmeme rağmen olmadı



Mesajı Yazan: Alforce
Mesaj Tarihi: 24 Ağustos 2023 Saat 17:20
Bu, bende düzgün bir şekilde çalışıyor.


Mesajı Yazan: ibrahimethem
Mesaj Tarihi: 24 Ağustos 2023 Saat 17:29
https://i.hizliresim.com/h1fhdfi.jpeg
Bende bu şekilde


Mesajı Yazan: Alforce
Mesaj Tarihi: 24 Ağustos 2023 Saat 17:47
Tamam, sanırım yanlış sorununu çözdüm.

Burda:
Var
  MyForm:TclGameForm;
  rightbutton, leftbutton : TClProButton;
  araba,engel1img,engelimg,engel2img: TClProImage;
  GameTimer,Timer,GameTimer1,GameTimer2,GameTimer3:TClTimer;
  b: Boolean;

Procedure Proc4OnGameTimer;
Const 
  engel2imgSpeed = -10;
begin
  engel2img.Align:= alNone; 
  engel2img.Top := engel2img.Top - engel2imgSpeed;//yukarı yön
  
  if (engel2img.Left + engel2img.Width) > TForm(MyForm).ClientWidth then  // sağ kenar kontrolü
    engel2img.Left := TForm(MyForm).ClientWidth - engel2img.Width;
  
  if (engel2img.Left) < 0 then // sol kenar kontrolü
    engel2img.Left := 0;
  
  if (engel2img.Top + engel2img.Height) > TForm(MyForm).ClientHeight then  // Alt sınır kontrolü
  begin
    engel2img.Top := TForm(MyForm).ClientHeight - engel2img.Height;
    engel2img.Top := 0;
  end;
  
  if engel2img then
    GameTimer.Enabled:= True;
end;

Procedure Proc2OnGameTimer;
Const 
  engel1imgSpeed= -10;
begin
  engel1img.Align := alNone; 
  engel1img.Top := engel1img.Top - engel1imgSpeed;//yukarı yön
  
  if (engel1img.Left + engel1img.Width) > TForm(MyForm).ClientWidth then  // sağ kenar kontrolü
    engel1img.Left := TForm(MyForm).ClientWidth - engel1img.Width;
  
  if (engel1img.Left) < 0 then // sol kenar kontrolü
    engel1img.Left := 0;
    
  if (engel1img.Top + engel1img.Height) > TForm(MyForm).ClientHeight then  // Alt sınır kontrolü
  begin
    engel1img.Top := TForm(MyForm).ClientHeight - engel1img.Height;
    engel1img.Top := 0;
  end;
  
  if engel1img then
    GameTimer.Enabled:= True;
end;

Procedure Proc3OnGameTimer;
Const 
  engelimgSpeed = -10;
begin
  engelimg.Align := alNone; 
  engelimg.Top := engelimg.Top - engelimgSpeed;//yukarı yön

  if (engelimg.Left + engelimg.Width) > TForm(MyForm).ClientWidth then  // sağ kenar kontrolü
    engelimg.Left := TForm(MyForm).ClientWidth - engelimg.Width;

  if (engelimg.Left) < 0 then // sol kenar kontrolü
    engelimg.Left := 0;

  if (engelimg.Top + engelimg.Height) > TForm(MyForm).ClientHeight then  // Alt sınır kontrolü
  begin
    engelimg.Top := TForm(MyForm).ClientHeight - engelimg.Height;
    engelimg.Top := 0;
  end;

  if engelimg then
    GameTimer.Enabled:= True;
end;

procedure SetImage3;
begin
  engel2img := MyForm.AddNewProImage(MyForm,'engel2img');
  clComponent.SetupComponent(engel2img,'{"Width":75, "Height":150, "Align":"None",
  "ImgUrl":"https://i.hizliresim.com/io5ymz8.png", "Left": 60, "Top": 0}');
end;

procedure SetImage2;
begin
  engel1img := MyForm.AddNewProImage(MyForm,'engel1img');
  clComponent.SetupComponent(engel1img,'{"Width":75, "Height":150, "Align":"None",
  "ImgUrl":"https://i.hizliresim.com/p1uujvb.png", "Left": 0, "Top": 30}');
end;

procedure SetImage1;
begin
  engelimg:= MyForm.AddNewProImage(MyForm,'engelimg');
  clComponent.SetupComponent(engelimg,'{"Width":75, "Height":150, "Align":"None",
  "ImgUrl":"https://i.hizliresim.com/rr72hin.png", "Left": 30, "Top": 10}');
end;

Function Max(in1,in2: Integer): Integer; begin

  if in1 >= in2 then
    Result:= in1
  else
    Result:= in2;
End;

Function Min(in1,in2: Integer): Integer; begin

  if in1 <= in2 then
    Result:= in1
  else
    Result:= in2;
End;

// Change background
Procedure Proc1OnGameTimer; begin

  if b then
    MyForm.SetFormBGImage('c4gxsvt.png')
  else
    MyForm.SetFormBGImage('anhjtzn.png');
  
  b:= not b;
End;

Procedure ProcOnGameTimer;
Const 
  arabaSpeed = 0;
Var
  intersect_area,intersect_x1, intersect_y1, intersect_x2, intersect_y2: Integer;
  b: Boolean;
begin
  araba.Top := araba.Top - arabaSpeed;//Yukarı yön
  
  if (araba.Left + araba.Width) > TForm(MyForm).ClientWidth then  // sağ kenar kontrolü
    araba.Left := TForm(MyForm).ClientWidth - araba.Width;
  
  if (araba.Left) < 0 then // sol kenar kontrolü
    araba.Left := 0;
  
  if (araba.Top + araba.Height) > TForm(MyForm).ClientHeight then  // alt sınıt  kontrolü
    araba.Top := TForm(MyForm).ClientHeight - araba.Height;
  
  if araba then
  GameTimer.Enabled := True;
  
  b:= False;
  
  {Engel}
  intersect_x1:= max(araba.Left, engelimg.Left);
  intersect_y1:= max(araba.Top, engelimg.Top);
  intersect_x2:= min(araba.Left+araba.Width, engelimg.Left+engelimg.Width);
  intersect_y2:= min(araba.Top+araba.Height, engelimg.Top+engelimg.Height);
  intersect_area:= (intersect_x2 - intersect_x1) * (intersect_y2 - intersect_y1);
  
  b:= b or (intersect_area > 0) and (araba.Top < engelimg.Top+engelimg.Height) and (not (araba.Top + araba.Height < engelimg.Top));

  {/Engel}
  
  {Engel1}
  intersect_x1:= max(araba.Left, engel1img.Left);
  intersect_y1:= max(araba.Top, engel1img.Top);
  intersect_x2:= min(araba.Left+araba.Width, engel1img.Left+engel1img.Width);
  intersect_y2:= min(araba.Top+araba.Height, engel1img.Top+engel1img.Height);
  intersect_area:= (intersect_x2 - intersect_x1) * (intersect_y2 - intersect_y1);
  
  b:= b or (intersect_area > 0) and (araba.Top < engel1img.Top+engel1img.Height) and (not (araba.Top + araba.Height < engel1img.Top));
  {/Engel1}
  
  {Engel2}
  intersect_x1:= max(araba.Left, engel2img.Left);
  intersect_y1:= max(araba.Top, engel2img.Top);
  intersect_x2:= min(araba.Left+araba.Width, engel2img.Left+engel2img.Width);
  intersect_y2:= min(araba.Top+araba.Height, engel2img.Top+engel2img.Height);
  intersect_area:= (intersect_x2 - intersect_x1) * (intersect_y2 - intersect_y1);
   
  b:= b or (intersect_area > 0) and (araba.Top < engel2img.Top+engel2img.Height) and (not (araba.Top + araba.Height < engel2img.Top));
  {/Engel2}
  
  
  if b then
  Begin
    ShowMessage('Engele dokunuldu');
    
    engelimg.Top:= clMath.generateRandom(-1000,100);
    engel1img.Top:= clMath.generateRandom(-1000,100);
    engel2img.Top:= clMath.generateRandom(-1000,100);
  End;
end; 

procedure rightbuttonOnClick;
Begin
  araba.Align := alNone;
  araba.Left:= araba.Left +25;
end;
 
procedure leftbuttonOnClick;
Begin
  araba.Align := alNone;
  araba.Left:= araba.Left -25;
end;

procedure SetImage;
begin
  araba := MyForm.AddNewProImage(MyForm,'araba');
  clComponent.SetupComponent(araba,'{"MarginBottom":-450,"Width" :75, "Height":150,
 "ImgUrl":"https://1.bp.blogspot.com/-eLqVU9iD9EM/WsoJrp3VRaI/AAAAAAAABjo/QH1WGuxqG1Y24swMOrKAZUZzSl8ScXXWgCLcBGAs/s1600/araba.png", "ImgFit":"yes"}');
end;

begin
  b:= False;
  MyForm := TclGameForm.Create(Self);
  MyForm.AddGameAssetFromUrl('https://i.hizliresim.com/c4gxsvt.png');
  MyForm.AddGameAssetFromUrl('https://i.hizliresim.com/anhjtzn.png');
  
  
  rightbutton := MyForm.AddNewProButton(MyForm,'rightbutton','');
  clComponent.SetupComponent(rightbutton,'{"caption":" ", "MarginBottom":-700, "Width" :200,"MarginLeft":275, 
  "Height":70,"RoundHeight":2,
  "RoundWidth":2}');
  MyForm.SetImage(rightbutton,'https://i.hizliresim.com/rctnzmd.png'); 
  MyForm.AddNewEvent(rightbutton,tbeOnClick,'rightbuttonOnClick');
  
  
  
  leftbutton := MyForm.AddNewProButton(MyForm,'leftbutton','');
  clComponent.SetupComponent(leftbutton,'{"caption":" ",  "MarginBottom":-700,  "Width" :200,"MarginRight":300, 
  "Height":70,"RoundHeight":2,
  "RoundWidth":2}');
  MyForm.SetImage(leftbutton,'https://i.hizliresim.com/t73pt83.png'); 
  MyForm.AddNewEvent(leftbutton,tbeOnClick,'leftbuttonOnClick');
  
  Timer:= MyForm.AddNewTimer(MyForm,'timer',100);
  Timer.Enabled:= True;  
  MyForm.AddNewEvent(Timer,tbeOnTimer,'Proc1OnGameTimer');
  
  GameTimer:= MyForm.AddNewTimer(MyForm,'GameTimer',1000);
  GameTimer.Interval := 100;
  GameTimer.Enabled := True;
  MyForm.AddNewEvent(GameTimer,tbeOnTimer,'ProcOnGameTimer');
  
  GameTimer2:= MyForm.AddNewTimer(MyForm,'GameTimer2',1000);
  GameTimer2.Interval := 100;
  GameTimer2.Enabled := True;
  MyForm.AddNewEvent(GameTimer2,tbeOnTimer,'Proc2OnGameTimer');
  
  GameTimer1:= MyForm.AddNewTimer(MyForm,'GameTimer1',1000);
  GameTimer1.Interval := 100;
  GameTimer1.Enabled := True;
  MyForm.AddNewEvent(GameTimer1,tbeOnTimer,'Proc3OnGameTimer');
  
  GameTimer3:= MyForm.AddNewTimer(MyForm,'GameTimer3',1000);
  GameTimer3.Interval := 100;
  GameTimer3.Enabled := True;
  MyForm.AddNewEvent(GameTimer3,tbeOnTimer,'Proc4OnGameTimer');

  SetImage3;
  SetImage2;
  SetImage1;
  SetImage;
  engelimg.Left:= 60;
  engel1img.Left:= 200;
  engel2img.Left:= 340;
  engelimg.Top:= clMath.generateRandom(-1000,100);
  engel1img.Top:= clMath.generateRandom(-1000,100);
  engel2img.Top:= clMath.generateRandom(-1000,100);
  MyForm.Run;
end;


Mesajı Yazan: ibrahimethem
Mesaj Tarihi: 24 Ağustos 2023 Saat 18:02
Bu şekilde kodu değiştirdiğiniz zaman engeller random şekilde değil sürekli aynı yerden geliyor bunu çözmem mümkün müdür?



Mesajı Yazan: Alforce
Mesaj Tarihi: 24 Ağustos 2023 Saat 18:09
Tabi, bunu yapabilirsiniz ama bütün engellerin üst üste gelmemesi için kontrol etmeniz gerekir.

Rastgele bir şerid yapmak için:
Engel.Left:= (clMath.generateRandom(0,3)*140)+60;

Bu kodu webde yazdım, biraz modifiye etmen gerekebilir.



Sayfayı Yazdır | Pencereyi Kapat

Forum Software by Web Wiz Forums® version 12.07 - https://www.webwizforums.com
Copyright ©2001-2024 Web Wiz Ltd. - https://www.webwiz.net