# How much have I really learned?

This topic is 3314 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

## Recommended Posts

So I've been programming basic console programs for about a year now in C++. I've been using C++ for game developers module 1 by Frank Luna. And studying basic console programming from tutorials, video tutorials, even different books. Just to kinda get a different explanation on something I don't fully understand. Like I said I've been going at it for a year now and it feels like it's been an eternity. But my point is that before I seriously dive into actual Win32 API programming or even Direct3D. My main concern is that am I jumping the gun to fast? So I thought to determine that I would like someone to give me a task / program to write not something like an RPG that would take a whole day or even days to write. Something simple and a little trivial (I SAID A LITTLE, my brain cannot take too much). Then I will post the code up in a reply (or maybe I'll put it on pastebin, or send the files on a file hosting website and let you download it, whatever is the easiest for you cause I actually want you to help me :P). And then by looking at that code and seeing if I can actually complete the program determine just by one little program if I'm ready to move on. And you don't have to sit there for an hour looking over the code..... just off the top of your head see if I know my stuff. P.S. this can't be anything related to graphics only console programming. Thanks in advance to anyone that is willing to help!

##### Share on other sites
I think part of programming (and more generally any skill) is knowing what you know, what general directions exist that you don't understand and might be interested in, and what steps you can take to improve in a certain direction. It seems to me very hard for someone else to aid very much in that process unless they're really involved in working with you over a longer period or unless your request is very specific (eg, "What's a good tutorial for basic windows programming?"). Moreover, it's not particularly important what other people think of your skill level or your pace. If you try to do something too hard for you, you'll know really quick. The one thing I would avoid is doing something that's a great deal of effort (like building a huge RPG game with a complex story, etc) that doesn't really get at what you actually want to learn.

If you'd like to learn windows programming, grab a book about windows programming or search the web for tutorials. Start with hello world and then expand from there. If you want to learn DirectX, grab a book about DirectX. Display a rotating cube. Expand on that. Be creative in generating projects you'd like to program. =)

##### Share on other sites
it's hard to create a task that will test the spectrum of c++ programming that can be done in a day without it being very much like a university coursework ;)

