Skip to content

Commit 20e2102

Browse files
committed
Fixed width and height of sortables to fill window
1 parent d6a82fe commit 20e2102

File tree

2 files changed

+6
-3
lines changed

2 files changed

+6
-3
lines changed

SortController.cpp

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,19 +13,22 @@ void SortController::clear() {
1313

1414
void SortController::populate(int numOfElements) {
1515
for (int n = 0; n < numOfElements; n++) {
16-
Sortable sortable((float)(winWidth / numOfElements), (float)(winHeight / numOfElements) * (n+1), n); // Width defined to space max space in window, height defined by Sortable value
16+
std::cout << (winWidth / numOfElements) << std::endl;
17+
Sortable sortable(((float)winWidth / numOfElements), ((float)winHeight / numOfElements) * (n+1), n); // Width defined to space max space in window, height defined by Sortable value
1718
sortElements.push_back(sortable);
1819
}
1920
}
2021

2122
void SortController::startSort(int sortType) {
2223
std::cout << "Sort started via thread!" << std::endl;
24+
isSorting = true;
2325
while (!isSorted())
2426
{
2527
if (sortType == 0) {
2628
algo::bubbleSort(sortElements, timeSleep);
2729
}
2830
}
31+
isSorting = false;
2932
std::cout << "Sorting finished!" << std::endl;
3033
std::cout << std::endl;
3134
}

main.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ int main()
3636
switch (event.key.code)
3737
{
3838

39-
// Randomize and start sorting
39+
// Randomize and start sorting
4040
case sf::Keyboard::Space:
4141
if (!sortController.isSorting) {
4242
std::cout << "Randomizing..." << std::endl;
@@ -49,7 +49,7 @@ int main()
4949
break;
5050

5151
// Change sort type (increase)
52-
case (sf::Keyboard::Up):
52+
case sf::Keyboard::Up:
5353
sortType++;
5454
std::cout << "Sort changed to: " << sortType << std::endl;
5555
break;

0 commit comments

Comments
 (0)