Minggu, 29 April 2012
GAME DELPHI
LISTINGNYA
unit samurai;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, ExtCtrls, StdCtrls, jpeg;
type
TForm1 = class(TForm)
lbl1: TLabel;
lblclick: TLabel;
lblBravo: TLabel;
lblscore: TLabel;
btnstart: TButton;
btnexit: TButton;
btn1: TButton;
btn2: TButton;
btn3: TButton;
btn4: TButton;
lbl5: TLabel;
edtname: TEdit;
tmr1: TTimer;
tmr2: TTimer;
tmr3: TTimer;
img1: TImage;
procedure Selesai;
procedure btnstartClick(Sender: TObject);
procedure tmr1Timer(Sender: TObject);
procedure btn1Click(Sender: TObject);
procedure btn2Click(Sender: TObject);
procedure btn3Click(Sender: TObject);
procedure btn4Click(Sender: TObject);
procedure edtnameKeyPress(Sender: TObject; var Key: Char);
procedure tmr2Timer(Sender: TObject);
procedure tmr3Timer(Sender: TObject);
procedure btnexitClick(Sender: TObject);
private
{ Private declarations }
public
Tukar, Score, Tanya : Integer;
Blink : Boolean;
{ Public declarations }
end;
var
Form1: TForm1;
implementation
{$R *.dfm}
procedure TForm1.Selesai;
begin
Tmr1.Enabled := False;
btn1.Enabled := False;
btn2.Enabled := False;
btn3.Enabled := False;
btn4.Enabled := False;
edtName.Enabled := True;
edtName.SetFocus;
lblClick.Visible := False;
end;
procedure TForm1.btnstartClick(Sender: TObject);
begin
Score := 0;
Tukar := 0;
lblClick.Visible := True;
lblClick.Left := 16;
lblBravo.Caption := '';
lblBravo.Visible := False;
edtName.Enabled := False;
edtName.Clear;
Tmr1.Enabled := True;
btn1.Enabled := True;
btn2.Enabled := True;
btn3.Enabled := True;
btn4.Enabled := True;
lblScore.Caption := '0';
end;
procedure TForm1.tmr1Timer(Sender: TObject);
var
CapTmp : String;
begin
CapTmp := btn1.Caption;
btn1.Caption := btn2.Caption;
btn2.Caption := btn3.Caption;
btn3.caption := btn4.Caption;
btn4.Caption := CapTmp;
Inc(Tukar);
if Tukar > 16 then
Selesai;
end;
procedure TForm1.btn1Click(Sender: TObject);
begin
if btn1.Caption = 'x' then
Score := Score + 10
else
Score := Score - 5;
lblScore.Caption := IntToStr(Score);
end;
procedure TForm1.btn2Click(Sender: TObject);
begin
if btn2.Caption = 'x' then
Score := Score + 10
else
Score := Score - 5;
lblScore.Caption := IntToStr(Score);
end;
procedure TForm1.btn3Click(Sender: TObject);
begin
if btn2.Caption = 'x' then
Score := Score + 10
else
Score := Score - 5;
lblScore.Caption := IntToStr(Score);
end;
procedure TForm1.btn4Click(Sender: TObject);
begin
if btn4.Caption = 'x' then
Score := Score + 10
else
Score := Score - 5;
lblScore.Caption := IntToStr(Score);
end;
procedure TForm1.edtnameKeyPress(Sender: TObject; var Key: Char);
begin
if Key = #13 then
begin
lblBravo.Visible := True;
if Score >= 50 then
lblBravo.Caption := 'Bravooo... ' + edtName.Text
else
lblBravo.Caption := 'AAAHH OON ' + edtName.Text;
btnStart.SetFocus;
end;
end;
procedure TForm1.tmr2Timer(Sender: TObject);
begin
Blink := not Blink;
if Blink then
lblBravo.Font.Color := clRed
else
lblBravo.Font.Color := clBlue;
end;
procedure TForm1.tmr3Timer(Sender: TObject);
begin
if lblClick.Left <= 230 then
lblClick.Left := lblClick.Left + 1
else
lblClick.Left := 0;
end;
procedure TForm1.btnexitClick(Sender: TObject);
begin
Tanya := Application.MessageBox('YAKIN LOE KELUAR?',
'Confirmation', MB_YESNO + MB_ICONQUESTION);
if Tanya = 6 then
begin
Application.MessageBox('MAKASIH... !'
, 'Daaa ...Daaaaahhh...', MB_OK + MB_ICONINFORMATION);
Application.Terminate;
end;
end;
end.
Langganan:
Posting Komentar (Atom)
Tidak ada komentar:
Posting Komentar