bman214 23 Newbie Poster

Like I said, I'll probably begin work on this again if I get more pope to join my site.
<URL SNIPPED>

I might come back to this, though I will probably have to start over due to the amount of time it spent untouched.

I guess I'll mark this solved. *click*
Thank you all so much for helping. Please check out my website. I could use some motivation.

bman214 23 Newbie Poster

Just an update. I haven't worked much on this recently but I will continue work on my games if I get more people to join my website.

<URL SNIPPED>

Also, I had an idea for an RPG game played over email... Still thinking.

bman214 23 Newbie Poster

I added a bunch of functions. One for every building, research, law, attack, etc.

mitrmkar commented: Well Done! +4
Salem commented: Excellent! +19
bman214 23 Newbie Poster

Fixed the problem

bman214 23 Newbie Poster

When (as you have, after Dave's formatting), you see 6 closing braces in a row, and the last one is over 300 lines from it's buddy, then it's time to REFACTOR.

Add some functions man, there is no reasonable way to test that code in an incremental fashion.

Can you teach me how to go back and forth through functions?
Would u use:

int main(1)

and to get there would I use:

return 1;

or is there some other way?? Plz teach me

bman214 23 Newbie Poster

So u r saying I should use

else if (selection3 == 1){

else if (selection3 == 2){

else if (selection3 == 3){

else if (selection3 == 4){

else if (selection3 == 5){
bman214 23 Newbie Poster

I wish I could help. The thing is, i'm programming a TEXT-BASED game and I don't know how to add graphics (especialy moving ones) to C++.

bman214 23 Newbie Poster

Hello. I am working on a game called Kingdom Management. It was working fine until I added in the buildings you can make. Then it started skipping over the building, lawmaking, do nothing, and quit sections. All it could do is research.
Here is the code:

/*******************************************************************************
Kingdom Management the Game v.A-0
Creator: Bryce A Hart (BAH)
Owner:   "     " "    (""")
Title:   Kingdom Management, the Game
Version: Alpha 0.0.0
Notes:   PROOF OF CREATION/OWNERSHIP: DATE CREATED (Shows while hovering mouse over file)
         1/21/2010.

*******************************************************************************/
#include<iostream>
using namespace std;

int main(){
    //This is a game where you manage a kingdom and try to end with the most gold, land, or army.
    //Intro
    cout << "Welcome to Kingdom Management."<<endl;
    cout << "Let's begin."<<endl;
    system("pause");
    //Declare Variables (STATS)
    int selection, selection1, selection2, selection3, selection4, selection5, selection6, selection7; // This holds a selection for a console input (cin).
    int redo = 1; // This is for while loops at selections.
    int gold; // This is the ammount of money the kingdom has.
    int army; // This is the size of the kingdom's army.
    int pop = 10; // This is your population of workers available.
    int glory = 0; //This is your kingdom's "score."
    int turn = 1; //This is what turn you are on.
    //GAME BEGINS
    while (redo == 1){
    cout << "What type of kingdom would you like to have? Here are your selections:"<<endl;
    cout << "(1)Aggressive: \t 20 Gold \t 50 Army"<<endl;
    cout << "(2)Wealthy: \t 50 Gold \t …
bman214 23 Newbie Poster

Use fstream to print into a file.

Can you please put this into a code example for me?
is it like...

char code = NULL;
//... skip to the part that we save something...
cout << "Your code is "<<code<<". You can use that to recover your game."<<endl;
fstream<code> as <code.txt>

Is that correct?

bman214 23 Newbie Poster

Spit out a code = {0,1,2,3...} and have your code set up like this

main{
while(!correctcode(code)){
    cout>>"Gimme Code";
    cin<<code;}

if(code == 0) {//intro portion
   ...
   code = 1;}
if(code == 1) {//beat first boss
    ...
    code = 2;}
if(code ==2) {...}
}

It would essentially do the same as the jump, and you can even spit the code into a text file so they don't need to have it around.

How do you save the code to a text file?
is there a Save or SaveAs tag?

bman214 23 Newbie Poster

Thank you, but I still dont know all the parts and things about CImg (I am new-ish to C++ so, I can't totally understand it.

bman214 23 Newbie Poster

"goto" sux! DONT USE IT, it will make your code impossible to read!

i use think you need "goto", when you have bad program design, no question!

Well, I need to use something to jump to a line so people can save their progress. Or is there some way I can get it so it opens in the exact state it was before it closed?

bman214 23 Newbie Poster

Hello,
I am trying to use the CImg library to put images into C++, can someone help? I don't know how to use this program...

PLZ HELP

bman214 23 Newbie Poster

Omg im confused!!! R we on i, j, or k????

bman214 23 Newbie Poster

Well, you can "Jump" To different sections using a simple goto statement. However, goto's mess up the format of your code, and therefore is bad practice. So I would recommend using while/do-while/for loops to go to different parts of your code.

If you don't care about your format, then here is a goto example:

gohere:
     cout << "Hello" << endl;
     goto gohere;

This will make the code go to the 'gohere' marker. (An infinite loop)

So, can I tell it a certain line to go to?

if (gotocode == abc){
cout << "You have entered the code to jump to line 35."<<endl;
goto 35

I guess I could assign goto points in my code...

cout << "Welcome to line 34."<<endl;
abc:
cout << "WOOT 36!!!!"<<endl;
bman214 23 Newbie Poster

Do you know how to get the program to jump to a certain line of code? I want this function so i can assign passwords to different sections so if someone wants to "save" their progress, they can write down the password, and use it to get to the part of the game they were on.

PLZ HELP!!

bman214 23 Newbie Poster
#include<iostream> // not iostream.h
#include <stdio.h>
#include <stdlib.h>

using namespace std;

int main()
{
	//intro
	cout << "welcome to the final journey v. 0.0.3 alpha."<<endl;
	system("pause");
	cout << "you are an adventurer, traveling from town to town, looking for monsters and bold followers."<<endl;
	cout << "your homeland is chosan, a small town on the cho river. Through the years, you have traveled far and wide, eventually returning in your home land."<<endl;
	cout << " "<<endl;
	cout << " "<<endl;
	cout << "this... Is where you begin..."<<endl;
	cout << "the final journey."<<endl;
	system("pause");
	//variables
	  //attributes
	double hp = 25;
	double str = 10;
	double def = 10;
	double energy = 100;
	double army = 1;
	  //other variables
    int rannum = 0;
	int selectnum = 0;
	double tpts = 0.0;
	int train_a = 0;
	char tc1;
	char tc3;
	char tc2;
    char tin;
	double strlvlup = 0.0;
	double hplvlup = 0.0;
	double deflvlup = 0.0;
	/*random integer 1-9 generator
	srand ( time(null) );
	rannum = rand() % 9 + 1;*/ //between comments ( /*here!*/ ) in random number generator.
	//game starts
	  //wake up
	cout << "*you wake up to a normal day in chosan, and your energy is fully recharged.*"<<endl;
	cout << "here are your attributes:"<<endl;
	cout << "health (hp): \t"<<hp<<endl;
	cout << "strength (str): \t"<<str<<endl;
	cout << "defence (def): \t"<<def<<endl;
	cout << "energy (en): \t"<<energy<<endl;
	cout << "army size (army): \t"<<army<<endl;
	system("pause");
	cout << "let's get dressed and do some daily training, then embark on our journey."<<endl;
	cout << "*you get …
bman214 23 Newbie Poster

Cho River/Chosan are from kroea.

Really? I will have to change the program then. What are the chances that I randomly come up with a real place AND river based on its name...

Which compiler do you use??
------------------------------------
Where is no ";" after if()
"Q" != 'Q'
where is no endl after cin

I use the Dev-C++ Compiler.
so you are saying I should put !='Q' instead of "Q"?

bman214 23 Newbie Poster

Hello! I am making a text-based game (I am new to C++) called The Final Journey (I made the name up, didn't copy) and I have had some trouble with the code. I am using Dev-C++ (I plan to get VC++), just so you know. Here is what I have so far:

#include<iostream.h>
#include <stdio.h>
#include <stdlib.h>

using namespace std;

int main()
{
	//Intro
	cout << "Welcome to The Final Journey v. 0.0.3 Alpha."<<endl;
	system("pause");
	cout << "You are an adventurer, traveling from town to town, looking for monsters and bold followers."<<endl;
	cout << "Your homeland is Chosan, a small town on the Cho River. Through the years, you have traveled far and wide, eventually returning in your home land."<<endl;
	cout << " "<<endl;
	cout << " "<<endl;
	cout << "This... is where you begin..."<<endl;
	cout << "THE FINAL JOURNEY."<<endl;
	system("pause");
	//Variables
	  //Attributes
	double HP = 25;
	double str = 10;
	double def = 10;
	double energy = 100;
	double Army = 1;
	  //Other Variables
    int rannum = 0;
	int selectnum = 0;
	double tpts = 0.0;
	int train_a = 0;
	char tc1;
	char tc3;
	char tc2;
    char tin;
	double strlvlup = 0.0;
	double HPlvlup = 0.0;
	double deflvlup = 0.0;
	/*Random Integer 1-9 Generator
	srand ( time(NULL) );
	rannum = rand() % 9 + 1;*/ //Between comments ( /*Here!*/ ) in random number generator.
	//Game Starts
	  //WAKE UP
	cout << "*You wake up to a normal day in Chosan, and your energy is fully recharged.*"<<endl;
	cout << "Here …