Help me with my project please!

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
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
#include <iostream>
#include <fstream>
#include <vector>
#include <ctime>
#include"dos.h"
#include <stdio.h>
#include <stdlib.h>
#include <time.h>
#include "windows.h"
#include<string>
using namespace std;

HANDLE hCon;
string menu_choice;
void options();// declare these up here so i can declare them in menu method and menu in these methods without any confusion...
void tutorial ();

//anagram solvers from http://homepage.ntlworld.com/adam.bozon/anagramsolver.htm


char words[7];//character array for allo possible words. array used for counting points for indivisdual letters
	//to assign value to each letter of the alphabet according to scrabble rules

string word_set;
int randnum; 
int difficulty = 1;//for difficulty 1-3
char rand_color_dis = 'n';//used in options, converts to bool though for easier computing... set to no for default
bool rand_color_disable = 0;//to disable random color in case it gets annoying... which it porbably well... disable in options menu of game
enum Color { DARKBLUE = 1, DARKGREEN, DARKTEAL, DARKRED, DARKPINK, DARKYELLOW, GRAY, DARKGRAY, BLUE, GREEN, TEAL, RED, PINK, YELLOW, WHITE };

void SetColor(Color c){
        if(hCon == NULL)
                hCon = GetStdHandle(STD_OUTPUT_HANDLE);
        SetConsoleTextAttribute(hCon, c);
}



void load(){
	cout<<"Loading";
for(int i = 0;i <=2;i++){ //waits 3 seconds, just for cool loading effect....
	cout<<".";	
Sleep(1000);
}
system("cls");//clears screen after loading
}

void rand_color(){ // will set color to random color.... only in actual game, not menu screen, we need some consistency!!
	int rand_color = rand() % 14 + 1;//makes randum numbe from 1-15
	switch(rand_color){
	case 1:
		SetColor(DARKBLUE);
	break;
	case 2:
		SetColor(DARKGREEN);
	break;
	case 3:
		SetColor(DARKTEAL);
	break;
	case 4:
		SetColor(DARKRED);
	break;
	case 5:
		SetColor(DARKPINK);
	break;
	case 6:
		SetColor(DARKYELLOW);
	break;
	case 7:
		SetColor(GRAY);
	break;
	case 8:
		SetColor(DARKGRAY);
	break;
	case 9:
		SetColor(BLUE);
	break;
	case 10:
		SetColor(GREEN);
		case 11:
		SetColor(TEAL);
	break;
	case 12:
		SetColor(RED);
	break;
	case 13:
		SetColor(PINK);
	break;
	case 14:
		SetColor(YELLOW);
		break;
		case 15:
		SetColor(WHITE);
	break;
	}
	
	
	//TODO
	//FINISH THIS IN OPTIONS PORTION!!!
	
	if(rand_color_disable = 1){//boolean 1 for true... couly use char or something but booleans just to match rubric
		SetColor(GRAY);
	}

	
}

void menu(){
	 SetColor(GREEN);
cout<<"            TEXT TWIST"<<endl;
cout<<"\n \n  \n";
    SetColor(RED);
cout<<"            Play"<<endl;
cout<<endl;

    SetColor(YELLOW);
cout<<"            Options"<<endl;
cout<<endl;
        SetColor(TEAL);
cout<<"            Help"<<endl; //show tutorial here!!! with example and typing in using sleep
//in opstions allow difficulty to change, add more difficult sets as it increases!

cin>>menu_choice;
system("cls");

if(menu_choice =="Help" || menu_choice =="help"){


tutorial();


menu();
}
if(menu_choice =="Options" || menu_choice =="options"){
options();
}
}

void ready_load(){
	int i = 5;
	
	while(i>0){
cout<<"Ready in: "<<i;
i--;
Sleep(1000);
system("cls");

	}
}

void options(){
		
	int choice;

system("cls");
rand_color();

cout<<"1. RANDOM COLOR DISABLED:		"<<rand_color_dis<<endl;
cout<<endl;
cout<<"2. difficulty:		"<<difficulty<<" (1-3, 1- easiest, 3- hardest)"<<endl;

cout<<endl;
cout<<endl;

cout<<"Which would you like to change? ";
cin>> choice;



if (choice = 1){
	char rand_color_dis = 'y';//used in options, converts to bool though for easier computing... set to no for default
bool rand_color_disable = 1;
}

if(choice = 2){
	cout<<"Different levels of diifficulty are still being added... Stay tune foir more info"<<endl;
}

else{
	options();
}




cout<<endl;
cout<<"ok. Changes saved! \n "<<endl;
system("pause");//i kow this is terrible, but it to do it is the only way it will work
system("cls");
menu();


		}



