PDA

Click to See Complete Forum and Search --> : [C++] First Game + Source


Iron Skull
Nov 26th, 2005, 02:55 PM
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:

/*
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;
}

VBDeceiver
Apr 16th, 2006, 11:47 PM
Isn't this VBForums.com. :-x

k1ll3rdr4g0n
Apr 17th, 2006, 02:43 AM
Isn't this VBForums.com. :-x

The title of the page says "VB.Net Discussion and more!". The more includes C++ , VB6, PHP ect...

Btw, Iron Skull, why wouldn't you put
using namespace std;
at the top after you declared the libraries? If you put that then you don't have to put std:: every time ;).

VBDeceiver
Apr 17th, 2006, 10:59 AM
oh.. Alright...lol :-x Sounds Good. maybe I'll get into "More" Stuff now. :-p

merhaba
Apr 18th, 2006, 05:33 AM
This is a console game
How can we make the same game in Win app version..?

PlaGuE
Apr 18th, 2006, 05:20 PM
VBDeceiver. You have 17 posts... havent you seen the front page at all?