You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

45 lines
1.1 KiB

  1. #pragma once
  2. #include <curses.h>
  3. #include <string>
  4. static constexpr int UP = KEY_UP;
  5. static constexpr int DOWN = KEY_DOWN;
  6. static constexpr int LEFT = KEY_LEFT;
  7. static constexpr int RIGHT = KEY_RIGHT;
  8. static constexpr int EXIT_GAME = 'q';
  9. static constexpr uint32_t GAME_TOP_WALL_Y = 1;
  10. static constexpr uint32_t GAME_LEFT_WALL_X = 1;
  11. #define GAME_BOTTOM_WALL_Y (LINES - 4)
  12. #define GAME_RIGHT_WALL_X (COLS - 2)
  13. static constexpr uint32_t DIFFICULTY_BEGIN = 40000;
  14. static constexpr uint32_t DIFFICULTY_CAP = 28000;
  15. static constexpr uint32_t DIFFICULTY_CHANGE = 1000;
  16. class Graphics {
  17. private:
  18. bool vertical_ = false;
  19. uint32_t sleep_time_ = DIFFICULTY_BEGIN;
  20. WINDOW* box_ = nullptr;
  21. Graphics() = default;
  22. void createBox();
  23. void destroyBox();
  24. public:
  25. static Graphics& get();
  26. void init(const std::string& game_name);
  27. void finalize();
  28. void refreshScreen();
  29. void printChar(int y, int x, int img);
  30. void printMsg(int y, int x, const std::string& str);
  31. char readChar(int y, int x);
  32. int readInpt();
  33. void advanceDifficulty();
  34. void setVertical(bool value);
  35. };