source: trunk/Games/UTetris.pas

Last change on this file was 1, checked in by chronos, 3 years ago
  • Added: "Clovece nezlob se" game with adjustable board for different player count.
File size: 1.2 KB
Line 
1unit UTetris;
2
3{$mode delphi}
4
5interface
6
7uses
8 Classes, SysUtils, UGame, UGraphics, fgl;
9
10type
11 TShape = class
12 Body: array of Byte;
13 end;
14
15 { TShapes }
16
17 TShapes = class(TFPGObjectList<TShape>)
18 function AddNew(Body: array of Byte): TShape;
19 end;
20
21 { TTetris }
22
23 TTetris = class(TGame)
24 Shapes: TShapes;
25 Space: array of array of TColor;
26 procedure Paint(Canvas: TCanvas);
27 constructor Create; override;
28 destructor Destroy; override;
29 end;
30
31implementation
32
33{ TShapes }
34
35function TShapes.AddNew(Body: array of Byte): TShape;
36var
37 I: Integer;
38begin
39 Result := TShape.Create;
40 SetLength(Result.Body, Length(Body));
41 for I := 0 to Length(Result.Body) - 1 do
42 Result.Body[I] := Body[I];
43 Add(Result);
44end;
45
46{ TTetris }
47
48procedure TTetris.Paint(Canvas: TCanvas);
49begin
50 with Canvas do begin
51 Rectangle(Bounds(0, 0, Size.Width, Size.Height));
52 end;
53end;
54
55constructor TTetris.Create;
56begin
57 inherited;
58 Shapes := TShapes.Create;
59 Shapes.AddNew([2, 2, 2, 2]);
60 Shapes.AddNew([0, 6, 6, 0]);
61 Shapes.AddNew([2, 2, 6, 0]);
62 Shapes.AddNew([2, 6, 2, 0]);
63 Shapes.AddNew([2, 6, 4, 0]);
64end;
65
66destructor TTetris.Destroy;
67begin
68 Shapes.Free;
69 inherited;
70end;
71
72end.
73
Note: See TracBrowser for help on using the repository browser.