45 lines
1.2 KiB
C++
45 lines
1.2 KiB
C++
#ifndef GameUnitH
|
|
#define GameUnitH
|
|
|
|
#include <System.Classes.hpp>
|
|
#include <Vcl.Controls.hpp>
|
|
#include <Vcl.StdCtrls.hpp>
|
|
#include <Vcl.Forms.hpp>
|
|
#include <Vcl.Grids.hpp>
|
|
#include <Vcl.ExtCtrls.hpp>
|
|
|
|
class TfrmGame : public TForm
|
|
{
|
|
__published:
|
|
TPanel *pnlInfo;
|
|
TLabel *lblSteps;
|
|
TLabel *lblClock;
|
|
TStringGrid *sgBoard;
|
|
TButton *btnShuffle;
|
|
TButton *btnRules;
|
|
TTimer *tmrClock;
|
|
void __fastcall FormShow(TObject *Sender);
|
|
void __fastcall FormClose(TObject *Sender, TCloseAction &Action);
|
|
void __fastcall FormKeyDown(TObject *Sender, WORD &Key, TShiftState Shift);
|
|
void __fastcall sgBoardMouseDown(TObject *Sender, TMouseButton Button,
|
|
TShiftState Shift, int X, int Y);
|
|
void __fastcall sgBoardDrawCell(TObject *Sender, System::LongInt ACol,
|
|
System::LongInt ARow, const TRect &Rect, TGridDrawState State);
|
|
void __fastcall tmrClockTimer(TObject *Sender);
|
|
void __fastcall btnShuffleClick(TObject *Sender);
|
|
void __fastcall btnRulesClick(TObject *Sender);
|
|
private:
|
|
int steps;
|
|
int secs;
|
|
bool gameOver;
|
|
void StartGame();
|
|
bool TryMove(int col, int row);
|
|
bool CheckWin();
|
|
void UpdateLabels();
|
|
public:
|
|
__fastcall TfrmGame(TComponent* Owner);
|
|
};
|
|
|
|
extern PACKAGE TfrmGame *frmGame;
|
|
|
|
#endif
|