mirror of
https://github.com/RGBCube/serenity
synced 2025-07-27 00:47:45 +00:00
Snake: Save configured base color to Snake's configuration file
This commit is contained in:
parent
69beda23c3
commit
36042fc1d6
2 changed files with 8 additions and 1 deletions
|
@ -57,6 +57,7 @@ SnakeGame::SnakeGame(NonnullRefPtrVector<Gfx::Bitmap> food_bitmaps)
|
|||
reset();
|
||||
m_high_score = Config::read_i32("Snake"sv, "Snake"sv, "HighScore"sv, 0);
|
||||
m_high_score_text = DeprecatedString::formatted("Best: {}", m_high_score);
|
||||
m_snake_base_color = Color::from_argb(Config::read_u32("Snake"sv, "Snake"sv, "BaseColor"sv, m_snake_base_color.value()));
|
||||
}
|
||||
|
||||
void SnakeGame::pause()
|
||||
|
@ -85,6 +86,12 @@ void SnakeGame::reset()
|
|||
update();
|
||||
}
|
||||
|
||||
void SnakeGame::set_snake_base_color(Color color)
|
||||
{
|
||||
Config::write_u32("Snake"sv, "Snake"sv, "BaseColor"sv, color.value());
|
||||
m_snake_base_color = color;
|
||||
}
|
||||
|
||||
bool SnakeGame::is_available(Coordinate const& coord)
|
||||
{
|
||||
for (size_t i = 0; i < m_tail.size(); ++i) {
|
||||
|
|
|
@ -22,7 +22,7 @@ public:
|
|||
void pause();
|
||||
void reset();
|
||||
|
||||
void set_snake_base_color(Color color) { m_snake_base_color = color; };
|
||||
void set_snake_base_color(Color color);
|
||||
|
||||
private:
|
||||
explicit SnakeGame(NonnullRefPtrVector<Gfx::Bitmap> food_bitmaps);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue