Game: Word Scramble

closed account (oy8URXSz)
Guys, I really need a big help over here. I need to make a word scramble game. When the program is running, it will prompt the user to enter the name of the player. Once the name has been entered, it should show the mechanics of
how the game is played. When the player wishes to start the game, s/he should press the <ENTER> key or some other key which will activate the game. Initially, the player will be given $1000 as his starting score. When the game starts... the first word will now display on screen. The letters in the word to be guessed are scrambled. For each word s/he enters correctly, that person will get $10 for each letter of the word. If s/he makes a mistake, $200 will be deducted from his/her score. The player will be given an option if s/he wants to ask a clue regarding the word. If the user would like clue, a special key will be entered to display the first clue. A maximum of 2 clues will be given for each word. When the user opts to ask a clue, $150 will be deducted from his/her score.

NOTE: Only Basic programming constructs should only be seen in the program. The following constructs MUST be seen, namely: input/output commands, branching statements (if, if else, and/or switch statements), looping constructs (for, while, and/or do while), functions and procedures.

I'm now in the first part of the code. Here's the code.

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
#include<iostream>
#include<string>
#include<windows.h>
using namespace std;
int main()
{
	SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE),14);
	string name,guess,choice;
	cout<<"Hi there, what's your name?"<<endl;
	cin>>name;
	system("cls");
	cout<<"Welcome to the World of Scrambled Words "<<name<<endl;
	cout<<"This is just an easy game. Just simply unscramble the letters"<<endl;
	cout<<"to form the right word and get $10 for each word you enter correctly."<<endl;
	cout<<"If you can't guess it, pay $150 and enter V to get some helpful hints."<<endl;
	cout<<"Need one more helpful hint? Then enter H! But if you got the guess wrong,"<<endl;
	cout<<" you'll lose $200-Ouch! Be careful not to dwindle all your money or the"<<endl;
	cout<<"game's over. Here's $1000 for you, spend it wisely. Good Luck and Happy Gaming!"<<endl;
	cout<<"Are you ready?[YES/NO]"<<endl;
	cin>>choice;
	if (choice=="YES")
	{
		system("cls");
		cout<<"Guess this scrambled word"<<endl;
		cout<<"putremoc"<<endl;
		cin>>guess;
		if (guess =="computer")
			cout<<"Correct!"<<endl;
		else if (guess =="V")
			cout<<"HINT: A machine that manipulates data according to a list of instructions."<<endl;
		else if (guess=="H")
			cout<<"HINT: You're using it right now!"<<endl;
		else
			cout<<"Oops, wrong answer!"<<endl;
        }
	else if(choice=="NO")
	{
		cout<<"Are you chicken? Get out!";
	}
	else
	{
		cout<<"I can't understand you! Please restart.";
	}
	system("pause");
    return 0;
}


But I don't know
•how I will display and change the score(money) every time the user is correct or wrong;
•how would I display hints & let the user input an answer; and
•how would I proceed to the next scrambled word?


The other words for scrambling w/ two hints(separated by "&") are:

•game- something played for enjoyment & an activity providing entertainment

•engineer- a person who is professionally engaged in a field of engineering & one who is trained or professionally engaged in a branch of engineering.

•algorithm- type of effective method used to solve problem & a step-by-step problem-solving procedure, especially an established, recursive computational procedure for solving a problem in a finite number of steps.

•jumble- it's what the game is all about & to mix in a confused way.

•software- a type of program, procedure and documentation that perform's specific task & the programs, routines, and symbolic languages that control the functioning of the hardware and direct its operation.

•hardware- the physical components of a computer system & directly involved in the performance of data-processing or communications functions.

•glasses- these might help you see the answer.

•internet- a worldwide, publicly accessible series of interconnected computer networks that transmit data by packet switching using the standard Internet Protocol (IP)& an interconnected system of networks that connects computers around the world via the TCP/IP protocol.

•programmer- someone who writes computer software & one who prepares or writes instructional programs.
Last edited on
Use a struct like so:

1
2
3
4
5
6
7
struct data
{
  const char *word;
  const char *scramble,
  const char *hint1;
  const char *hint2
};


You can set the data like so:
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
const data d[] =
{
  { "computer", "putremoc", "HINT: A machine that manipulates data according to a list of instructions.", "HINT: You're using it right now!" },
  { ... },
};
const int d_size = sizeof(d) / sizeof(*d);
...
	score = 1000;
for(int i = 0; i < d_size; i++)
{
	if(i > 0)
		cout<<"Again?";
	cin>>choice;
	if (choice=="YES")
	{
		system("cls");
		cout<<"Guess this scrambled word"<<endl;
		cout<<d[i].scramble<<endl;
		cin>>guess;
		if (guess ==d[i].word)
			{ cout<<"Correct!"<<endl; score += ...; }
		else if (guess =="V")
			{ cout<<d[i].hint1<<endl; score -= 150; }
		else if (guess=="H")
			{ cout<<d[i].hint2<<endl; score -= ...; }
		else
			{ cout<<"Oops, wrong answer!"<<endl; score -= ...; }
        }
	else if(choice=="NO")
	{
		cout<<"Are you chicken? Get out!";
		break;
	}
...
}
Last edited on
Topic archived. No new replies allowed.