PRAKTIKUM BORLAND DELPHI 2010 GAMES (BY BSI)

//*Coding Games By Lhourens.R.L*//
//*BSI *//
//*Target Shape,Timer,ProgressBar*//

------------------------------------------------------------------------------------------------

unit Tugas_13090318;

interface

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

type
  TForm1 = class(TForm)
    Timer1: TTimer;
    Panel2: TPanel;
    Shape2: TShape;
    Timer2: TTimer;
    ProgressBar2: TProgressBar;
    Panel1: TPanel;
    Shape1: TShape;
    ProgressBar1: TProgressBar;
    Timer3: TTimer;
    procedure FormKeyDown(Sender: TObject; var Key: Word; Shift: TShiftState);
    procedure Timer1Timer(Sender: TObject);
    procedure Timer2Timer(Sender: TObject);
    procedure FormActivate(Sender: TObject);
    procedure Timer3Timer(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  Form1: TForm1;
  Kanan,kiri,atas,bawah,Knn,kr,ats,bwh : Boolean;
implementation

{$R *.dfm}

procedure TForm1.FormActivate(Sender: TObject);
begin
Timer2.Enabled:=true;
end;

procedure TForm1.FormKeyDown(Sender: TObject; var Key: Word;
  Shift: TShiftState);
begin
If Key = 37 Then
  Begin
  atas :=false;
  bawah:=false;
  kiri:=true;
  kanan:=false;
  End;
If Key = 38 Then
  Begin
   atas:=true;
   bawah:=false;
   kiri:=false;
   kanan:=false;
   end;
If Key = 39 Then
  Begin
  atas:=false;
  bawah:=false;
  kanan:=true;
  kiri:=false;
  End;

  If Key = 40 Then
  Begin
  atas:=false;
  bawah:=true;
  kiri:=false;
  kanan:=false;
  End;

 //Batas...Shape1

end;

procedure TForm1.Timer1Timer(Sender: TObject);
begin
If atas = true then
  Begin
  Shape1.Top:=Shape1.Top - 5;
  If Shape1.Top <= 0 then
  Begin
    atas:=false;
    bawah:=true;
    kanan:=false;
    kiri:=false;
    end;
 End
Else If bawah = true then
begin
  shape1.Top :=shape1.Top + 5;
  If Shape1.Top + Shape1.Height >= Panel1.ClientHeight Then
     Begin
     atas:=True;
     bawah:=false;
     kanan:=false;
     kiri:=false;
     end;
  End

Else If kiri = true then
  Begin
  shape1.Left := shape1.left - 5;
  If Shape1.Left <= 0 Then
     Begin
       atas:=false;
       bawah:=false;
       kanan:=true;
       kiri:=false;
       End;
   End

Else if kanan = true then
  Begin
  shape1.left :=shape1.left + 5;
  If Shape1.left + Shape1.Width >= Panel1.ClientWidth Then
     Begin
      atas:=false;
      bawah:=false;
      kanan:=false;
      kiri:=True;
      End;
  End;


end;

procedure TForm1.Timer2Timer(Sender: TObject);
begin
ProgressBar1.Position:=ProgressBar1.Position + 1;
  If ProgressBar1.Position = 100 Then
     Begin
      ProgressBar1.Position:=ProgressBar1.Position - 100;
      Shape1.Refresh;
      End;
  //batas ProgressBar

ProgressBar2.Position:=ProgressBar2.Position + 1;
  If ProgressBar2.Position = 100 Then
     Begin
      ProgressBar2.Position:=ProgressBar2.Position - 100;
      Shape2.Refresh;
      End;

end;

procedure TForm1.Timer3Timer(Sender: TObject);
begin
If atas = true then
  Begin
  Shape2.Top:=Shape2.Top + 5;
  If Shape2.Top <= 0 then
  Begin
    atas:=false;
    bawah:=true;
    kanan:=false;
    kiri:=false;
    end;
 End
Else If bawah = true then
begin
  shape2.Top :=shape2.Top - 5;
  If Shape2.Top + Shape2.Height >= Panel2.ClientHeight then
     Begin
     atas:=True;
     bawah:=false;
     kanan:=false;
     kiri:=false;
     end;
  End

Else If kiri = true then
  Begin
  shape2.Left := shape2.left + 5;
  If Shape2.Left <= 0 Then
     Begin
       atas:=false;
       bawah:=false;
       kanan:=true;
       kiri:=false;
       End;
   End

Else if kanan = true then
  Begin
  shape2.left :=shape2.left - 5;
  If Shape2.left + Shape2.Width >= Panel2.ClientWidth Then
     Begin
      atas:=false;
      bawah:=false;
      kanan:=false;
      kiri:=True;
      End;
  End;

end;

end.











Screen Shut Program :





Silahkan Download Project Games||Tugas_delphi_2010_LabE||


Sekian dan Terima Kasih.....Sobat BSI....

Komentar

Postingan populer dari blog ini

SOURCE CODING MP3 PALYER by Lhourens

WebCam Sederhana Menggunakan Pemrograman Delphi

Membuat Aplikasi Database Delphi Berbasis Cloud Database