我想在网格中渲染像素,网格重复显示的像素随着角色移动。 但我不知道如何实现。 我渲染像素的循环看起来像这样:

for (int c = 0; c < width / scale; c += 10)
    {

    for (int k = 0; k < height / scale; k += 10)
        SDL_RenderPoint(renderer, spread(c, x), (float)k + y) ; // 渲染像素

    }

其中 xy 是角色位置,spread 函数只是:

float spread(int c, float x)
    {

    float r = c - x ;
    return r ;

    }

但它只创建一个终点的方形点集,如何让它无限循环?