void tutorial(){

    char answer[7] = {'m','a','i','l'};

	rand_color();//makes random color! This should be fun...
system("cls");
cout<<"Welcome to the tutorial! This will show you how to play the game \n it will simulate a real game, please keep in mind \"//\" are \n instrucionts used only in the tutorial, not in the actual game!"<<endl;
	system("pause");//i know this is not supposed to be used but it is the only way. cin.get does not work when system("cls") is used right after
system("cls");

cout<<"Here are your first set of words: fmalie"<<endl;
Sleep(1000);
cout<<endl;
cout<<"//You Must type in all possible words! Like this:"<<endl;

Sleep(3000);
for(int i = 0;i <=7;i++){

Sleep(400);
cout<<answer[i];
}
cout<<"Correct! 400 points!"<<endl;
Sleep(1400);

system("cls");

cout<<"Here are your first set of words: fmalie"<<endl;
cout<<endl;
cout<<"//Here is another example:"<<endl;
Sleep(3000);
 char answer_1[7] = {'m','e'};
for(int j = 0;j <=7;j++){

Sleep(400);
cout<<answer_1[j];
}
cout<<"Correct! 200 points"<<endl;
Sleep(1400);
system("cls");

cout<<"Here are your first set of words: fmalie"<<endl;
cout<<endl;
cout<<"//Make sure you dont type in anything incorrect \n It will subtract from your points!"<<endl;
Sleep(3500);
char answer_2[7] = {'l','e','m','e'};
for(int c = 0;c <=7;c++){

Sleep(400);
cout<<answer_2[c];
}
cout<<"Incorrect, you have lost 50 points!"<<endl;

system("cls");
rand_color();
cout<<"\n \n That is the end of the tutorial!\n \n The point system char: \n \n Letters		Points \n 2			200 \n 3		300 \n 4			400 \n 5			500 \n 6			600 \n 7			700 \n \n press enter to continue!";
	system("pause");//i know this is not supposed to be used but it is the only way. cin.get does not work when system("cls") is used right after
system("cls");


}







void intro(){
	char intro[90] = {'W','e','l','c','o','m','e',' ','T','o',' ','T','e','x','t',' ','T','w','i','s','t',' ','B','y',' ','*','*','*','*','*','*',' ','*','*','*','*','*'};

	for(int i = 0;i<=65;i++){

	
		if(i == 7 || i == 10 || i == 21) {
		cout<<"\n  \n";
		}

		SetColor(BLUE);
	cout<<intro[i];
	Sleep(75);
	}
	system("cls");
		load();
	}

void begin_words(){
	


}


void get_string(){

	
		
		randnum= rand() % 14 + 1;//fifteen possible numbers

		switch(randnum){
		case 1:
			word_set = "detraly";
			break;
			
			case 2:
			word_set = "zolefya";
			break;
			case 3:
			word_set = "yamilrw";
			break;
			case 4:
			word_set = "prtadg";
			break;
			case 5:
			word_set = "nemofoi";
			break;
			case 6:
			word_set = "tcvodil";
			break;
			case 7:
			word_set = "xoktre";
			break;
			
			case 8:
			word_set = "pyhltwi";
			break;
			case 9:
			word_set = "qutrilb";
			break;
			case 10:
			word_set = "zefihld";
			break;
			case 11:
			word_set = "eicldfm";
			break;
			case 12:
			word_set = "pilogva";
			break;
			case 13:
			word_set = "itghojs";
			break;
			case 14:
			word_set = "viofslb";
			break;
			case 15:
			word_set = "jouygln";
			break;
		}
		//EASY USE ARRAYS FOR EACH SET OF LETTERS FOR ALL POSSIBLE WORDS AND USE FOR LOOP TO SORT THROUGH
}




char char_to_point(char *letter){//need to have defined array above because this methods serves to purposes:
return 0;
}



int main() {
	srand( time(0));//to make random num in get_string. if this is in the fuctino then it will return same num each time



	intro();
menu();
system("cls");
ready_load();
cout<<"Here is your first set:";
get_string();
cout<<word_set<<endl;

system("pause");//pauses program, prevents from closing
return 0;
}



yes i am aware that alot of it does not do anything, but i just want to get theis random color thing working. it was working fin with the random colors before, but i thought my teacher might be annoyed while grading it. so i wanted to make an option to turn it off... that is where the problems began look at the end of the random color method, and the options method...

first of all, type in help on menu to test the random color. it would switch every time before i tried to add in disable, but now it is just gray, even though in options it says it disabled random color is off. and in options, when i try to change anything... it really doesnt so anything, and it just prints out all of the possible cout statemtnes in the three if statements

please help!!!

thanks!

thanks!
Last edited on
Is it part of the homework that it generate random colors?

If not, remove it. All you end up doing is making the teacher's job harder trying to wade through excess.
haha well he likes original ideas, so i would like to keep it if possible

the random colors work fine, but when i try to add in a way to disable them in options, then it gives me issues
Last edited on
is it possible to do the have the disable random color option in the settings?
As far as i ses this condition will always be true ..


if(rand_color_disable = 1){//boolean 1 for true... couly use char or something but booleans just to match rubric
SetColor(GRAY);
}



So, it will be better if change it to if(rand_color_disable==1) then i guess your code will work as expected.

Topic archived. No new replies allowed.