Лабораторные работы: пятнашки и редактор фигур
This commit is contained in:
commit
a5dbf9d3a2
1 changed files with 2579 additions and 0 deletions
46
GameUnit.h
Normal file
46
GameUnit.h
Normal file
|
|
@ -0,0 +1,46 @@
|
|||
// Игра "Пятнашки"
|
||||
#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
|
||||
Loading…
Reference in a new issue