SilabGarza - RS Private Server  
Home Forum Play Register Store Market Highscores Mark Forums Read
Go Back   SilabGarza - RS Private Server > SilGar Media > Computers > Programming
Reload this Page C++ Text Game!


C++ Text Game!
Old
  (#1 (permalink))
Zvp is Offline
<span style="color: greenyellow">-Epic Gfxer-</span>
image
 
Zvp's Avatar
 
Posts: 2,455
Cookies Given: 0
Cookies Received: 1
Time Online: 12 d 34 m
Clan: KAPP
   
Default C++ Text Game! - 07-29-2012, 09:29 PM

Well.
This is probably the most fun C++ project I've ever done.
Since, I hate doing graphics with C++, I decided to do it with just normal programming.
It's quite interesting. I learned a lot of new things in order to get this too work. Since I'm quite new, but understand everything extremly well, and can write any basic program I feel like, but I'm still learning. I learned Switch statements, with cases, which helps a lot.
Goto, which I knew how to do, but then decided to try that out and it works.
I'm using num = rand() %30; for the damage.
It's not complete, which is why I called it a project.
When I'm done I'll put up the . exe file if you guys want.
I think you'll understand what's going on, if you know some programming:
Code:
/* Adventure Text Game!
Programmer: Zach Perkitny */
#include <windows.h>
#include <iostream>
#include <stdlib.h>
#include <string>
#include <time.h>

using namespace std;

int main(int argc, char *argv[])
{
	int reply;
	int anwser;
	int num;
	int attack1;
	int num1;
	int attack2;
	int num2;
	string a1;
	a1 = "Yes";
	string a2;
	a2 = "";
	string a3;
	a3 = "yes";
	string a4;
	a4 = "no";
	string a5;
	a5 = "No";
	int journey1;
	cout<<"Hello welcome to The Adventure Game!"<<endl;
	cout<<"Please enter a number to choose your path in the game!"<<endl;
	cout<<"To end the game you can simply enter a negative number\n or any number that is not a number to move on!"<<endl;
	cout<<"Enter 1 to go to the left door,\n enter 2 to go to the right door,\n or enter 3 to enter the center door"<<endl;
	cout<<"Door 1 is for the warrior quest, 2 for the ranger and 3 for the thief."<<endl;
	cin>>reply;
	
	switch (reply){
		case 1:
			cout<<"You've entered the left door where you notice there is a chest."<<endl;
			cout<<"Enter 4 to open"<<endl;
			cin>>reply;
			if(reply == 4){
				goto warrior;
			}
		case 2:
			cout<<"You've entered the right door where you notice there is a chest."<<endl;
			cout<<"Enter 5 to open"<<endl;
			cin>>reply;
			if(reply == 5){
				goto ranger;
			}
		case 3:
			cout<<"You've entered the center door where you notice there is a chest."<<endl;
			cout<<"Enter 6 to open"<<endl;
			cin>>reply;
			if(reply == 6){
				goto thief;
			}
		default:
			break;
	}
	warrior:
			cout<<"You've chosen the path of the warrior. You will now recieve the following items:"<<endl;
			cout<<"Full Iron Armour, helm, boots, body etc. You also have the choice between:"<<endl;
			cout<<"Owning a One Hand Iron Sword and have a sheild, \n or owning a Two Handed Iron greatsword?"<<endl;
			cout<<"Enter 1 for One Handed, and 2 for Two Handed:"<<endl;
			cin>>anwser;
			if(anwser == 1){
				goto one;
			}
			else if(anwser == 2){
				goto two;
			}

	ranger:
			cout<<"You've chosen the path of the ranger. You will now recieve the following items:"<<endl;
			cout<<"Full Leather Armour, helm, boots, body, iron arrows, etc. \n You also have the choice between:"<<endl;
			cout<<"Owning a Short Bow for quick and lower damage or:"<<endl;
			cout<<"Owning a Long Bow for slower, but higher damage."<<endl;
			cout<<"Enter 3 for Short Bow, and 4 for Long Bow"<<endl;
			cin>>anwser;
			if(anwser == 3){
				goto shor;
			}
			if(anwser == 4){
				goto lon;
			}
	thief:
			cout<<"You've chosen to be a theif, nice choice, and you will have the ability\n to sneak by enemies, steal items."<<endl;
			cout<<"You recieve Leather armour, heml, boots, body."<<endl;
			cout<<"And you get a dagger or normal sword"<<endl;
			cout<<"Enter 5 for a dagger, and 6 for a Normal Sword"<<endl;
			cin>>anwser;
			if(anwser == 5){
				goto dagger;
			}
			if(anwser == 6){
				goto sword;
			}
	one:
		cout<<"You've chosen the One Handed Sword\n with the sheild"<<endl;
		cout<<"Would you like to move on? Type yes to do so."<<endl;
		cin>>a2;
		if(a2 == a1){
			goto journey1;
		}
		else if(a2 == a3){
			goto journey1;
		}
		else if(a2 == a4){
			goto one;
		}
		else if(a2 == a5){
			goto one;
		}
	two:
		cout<<"You've chosen the Two Handed Sword"<<endl;
		cout<<"Would you like to move on? Type yes to do so."<<endl;
		cin>>a2;
		if(a2 == a1){
			goto journey2;
		}
		else if(a2 == a3){
			goto journey2;
		}
		else if(a2 == a4){
			goto two;
		}
		else if(a2 == a5){
			goto two;
		}
	shor:
		cout<<"You've chosen the Short Bow"<<endl;
		cout<<"Would you like to move on? Type yes to do so."<<endl;
		cin>>a2;
		if(a2 == a1 && a2 == a3){
			goto journey3;
		}
		else if(a2 == a3){
			goto journey3;
		}
		else if(a2 == a4){
			goto shor;
		}
		else if(a2 == a5){
			goto shor;
		}
	lon:
		cout<<"You've chosen the Long Bow"<<endl;
		cout<<"Would you like to move on? Type yes to do so."<<endl;
		cin>>a2;
		if(a2 == a1){
			goto journey4;
		}
		else if(a2 == a3){
			goto journey4;
		}
		else if(a2 == a4){
			goto lon;
		}
		else if(a2 == a5){
			goto lon;
		}
	dagger:
		cout<<"You've chosen the Dagger"<<endl;
		cout<<"Would you like to move on? Type yes to do so."<<endl;
		cin>>a2;
		if(a2 == a1 && a2 == a3){
			goto journey5;
		}
		else if(a2 == a3){
			goto journey5;
		}
		else if(a2 == a4){
			goto dagger;
		}
		else if(a2 == a5){
			goto dagger;
		}
	sword:	
		cout<<"You've chosen the Sword"<<endl;
		cout<<"Would you like to move on? Type yes to do so."<<endl;
		cin>>a2;
		if(a2 == a1){
			goto journey6;
			}
		else if(a2 == a3){
			goto journey6;
		}
		else if(a2 == a4){
			goto sword;
		}
		else if(a2 == a5){
			goto sword;
		}
		
	journey1:
		cout<<"You enter a room where you encounter a zombie!"<<endl;
		fail1:
		cout<<"I will teach you how to fight now!"<<endl;
		cout<<"Enter 1 to slash!"<<endl;
		cin>>journey1;
		srand(GetTickCount()); 
		num = rand() % 30 + 1;
		if(journey1 == 1){
			cout<<"You attack the zombie and hit a: "<<num<<endl; 
			cout<<"The zombie now has: "<< 30 - num<<" hp left"<<endl;
			ready:
			cout<<"Enter 1 to end your turn!"<<endl;
			cin>>attack1;
		}
	
		else{
			cout<<"What are you doing!?!?!"<<endl;
			goto fail1;
		}
		srand(GetTickCount()); 
		num1 = rand() % 30;
		if(attack1 == 1){
		cout<<"The zombie now tries to hit you!"<<endl;
		cout<<"He attacks you and hits a: "<<num1<<endl;
		cout<<"You have "<< 50 - num1<<" hp left"<<endl;
		cout<<"Enter 1 if you're ready:"<<endl;
		cin>>attack2;
		}
		else {
		cout<<"You ready yet?"<<endl;
		goto ready;
		}
		if(attack2 == 1){
		attack2:
		cout<<"Enter 2 to do a super slash"<<endl;
		cin>>journey1;
		}
		else{
		cout<<"Comeon!"<<endl;
		goto attack2;
		}
		srand(GetTickCount()); 
		num2 = rand() % 30 + 15;
		if(journey1 == 2){
		cout<<"You hit a "<<num2<<endl;
		}
		else{
		}
		if(30 - num - num2 <= 0){
		cout<<"You've killed the zombie!"<<endl;
		goto next;
		}
		else{
		}
		num1 = 0;
		if(30 - num2 > 0){
			cout<<"The zombie how has "<<30 - num - num2<<" hp"<<endl;
			cout<<"The zombie is stunned!"<<endl;
			cout<<"Enter 1 to Finish him!"<<endl;
			cin>>num1;
		}
		else{
		}	
		srand(GetTickCount()); 
		num2 = rand() % 50 + 10;
		if(num1 == 1){
			cout<<"You hit a "<<num2<<endl;
		}
		else{
		}
		if(30 - num - num2 - num1 <= 0){
			cout<<"You've killed the zombie!"<<endl;
			goto next;
		}
		next:
			
	journey2:
	journey3:
	journey4:
	journey5:
	journey6:
		
		
	system("PAUSE");
	return 0;
}



Click the picture for my gallery.

Gifts:
Spoiler


[Steven] [Harry] [Jordan] [Niels] [Benji] [Aaron] [Martin]

Last edited by Zvp; 07-29-2012 at 09:39 PM.
  
Old
  (#2 (permalink))
Zvp is Offline
<span style="color: greenyellow">-Epic Gfxer-</span>
image
 
Zvp's Avatar
 
Posts: 2,455
Cookies Given: 0
Cookies Received: 1
Time Online: 12 d 34 m
Clan: KAPP
   
Default 07-31-2012, 08:20 PM

Bump.
May I get some comments lol :P?



Click the picture for my gallery.

Gifts:
Spoiler


[Steven] [Harry] [Jordan] [Niels] [Benji] [Aaron] [Martin]
  
Old
  (#3 (permalink))
Tee Rouze is Offline
Senior Member
image
 
Tee Rouze's Avatar
 
Posts: 3,309
Cookies Given: 46
Cookies Received: 30
Time Online: 77 d 19 h 46 m
Clan: ENZ
   
Default 07-31-2012, 08:25 PM

You've got barely any comments because barely anyone understands this, lol.


"My conclusion is, Hate is Baggage; Life's too short to be pissed off all the time."
  
Old
  (#4 (permalink))
Ahri is Offline
Evil wakes in vengeance
image
 
Ahri's Avatar
 
Posts: 2,325
Cookies Given: 849
Cookies Received: 567
Time Online: 149 d 7 h 24 m
Clan: FBI
   
Default 07-31-2012, 08:26 PM

Is it runnable and working?






Spoiler


  
Old
  (#5 (permalink))
nater360
Guest
 
nater360's Avatar
 
Posts: n/a
Time Online: N/A
   
Default 07-31-2012, 09:36 PM

++ annoys me but I might look at this later
  
Old
  (#6 (permalink))
Zvp is Offline
<span style="color: greenyellow">-Epic Gfxer-</span>
image
 
Zvp's Avatar
 
Posts: 2,455
Cookies Given: 0
Cookies Received: 1
Time Online: 12 d 34 m
Clan: KAPP
   
Default 07-31-2012, 09:41 PM

Quote:
Originally Posted by Tee Rouze View Post
You've got barely any comments because barely anyone understands this, lol.
I'll add some, I thought some people here knew C++, but I will.
Quote:
Originally Posted by ecuiz View Post
Is it runnable and working?
Yeah, when it's done I'll post a . exe file for you guys if you want.



Click the picture for my gallery.

Gifts:
Spoiler


[Steven] [Harry] [Jordan] [Niels] [Benji] [Aaron] [Martin]
  
adsense code2.3
Closed Thread

Bookmarks

C++ Text Game!

Programming




Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
adsense2.6
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



All times are GMT -7. The time now is 10:36 AM.





Powered by vBulletin® Version 3.8.8
Copyright ©2000 - 2017, vBulletin Solutions, Inc.