I am trying to make one of the sorting algorithm visualisations with rectangles in raylib.
In my while (!WindowShouldClose())
loop, I am not sure how to thread the sorting algorithm. Here is how it looks:
std::vector<int> rand_arr;
for (int i = 0; i < 40; ++i) rand_arr.push_back(i);
std::random_shuffle(rand_arr.begin(), rand_arr.end());
while (!WindowShouldClose())
{
BeginDrawing();
ClearBackground(BLACK);
for (unsigned i = 0; i < 40; i++)
DrawRectangle(i * 20, 800 - 20 * rand_arr[i], 20 - 1, rand_arr[i] * 20, RAYWHITE);
EndDrawing();
}
where rand_arr
is the array storing values for rectangles and has to be sorted with std::qsort
. This code currently outputs a window with rectangles aligned at random.