title: How should I make my blocks keep their color even if the global color changes?
body: <p>I am creating a drawing app with oclPixelGameEngine, and I can't figure out how I should make my blocks(pixels) keep their color, even after the global colors change, when I change the global colors now, every already drawn block changes its color.
  *EDIT I forgot to mention this code is executed every frame, and the colors aren't, they are defined only at the start, and when I press some key, they change.</p>
  
  <p>I have tried making a variables inside the for loop, still the problem persists.</p>
  
  <pre class="lang-cpp prettyprint-override"><code>class Example : public olc::PixelGameEngine
  {
  public:
      Example()
      {
          sAppName = "RandomStuff";
      }
  
  private:
      sCell* world;
      int nWorldWidth = 16;
      int nWorldHeight = 16;
  
  public:
  
      int fColors[12] =
      {
          255,0,0,
          0,255,0,
          0,0,255,
          255,255,255
  
      };
  
      int rColor = 255;
      int gColor = 255;
      int bColor = 255;
  
      int fColorsPos = 0;
  
      bool colorsSet = false;
  
      bool OnUserCreate() override
      {
          // Provede se hned po zapnutí
  
          world = new sCell[nWorldWidth * nWorldHeight];
  
          return true;
      }
  
      bool OnUserUpdate(float fElapsedTime) override
      {
          // Zapne se každý snímek
  
          float fBlockWidth = 1.0f;
          float fSourceX = GetMouseX();
          float fSourceY = GetMouseY();
  
          if (GetMouse(0).bReleased)
          {
              int i = ((int)fSourceY / (int)fBlockWidth) * nWorldWidth + ((int)fSourceX / (int)fBlockWidth);
              world[i].exist = !world[i].exist;
          }
  
          if (GetKey(olc::Key::RIGHT).bPressed) {
              rColor = fColors[fColorsPos];
              gColor = fColors[fColorsPos + 1];
              bColor = fColors[fColorsPos + 2];
              fColorsPos += 3;
              if (fColorsPos &gt; 3*4-1)
                  fColorsPos = 0;
          }
  
          //Renderování
  
          Clear(olc::BLACK);
  
          for (int x = 0; x &lt; nWorldWidth; x++)
              for (int y = 0; y &lt; nWorldHeight; y++)
              {
                  if (world[y * nWorldWidth + x].exist)
                          FillRect(x * fBlockWidth, y * fBlockWidth, fBlockWidth, fBlockWidth,olc::Pixel(rColor, gColor, bColor));
              }
  
          return true;
      }
  };
  </code></pre>
  
  <p>When I created the for loop color variables, I expected them to stay constant for every block, but the blocks still change their colors.</p>