This is the First game i maded in C++ this maybe usefull for newbs. who want to learn C++ the Source Contains: If Triggers, Loops, Random, Variables and Functions.
The Source:
Code:/* Maded by: Iron Skull Maded on: 26-11-'05 */ #include <iostream> #include <stdlib.h> int MenuFunction; int GameStart(void); int GuessedNumber; int RightNumber; int lives; int main (void) { lives = 3; std::cout << "\t\t\tWelcome to Guess the Number!\n"; std::cout << "\t\t\tMaded by: Robin Vossen\n\n"; std::cout << "\tMenu:\n\t1 - Start Game\n\t2 - Help\n\t3 - Quit Game\n\n"; while (MenuFunction =! 0) { std::cout << "Pick Command:\n"; std::cin >> MenuFunction; if (MenuFunction == 1){ /*Game Start*/ GameStart(); break; }else if (MenuFunction == 2){ /*Show Help*/ std::cout << "This is Help...\n"; }else if (MenuFunction == 3){ /*Quit App*/ break; } } return 0; } int GameStart(void) { RightNumber = rand() % 100; RightNumber++; StartOfGame: GuessedNumber = 0; std::cout << "Now you have to pick a number between 1 and 100\n"; std::cin >> GuessedNumber; if (GuessedNumber == RightNumber){ std::cout << "\aY\ao\au\a \aG\au\ae\as\as\ae\ad\a \at\ah\ae\a \an\au\am\ab\ae\ar\a!\a\n\n\n"; main(); }else{ lives = lives - 1; if (lives > 0){ std::cout << "Wrong Number you still have " << lives << " chance(s)!\n"; goto StartOfGame; }else{ std::cout << "Game Over!\nThe Right Number was " << RightNumber << "\n"; } } return 0; }




Reply With Quote