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.Position.Y := engel2img.Position.Y - engel2imgSpeed;//Move up if (engel2img.Position.X + engel2img.Width) > TForm(MyForm).ClientWidth then // Form Right border control engel2img.Position.X := TForm(MyForm).ClientWidth - engel2img.Width; if (engel2img.Position.X) < 0 then // Left border control engel2img.Position.X := 0;
if (engel2img.Position.Y + engel2img.Height) > TForm(MyForm).ClientHeight then // Form Bottom border control begin engel2img.Position.Y := TForm(MyForm).ClientHeight - engel2img.Height; engel2img.Position.Y := 0; engel2img.Position.X:= clMath.generateRandom(150,250); end; if engel2img then GameTimer.Enabled := True; end; Procedure Proc2OnGameTimer; Const engel1imgSpeed= -10; begin engel1img.Align := alNone; engel1img.Position.Y := engel1img.Position.Y - engel1imgSpeed;//Move up if (engel1img.Position.X + engel1img.Width) > TForm(MyForm).ClientWidth then // Form Right border control engel1img.Position.X := TForm(MyForm).ClientWidth - engel1img.Width; if (engel1img.Position.X) < 0 then // Left border control engel1img.Position.X := 0;
if (engel1img.Position.Y + engel1img.Height) > TForm(MyForm).ClientHeight then // Form Bottom border control begin engel1img.Position.Y := TForm(MyForm).ClientHeight - engel1img.Height; engel1img.Position.Y := 0; engel1img.Position.X:= clMath.generateRandom(50,150); end; if engel1img then GameTimer.Enabled := True; end; Procedure Proc3OnGameTimer; Const engelimgSpeed = -10; begin engelimg.Align := alNone; engelimg.Position.Y := engelimg.Position.Y - engelimgSpeed;//Move up if (engelimg.Position.X + engelimg.Width) > TForm(MyForm).ClientWidth then // Form Right border control engelimg.Position.X := TForm(MyForm).ClientWidth - engelimg.Width; if (engelimg.Position.X) < 0 then // Left border control engelimg.Position.X := 0;
if (engelimg.Position.Y + engelimg.Height) > TForm(MyForm).ClientHeight then // Form Bottom border control begin engelimg.Position.Y := TForm(MyForm).ClientHeight - engelimg.Height; engelimg.Position.Y := 0; engelimg.Position.X:= clMath.generateRandom(0,100); end; if engelimg then GameTimer.Enabled := True; end;
procedure SetImage3; begin engel2img := MyForm.AddNewProImage(MyForm,'engel2img'); clComponent.SetupComponent(engel2img,'{"MarginBottom":600,"Width" :150, "MarginLeft":250, "Height":150,"RoundHeight":10,"RoundWidth":10, "ImgUrl":"https://i.hizliresim.com/io5ymz8.png", "ImgFit":"yes"}'); end; procedure SetImage2; begin engel1img := MyForm.AddNewProImage(MyForm,'engel1img'); clComponent.SetupComponent(engel1img,'{"MarginBottom":300,"Width" :150, "MarginRight":250, "Height":150,"RoundHeight":10,"RoundWidth":10, "ImgUrl":"https://i.hizliresim.com/dbtk62n.png", "ImgFit":"yes"}'); end; procedure SetImage1; begin engelimg := MyForm.AddNewProImage(MyForm,'engelimg'); clComponent.SetupComponent(engelimg,'{"MarginBottom":-50,"Width" :150, "MarginLeft":250, "Height":150,"RoundHeight":10,"RoundWidth":10, "ImgUrl":"https://i.hizliresim.com/8lnv0rh.png", "ImgFit":"yes"}'); end;
Procedure Proc1OnGameTimer; begin if b then MyForm.SetFormBGImage('c4gxsvt.png') else MyForm.SetFormBGImage('anhjtzn.png'); b:= not b; End;
Procedure ProcOnGameTimer; Const testImgSpeed = 0; begin testImg.Position.Y := testImg.Position.Y - testImgSpeed;//Move up if (testImg.Position.X + testImg.Width) > TForm(MyForm).ClientWidth then // Form Right border control testImg.Position.X := TForm(MyForm).ClientWidth - testImg.Width; if (testImg.Position.X) < 0 then // Left border control testImg.Position.X := 0;
if (testImg.Position.Y + testImg.Height) > TForm(MyForm).ClientHeight then // Form Bottom border control testImg.Position.Y := TForm(MyForm).ClientHeight - testImg.Height; if testImg then GameTimer.Enabled := True; end;
procedure rightbuttonOnClick; begin testImg.Align := alNone; testImg.Position.X := testImg.Position.X + 25; end; procedure leftbuttonOnClick; begin testImg.Align := alNone; testImg.Position.X := testImg.Position.X - 25; end;
procedure SetImage; begin testImg := MyForm.AddNewProImage(MyForm,'testImg'); clComponent.SetupComponent(testImg,'{"MarginBottom":-450,"Width" :150, "Height":150,"RoundHeight":10,"RoundWidth":10, "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;
Kodum şu şekilde attığınız kodu engelin içinde de denedim ayrı olarak ana arabam olan (testimg) içinde de denedim oyun ekranı açılmasına rağmen kod devreye girmiyor. Ayrı bir yere yapıştırdığımda ise direkt olarak hata alıyorum sebebi nedir sizce ?
|