have you done a tic-tac-toe game? how about using something like alegro to make a space shooting game (I believe frank d luna has an example program that draws a map of space with moving stars (full stops). you could expand this to include enemies, power ups, etc.

##### Share on other sites
Quote:
 Original post by Roberts91So I thought to determine that I would like someone to give me a task / program to write not something like an RPG that would take a whole day or even days to write.

Sorry to break it to you, but if you think a program which takes "a whole day or maybe even days" to write is excessive, then I highly doubt you have learned anything worthwhile. Programming isn't magic - it takes time. Lots of time for almost any useful program.

That said, maybe you should just "buckle-down" and make an RPG or something. You can't learn the hard parts of program by writing one-shot programs that take an hour to write and you never touch again. So go and write that program that takes long enough to write that you've forgotten what your original code intended when you next use it. Make it big enough that you get some real bugs and get that experience using your debugger. But most importantly, make it interesting to you so that you keep on working on it.

Well, that's how I see it anyway.

##### Share on other sites
just an idea but a text base game (No graphics) is a good idea. It doesn't have to RPG but a mystery or something. I have this great book and one of the final projects if a text base game with inheritance and all those higher up C++ stuff. I'm still new to C++ so I haven't got to that stuff but I think text games are great for non-graphic games. Even a card game like black jack is good.

##### Share on other sites
For text, you can try tic-tac-toe, guess the number, rock paper scissors, and hangman. Most of these could probably be made in less than a day.

##### Share on other sites
I also suggest Black jack because it used Inheritance and Polymorphisms.

##### Share on other sites
@jdinia so you think that I should go ahead and dive into C++ for game developers module 2 (module 2 starts on the win32 api and you eventually create games like pong, a hockey game, and all sorts of other stuff in that book)?

@Ezbez - no don't get me wrong as I have wrote several simple to even quite complex text RPG's just using the knowledge I have. It's just for this certain task that I didn't want to write something complex. Like let's say if your applying for a job and the hiring manager or whatever asks you to create a demo showing what you know. He wouldn't ask you to make a MMORPG. Instead he would ask for a simple demo. Not something thats going to take him forever to write. Believe it or not a huge program doesn't really show off your knowledge only that you can manage code well. IMO

##### Share on other sites
What I suggest you do is look into websites that have programming challenges. They are typically small and quick ways to see if you can break down problems and create an algorithm to solve it. Remember that programming is not all about memorizing a language, in fact it is mostly about taking problems and creating the algorithms to solve them using a language. I suggest a google search for some websites, or you could give this one a try:

If you have any trouble or want us to go over your solutions for the challenges then by all means make a post here in the beginners board and we can "critique" you.

##### Share on other sites
@mich4elp I have taken your challenge and I wrote Guess the Number here is the code:

// Guess the Number v1.0 by Roberts91#include <iostream>#include <cstdlib>#include <ctime>using namespace std;int main(){		srand( time(0) ); 	int n_random = rand() % 100;	bool quit = false;	int g_number = 0;	cout << "Welcome to Guess the Number v1.0!\n";	while(quit == false)	{		cout << "Please enter a number from 1 to 100: ";		cin >> g_number;		if(g_number == n_random)		{			cout << "Congrats you are correct!" << endl;			quit = true;		}		else if(g_number > n_random)		{			cout << "You guessed to high!" << endl;		}		else if(g_number < n_random)		{			cout << "You guessed to low!" << endl;		}	}}

It was a little simple to write so I'm gonna give a go at the Rock Paper Scissors game. I would do the Tic-Tac-Toe and hangman games as well but I think the only real way you can make a game like that is either using a graphics library or using ASCII graphics but since I don't know how to do either I'll stick with the other 2. Though I do have a good idea on how the ASCII graphics could be implemented I just wouldn't know how to keep the graphics "statically" drawn onto a console window. I'll update this post when I've completed the Rock Paper Scissors game.

Update:
Okay before I post this code I just want to say when I was thinking up on how I could determine if the computer beat the player or vice versa. Well let's just say it's a really cheap way of doing it and it was the first thing that came to my mind. There are probably a thousand better ways of doing it but atleast it works :P.

Rock Paper Scissors:
// Rock Paper Scissors v1.0 by Roberts91#include <iostream>#include <cstdlib>#include <ctime>using namespace std;int main(){	srand( time(0) );	int selection = 0;	int random = 1 + rand() % 3;	cout << "Welcome to Rock Paper Scissors v1.0!\n";	cout << "Please select one of the following 1) Rock, 2) Paper, 3) Scissors.\n";	cin >> selection;		// For when there is a tie.	if(selection == random)	{		cout << "It's a tie! No one won!" << endl;	}	// For when the computer beats the player.	else if(		(selection == 1 && random == 2) ||		(selection == 3 && random == 1) ||		(selection == 2 && random == 3))	{		cout << "Sorry you lose!" << endl;	}		// For when the player beats the computer.	else if(		(selection == 1 && random == 3) ||		(selection == 2 && random == 1) ||		(selection == 3 && random == 2))	{		cout << "Congrats you win!" << endl;	}}

P.S. tell me what you think

[Edited by - Roberts91 on December 25, 2008 11:52:59 PM]

##### Share on other sites
Quote:
 Original post by Roberts91@mich4elp I have taken your challenge and I wrote Guess the Number here is the code:// Guess the Number v1.0 by Roberts91#include #include #include using namespace std;int main(){ srand( time(0) ); int n_random = rand() % 100; bool quit = false; int g_number = 0; cout << "Welcome to Guess the Number v1.0!\n"; while(quit == false) { cout << "Please enter a number from 1 to 100: "; cin >> g_number; if(g_number == n_random) { cout << "Congrats you are correct!" << endl; quit = true; } else if(g_number > n_random) { cout << "You guessed to high!" << endl; } else if(g_number < n_random) { cout << "You guessed to low!" << endl; } }}It was a little simple to write so I'm gonna give a go at the Rock Paper Scissors game. I would do the Tic-Tac-Toe and hangman games as well but I think the only real way you can make a game like that is either using a graphics library or using ASCII graphics but since I don't know how to do either I'll stick with the other 2. Though I do have a good idea on how the ASCII graphics could be implemented I just wouldn't know how to keep the graphics "statically" drawn onto a console window. I'll update this post when I've completed the Rock Paper Scissors game.Update: Okay before I post this code I just want to say when I was thinking up on how I could determine if the computer beat the player or vice versa. Well let's just say it's a really cheap way of doing it and it was the first thing that came to my mind. There are probably a thousand better ways of doing it but atleast it works :P. Rock Paper Scissors:// Rock Paper Scissors v1.0 by Roberts91#include #include #include using namespace std;int main(){ srand( time(0) ); int selection = 0; int random = 1 + rand() % 3; cout << "Welcome to Rock Paper Scissors v1.0!\n"; cout << "Please select one of the following 1) Rock, 2) Paper, 3) Scissors.\n"; cin >> selection; // For when there is a tie. if(selection == random) { cout << "It's a tie! No one won!" << endl; } // For when the computer beats the player. else if( (selection == 1 && random == 2) || (selection == 3 && random == 1) || (selection == 2 && random == 3)) { cout << "Sorry you lose!" << endl; } // For when the player beats the computer. else if( (selection == 1 && random == 3) || (selection == 2 && random == 1) || (selection == 3 && random == 2)) { cout << "Congrats you win!" << endl; }}P.S. tell me what you think

It's a good start but until you write your first tic-tac-toe game it isn't much. Once you realize how complicated it can get depending on how smart you want your A.I. to be you'll understand.

##### Share on other sites
Once you start getting your feet wet in graphics, a Tetris clone is a very good first game experience. It may be boring, but it'll teach you a lot (especially if you can manage to finish it).

##### Share on other sites
@Roberts91:
I'd recommend you take your Rock, Paper, Scissors game and expand it to add these 3 things:

1) Inform the user what their opponent did. Example: "You use 'rock', your opponent used 'scissors'". This will force you to learn how to mix text together, instead of typing out manually all the possible mixtures of rock, paper, and scissors you and your opponent might use.

