;, img9.bmp );
{$ R * .dfm} RedrawCell (index: integer) ;, Row: integer;:=index div 5;:=index mod 5; .DrawGridDrawCell (frmMain, Col, Row, frmMain. DrawGrid.CellRect (Col, Row), []); LoadImages ;: integer; i:=0 to MAX_IMAGES - 1 do [i]:=TImage.Create (nil); [i] .Picture.LoadFromFile (ImagePaths [i ]); TfrmMain.FormCreate (Sender: TObject) ;: integer ;; i:=0 to 19 do [i]:=i ;;. Click; LinearIndexOf (Row, Column: integer): integer;:=5 * Row + Column; RandomizeThePermutationArray ;, RandomPosition, Temp: integer; i:=0 to 18 do:=i + Random (19 - i) + 1;:=RandomPermutationArray [i]; [i]:=RandomPermutationArray [RandomPosition]; [ RandomPosition]:=Temp ;; AssignPartnerships ;: integer; i:=0 to 19 doi mod 2=0 then
PartnerOf [RandomPermutationArray [i]]:=RandomPermutationArray [i + 1]
PartnerOf [RandomPermutationArray [i]]:=RandomPermutationArray [i - 1]; AssignImagesToCells ;: integer; i:=0 to 19 do [RandomPermutationArray [i]]:=i div 2; InitializeCellModes;:integer; i:=0 to 19 do [i]:=CELL_INVISIBLE; TfrmMain.itemNewGameClick (Sender: TObject) ;: integer; .Enabled:=true;:=30 ;;;;;:=0; i:= 0 to 19 do (i) ;; TfrmMain.DrawGridDrawCell (Sender: TObject; ACol, ARow: Integer; Rect: TRect; State: TGridDrawState) ;: integer;:=LinearIndexOf (ARow, ACol); ModeOfCell [index]=CELL_INVISIBLE then.Canvas.Brush.Color:=clBlack; .Canvas.FillRect (Rect) if ModeOfCell [index]=ALREADY_MATCHED then.Canvas.Brush.Color:=clWhite; .Canvas.FillRect (Rect) begin.Canvas.StretchDraw (Rect , Images [ImageOfCell [index]]. Picture.Graphic) ;; TfrmMain.DrawGridSelectCell (Sender: TObject; ACol, ARow: Integer; var CanSelect: Boolean) ;: integer;:=LinearIndexOf (ARow, ACol); ModeOfCell [index ]=ALREADY_MATCHED then; NumberOfVisibleCells=0 then:=index; [FirstCell]:=CELL_VISIBLE; (FirstCell); (NumberOfVisibleCells) if (NumberOfVisibleCells=1) and (FirstCell lt; gt; index) then:=index; [SecondCell]:=CELL_VISIBLE; (SecondCell); PartnerOf [SecondCell]=FirstCell then
Sleep (100);
ModeOfCell [FirstCell]:=ALREADY_MATCHED;
RedrawCell (FirstCell);
ModeOfCell [SecondCell]:=ALREADY_MATCHED;
RedrawCell (SecondCell);
NumberOfVisibleCells:=0 (NumberOfVisibleCells) begin (FirstCell lt; gt; index) and (SecondCell lt; gt; index) then [index]:=CELL_VISIBLE; (index) ;; FirstCell lt; gt ; index then [FirstCell]:=CELL_INVISIBLE; (FirstCell) ;; SecondCell lt; gt; index then [SecondCell]:=CELL_INVISIBLE; (SecondCell) ;;:=index;:=1; TfrmMain.Timer1Timer (Sender: TObject) ;: integer;:=0;:=tick - 1; .text:=inttostr ( tick); edit1.text= 0 then.Enabled:=false; ( GAME OVER ) ;; i:=0 to 19 doModeOfCell [i]=ALREADY_MATCHED then:=n + 1 ;; n=20 then.Enabled:=false; ( You Win ) ;;; TfrmMain.Exit1Click (Sender: TObject) ;;;.: Unit2 ;, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms ,, StdCtrls, ExtCtrls, MainUnit, Spin;=class (TForm):TRadioGroup ;: TSpinEdit ;: TButton; RadioGroup1Click (Sender: TObject); Button1Click (Sender: TObject); SpinEdit1KeyPress (Sender: TObject; var Key: Char);
{Private declarations}
{Public declarations} ;: TForm2 ;: integer;
{$ R * .dfm} TForm2.RadioGroup1Click (Sender: TObject);
{case RadioGroup1.ItemIndex of
:
tick:=60;
:
tick:=45;
:
tick:=30;
: SpinEdit1.Value lt; gt; 0 then
tick:=SpinEdit1.Value ;;. Hide; .ProcessMessages; .Timer1.Enabled:=true; .RandomizeThePermutationArray; .AssignPartnerships; .AssignImagesToCells; .InitializeCellModes;:=0; i:=0 to 19 do
frmMain.RedrawCell (i);}; TForm2.Button1Click (Sender: TObject); RadioGroup1.ItemIndex of
:
tick:=60;
:
tick:=45;
:
tick:=30;
: SpinEdit1.Value lt; gt; 0 then
tick:=SpinEdit1.Value ;;. Hide; .ProcessMessages; .Timer1.Enabled:=true; .RandomizeThePermutationArray; .AssignPartnerships; .AssignImagesToCells; .InitializeCellModes;:=0; i:=0 to 19 do
frmMain.RedrawCell (i) ;; TForm2.SpinEdit1KeyPress (Sender: TObject; var Key: Char); (key= - ) then:=# 0 ;;.: Unit3; , Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms ,, StdCtrls, ExtCtrls, XPMan;=class (TForm): TButton ;: TImage ;: TXPManifest; Button1Click (Sender: TObject);
{Private declarations}
{Public declarations} ;: TForm3;