Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- unit Unit1;
- {$mode objfpc}{$H+}
- interface
- uses
- Classes, SysUtils, FileUtil, Forms, Controls, Graphics, Dialogs, StdCtrls,
- ExtCtrls;
- type
- { TForm1 }
- TForm1 = class(TForm)
- pwysokosc: TEdit;
- szerokosc: TLabel;
- pszerokosc: TEdit;
- wysokosc: TLabel;
- Zamknij: TButton;
- Generuj: TButton;
- tytul: TLabel;
- procedure FormCreate(Sender: TObject);
- procedure GenerujClick(Sender: TObject);
- procedure pwysokoscChange(Sender: TObject);
- procedure tytulClick(Sender: TObject);
- procedure ZamknijClick(Sender: TObject);
- procedure cegla(x : integer; y : integer; z : integer);
- private
- { private declarations }
- public
- { public declarations }
- end;
- var
- Form1: TForm1;
- implementation
- {$R *.lfm}
- { TForm1 }
- procedure TForm1.FormCreate(Sender: TObject);
- begin
- end;
- procedure TForm1.cegla(x : integer; y : integer; z : integer);
- var brick : TFileName;
- Image1: TImage;
- begin
- Image1:=Timage.Create(self);
- with TImage.Create(self) do begin
- if(z <> 1) then
- begin
- brick := '33.png';
- Width:=40;
- end
- else
- begin
- brick := '22.png';
- Width:=60;
- end;
- Height:=20;
- Left:=x;
- Picture.LoadFromFile(brick);
- Top:=y;
- Parent:=self;
- Visible:=True;
- end;
- Image1.Free;
- end;
- procedure TForm1.GenerujClick(Sender: TObject);
- var i : integer;
- brickxxx : TFileName;
- iszerokosc: integer;
- iwysokosc: integer;
- x: integer;
- y: integer;
- t: integer;
- begin
- iszerokosc:=strtoint(pszerokosc.Text);
- iwysokosc:=strtoint(pwysokosc.Text);
- if(iszerokosc < 5 ) or (iwysokosc < 1) then
- begin
- ShowMessage('Nieprawidlowe dane! '+#13+'Proszę wprowadzić poprawną szerokość i wysokość.');
- end
- else
- begin
- y:= 200;
- x:= 0;
- for t:= 1 to iwysokosc do
- begin
- if(iszerokosc mod 2 = 0) then
- begin
- for i:= 0 to (iszerokosc div 2)-1 do
- begin cegla(x,y,0);x+=40; end;
- x:=0;
- y:= y + 20;
- cegla(x,y,1);
- x:=x+60;
- for i:= 1 to (iszerokosc div 2)-3 do
- begin cegla(x,y,0); x+=40; end;
- cegla(x,y,1);
- end
- else
- begin
- for i:= 0 to iszerokosc-4 do
- begin cegla(x,y,0);x+=40; end;
- cegla(x,y,1);
- x:=0;
- y:= y + 20;
- cegla(x,y,1);
- x:=x+60;
- for i:= 1 to iszerokosc-3 do
- begin cegla(x,y,0); x+=40; end;
- end;
- x:=0;
- y:=y+20;
- end;
- end;
- end;
- procedure TForm1.ZamknijClick(Sender: TObject);
- begin
- close;
- end;
- end.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement