diff --git a/src/guiconsole/console.cpp b/src/guiconsole/console.cpp index 4f9d9cc..8785d00 100644 --- a/src/guiconsole/console.cpp +++ b/src/guiconsole/console.cpp @@ -129,12 +129,15 @@ void ConsoleManager::handleCommand() App::procClose(); break; case consolecommands::HELP: - printToConsole("list of available commands:% get% set% reset% exit%%type help for additional information"); + printToConsole("list of available commands:% get% set% reset% exit% vars%%type help for additional information"); handleHelpCommand(command); break; case consolecommands::RESET: d_particle_manager->resetParticles(); break; + case consolecommands::VARS: + printToConsole("Invalid Command"); + break; } } } @@ -257,6 +260,12 @@ void ConsoleManager::handleSetCommand(const std::string& str) case consolecommands::COLOR_A: d_particle_manager->setColorA(numeric_value); break; + case consolecommands::COLOR_RAND: + d_particle_manager->setColorRand(numeric_value); + break; + case consolecommands::COLORS: + printToConsole("cannot set command 'colors', specify each value with color_r/g/b"); + break; } } } @@ -310,6 +319,13 @@ void ConsoleManager::handleGetCommand(const std::string& str) case consolecommands::COLOR_A: ss << d_particle_manager->getColorA(); break; + case consolecommands::COLOR_RAND: + ss << "cannot get color_rand, command is specific to set"; + break; + case consolecommands::COLORS: + ss << "R " << d_particle_manager->getColorR() + << "%G " << d_particle_manager->getColorG() + << "%B " << d_particle_manager->getColorB(); } printToConsole(ss.str()); } @@ -341,10 +357,10 @@ void ConsoleManager::handleHelpCommand(const std::string& str) }else{ switch(key) { case consolecommands::GET: - printToConsole("get:% retrieve variable values, list of var's:% mass,drag,mouseforce% particlecount,color_r/g/b/a"); + printToConsole("get:% retrieve variable values, to list of vars:% help vars"); break; case consolecommands::SET: - printToConsole("set:% set value of variable, list of var's allowed:% mass,drag,mouseforce% color_r/g/b/a"); + printToConsole("set:% set value of variable, to list of vars:% help vars"); break; case consolecommands::RESET: printToConsole("reset:% remove all acting force on particles and% position them at the center of the screen"); @@ -352,6 +368,9 @@ void ConsoleManager::handleHelpCommand(const std::string& str) case consolecommands::EXIT: printToConsole("exit:% exit the program, esc will also exit the% program"); break; + case consolecommands::VARS: + printToConsole("list of available program variables:% drag,mass,mouseforce,particlecount% color_r/g/b/a,colors,color_rand"); + break; } } } \ No newline at end of file diff --git a/src/guiconsole/consolecommands.hpp b/src/guiconsole/consolecommands.hpp index 1d18637..7264423 100644 --- a/src/guiconsole/consolecommands.hpp +++ b/src/guiconsole/consolecommands.hpp @@ -11,7 +11,8 @@ namespace consolecommands { "set", "get", "help", - "reset" + "reset", + "vars" }; std::string valid_variables[] = { @@ -22,7 +23,9 @@ namespace consolecommands { "color_r", "color_g", "color_b", - "color_a" + "color_a", + "color_rand", + "colors" }; enum Key { @@ -30,7 +33,8 @@ namespace consolecommands { SET, GET, HELP, - RESET + RESET, + VARS }; enum VarKey { @@ -41,7 +45,9 @@ namespace consolecommands { COLOR_R, COLOR_G, COLOR_B, - COLOR_A + COLOR_A, + COLOR_RAND, + COLORS }; bool isValidCommandKey(const std::string& key, Key& k) diff --git a/src/particlemanager.cpp b/src/particlemanager.cpp index 8f3bc7a..e046926 100644 --- a/src/particlemanager.cpp +++ b/src/particlemanager.cpp @@ -23,8 +23,8 @@ const GLfloat ParticleManager::g_vertex_buffer_data[] = { ParticleManager::ParticleManager(sf::Window* parent_window, int maxparticles, float drag, float mass, float size, float mouseforce): d_MAXPARTICLES(maxparticles), d_DRAG(drag), d_MASS(mass), -d_SIZE(size), d_MOUSEFORCE(mouseforce), d_R(120), d_G(200), -d_B(10), d_A(255) +d_SIZE(size), d_MOUSEFORCE(mouseforce), d_R(15), d_G(200), +d_B(75), d_A(255) { d_parent_window = parent_window; @@ -53,7 +53,7 @@ void ParticleManager::initParticles() for(int i=0; i<(int)sqrt(d_MAXPARTICLES); i++) { for(int j=0; j<(int)sqrt(d_MAXPARTICLES); j++) { Particle particle; - glm::vec2 d2Pos = glm::vec2(j*0.06, i*0.06) + glm::vec2(-20.0f,-20.0f); + glm::vec2 d2Pos = glm::vec2(j*0.06, i*0.06) + glm::vec2(-17.0f,-17.0f); particle.pos = glm::vec3(d2Pos.x,d2Pos.y,-70); particle.life = 1000.0f; @@ -355,6 +355,14 @@ void ParticleManager::setColorA(const unsigned char& val) d_A = val; } +void ParticleManager::setColorRand(const int& val) +{ + if(val > 255 || val < 0) return; + d_R = std::rand() % 255 - val; + d_G = std::rand() % 255 - val; + d_B = std::rand() % 255 - val; +} + void ParticleManager::resetParticles() { d_particles_container.clear(); @@ -416,4 +424,5 @@ int ParticleManager::getColorB() int ParticleManager::getColorA() { return d_A; -} \ No newline at end of file +} + diff --git a/src/particlemanager.hpp b/src/particlemanager.hpp index e9f61d9..3a76242 100644 --- a/src/particlemanager.hpp +++ b/src/particlemanager.hpp @@ -46,6 +46,7 @@ class ParticleManager{ void setColorG(const unsigned char& val); void setColorB(const unsigned char& val); void setColorA(const unsigned char& val); + void setColorRand(const int& val); //get functions