My SFML program is not redrawing my sorted array of sqaures

19 views Asked by At

I'm making a bubble sorter visualizer. After making random squares and displaying them. Then it goes into my bubble sorter and I rerun my draw and display functions but the new updated array is not displaying. It stays the same

I tried changing different spots of where it clears the screen and also where it displays.

//Bubble Sorter

    if (part == 2) {
        for (int j = 0; j < arraySize; j++) {

            if (squareArray[itera].getSize().y > squareArray[itera + 1].getSize().y) {


            sf::RectangleShape temp = squareArray[itera];

            squareArray[itera] = squareArray[itera + 1];

            squareArray[itera + 1] = temp;
        }
    }
}


    //Draws squares
    for (int i = 0; i < arraySize; i++) {
        window.draw(squareArray[i]); //Draws the square
        std::string counter = std::to_string(i);
        text.setString("Squares:" + counter); //Sets counter to string

    }

    window.draw(text); // Draws the text
    window.display(); // Displays Everything

https://pastebin.com/n1ht4JbX

0

There are 0 answers