How can I remain previous Rects

  api, c++, winapi

I want ask some questions about Win Api. (C++)

[At first, I initialize some arrays which makes 6 rects,
and move it to left using OffsetRect function.

I want to make, if the coordinates of the last rect reach a certain point (for example, rc.right < -100), I want it to be constantly regenerated.

But if the coordinates of the last rect reach a certain point which I want, users can see the rect disappearing or creating in real-time. But I hope it is already created and moved continuously.

enter image description here

I am going to upload part of my codes(that I think essential), so review it and help me please..

HRESULT stage2::init()
{
    for (int i = 0; i < rand_Ground; i++)
    {
        _ground[i].landRC = RectMake(100 + (i * 146), 434, 145, 150);
    }
   for (int i = 0; i < rand_foothold; i++)
        {
            _foothold[i].landRC = RectMake(_ground[rand_Ground - 1].landRC.right + 100 + (i * 270), _ground[rand_Ground - 1].landRC.top - 70, 150, 30);
    }   
}

void stage2::update()
{
    for (int i = 0; i < rand_Ground; i++)
    {
        OffsetRect(&_ground[i].landRC, -OBJECTSPEED, 0);
   }
    for (int i = 0; i < rand_foothold; i++)
    {
        OffsetRect(&_foothold[i].landRC, -OBJECTSPEED, 0);
        if (_foothold[rand_foothold - 1].landRC.right < 0)
        {
                    for (int i = 0; i < rand_foothold; i++)
                {
                    _foothold[i].landRC = RectMake(rect.right + 100 + (i * 270), rect.top - 70, 150, 30);
          }
          

   
}

Source: Windows Questions C++

LEAVE A COMMENT