HELP! How to make slot machine columns rotate separately

Dec 9, 2019 at 8:16pm
Hi guys, I'm quite new to C++, but I'm building a slot machine console program, and I need to make the columns stop rotating one by one. I have manage to make the whole array visually 'rotate', so the whole array spins and stops at the same time, but I don't know how to separate the columns (each wheel).
I'm really stucked on how to do this. Any help will be kindly appreciated


This is the section for randomising and printing the slots from the array

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
 
while (spin == true)
		{

			Set_Color(rand() % 15, 0);

			Draw_String(0, 0, "");


			for (int i = 0; i < rows; i++) { //prints rows

				for (int j = 0; j < cols; j++) { //prints columns

					int random = rand() % 5;

					int temp = slots[i][j];
					slots[i][j] = slots[random][j];
					slots[random][j] = temp;
					cout << "|   " << slots[i][j] << "   |";
				}
				cout << "\n";

			}

			// SECTION: synchronize to a constant frame rate 

			Sleep(100);

			if (GetKeyState('S') & 0x8000)
			{
				// if S is pressed, stop spinning
				spin = false;
			}

			cout << "\n";

			cout << "Press 'S' to stop spinning       ";

		}

		Draw_String(0, 0, "");

		//loop to print randomised slot result
		for (int i = 0; i < 5; i++) {

			for (int j = 0; j < 5; j++) {

				cout << "|   " << slots[i][j] << "   |";
			}
			cout << "\n";

		}


If you need the entire code let me know
Many thanks in advance!
Last edited on Dec 9, 2019 at 8:20pm
Dec 9, 2019 at 8:27pm
Topic archived. No new replies allowed.