Var
MyForm:TclGameForm;
rightbutton, leftbutton : TClProButton;
testImg,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;//Move up
if (engel2img.Left + engel2img.Width) > TForm(MyForm).ClientWidth then // Form Right border control
engel2img.Left := TForm(MyForm).ClientWidth - engel2img.Width;
if (engel2img.Left) < 0 then // Left border control
engel2img.Left := 0;
if (engel2img.Top + engel2img.Height) > TForm(MyForm).ClientHeight then // Form Bottom border control
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;//Move up
if (engel1img.Left + engel1img.Width) > TForm(MyForm).ClientWidth then // Form Right border control
engel1img.Left := TForm(MyForm).ClientWidth - engel1img.Width;
if (engel1img.Left) < 0 then // Left border control
engel1img.Left := 0;
if (engel1img.Top + engel1img.Height) > TForm(MyForm).ClientHeight then // Form Bottom border control
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;//Move up
if (engelimg.Left + engelimg.Width) > TForm(MyForm).ClientWidth then // Form Right border control
engelimg.Left := TForm(MyForm).ClientWidth - engelimg.Width;
if (engelimg.Left) < 0 then // Left border control
engelimg.Left := 0;
if (engelimg.Top + engelimg.Height) > TForm(MyForm).ClientHeight then // Form Bottom border control
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
testImgSpeed = 0;
Var
intersect_area,intersect_x1, intersect_y1, intersect_x2, intersect_y2: Integer;
b: Boolean;
begin
testImg.Top := testImg.Top - testImgSpeed;//Move up
if (testImg.Left + testImg.Width) > TForm(MyForm).ClientWidth then // Form Right border control
testImg.Left := TForm(MyForm).ClientWidth - testImg.Width;
if (testImg.Left) < 0 then // Left border control
testImg.Left := 0;
if (testImg.Top + testImg.Height) > TForm(MyForm).ClientHeight then // Form Bottom border control
testImg.Top := TForm(MyForm).ClientHeight - testImg.Height;
if testImg then
GameTimer.Enabled := True;
b:= False;
{Engel}
intersect_x1:= max(testImg.Left, engelimg.Left);
intersect_y1:= max(testImg.Top, engelimg.Top);
intersect_x2:= min(testImg.Left+testImg.Width, engelimg.Left+engelimg.Width);
intersect_y2:= min(testImg.Top+testImg.Height, engelimg.Top+engelimg.Height);
intersect_area:= (intersect_x2 - intersect_x1) * (intersect_y2 - intersect_y1);
b:= b or (intersect_area > 0) and (testImg.Top < engelimg.Top+engelimg.Height);
{/Engel}
{Engel1}
intersect_x1:= max(testImg.Left, engel1img.Left);
intersect_y1:= max(testImg.Top, engel1img.Top);
intersect_x2:= min(testImg.Left+testImg.Width, engel1img.Left+engel1img.Width);
intersect_y2:= min(testImg.Top+testImg.Height, engel1img.Top+engel1img.Height);
intersect_area:= (intersect_x2 - intersect_x1) * (intersect_y2 - intersect_y1);
b:= b or (intersect_area > 0) and (testImg.Top < engel1img.Top+engel1img.Height);
{/Engel1}
{Engel2}
intersect_x1:= max(testImg.Left, engel2img.Left);
intersect_y1:= max(testImg.Top, engel2img.Top);
intersect_x2:= min(testImg.Left+testImg.Width, engel2img.Left+engel2img.Width);
intersect_y2:= min(testImg.Top+testImg.Height, engel2img.Top+engel2img.Height);
intersect_area:= (intersect_x2 - intersect_x1) * (intersect_y2 - intersect_y1);
b:= b or (intersect_area > 0) and (testImg.Top < engel2img.Top+engel2img.Height);
{/Engel2}
if b then
Begin
ShowMessage('Engele dokanıldı');
engelimg.Top:= 1;
engel1img.Top:= 1;
engel2img.Top:= 1;
End;
end;
procedure rightbuttonOnClick;
Begin
testImg.Align := alNone;
testImg.Left:= testImg.Left +25;
end;
procedure leftbuttonOnClick;
Begin
testImg.Align := alNone;
testImg.Left:= testImg.Left -25;
end;
procedure SetImage;
begin
testImg := MyForm.AddNewProImage(MyForm,'testImg');
clComponent.SetupComponent(testImg,'{"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;