Class project

Hi, i started using c++ a couple of months ago, and in my class we are on our final project, which i have been working on for quite some time. I am still a bit noobish at programming, but im getting a little better. For our final project, we need to incorporate several things, and I have put in everything i need except arrays and classes. The main problem i am having is i dont know how i would implement classes into my project. I have read in the book and online about them and i am still confused. I already know how i am going to put in arrays, so im not too worried about that. Also, I was wondering if there were an easier way to shorten the length of saying each variable that needs to be carried over to a function, as it can be annoying if i want to add something into my program. (Idk, but maybe classes can help me with that lol) I dont necessarily want an answer, but any examples, advice, or explanation would be extremely helpful. The code is a little "game" i made where you have to stop the arrow within the bounds in the middle inbetween the brackets. you have to press space to stop it, but then press another key (besides space) to go to the next level. Thanks!

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
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
#include <iostream>
#include <time.h>
#include <windows.h>
#include <conio.h>
#include <stdlib.h>
#include <stdio.h>
using namespace std;
void CLEAR_SCREEN();
void BAR_MOVEMENT();
double KEY_PRESSED (double& x, int& level, bool& Game, bool& AddX, bool& SubX, int& SleepTime, int& Stage, int& RandomX, double& y, bool Start, int& score);
double OUTPUT (int& Level, bool Start);
double LEVEL_UP (int& level, double& x, double& y, int& RandomX, bool Start, int& score, bool& AddX, bool& SubX, int& stage);
void GotoXY(HANDLE StdOut, SHORT x, SHORT y)
{
    COORD Cord;
    Cord.X = x;
    Cord.Y = y;
    SetConsoleCursorPosition(StdOut, Cord);
}
int main(int Level)
{
	int Start_Sleep = 150;
	system("color F");
	cout <<"                                -";
	Sleep(Start_Sleep);
	cout <<"R";
	Sleep(Start_Sleep);
	cout <<"E";
	Sleep(Start_Sleep);
	cout <<"F";
	Sleep(Start_Sleep);
	cout <<"L";
	Sleep(Start_Sleep);
	cout <<"E";
	Sleep(Start_Sleep);
	cout <<"X";
	Sleep(Start_Sleep);
	cout <<" ";
	Sleep(Start_Sleep);
	cout <<"T";
	Sleep(Start_Sleep);
	cout <<"E";
	Sleep(Start_Sleep);
	cout <<"S";
	Sleep(Start_Sleep);
	cout <<"T";
	Sleep(Start_Sleep);
	cout <<"E";
	Sleep(Start_Sleep);
	cout <<"R";
	Sleep(Start_Sleep);
	cout <<"-";
	Sleep(Start_Sleep);
	BAR_MOVEMENT();  
	return 0;
}
void BAR_MOVEMENT()
{
double x = 18, y = 3;
int SleepTime = 100;
int Level = 1;
int Stage = 1;
int RandomX = 1;
bool Game = true;
bool AddX = true;
bool SubX = false;
bool Start = true;
int score = 0;
HANDLE hStdout = GetStdHandle (STD_OUTPUT_HANDLE);
CONSOLE_SCREEN_BUFFER_INFO ScreenBufferInfo = { 0 };
GetConsoleScreenBufferInfo(hStdout, &ScreenBufferInfo);
GotoXY( hStdout,
ScreenBufferInfo.dwCursorPosition.X,
ScreenBufferInfo.dwCursorPosition.Y );
OUTPUT(Level, Start);
	cout << "   Score:" << score;
	cout << "\n                                                               ----------";
	cout << "\n                                                                Level: " << Level;
	cout << "\n                                                                Stage: " << Stage;
Start = false;
while (Game == true)
{
		if (AddX == true)
		{
				do
				{
						if((GetAsyncKeyState(VK_SPACE)))
						KEY_PRESSED (x, Level, Game, AddX, SubX, SleepTime, Stage, RandomX, y, Start, score);
				Sleep (SleepTime);
						if((GetAsyncKeyState(VK_SPACE)))
						KEY_PRESSED (x, Level, Game, AddX, SubX, SleepTime, Stage, RandomX, y, Start, score);
				GotoXY(hStdout, x, y);
				cout << " ^ ";
				x = x++;
						if(x == 58)
						{
						AddX = false;
						SubX = true;
						}
				}
				while (AddX == true);
		}
		if (SubX == true)
		{
				do
				{
						if((GetAsyncKeyState(VK_SPACE)))
						KEY_PRESSED (x, Level, Game, AddX, SubX, SleepTime, Stage, RandomX, y, Start, score);
				Sleep (SleepTime);
						if((GetAsyncKeyState(VK_SPACE)))
						KEY_PRESSED (x, Level, Game, AddX, SubX, SleepTime, Stage, RandomX, y, Start, score);
				GotoXY(hStdout, x, y);
				cout << " ^ ";
				x = x--;
						if(x == 17)
						{
						SubX = false;
						AddX = true;
						}
				}
				while (SubX == true || x == 1);
		}

}
}

