Jump to content
  • Advertisement
Sign in to follow this  
C_Programmer0101

Need help with functions

This topic is 5040 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

How can I implement this function New Game() In case 1: #include <iostream> #include <string> #include <stdlib.h> #include <conio.h> using namespace std; int choice=0; void NewGame(); void GameMenu(); bool playingGame=true; bool answer1=true; void NewGame() { cout<<"\t\t _|_|_ cout<<"\t\t _|_|_ cout<<"\t\t | | cout<<"\t\t } void GameMenu() { cout<<"\t\t **************************\n"; cout<<"\t\t * *\n"; cout<<"\t\t * *\n"; cout<<"\t\t * 1. New Game *\n"; cout<<"\t\t * 2. High Score *\n"; cout<<"\t\t * 3. Options *\n"; cout<<"\t\t * 4. Exit *\n"; cout<<"\t\t * *\n"; cout<<"\t\t *Created By C_Programmer!*\n"; cout<<"\t\t **************************\n"; } int main() { while(playingGame) { GameMenu(); cout<<"Choose from the Menu: "; cin>>choice; switch(choice) { case 1: cout<<"Starting New Game\n"; break; case 2: cout<<"High Score Works\n"; break; case 3: cout<<"Options Works\n"; break; case 4: playingGame=false; cout<<"Exiting Works\n"; break; } } system("PAUSE"); return 0; } Thank You!!!!

Share this post


Link to post
Share on other sites
Advertisement
Just call 'NewGame()' in the 'case 1:' expression:

#include <iostream>
#include <string>
#include <stdlib.h>
#include <conio.h>

using namespace std;

int choice=0;

void NewGame();
void GameMenu();
bool playingGame=true;
bool answer1=true;

void NewGame()
{
// I added quotes and 'endl' below
cout<<"\t\t _|_|_ " << endl;
cout<<"\t\t _|_|_ " << endl;
cout<<"\t\t | | " << endl;
cout<<"\t\t " << endl;


}

void GameMenu()
{
cout<<"\t\t **************************\n";
cout<<"\t\t * *\n";
cout<<"\t\t * *\n";
cout<<"\t\t * 1. New Game *\n";
cout<<"\t\t * 2. High Score *\n";
cout<<"\t\t * 3. Options *\n";
cout<<"\t\t * 4. Exit *\n";
cout<<"\t\t * *\n";
cout<<"\t\t *Created By C_Programmer!*\n";
cout<<"\t\t **************************\n";


}
int main()
{
while(playingGame)
{
GameMenu();

cout<<"Choose from the Menu: ";
cin>>choice;

switch(choice)
{
case 1:
cout<<"Starting New Game\n";
// call to 'NewGame()' function
NewGame();
break;
case 2:
cout<<"High Score Works\n";
break;
case 3:
cout<<"Options Works\n";
break;
case 4: playingGame=false;
cout<<"Exiting Works\n";
break;

}

}

system("PAUSE");
return 0;
}




Good luck,
Pat.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!