Blame lazarus/pixel-art/stars/unit1.pas
|
|
c0c0da |
unit Unit1;
|
|
|
c0c0da |
|
|
|
c0c0da |
{$mode objfpc}{$H+}
|
|
|
c0c0da |
|
|
|
c0c0da |
interface
|
|
|
c0c0da |
|
|
|
c0c0da |
uses
|
|
|
c0c0da |
Classes, SysUtils, FileUtil, Forms, Controls, Graphics, Dialogs, ExtCtrls,
|
|
|
c0c0da |
Math;
|
|
|
c0c0da |
|
|
|
c0c0da |
type
|
|
|
c0c0da |
|
|
|
c0c0da |
{ TForm1 }
|
|
|
c0c0da |
|
|
|
c0c0da |
TForm1 = class(TForm)
|
|
|
c0c0da |
Timer1: TTimer;
|
|
|
c0c0da |
procedure FormCreate(Sender: TObject);
|
|
|
c0c0da |
procedure FormPaint(Sender: TObject);
|
|
|
c0c0da |
procedure Timer1Timer(Sender: TObject);
|
|
|
c0c0da |
private
|
|
|
c0c0da |
{ private declarations }
|
|
|
c0c0da |
public
|
|
|
c0c0da |
{ public declarations }
|
|
|
c0c0da |
end;
|
|
|
c0c0da |
|
|
|
c0c0da |
const
|
|
|
c0c0da |
starsCount = 200;
|
|
|
c0c0da |
|
|
|
c0c0da |
var
|
|
|
c0c0da |
Form1: TForm1;
|
|
|
c0c0da |
sx: array [0..starsCount] of integer;
|
|
|
c0c0da |
sy: array [0..starsCount] of integer;
|
|
|
c0c0da |
sz: array [0..starsCount] of integer;
|
|
|
c0c0da |
|
|
|
c0c0da |
implementation
|
|
|
c0c0da |
|
|
|
c0c0da |
{$R *.lfm}
|
|
|
c0c0da |
|
|
|
c0c0da |
procedure TForm1.FormCreate(Sender: TObject);
|
|
|
c0c0da |
var
|
|
|
c0c0da |
i : integer;
|
|
|
c0c0da |
begin
|
|
|
c0c0da |
for i := 0 to starsCount-1 do begin
|
|
|
c0c0da |
sx[i] := Random(ClientWidth);
|
|
|
c0c0da |
sy[i] := Random(ClientHeight);
|
|
|
c0c0da |
sz[i] := RandomRange(1, 10);
|
|
|
c0c0da |
end;
|
|
|
c0c0da |
end;
|
|
|
c0c0da |
|
|
|
c0c0da |
procedure TForm1.Timer1Timer(Sender: TObject);
|
|
|
c0c0da |
var
|
|
|
c0c0da |
i: integer;
|
|
|
c0c0da |
begin
|
|
|
c0c0da |
for i := 0 to starsCount-1 do begin
|
|
|
c0c0da |
sx[i] := sx[i] - sz[i];
|
|
|
c0c0da |
if sx[i] < 0 then begin
|
|
|
c0c0da |
sx[i] := ClientWidth;
|
|
|
c0c0da |
sy[i] := Random(ClientHeight);
|
|
|
c0c0da |
sz[i] := RandomRange(1, 10);
|
|
|
c0c0da |
end;
|
|
|
c0c0da |
end;
|
|
|
c0c0da |
|
|
|
c0c0da |
Refresh;
|
|
|
c0c0da |
end;
|
|
|
c0c0da |
|
|
|
c0c0da |
procedure TForm1.FormPaint(Sender: TObject);
|
|
|
c0c0da |
var
|
|
|
c0c0da |
i: integer;
|
|
|
c0c0da |
begin
|
|
|
c0c0da |
for i := 0 to starsCount-1 do begin
|
|
|
c0c0da |
Canvas.Pixels[ sx[i], sy[i] ] := clWhite;
|
|
|
c0c0da |
end;
|
|
|
c0c0da |
end;
|
|
|
c0c0da |
|
|
|
c0c0da |
end.
|
|
|
c0c0da |
|