tetromino.hh 550 B

123456789101112131415161718192021222324252627282930313233343536
  1. #ifndef TETROMINO_HH
  2. #define TETROMINO_HH
  3. #include <SDL2/SDL.h>
  4. #include "constants.hh"
  5. #include "well.hh"
  6. class Tetromino
  7. {
  8. public:
  9. Tetromino(Well* well);
  10. void update();
  11. void move(int direction);
  12. void rotate();
  13. void draw(SDL_Renderer* renderer, SDL_Texture* blocksTexture);
  14. int score = 0;
  15. private:
  16. Well* well;
  17. Type type;
  18. char shape[4][5][5];
  19. int x;
  20. int y;
  21. int angle; // 0-0deg, 1-90deg, 2-180deg, 3-270-deg
  22. bool checkDownCollision();
  23. bool checkLeftSide();
  24. bool checkRightSide();
  25. bool checkRotation();
  26. void reset();
  27. };
  28. #endif