Programalama > DELPHI

Etiketler: yilan, oyunu

Ort. 0
Puan ver:
unit Unit1;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, ExtCtrls, StdCtrls, jpeg;

type
  TForm1 = class(TForm)
    Image1: TImage;
    Timer1: TTimer;
    Timer2: TTimer;
    Timer3: TTimer;
    Timer4: TTimer;
    Timer5: TTimer;
    Edit1: TEdit;
    Edit2: TEdit;
    Edit3: TEdit;
    Button1: TButton;
    Edit4: TEdit;
    procedure FormCreate(Sender: TObject);
    procedure Timer1Timer(Sender: TObject);
    procedure Timer2Timer(Sender: TObject);
    procedure Timer3Timer(Sender: TObject);
    procedure Timer4Timer(Sender: TObject);
    procedure FormKeyDown(Sender: TObject; var Key: Word;
      Shift: TShiftState);
    procedure Timer5Timer(Sender: TObject);
    procedure FormClose(Sender: TObject; var Action: TCloseAction);
    procedure Button1Click(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  Form1: TForm1;

implementation

{$R *.dfm}

procedure TForm1.FormCreate(Sender: TObject);
begin
canvas.MoveTo(250,250);
canvas.Pen.Width:=canvas.Pen.Width+5;
button1.Click;
timer1.Enabled:=true;
end;

procedure TForm1.Timer1Timer(Sender: TObject);
var
x,y :integeR;
begin
x:=canvas.PenPos.X;
y:=canvas.PenPos.Y;
form1.Refresh;
canvas.LineTo(x+StrToInt(edit1.Text),y);
end;

procedure TForm1.Timer2Timer(Sender: TObject);
var
x,y :integeR;
begin
x:=canvas.PenPos.X;
y:=canvas.PenPos.Y;
form1.Refresh;
canvas.LineTo(x-StrToInt(edit1.Text),y);

end;

procedure TForm1.Timer3Timer(Sender: TObject);
var
x,y :integeR;
begin
x:=canvas.PenPos.X;
y:=canvas.PenPos.Y;
form1.Refresh;
canvas.LineTo(x,y-StrToInt(edit1.Text));
end;


procedure TForm1.Timer4Timer(Sender: TObject);
var
x,y :integeR;
begin
x:=canvas.PenPos.X;
y:=canvas.PenPos.Y;
form1.Refresh;
canvas.LineTo(x,y+StrToInt(edit1.Text));
end;


procedure TForm1.FormKeyDown(Sender: TObject; var Key: Word;
  Shift: TShiftState);
begin
if key= vk_left then
begin
if not (timer1.Enabled = true) then
begin
timer1.Enabled:=false;
timer2.Enabled:=true;
timer3.Enabled:=false;
timer4.Enabled:=false;
end;
end;
if key= vk_right then
begin
if not (timer2.Enabled = true) then
begin
timer1.Enabled:=true;
timer2.Enabled:=false;
timer3.Enabled:=false;
timer4.Enabled:=false;
end;
end;
if key= vk_up then
begin
if not (timer4.Enabled = true) then
begin
timer1.Enabled:=false;
timer2.Enabled:=false;
timer3.Enabled:=true;
timer4.Enabled:=false;
end;
end;
if key= vk_down then
begin
if not (timer3.Enabled = true) then
begin
timer1.Enabled:=false;
timer2.Enabled:=false;
timer3.Enabled:=false;
timer4.Enabled:=true;
end;
end;
if (ssalt in shift) and (key = vk_f5) then
begin
canvas.MoveTo(image1.Left+10,image1.Top+50);
timer1.Enabled:=false;
timer2.Enabled:=false;
timer3.Enabled:=true;
timer4.Enabled:=false;
end;
if (ssalt in shift) and (key = vk_f3) then
begin
button1.Click;
end;
end;


procedure TForm1.Timer5Timer(Sender: TObject);
var
x,y:integer;
begin
x:=canvas.PenPos.X;
y:=canvas.PenPos.Y;
if x<0 then
canvas.MoveTo(form1.Width,y);
if y<0 then
canvas.MoveTo(x,form1.Height);
if x>form1.Width then
canvas.MoveTo(0,y);
if y>form1.Height then
canvas.MoveTo(x,0);
if (X>image1.Left) and (x<image1.Left+image1.Width) and (y>image1.Top) and (y<image1.Top+image1.Height) then
begin
button1.Click;
edit4.Text:=Inttostr(StrToInt(edit4.Text)+1)
end;
end;



procedure TForm1.FormClose(Sender: TObject; var Action: TCloseAction);
begin
showmessage(edit4.Text+' Yem yediniz');
end;

procedure TForm1.Button1Click(Sender: TObject);
begin
image1.Left:=random(form1.Width);
image1.Top:=random(form1.Height);
edit1.Text:=Inttostr(StrToInt(edit1.Text)+2);
timer1.Interval:=timer1.Interval+1;
timer2.Interval:=timer2.Interval+1;
timer3.Interval:=timer3.Interval+1;
timer4.Interval:=timer4.Interval+1;
end;

end.


Yorumlar                 Yorum Yaz
srkn (3) Sakıncalı Yorum 13 September 19:31
Hocam kodlarda sıkıntı yok fakat hangi nesneleri ekleyeceğiz, kod bölümüğne baktığımızda 5 tane Timer , + tane Edit 1 tanede Buton gözüküyo fakat programı çalıştırdığımızda hiç bi işlev yok
KATEGORİLER
ASP - 240
ASP.NET - 24
C# - 75
C++ - 174
CGI - 8
DELPHI - 247
FLASH - 49
HTML - 536
PASCAL - 246
PERL - 11
PHP - 160
WML - 9
XML - 2
Copyright © 2002 - 2024 Hazır Kod - Tüm Hakları Saklıdır.
Siteden yararlanırken gizlilik ilkelerini okumanızı tavsiye ederiz.
hazirkod.com bir İSOBİL projesidir.