Just starting out, self taught.

So i am new at programming in C++. I really like it ant its a fun way to pass time. But i was wondering if anyone could give me some pointers as to how i should go about teaching myself better. i think i have a pretty good understanding of the basics.

I have been working on a simple text based RPG just as a sort of test for myself more then anything. So if anyone could give me some tips with what i have so far that would be great. im not going for much with this but one of the things i would like to get done with this RPG is to be able to make a choice and have the program pick a random outcome

for example:

your character has a base camp and after everything you do you come back to that base.
in game you chose the option to explore, lets say that is '1'
your player can go out into the wilderness and has possible chance of finding a town, some mountains, a lake, getting into a fight with monsters, or what ever.

Anyways, all the help i can get would be greatly appreciated.

Thank you very much in advance!


1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
#include <iostream>

using namespace std;

int main()
{
	
	//Character list
	char Name [20];
	char CPL[20];
	char Son[20];
	
	//Choices
	int MenuChoice;
	int Choice1;
	
	cout << endl;
	cout << "  ____                        " << endl;
	cout << " |  _ \\ ___   __ _ _   _  ___ " << endl;
	cout << " | |_) / _ \\ / _` | | | |/ _ \\" << endl;
	cout << " |  _ < (_) | (_| | |_| |  __/" << endl;
	cout << " |_| \\_\\___/ \\__, |\\__,_|\\___|" << endl;
	cout << "             |___/            " << endl << endl;
	
	cout << endl << "By ******* ******" << endl << endl;
	
	cout << " __________________" << endl;
	cout << "|----Menu----------|" << endl;
	cout << "|------------------|" << endl;
	cout << "|-1.-Start Game----|" << endl;
	cout << "|-2.-Options-------|" << endl;
	cout << "|-3.-Quit Game-----|" << endl;
	cout << "|------------------|" << endl;
	cout << " Make your choice: ";
	
	cin >> MenuChoice;
	{
		if(MenuChoice == 2)
		{
			cout << endl << "We are working on options" << endl;
		}
		if(MenuChoice == 3)
		{
			return 0;
		}
	}
	
	cout << endl << endl << endl;
	
	cout << "Well dont just stand there, say something!" << endl << endl;
	
	cout << "	-I'm sorry, sir what was that?" << endl << endl;
	
	
	cout << "I said what is your name private?" << endl << endl;
	
	cout << "Enter your name: ";
	
	// This is the player's name.
	cin.getline(Name, 20);
	
	cout << endl << endl << "So, Private " << Name << "? Well private, just be glad its only your first day, and if I were say your sargent this would have ended differently." << endl << endl;
		
	cout << "	-Thank you Corporal, I'm sorry I don't think I got your name." << endl << endl;
	
	cout << endl << "Of course." << endl;
	
	cout << endl << "Enter the Corporal's name: ";
	
	// This will name the Corporal. Story line.
	cin.getline(CPL, 20);
	
	cout << endl << "My name is Corporal " << CPL << ".";
	
	cout << endl << endl << "	-So CPL " << CPL << " do you know what we are even doing in this place?";
	
	cout << endl << endl << "I would love to say that I know but I do not." << endl <<  "Do you know what the outside is like?" << endl << "I have been in this pit for almost two years and I still dont know anything.";
	
	cout << endl << endl << "	-I was just transfered from another of these underground bunkers." << endl << " I have been so out of it for the past few days. I recently lost contact with my son...";
	
	cout << endl << endl << "Enter your son's name: ";
	
	// You will name your son. Has to do with story line
	cin.getline(Son, 20);
	
	cout << endl << "	-His name is " << Son <<". Last I heard of him, the war was getting bad." << endl << "It has been nearly a month since then. ";
	
	// This is the first choice you make. Work on it...
{		
		cout << endl << "Would you like to keep talking with " << CPL << "?" << endl << "(1=Yes/2=No)" << endl;
		cin >> Choice1;
		{
			if(Choice1 == 1)
			{
				cout << "Something.";
			}
			if(Choice1 == 2)
			{
				cout << endl << "I should really be going now.";
			}
		}
}
	// Ends the game
char EndGame;	
	cout << endl << endl << "Press any key, then hit enter to continue..." << endl;
	cin >> EndGame;
	return 0;
}
I am using dev-c++ as my IDE.

Oh and one more thing i should add. Keep in mind that i am TERRIBLE at making up stories for myself.

Even if you don't have any good help with my post specifically if you could point me in the right direction with a basic story line that i can maybe work with that would be cool too.

~Thank You Again!
Last edited on
If you're interested in making a game I'd keep studying and make it so you're programs aren't as linear. That can only come with more study though.

Immediate tips:
1. No using namespace std; it gets to be a bad habit later on.
2.

1
2
3
4
5
6
7
8
if(Choice1 == 1)
			{
				cout << "Something.";
			}
			if(Choice1 == 2)
			{
				cout << endl << "I should really be going now.";
			}


Whenever you are testing the same condition twice for a certain value(s) use else if

3. Be careful with using std::cin and std::cin.getline(); together. You can use them together but... http://stackoverflow.com/questions/1183971/using-getlinecin-s-after-using-cin-n

