Woot! My First Game Ever!

This is a discussion on Woot! My First Game Ever! within the C++ Programming forums, part of the General Programming Boards category; I've been doing C++ for about three weeks, and this is my first game ever. It's a nice little adventure ...

  1. #1
    Registered User LordVirusXXP's Avatar
    Join Date
    Dec 2002
    Posts
    86

    Talking Woot! My First Game Ever!

    I've been doing C++ for about three weeks, and this is my first game ever. It's a nice little adventure game. I hope you like it.

    geocities.com/lordvirusxxp/game2.zip
    Last edited by LordVirusXXP; 01-01-2003 at 09:40 PM.
    - Dean

  2. #2
    Registered User abrege's Avatar
    Join Date
    Nov 2002
    Posts
    369
    Thats pretty neat. Suggestions:

    1. Create error-checking for user input so that entering a non-integer will not crash the program.
    2. When the character dies, the user should be informed.
    3. "Enter the value 69 to exit the program"?! How about using system("pause"), getch(), or cin.get() to pause the program until the user hits a key?
    4. A background story would be nice

    Other than that, the game is pretty well done for 3 weeks of learning. I want to see more newbies create "problem solving" games like these Can we see the source code?
    I am against the teaching of evolution in schools. I am also against widespread
    literacy and the refrigeration of food.

  3. #3
    Registered User LordVirusXXP's Avatar
    Join Date
    Dec 2002
    Posts
    86

    Talking

    Originally posted by abrege
    Thats pretty neat. Suggestions:

    1. Create error-checking for user input so that entering a non-integer will not crash the program.
    2. When the character dies, the user should be informed.
    3. "Enter the value 69 to exit the program"?! How about using system("pause"), getch(), or cin.get() to pause the program until the user hits a key?
    4. A background story would be nice

    Other than that, the game is pretty well done for 3 weeks of learning. I want to see more newbies create "problem solving" games like these Can we see the source code?
    I haven't learned about getch(), cin.get(), or anything like that yet. And I wasn't too worried about a good storyline. But thanks, I'm kinda proud of it. Here's my source code. There are no comments:

    Code:
    #include <iostream.h>
    class Mosadna
    {
    	int HP;
    public:
    	Mosadna();
    	~Mosadna();
    	int GetHP() const;
    	void SetHP(int x);
    };
    
    	
    Mosadna::Mosadna()
    {
    	HP = 200;
    }
    Mosadna::~Mosadna()
    {
    }
    int Mosadna::GetHP() const
    {
    	return HP;
    }
    void Mosadna::SetHP(int x)
    {
    	HP -= x;
    }
    
    Mosadna Sebba;
    
    int damage = Sebba.GetHP();
    bool knife = false;
    bool ending = false;
    
    bool knifex()
    {
    knife = true;
    return knife;
    }
    
    void Ending()
    {
    	cout << "\n\nYou survived the horrible fields of Lawnmower Land, found the magical knife, and cracked the password to escape this horrible place. Congratulations!\n\nTHE END";
    	ending = true;
    	for ( ;; )
    	{
    		int end;
    		cout << "\nEnter the value 69 to exit the program: ";
    		cin >> end;
    		{
    		if (end == 69)
    			break;
    		else 
    			continue;
    		}
    		}
    }
    
    void MenuZ()
    {
    	cout << "\nYou see a tree. Engraved in it are the words 'Passoword'. Carve in the password with your knife, or enter the number '5' to exit:  ";
    	for( ;; )
    	{
    	bool exit4 = false;
    	int password;
    	cin >> password;
    	switch (password)
    	{
    	case 5: exit4 = true;
    		break;
    	case 52: cout << "\nWhoa, you're close!";
    		break;
    	case 53: cout << "\nOh, you almost have it!!!";
    		break;
    	case 54: cout << "\nPerfect!";
    		Ending();
    		break;
    		case 55: cout << "\nOh, you almost have it!!!";
    		break;
    	case 56: cout << "\nWhoa, you're close!";
    		break;
    	default: cout << "\nThat wont work, try something else: ";
    		break;
    	}
    	if (damage < 1 || exit4 || ending)
    		break;
    	else 
    		continue;
    	}
    	}
    void MenuY()
    {
    	cout << "\nWow, what a beautiful place! ";
    	for ( ;; )
    	{
    	cout << "\n";
    	cout << "\n1 - Go North\n2 - East\n3 - West\n4 - Go back\nCommand: ";
    	bool exit3 = false;
    	int input2;
    	cin >> input2;
    	switch (input2)
    	{
    	case 1: cout << "\nThere's nothing here at all, except a piece of paper that says '54' on it.\nYou're going to have to go back.\n";
    		break;
    	case 2: cout << "\nOn, no! You were attacked by evil goblins!\n";
    		damage -= 80;
    		{
    		if (damage > 1)
    			cout << "\nRemaining HP: " << damage;
    		else
    			break;
    		}
    		break;
    	case 3: cout << "\nYou're in a forest clearing.\n";
    		{
    		if (knife)
    		MenuZ();
    		else
    			continue;
    		}
    		break;
    	case 4: exit3 = true;
    		break;
    	default: cout << "\nThat wont work, try something else: ";
    	}
    	{
    	if (exit3 || damage < 1 || ending)
    		break;
    	else
    		continue;
    	}
    	}
    }
    void MenuX()
    {
    		
    	cout << "\nWhere do you want to go?";
    	for ( ;; )
    	{
    	cout << "\n1 - Woods\n2 - Swamp\n3 - Hut\n4 - Exit\nCommand: ";
    	bool exit2 = false;
    		int input2;
    		cin >> input2;
    		switch (input2)
    		{
    			{
    		case 1: MenuY();
    		break;
    			}
    			{
    		case 2: cout << "\nThe poison from the swamp's atmoshpere has hurt you!";
    		damage -= 75;
    				{
    		if (damage > 1)
    			cout << "\nRemaining HP: " << damage;
    		else
    			break;
    		}
    		break;
    			}
    		case 3: 
    			{
    			if (knife)
    				cout << "\nThere's nothing here. You have to go back.";
    			else
    			cout << "\nThe door to the hut is locked, but there's a knife in front of the door. You\ntake the knife\n";
    			knifex();
    			}
    			break;
    			{
    		case 4: exit2 = true;
    			break;
    			}
    		
    		default: cout << "\nThat wont work, try something else:\n ";
    			
    		}
    		{
    			if ( exit2 || damage < 1 || ending)
    				break;
    			else 
    				continue;
    		}
    		{
    		if (exit2)
    				break;
    			else
    				continue;
    		}
    		}
    }
    void RunStats()
    {
    	cout << "\nYour remaining HP: " << damage;
    }
    void RunExploration()
    {
    	MenuX();
    }
    
    
    main()
    {
    
    bool exit = false;
    int hurt = damage;
    
    	cout << "Warning: Any non-intenger input values will result in a program crash\n";
    	cout << "You're toal HP: " << damage << "\n\n";
    for ( ;; )
    {
    	cout << "\n\n1 - Check Stats\n2 - Go Exploring\n3 - Exit\nCommand: ";
    	int input;
    	cin >> input;
    	switch (input)
    	{
    	case 1: RunStats();
    		break;
    	case 2: RunExploration();
    		break;
    	case 3: exit = true;
    		break;
    	default: cout << "\nThat wont work, try something else: ";
    		break;
    	}
    	{
    		if (exit || damage < 1 || ending)
    		break;
    	else
    		continue;
    	}
    	}
    cout << "\n\n\n\nGAME OVER       ";
    
    return 0;
    }
    Last edited by LordVirusXXP; 01-01-2003 at 10:35 PM.
    - Dean

  4. #4
    I lurk
    Join Date
    Aug 2002
    Posts
    1,361
    It looks like your programming skill would benefit a lot if you browsed through this website: http://www.parashift.com/c++-faq-lite/

    There's many things I could suggest... but there's just too many. Nothing major though.

    AND USE CODE TAGS

  5. #5
    Registered User LordVirusXXP's Avatar
    Join Date
    Dec 2002
    Posts
    86
    Thanks for the site, but I do use code tags. The hyperlink to my game wasn't working, so I just gave people the address.
    - Dean

  6. #6
    I lurk
    Join Date
    Aug 2002
    Posts
    1,361
    Originally posted by LordVirusXXP
    Thanks for the site, but I do use code tags. The hyperlink to my game wasn't working, so I just gave people the address.
    No, edit your above post (with the code in it) and enclose it in [code ] and [ /code]

    Without the spaces.

  7. #7
    Registered User LordVirusXXP's Avatar
    Join Date
    Dec 2002
    Posts
    86
    I know what I'm doing. It honestly didn't work. The code tags and the address were perfect, and it didn't work.
    - Dean

  8. #8
    Registered User abrege's Avatar
    Join Date
    Nov 2002
    Posts
    369
    The link you had worked, all we needed to do was right click it and hit "save target as".

    As for code tags, put [ code ] and [/ code ] around your code and it should look like this:

    Code:
    #include <iostream> main() { std::cout << "HW\n"; }
    Really makes it more readable
    Last edited by abrege; 01-01-2003 at 10:29 PM.
    I am against the teaching of evolution in schools. I am also against widespread
    literacy and the refrigeration of food.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. how do the game engine and the api interact?
    By Shadow12345 in forum Game Programming
    Replies: 9
    Last Post: 12-08-2010, 12:08 AM
  2. game engine advice?
    By stien in forum Game Programming
    Replies: 0
    Last Post: 01-23-2007, 03:46 PM
  3. 2D RPG Online Game Project. 30% Complete. To be released and marketed.
    By drallstars in forum Projects and Job Recruitment
    Replies: 2
    Last Post: 10-28-2006, 01:48 AM
  4. C++ Game of Life Program
    By rayrayj52 in forum C++ Programming
    Replies: 16
    Last Post: 09-26-2004, 04:58 PM
  5. My Maze Game --- A Few Questions
    By TechWins in forum Game Programming
    Replies: 18
    Last Post: 04-25-2002, 12:00 AM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21