C++ starter

Started by
36 comments, last by Thiatsii 9 years, 7 months ago

thank you so much to every one who replyed. everything was very use full. i will keep trying to learn. ill watch the tutorials and start by making a pong from scratch with just my mind and no code to coppy paste! ;)

I just thought I'd mention, that while copy/pasting is certainly discouraged, don't be afraid to reference things, especially in these early stages of programming. Look stuff up, look over other people's code and see how they do it, hell, even copy/paste and THEN play around with the code changing things to see what it does. In my experience, it's where most of the things I learn come from. If you try to always/only code from memory, you'll hinder your progress (in my humble and inexperienced opinion). But, any time I want to try to do something new, I search and reference for the best/recommended way to do it. Rather than reinvent the wheel, sometimes it's handy to look at someone else's wheel and improve/adapt/learn from what they've done. Afterward, you've learned something new, a new method, new command, or what-have-you.

I'm only guessing, but I think most programmers, even after decades of programming, still constantly reference things and look things up. Programming entirely from memory might be a useful exercise to test your abilities/knowledge, but I would hazard a guess it's not the best way to do things in the long run.

Beginner here <- please take any opinions with grain of salt

Advertisement
i said in my mind because. when i pictured a top programmer ex: people who first made things like game engines or even windows. they all did it from nothing at all no tutorials or anything and that is why i really like programming because you can create somthing that is completely yours and different from anything else. one of my dreams was to make my own engine completely from scratch no extra lib or anything but now i relize that most programmers now days like u said just look at what has allready been made and use that instead.

I probably don't have the best perspective on this, as I'm rather new myself, but I'm willing to bet those people you're imagining didn't "do it all from nothing." Sure, there will always be the people on the cutting edge of technology (or art, or music, or anything), but typically they didn't just appear there one day out of thin air. They built their knowledge off what others had done before, and took it further and made something new with it. It would be like trying to write the 'Great American Novel', having never read a book yourself tongue.png

This is probably venturing into more of a philosophical discussion about the nature of creativity so I won't expand much more, and this is probably unsolicited advice, but at this point, you should focus on expanding your knowledge of programming, and that certainly includes what other programmers have figured out after decades of programming smile.png

Especially when we're talking about games. Games are so much more than the code that makes them. Even the most brilliant and industry-changing games are still probably like 95% standard coding practices and methods. You don't need to completely reinvent raycasting or player input methods to do something new and interesting with them.

But, I totally share your passion for making something new. The creative process is one of the things I love most about game programming. I'm completely not recommending that you stifle your creativity and dedicate yourself to making flappy-bird clones. I myself shy away from using game engines (though not libraries) as I feel it gives me more control over what I'm doing with the game (and also just to teach myself what is going on under the hood of the engines). But, you'll still want to learn the standard and recommended ways of doing things before (or at the very least, along side) doing your own thing, I think. Creativity doesn't exist in a bubble.

In essence, it's best to learn the rules before breaking them tongue.png

Beginner here <- please take any opinions with grain of salt

i have 1 very big question to ask. ok i am only 15 and been so into programming since i was 12 and i know this is what i love. but i am not a very good at teaching my self through books or video but i have tryed so hard and i have learned so much but it never seems like i know enough. like i am always going to be a beginner. so should i just give up and wait till i go to college for game dev and learn there or keep going on like a snail and learning really slowly and feeling like i know nothing all the time?

C++ programming just takes a few years to get really comfortable working with it. I would say it took me well over 5 years to get to a level where I can look at any code and understand it now. It just takes time to learn. Remember there are always many different ways to program code, some good, some bad. I found that reading the Scott Meyer's books http://www.aristeia.com/books.html really helped me understand the nitty-gritty details of how the language works.

some times i get bored of failing and not learning anything new then quit for a week. and when i come back i forget everything i learned. what are some ways you learned and kept going and doing the same thing over and over again with out just giving up for a while.

some times i get bored of failing and not learning anything new then quit for a week. and when i come back i forget everything i learned. what are some ways you learned and kept going and doing the same thing over and over again with out just giving up for a while.

I always like to start small and get something visible on the screen before adding complexity to it. So when starting to make a game, I typically code things up very quickly to get something output to the console first and then into a 3D window even if it isn't anything more than a dot. Once I have a dot on the screen, then I start building on that to make it move, change color etc... Being able to see progress as I work really keeps me motivated. If I program for more than a day and I still have nothing to show on the screen for it, I get discouraged.

After a while you'll start to build your own library of code and functions to do things, so making a game becomes much easier/faster because you end up reusing code that you wrote many years ago that you know that works as you want it to because you've invested time to making it work in previous projects.


I'm only guessing, but I think most programmers, even after decades of programming, still constantly reference things and look things up. Programming entirely from memory might be a useful exercise to test your abilities/knowledge, but I would hazard a guess it's not the best way to do things in the long run.

The more you learn, the more impossible it becomes to remember every detail of everything. But so long as you keep your skills in use, you can get by with looking the details up when you need them. My memory was terrible 30 or so years ago when I started programming and it's even worse now, so I always have to have several reference sources close by whenever I do anything.


