WWW.MERAIHMIMPI3.BLOGSPOT.COM. Diberdayakan oleh Blogger.
RSS

MEMBUAT GAME SEDERHANA MENGGUNAKAN DELPHI

Program Games Sederhana Delphi
Halo sahabat bringinfo , udah bosan bikin program dekstop atau hitung menghitung pake delphi??? Oke sekarang saatnya menyuguhka tutorial cara membuat program game sederhana menggunakan delphi,,,
Game ini sangat lucu atau cupu yaa?? langsung saja ke KTP eh salah ke TKP,,(heheheee). Game ini terdiri dari empat tombol jebakan, lho!! hati-hati yaaa,,, untuk lebih jelasnya lihat form dibawah ini untuk memulai bikin programnya,,,,





Dan seperti biasa dalam tutorial delphi di bringinfo ini hanya memberikan screenshot program dan listingnya,, jika sahabat ingin bertanya, silahkan berkomentar ria,,,,,, Dan listingnya,,,,,,
unit untGames;

interface

uses
...

type
TForm1 = class(TForm)
...
procedure Selesai;
procedure btnStartClick(Sender: TObject);
procedure Timer1Timer(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 Timer2Timer(Sender: TObject);
procedure Timer3Timer(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
Timer1.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;

Timer1.Enabled := True;
btn1.Enabled := True;
btn2.Enabled := True;
btn3.Enabled := True;
btn4.Enabled := True;
lblScore.Caption := '0';
end;

procedure TForm1.Timer1Timer(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 btn3.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 := 'Not Lucky ' + edtName.Text;

btnStart.SetFocus;
end;
end;

procedure TForm1.Timer2Timer(Sender: TObject);
begin
Blink := not Blink;
if Blink then
lblBravo.Font.Color := clRed
else
lblBravo.Font.Color := clBlue;
end;

procedure TForm1.Timer3Timer(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('Are You Sure To Quit From This Program?',
'Confirmation', MB_YESNO + MB_ICONQUESTION);
if Tanya = 6 then
begin
Application.MessageBox('Thanx So Much... For Using This Program'
, 'Byee. .
Byee..', MB_OK + MB_ICONINFORMATION);
Application.Terminate;
end;
end;

end.
  • Digg
  • Del.icio.us
  • StumbleUpon
  • Reddit
  • RSS

0 komentar:

Posting Komentar