application.hh 989 B

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. #ifndef APPLICATION_HH
  2. #define APPLICATION_HH
  3. #include <SDL2/SDL.h>
  4. #include <SDL2/SDL_ttf.h>
  5. #include "well.hh"
  6. #include "tetromino.hh"
  7. #include "constants.hh"
  8. class Application
  9. {
  10. public:
  11. Application();
  12. int run();
  13. private:
  14. bool quit = false;
  15. bool sPressed = false;
  16. SDL_Event event;
  17. SDL_Window* window;
  18. SDL_Renderer* renderer;
  19. SDL_Texture* blocksTexture;
  20. SDL_Rect uiBlockPos;
  21. const SDL_Rect uiBlockTex {56,0,8,8};
  22. TTF_Font *font = NULL;
  23. const SDL_Color fontColor{0, 0, 0};
  24. SDL_Texture* scoreTexture = NULL;
  25. SDL_Rect scoreRect{(Constants::WIDTH+3)*Constants::BLOCK_SIZE,(Constants::HEIGHT/2-2)*Constants::BLOCK_SIZE,100,100};
  26. SDL_Texture* scoreLabelTexture = NULL;
  27. SDL_Rect scoreLabelRect{(Constants::WIDTH+3)*Constants::BLOCK_SIZE,(Constants::HEIGHT/2-3)*Constants::BLOCK_SIZE,100,100};
  28. Well well;
  29. Tetromino tetromino = nullptr;
  30. void render();
  31. void handleEvents();
  32. void update();
  33. int speed = 250;
  34. int score = 0;
  35. SDL_Joystick* controller = NULL;
  36. };
  37. #endif