I'm only guessing, but I think most programmers, even after decades of programming, still constantly reference things and look things up. Programming entirely from memory might be a useful exercise to test your abilities/knowledge, but I would hazard a guess it's not the best way to do things in the long run.

The more you learn, the more impossible it becomes to remember every detail of everything. But so long as you keep your skills in use, you can get by with looking the details up when you need them. My memory was terrible 30 or so years ago when I started programming and it's even worse now, so I always have to have several reference sources close by whenever I do anything.

This is so true! A few weeks ago I lost my internet connection on the weekend when I was programming. I realized very quickly how difficult it was to program without access to the internet to look things up. I had to pull out my text books to find code examples to refresh my memory on how certain things worked. Needless to say, that weekend I got very little done :)

i feel like u can learn C++ but then u get a engine or some lib and then bam! u know nothing again. because now all the sf::and keywords i don't know and there is not many tut's up to date for this and i don't know how i'm supposed to go through and learn everything on my own. mainly because when i learned c++ it was everything for console stuff and nothing else.

Nothing to get stressed over. Programming is one of those things where you never stop learning. Everything in the C++ standard is in the namespace std{} so that you have to do std::cout, std::cin, std::vector, std::string, etc. C++ library authors usually put their code in a namespace to help prevent possible naming conflict with the C++ standard (in case they happen to name a function or object the same as the C++ standard). You learn C++, then you learn a library to use with C++, but I wouldn't view learning the library as learning C++ (that is just my view on it though).

If you haven't already, play around with namespaces. For example (sorry if this isn't very helpful, but thought I'd throw it out there):


#include <algorithm>
#include <array>
#include <iostream>

namespace samp{
	void sort(int num)
	{
		for(int i = 0; i < num; i++)
		{
			std::cout << "Yep I'm not std::sort(), but I work!\n";
		}
	}
	
	void sort(void)
	{
		std::cout << "Still the namespace samp sort()\n";
	}
}

void sort(void)
{
	std::cout << "Local sort.\n";
}

int main()
{
	std::array<int, 10> s = {5, 7, 4, 2, 8, 6, 1, 9, 0, 3};
	std::sort(s.begin(), s.end());
	for(auto a : s){
		std::cout << a << " ";
	}
	std::cout << '\n';
	
	samp::sort(5);
	sort(); // oops, meant for it to be samp::sort()
	sort();
	
}

Output:


0 1 2 3 4 5 6 7 8 9 
Yep I'm not std::sort(), but I work!
Yep I'm not std::sort(), but I work!
Yep I'm not std::sort(), but I work!
Yep I'm not std::sort(), but I work!
Yep I'm not std::sort(), but I work!
Local sort.
Local sort.

i feel like u can learn C++ but then u get a engine or some lib and then bam! u know nothing again. because now all the sf::and keywords i don't know and there is not many tut's up to date for this and i don't know how i'm supposed to go through and learn everything on my own. mainly because when i learned c++ it was everything for console stuff and nothing else.

Nothing to get stressed over. Programming is one of those things where you never stop learning. Everything in the C++ standard is in the namespace std{} so that you have to do std::cout, std::cin, std::vector, std::string, etc. C++ library authors usually put their code in a namespace to help prevent possible naming conflict with the C++ standard (in case they happen to name a function or object the same as the C++ standard). You learn C++, then you learn a library to use with C++, but I wouldn't view learning the library as learning C++ (that is just my view on it though).

If you haven't already, play around with namespaces. For example (sorry if this isn't very helpful, but thought I'd throw it out there):


#include <algorithm>
#include <array>
#include <iostream>

namespace samp{
	void sort(int num)
	{
		for(int i = 0; i < num; i++)
		{
			std::cout << "Yep I'm not std::sort(), but I work!\n";
		}
	}
	
	void sort(void)
	{
		std::cout << "Still the namespace samp sort()\n";
	}
}

void sort(void)
{
	std::cout << "Local sort.\n";
}

int main()
{
	std::array<int, 10> s = {5, 7, 4, 2, 8, 6, 1, 9, 0, 3};
	std::sort(s.begin(), s.end());
	for(auto a : s){
		std::cout << a << " ";
	}
	std::cout << '\n';
	
	samp::sort(5);
	sort(); // oops, meant for it to be samp::sort()
	sort();
	
}

Output:


0 1 2 3 4 5 6 7 8 9 
Yep I'm not std::sort(), but I work!
Yep I'm not std::sort(), but I work!
Yep I'm not std::sort(), but I work!
Yep I'm not std::sort(), but I work!
Yep I'm not std::sort(), but I work!
Local sort.
Local sort.

that helped a lot. i can read the code but there is just something about reading some one else's code that i don't know what does that gives me the worst headache. i hate watching video tutorials because while watching them i get a headache looking at what there writing and i stop following along. i think its just trying to understand what they are doing when i know so little and they get in to detailed stuff i have not learned. in other words i guess i should just learn pure c++ before trying to use sfml?

This topic is closed to new replies.

Advertisement