resize
This commit is contained in:
		| @@ -77,7 +77,7 @@ void Game::Run() { | ||||
| Game::Game() : | ||||
|         m_wrong_guesses(0), | ||||
|         m_game_state(State::PLAY), | ||||
|         m_hills(get_hills()) { | ||||
|         m_hills(get_resized(get_hills(), 400, 400)) { | ||||
|     const char *defaultFontPath = getDefaultFontPath(); | ||||
|     if (defaultFontPath == nullptr) { | ||||
|         std::stringstream ss; | ||||
| @@ -133,6 +133,10 @@ void Game::draw(SDL_Renderer *renderer) { | ||||
|     draw_guesses(renderer); | ||||
| } | ||||
|  | ||||
| void Game::draw_hang_man(SDL_Renderer *renderer) { | ||||
|  | ||||
| } | ||||
|  | ||||
| void Game::draw_guesses(SDL_Renderer *renderer) { | ||||
|     size_t len = strlen(word); | ||||
|     int total_width = (len - 1) * STEP_SIZE + CHAR_SIZE; | ||||
|   | ||||
| @@ -34,5 +34,6 @@ public: | ||||
| private: | ||||
|     void draw_guesses(SDL_Renderer *renderer); | ||||
|  | ||||
|     void draw_hang_man(SDL_Renderer *renderer); | ||||
| }; | ||||
|  | ||||
|   | ||||
| @@ -66,3 +66,13 @@ SDL_Surface *resize_surface(SDL_Surface *t_surface, int t_width, int t_height) { | ||||
| } | ||||
|  | ||||
|  | ||||
| std::vector<SDL_Surface *> get_resized(const std::vector<SDL_Surface *> &t_originals, int t_width, int t_height) { | ||||
|     std::vector<SDL_Surface *> ret; | ||||
|     ret.reserve(t_originals.size()); | ||||
|     for (SDL_Surface *original: t_originals) { | ||||
|         SDL_Surface *resized = resize_surface(original, t_width, t_height); | ||||
|         SDL_FreeSurface(original); | ||||
|         ret.push_back(resized); | ||||
|     } | ||||
|     return ret; | ||||
| } | ||||
|   | ||||
| @@ -11,6 +11,8 @@ constexpr size_t array_len(T *array[]) { | ||||
|     return i; | ||||
| } | ||||
|  | ||||
| std::vector<SDL_Surface *> get_resized(const std::vector<SDL_Surface *>& t_original, int t_width, int t_height); | ||||
|  | ||||
| std::vector<SDL_Surface *> get_hills(); | ||||
|  | ||||
| SDL_Surface *resize_surface(SDL_Surface *t_surface, int t_width, int t_height); | ||||
|   | ||||
		Reference in New Issue
	
	Block a user