Results 1 to 6 of 6

Thread: [C++] First Game + Source

Hybrid View

  1. #1

    Thread Starter
    Hyperactive Member Iron Skull's Avatar
    Join Date
    Aug 2005
    Location
    The Netherlands
    Posts
    325

    Talking [C++] First Game + Source

    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;
    }
    Attached Files Attached Files

    506C65617365205261746520506F7374732E2E2E

  2. #2
    Junior Member VBDeceiver's Avatar
    Join Date
    Jan 2006
    Posts
    30

    Re: [C++] First Game + Source

    Isn't this VBForums.com. :-x
    If Mans Mind Can Make it, Mans Mind Can Break it.

  3. #3
    Fanatic Member
    Join Date
    Oct 2004
    Posts
    751

    Re: [C++] First Game + Source

    Quote Originally Posted by VBDeceiver
    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
    Code:
    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 .
    My Projects: [ Instant Messagener Client/Server ] [ VBPictochat ]

    My Sites:
    [ Datanethost ]
    [ Helpdesk ]

    Remember if my post was helpful then Rate This Post.

  4. #4
    Junior Member VBDeceiver's Avatar
    Join Date
    Jan 2006
    Posts
    30

    Re: [C++] First Game + Source

    oh.. Alright...lol :-x Sounds Good. maybe I'll get into "More" Stuff now. :-p
    If Mans Mind Can Make it, Mans Mind Can Break it.

  5. #5
    Fanatic Member merhaba's Avatar
    Join Date
    Sep 2002
    Location
    Istanbul,Bartin-Gallipoli(Gelibolu-Canakkale)
    Posts
    601

    Re: [C++] First Game + Source

    This is a console game
    How can we make the same game in Win app version..?

  6. #6
    Hyperactive Member PlaGuE's Avatar
    Join Date
    Jun 2005
    Location
    in ur mind.
    Posts
    445

    Re: [C++] First Game + Source

    VBDeceiver. You have 17 posts... havent you seen the front page at all?
    Without balance, there could only be chaos.
    Without chaos, there could be no balance.
    I live with karma. Eat with destiny. Dream of life without shackles....
    Yet. If life had no consequences, life could not exist, nor could it flourish.


    If at first you dont succeed.You're screwed.

    C++/Java NOOB.

    I aint a professional at PHP, but if i can help i will.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width