Just keep that in mind so you hopefully don't run into issues later. ;)
Just a tip from me! I would sleep the out put of the next line depending on how long the sentence is before I output the next line, that just an idea unless you like your story telling to pop up the hole screen,. random out comes = random function between the number of possibilities.
IMHO trying to write an RPG before you understand object oriented programming is a total waste of time. You'll soon want to have characters that can interact with each other and their environment, acquire, use and track inventory items, learn skills and advance abilities, etc., etc. BUT, you won't be able to because you're still writing procedural code and keeping track of all those parameters without an OOP-based framework is confusing, tedious, error-prone and just plain BORING.

If you insist on doing this just try and make a small, simple RPG which has one character, four rooms and a few items to find plus a key to get out. You'll quickly see how hard it is just to keep track of where your character is. If you try to create some big, open-ended world I guarantee you'll soon be lost in pages of spaghetti code and lose interest in programming.

I suggest you study some of the good tutorials and then practice your skills by making simple programs that interest you personally. Think up some application that you can use now even though it's simple and then add features as your knowledge of programming grows. Come back to the games when you can do them justice...

IMHO trying to write an RPG before you understand object oriented programming is a total waste of time. You'll soon want to have characters that can interact with each other and their environment, acquire, use and track inventory items, learn skills and advance abilities, etc., etc. BUT, you won't be able to because you're still writing procedural code and keeping track of all those parameters without an OOP-based framework is confusing, tedious, error-prone and just plain BORING.

If you insist on doing this just try and make a small, simple RPG which has one character, four rooms and a few items to find plus a key to get out. You'll quickly see how hard it is just to keep track of where your character is. If you try to create some big, open-ended world I guarantee you'll soon be lost in pages of spaghetti code and lose interest in programming.

I suggest you study some of the good tutorials and then practice your skills by making simple programs that interest you personally. Think up some application that you can use now even though it's simple and then add features as your knowledge of programming grows. Come back to the games when you can do them justice...


Yeah it's like I said he needs to learn more features of C++ if he wants to get anywhere with making a game. Ignoring the fact it's in the console right now. He can worry about that a little later (Really though you learn a lot more using an API early on than you do starting with just the console)
Alright. thanks for the help.

Could someone point me in the right direction of some useful websites that have useful tutorials i can read through? Or maybe a few ideas for some exercises i can try to work on.
cnoeval wrote:
IMHO trying to write an RPG before you understand object oriented programming is a total waste of time.


I really hate this argument.

The only way to learn programming concepts is to program. Reading it in a book doesn't cut it... you have to actually sit down and do it and see how it works to really understand it.

So how is it better for him to learn OOP concepts while programming boring test projects than it would be for him to learn OOP concepts while programming games?

If anything... programming something fun will accelerate his learning by keeping him engaged/interested and by showing him practical applications of the concepts he's learning.


He's not trying to make the next Halo or anything. He's making a dinky amateur game that probably nobody besides him will ever play because it's fun and because it's an educational project. Don't discourage him from learning through fun means.


Austin J wrote:
Yeah it's like I said he needs to learn more features of C++ if he wants to get anywhere with making a game.


I agree... but this is exactly HOW you learn more features. It's not a "waste of time" at all.

Austin J wrote:
Ignoring the fact it's in the console right now. He can worry about that a little later (Really though you learn a lot more using an API early on than you do starting with just the console)


I also agree with this. Console shmonsole. I also think it'd be easier to start with something a little more animated and less event based... like a really basic vertical shooter. Event based programs are a lot harder to write effectively than newbies think.
Last edited on
I've only got 2 things to say. First of all, try not to hard code too much of your program, it will lead to programs being way too long and will take too long doing the trivial stuff. Secondly and more importantly, have fun with it. Just take it where you feel like it. My first C++ project was also an RPG, and I had no story whatsoever.
idk how much you are going to learn on this path. it reminds me a lot of the sort of stuff i tried to program when i was in highschool and it just caused me to lose interest. i later realized that i should have been trying to solve problems.

try writing a function that will take a list of integers and sort them in ascending order. try to make it as efficient and succinct as possible. then bring it back here for review.

i can almost guarantee you that no mater how well you do someone will show you how it could have been done better. usually when you work really hard on a problem and then someone shows you how it can be done better still you will learn a lot from that exchange.
Last edited on
MarketAnarchist wrote:
idk how much you are going to learn on this path.


I guess it depends on the person.

Though this is how I learned.. and I think I turned out alright.

i later realized that i should have been trying to solve problems.


That's kind of vague. I mean anything in programming could be considered problem solving.

Sorting a list of integers vs. figuring out how to have a player move between two rooms. They're both problems.. and they both require you to think critically and evaluate what you're doing.

The only difference in my mind is that the latter produces a more interesting result and therefore tends to hold my interest and keep me excited longer.


But I guess everyone is different. It's up to the OP to decide what he wants to do.
yes i would say figuring out how to have a character move between two rooms definitely counts as solving a problem.

i was talking about improvising branching if statements. like his program up there. i used to do that sort of stuff on my calculator in algebra class.
Last edited on
Topic archived. No new replies allowed.