double KEY_PRESSED (double& x, int& level, bool& Game, bool& AddX, bool& SubX, int& SleepTime, int& Stage, int& RandomX, double& y, bool Start, int& score)
{
HANDLE hStdout = GetStdHandle (STD_OUTPUT_HANDLE);
CONSOLE_SCREEN_BUFFER_INFO ScreenBufferInfo = { 0 };
GetConsoleScreenBufferInfo(hStdout, &ScreenBufferInfo);
GotoXY( hStdout,
ScreenBufferInfo.dwCursorPosition.X,
ScreenBufferInfo.dwCursorPosition.Y );
	if(AddX == true)
	{
		if (level == 1 && x >= 35 && x <= 43)
		LEVEL_UP (level, x, y, RandomX, Start, score, SubX, AddX, Stage);

		else if (level == 2 && x >= 36 && x <= 42)
		LEVEL_UP (level, x, y, RandomX, Start, score, SubX, AddX, Stage);

		else if (level == 3 && x >= 37 && x <= 41)
		LEVEL_UP (level, x, y, RandomX, Start, score, SubX, AddX, Stage);

		else if (level ==4 && x >= 38 && x <= 40)
		{
		Stage = Stage++;
		level = 0;
		SleepTime = SleepTime - 20;
		LEVEL_UP (level, x, y, RandomX, Start, score, SubX, AddX, Stage);
		}
		else
		{
		system("color 48");
		cout <<"\nLOSE!\n";
		system("pause");
		exit(1);
		}
	}

	if(SubX == true)
	{
		if (level == 1 && x >= 33 && x <= 41)
		LEVEL_UP (level, x, y, RandomX, Start, score, SubX, AddX, Stage);

		else if (level == 2 && x >= 34 && x <= 40)
		LEVEL_UP (level, x, y, RandomX, Start, score, SubX, AddX, Stage);

		else if (level == 3 && x >= 35 && x <= 39)
		LEVEL_UP (level, x, y, RandomX, Start, score, SubX, AddX, Stage);

		else if (level ==4 && x >= 36 && x <= 38)
		{
		Stage = Stage++;
		level = 0;
		SleepTime = SleepTime - 20;
		LEVEL_UP (level, x, y, RandomX, Start, score, SubX, AddX, Stage);
		}
		else
		{
		system("color 48");
		cout <<"\n LOSE!\n ";
		system("pause");
		exit(1);
		}
	}
	if (Stage == 3 && level == 1)
	SleepTime = SleepTime + 8;
	if (Stage == 4 && level == 1)
	SleepTime = SleepTime + 9;
	if (Stage == 5 && level == 1)
	SleepTime = SleepTime + 11;
	if (Stage == 6 && level == 1)
	SleepTime = SleepTime + 13;
	if (Stage == 7 && level == 1)
	SleepTime = SleepTime + 15;
	if (Stage == 8 && level == 1)
	SleepTime = SleepTime + 17;
	if (Stage == 9 && level == 1)
	SleepTime = SleepTime + 19;
	if (Stage == 10 && level == 1 || Stage == 11 && level == 1 || Stage == 12 && level == 1 || Stage == 13 && level == 1 || Stage == 14 && level == 1 || Stage == 15 && level == 1 || Stage == 16 && level == 1)
	SleepTime = SleepTime + 19;
	if (Stage == 17 && level == 1 || Stage == 18 && level == 1 || Stage == 19 && level == 1 || Stage == 20 && level == 1)
	SleepTime = SleepTime + 19;
	return 0;

}

double LEVEL_UP (int& level, double& x, double& y, int& RandomX, bool Start, int& score, bool& AddX, bool& SubX, int& stage)
{
if(x == 39 && AddX == false)
score = score + 5;
if(x == 37 && SubX == false)
score = score + 5;
HANDLE hStdout = GetStdHandle (STD_OUTPUT_HANDLE);
CONSOLE_SCREEN_BUFFER_INFO ScreenBufferInfo = { 0 };
GetConsoleScreenBufferInfo(hStdout, &ScreenBufferInfo);
GotoXY( hStdout,
ScreenBufferInfo.dwCursorPosition.X,
ScreenBufferInfo.dwCursorPosition.Y );
	cout <<"\n WIN!\n ";
	system("pause"); 
	CLEAR_SCREEN();
	level = level++;

	x = 17;
	y = 0;
	GotoXY(hStdout, x, y);
	OUTPUT(level, Start);
	srand ( time(NULL) );
	RandomX = rand() % 2 + 1;
	y = 3;
	if (RandomX == 1)
	x = 18;
	else if (RandomX == 2)
	x = 57;
	score = score +20;
	cout << "   Score:" << score;
	cout << "\n                                                               ----------";
	cout << "\n                                                                Level: " << level;
	cout << "\n                                                                Stage: " << stage;

	return 0;
}
double OUTPUT(int& Level, bool Start)
{
	if (Start != true)
	cout <<"               -REFLEX TESTER-";
	if(Level == 1)
	cout <<"\n\n                 <_________________/   *   \\________________>";

	if(Level == 2)
	cout <<"\n\n                 <__________________/  *  \\_________________>";

	if(Level == 3)
	cout <<"\n\n                 <___________________/ * \\__________________>";

	if(Level == 4)
	cout <<"\n\n                 <____________________/*\\___________________>";

	return 0;
}

When you pass by arguments with references you should make the references const so you don't accidently change the data your passing.

As far as classes go i'm assuming you know the basic sutff like access identifiers. If you need to research a little more the tutorial on the site here is good. Also just an overall design tip: it's nice to put comments in your code for other people esspecially if your showing it to other people.
Ok i kinda see what you are saying but yes i could use some good tutorials ive been looking for a good one but it seems like in order to implement it in my code i would have to start all over. I was wondering if there could be another way i could implement classes without having to change everything. Also i had comments in my code but i had to take them out because the limit is 9000 words although i probably could have just posted them in another message box lol but thank you for responding!
Why, exactly, are you doing Windows programming without first understanding classes?
Well, i had just started programming about 2 months ago and our teacher is just now covering classes. im just trying to get through the basics.
Windows programming isn't "the basics".
ok, thanks for the help
Topic archived. No new replies allowed.