init word aswell
This commit is contained in:
parent
7eab5371ce
commit
7d992f3b30
10
src/Game.cpp
10
src/Game.cpp
@ -64,17 +64,15 @@ Game::Game() : guessed() {
|
|||||||
std::mt19937 rng(random_device());
|
std::mt19937 rng(random_device());
|
||||||
|
|
||||||
size_t words_len = array_len(words);
|
size_t words_len = array_len(words);
|
||||||
this->all_words = std::vector<const char *>();
|
all_words = std::vector<const char *>();
|
||||||
this->all_words.reserve(words_len);
|
all_words.reserve(words_len);
|
||||||
for (int i = 0; i < words_len; i++)
|
for (int i = 0; i < words_len; i++)
|
||||||
all_words.push_back(words[i]);
|
all_words.push_back(words[i]);
|
||||||
std::shuffle(all_words.begin(), all_words.end(), rng);
|
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::handle_key(SDL_Keycode event) {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void Game::select_word() {
|
|
||||||
|
|
||||||
}
|
|
||||||
|
10
src/Game.hpp
10
src/Game.hpp
@ -3,14 +3,15 @@
|
|||||||
#include <SDL_rect.h>
|
#include <SDL_rect.h>
|
||||||
#include <SDL_events.h>
|
#include <SDL_events.h>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
#include <optional>
|
||||||
|
|
||||||
const SDL_Point SCREEN_SIZE{800, 800};
|
const SDL_Point SCREEN_SIZE{800, 800};
|
||||||
|
|
||||||
class Game {
|
class Game {
|
||||||
private:
|
private:
|
||||||
std::vector<const char*> all_words;
|
std::vector<const char *> all_words;
|
||||||
std::vector<std::string> guessed;
|
std::vector<std::optional<char>> guessed;
|
||||||
std::string word;
|
const char *word;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
static void Run();
|
static void Run();
|
||||||
@ -18,8 +19,5 @@ public:
|
|||||||
Game();
|
Game();
|
||||||
|
|
||||||
void handle_key(SDL_Keycode event);
|
void handle_key(SDL_Keycode event);
|
||||||
|
|
||||||
private:
|
|
||||||
void select_word();
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user