Advertisement
Guest User

Untitled

a guest
Dec 27th, 2013
148
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Delphi 2.53 KB | None | 0 0
  1. unit Unit1;
  2.  
  3. {$mode objfpc}{$H+}
  4.  
  5. interface
  6.  
  7. uses
  8.   Classes, SysUtils, FileUtil, Forms, Controls, Graphics, Dialogs, StdCtrls,
  9.   ExtCtrls;
  10.  
  11. type
  12.  
  13.   { TForm1 }
  14.  
  15.   TForm1 = class(TForm)
  16.     pwysokosc: TEdit;
  17.     szerokosc: TLabel;
  18.     pszerokosc: TEdit;
  19.     wysokosc: TLabel;
  20.     Zamknij: TButton;
  21.     Generuj: TButton;
  22.     tytul: TLabel;
  23.     procedure FormCreate(Sender: TObject);
  24.     procedure GenerujClick(Sender: TObject);
  25.  
  26.     procedure pwysokoscChange(Sender: TObject);
  27.     procedure tytulClick(Sender: TObject);
  28.     procedure ZamknijClick(Sender: TObject);
  29.     procedure cegla(x : integer; y : integer; z : integer);
  30.   private
  31.     { private declarations }
  32.   public
  33.     { public declarations }
  34.  
  35.   end;
  36.  
  37. var
  38.   Form1: TForm1;
  39.  
  40. implementation
  41.  
  42. {$R *.lfm}
  43.  
  44. { TForm1 }
  45.  
  46. procedure TForm1.FormCreate(Sender: TObject);
  47. begin
  48.  
  49. end;
  50.  
  51. procedure TForm1.cegla(x : integer; y : integer; z : integer);
  52. var brick : TFileName;
  53.    Image1: TImage;
  54.  
  55. begin
  56.   Image1:=Timage.Create(self);
  57.    with TImage.Create(self) do begin
  58.    if(z <> 1) then
  59.   begin
  60.   brick := '33.png';
  61.   Width:=40;
  62.   end
  63.   else
  64.   begin
  65.   brick := '22.png';
  66.   Width:=60;
  67.   end;
  68.   Height:=20;
  69.   Left:=x;
  70.   Picture.LoadFromFile(brick);
  71.   Top:=y;
  72.   Parent:=self;
  73.   Visible:=True;
  74.   end;
  75.    Image1.Free;
  76. end;
  77.  
  78. procedure TForm1.GenerujClick(Sender: TObject);
  79.    var i : integer;
  80.  
  81.       brickxxx : TFileName;
  82.       iszerokosc: integer;
  83.       iwysokosc: integer;
  84.       x: integer;
  85.       y: integer;
  86.       t: integer;
  87. begin
  88.   iszerokosc:=strtoint(pszerokosc.Text);
  89.   iwysokosc:=strtoint(pwysokosc.Text);
  90.   if(iszerokosc < 5 ) or (iwysokosc < 1) then
  91.   begin
  92.   ShowMessage('Nieprawidlowe dane! '+#13+'Proszę wprowadzić poprawną szerokość i wysokość.');
  93.   end
  94.   else
  95.   begin
  96.   y:= 200;
  97.   x:= 0;
  98.   for t:= 1 to iwysokosc do
  99.   begin
  100.   if(iszerokosc mod 2 = 0) then
  101.      begin
  102.       for i:= 0 to (iszerokosc div 2)-1 do
  103.       begin cegla(x,y,0);x+=40;  end;
  104.       x:=0;
  105.       y:= y + 20;
  106.       cegla(x,y,1);
  107.       x:=x+60;
  108.       for i:= 1 to (iszerokosc div 2)-3 do
  109.       begin cegla(x,y,0); x+=40; end;
  110.       cegla(x,y,1);
  111.       end
  112.   else
  113.       begin
  114.       for i:= 0 to iszerokosc-4 do
  115.       begin cegla(x,y,0);x+=40;  end;
  116.       cegla(x,y,1);
  117.       x:=0;
  118.       y:= y + 20;
  119.       cegla(x,y,1);
  120.       x:=x+60;
  121.       for i:= 1 to iszerokosc-3 do
  122.       begin cegla(x,y,0); x+=40; end;
  123.       end;
  124.    x:=0;
  125.    y:=y+20;
  126.    end;
  127. end;
  128.  
  129. end;
  130.  
  131. procedure TForm1.ZamknijClick(Sender: TObject);
  132. begin
  133.   close;
  134. end;
  135.  
  136. end.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement