This commit is contained in:
Love 2024-08-04 16:16:31 +02:00
parent 549214014d
commit 5ab7b40154
4 changed files with 18 additions and 1 deletions

View File

@ -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;

View File

@ -34,5 +34,6 @@ public:
private:
void draw_guesses(SDL_Renderer *renderer);
void draw_hang_man(SDL_Renderer *renderer);
};

View File

@ -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;
}

View File

@ -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);