66 lines
1.0 KiB
C
66 lines
1.0 KiB
C
|
/*
|
||
|
* TetrisGame.h
|
||
|
*
|
||
|
* Created on: May 5, 2013
|
||
|
* Author: chibi_000
|
||
|
*/
|
||
|
|
||
|
#ifndef TETRISGAME_H_
|
||
|
#define TETRISGAME_H_
|
||
|
|
||
|
#include "../Domain/Array2.h"
|
||
|
#include "PieceGenerator.h"
|
||
|
|
||
|
class TetrisGame {
|
||
|
|
||
|
private:
|
||
|
Array2 grid;
|
||
|
Piece current, next;
|
||
|
PieceGenerator gen;
|
||
|
|
||
|
int score, level;
|
||
|
int cy, cx;
|
||
|
|
||
|
// Position convert
|
||
|
int xToPiece(int col_g);
|
||
|
int xToGrid(int col_p);
|
||
|
int yToPiece(int row_g);
|
||
|
int yToGrid(int row_p);
|
||
|
|
||
|
// Pieces
|
||
|
void pickNextPiece();
|
||
|
void putPieceInGrid();
|
||
|
|
||
|
// Lines
|
||
|
int markFullLines();
|
||
|
void removeFullLines();
|
||
|
|
||
|
// Collisions
|
||
|
bool collides(int cx, int cy, const Piece& p);
|
||
|
bool collidesDown();
|
||
|
bool collidesLeft();
|
||
|
bool collidesRight();
|
||
|
|
||
|
public:
|
||
|
TetrisGame(int w=10, int h=20, const PieceGenerator& gen = PieceGenerator());
|
||
|
virtual ~TetrisGame();
|
||
|
|
||
|
// Gameplay
|
||
|
bool isGameOver();
|
||
|
void tick();
|
||
|
|
||
|
void moveLeft();
|
||
|
void moveRight();
|
||
|
void moveDown();
|
||
|
void rotate();
|
||
|
|
||
|
// Getters
|
||
|
int get(int x, int y);
|
||
|
int getScore();
|
||
|
int getLevel();
|
||
|
int getTickTime();
|
||
|
Piece getNextPiece();
|
||
|
};
|
||
|
|
||
|
#endif /* TETRISGAME_H_ */
|