2) Make it first to 3 points wins. This will force you to keep track of points.

3) Make it so when someone wins or loses, the program does not close. Instead, it asks if you'd like to try again. If the user chooses not to play again, then it quits, otherwise, it resets the points and starts again without closing the program.
This will force you to make your programs never quit until the user actually wants them to quit.

It shouldn't take you more than a hour or so to add those features, then you could advance to other projects.

##### Share on other sites
if you want to do console "graphics" without using ncurses(if you're doing rock paper scissors I don't think you're ready for ncurses), you can do this,(recommended for a tic-tac-toe game):

in your print board method have 5 cout statements

print out something like this

1 | 2 | 3
- + - + -
4 | 5 | 6
- + - + -
7 | 8 | 9

there! instant tic-tac-toe board. replace the numbers with X or O when the person plays.

you can make the board draw in the same place by clearing every time. do this with

system("clear");

or
system("cls");

then prompt the user for their next play.

##### Share on other sites
@Servant of the Lord
I added those features to my Rock Paper Scissors game tell me what you think:

// Rock Paper Scissors v1.0 by Roberts91#include <iostream>#include <cstdlib>#include <ctime>#include <string>using namespace std;int main(){	bool quit = false;	srand( time(0) );	int selection = 0;	int computerWins = 0; // Keep track of how many times the computer wins.	int userWins = 0; // Keep track of how many times the user wins.	std::string rock = "Rock";	std::string paper = "Paper";	std::string scissors = "Scissors";	cout << "Welcome to Rock Paper Scissors v1.0!\n";	while(quit == false)	{		int random = 1 + rand() % 3; // For each new game computer make new selection.		cout << "Your score " << userWins << "." << endl;		cout << "Computer score " << computerWins << "." << endl;		cout << "Please select one of the following 1) Rock, 2) Paper, 3) Scissors, 4) Quit.\n";		cin >> selection;				// Users selection.		switch( selection )		{		case 1:			cout << "You selected " << rock << "!" << endl;			break;		case 2:			cout << "You selected " << paper << "!" << endl;			break;		case 3:			cout << "You selected " << scissors << "!" << endl;			break;		case 4:			quit = true;			break;		}		// Computers selection.		switch( random )		{		case 1:			cout << "The computer has chosen " << rock << "!" << endl;			break;		case 2:			cout << "The computer has chosen " << paper << "!" << endl;			break;		case 3:			cout << "The computer has chosen " << scissors << "!" << endl;			break;		}		// For when there is a tie.		if(selection == random)		{			cout << "It's a tie! No one won!" << endl;		}		// For when the computer beats the player.		else if(			(selection == 1 && random == 2) ||			(selection == 3 && random == 1) ||			(selection == 2 && random == 3))		{			cout << "Sorry you lose!" << endl;			computerWins++;			}				// For when the player beats the computer.		else if(			(selection == 1 && random == 3) ||			(selection == 2 && random == 1) ||			(selection == 3 && random == 2))		{			cout << "Congrats you win!" << endl;			userWins++;		}		if(computerWins == 3)		{			int ng_selection = 0;			cout << "The computer has won " << computerWins << " times! Game Over!" << endl;			cout << "Would you like to try again? 1)Try again, 2)Quit." << endl;			cin >> ng_selection;			if(ng_selection == 1)			{				computerWins = 0;				userWins = 0;			}			if(ng_selection == 2)			{				quit = true;			}		}		else if(userWins == 3)		{			int ng_selection = 0;			cout << "Congrats you have won " << userWins << " times! The End!" << endl;			cout << "Would you like to try again? 1)Try again, 2)Quit." << endl;			cin >> ng_selection;			if(ng_selection == 1)			{				computerWins = 0;				userWins = 0;			}			if(ng_selection == 2)			{				quit = true;			}		}	}}

edit: I'm not really sure why I made strings for Rock paper and scissors I think it's because I had thought of an idea and forgot to even use it. lol

##### Share on other sites
For tic-tac-toe, you can just draw the board in its current state every time you have to make a move. You don't have to statically update it.
Plus, here are some other good challenges you can look at:

http://cemc.math.uwaterloo.ca/contests/past_contests.html

Scroll down the Canadian Computing Competition, from 2004-2008, download the junior problems at the top of the page. They are good practice.

##### Share on other sites
Quote:
 Original post by Roberts91@Servant of the LordI added those features to my Rock Paper Scissors game tell me what you think:

It's very good! I'd now move on to tic-tac-toe like others are suggesting, and then possibly a small text-adventure game.
Quote:
 edit: I'm not really sure why I made strings for Rock paper and scissors I think it's because I had thought of an idea and forgot to even use it. lol

I think you were planning on doing something like this:

std::string selectionText = "";switch( selection ){	case 1:		selectionText = "rock";	break;	case 2:		selectionText = "paper";	break;	case 3:		selectionText = "scissors";	break;}cout << "You selected " << selectionText << "!" << endl;