init word aswell

This commit is contained in:
Love 2024-08-02 16:18:15 +02:00
parent 7eab5371ce
commit 7d992f3b30
2 changed files with 8 additions and 12 deletions

View File

@ -64,17 +64,15 @@ Game::Game() : guessed() {
std::mt19937 rng(random_device());
size_t words_len = array_len(words);
this->all_words = std::vector<const char *>();
this->all_words.reserve(words_len);
all_words = std::vector<const char *>();
all_words.reserve(words_len);
for (int i = 0; i < words_len; i++)
all_words.push_back(words[i]);
std::shuffle(all_words.begin(), all_words.end(), rng);
word = all_words.back();
all_words.pop_back();
}
void Game::handle_key(SDL_Keycode event) {
}
void Game::select_word() {
}

View File

@ -3,14 +3,15 @@
#include <SDL_rect.h>
#include <SDL_events.h>
#include <vector>
#include <optional>
const SDL_Point SCREEN_SIZE{800, 800};
class Game {
private:
std::vector<const char *> all_words;
std::vector<std::string> guessed;
std::string word;
std::vector<std::optional<char>> guessed;
const char *word;
public:
static void Run();
@ -18,8 +19,5 @@ public:
Game();
void handle_key(SDL_Keycode event);
private:
void select_word();
};