Skip to content

Commit

Permalink
Now you can also change the Fruit color
Browse files Browse the repository at this point in the history
  • Loading branch information
alexdantas committed Aug 30, 2014
1 parent c49572f commit 12dbcac
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 1 deletion.
8 changes: 8 additions & 0 deletions src/Config/Globals.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ std::string Globals::Game::current_level = "";
ColorPair Globals::Theme::player_head;
ColorPair Globals::Theme::player_head_dead;
ColorPair Globals::Theme::player_body;
ColorPair Globals::Theme::fruit;

Globals::Game::BoardSize Globals::Game::board_size = LARGE;

Expand Down Expand Up @@ -124,6 +125,8 @@ void Globals::init()
Globals::Theme::player_head_dead = Colors::pair("red", "default", true);
Globals::Theme::player_body = Colors::pair("green", "default", true);

Globals::Theme::fruit = Colors::pair("red", "default", true);

/// HACK Initializing the default level file directory.
/// I know this is hacky, but couldn't find another way to
/// initialize it.
Expand Down Expand Up @@ -243,6 +246,9 @@ void Globals::loadFile()
INI_GET(tmp, "theme", "player_body");
Globals::Theme::player_body = ColorPair::fromString(tmp);

INI_GET(tmp, "theme", "fruit");
Globals::Theme::fruit = ColorPair::fromString(tmp);

SAFE_DELETE(ini);
}
void Globals::saveFile()
Expand Down Expand Up @@ -335,6 +341,8 @@ void Globals::saveFile()

INI_SET("theme", "player_body", Globals::Theme::player_body.toString());

INI_SET("theme", "fruit", Globals::Theme::fruit.toString());

try
{
ini->saveAs(Globals::Config::file);
Expand Down
1 change: 1 addition & 0 deletions src/Config/Globals.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,7 @@ namespace Globals
extern ColorPair player_head;
extern ColorPair player_head_dead;
extern ColorPair player_body;
extern ColorPair fruit;
};

// Flags to warn the user of some error at the end
Expand Down
3 changes: 2 additions & 1 deletion src/Entities/FruitManager.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
#include <Entities/FruitManager.hpp>
#include <Engine/Helpers/Utils.hpp>
#include <Config/Globals.hpp>

FruitManager::FruitManager(int amount):
amount(amount)
Expand Down Expand Up @@ -61,6 +62,6 @@ void FruitManager::draw(Window* win)
win->print("$",
this->fruit[i].x,
this->fruit[i].y,
Colors::pair("red", "default", true));
Globals::Theme::fruit);
}

0 comments on commit 12dbcac

Please sign in to comment.