Using C++

Started by
33 comments, last by frob 10 years ago

Overdramatic twaddle

No, it’s nearly exactly correct.
Notice how the most correct advice has been simply to get your hands on and do it. Because at such a beginner level the amount of potential advice we could give is so overwhelming it is best to just summarize as, “Just do it.”

What would I do if I just learned how to use a hammer and maybe a saw and wanted to build a house?
I would just do it, starting perhaps with miniatures, like miniature programs.

there's no need for expertise in the entire language, there's not a company I've ever worked for that would permit you to use it all anyway. C only has 30 odd keywords, get your head around loops and decisions and pretty much you're on a running start. A modern ide's autocomplete holds your hand through any most of the more complicated parts.

No one said there needed to be expertise in the entire language and the number of keywords you know in a language are not what indicate how versed you are in that language. Loops are per-language syntactical sugar and an IDE’s auto-complete has nothing to do with making video games directly.

Making video games, regardless of language, requires knowledge of high-level concepts such as game loops, input-handling, etc.



My advice echoes the “just do it” crowd, but I would add that when I was such a beginner, barely just having learned if/else (not yet for, while, etc.), I made a number-guessing game in which the computer picked a random number and you had to guess it.
It’s total crap but it goes to show you how wide the range of “games” is and how little you actually need to know in order to make one.

From there I of course gradually made more and more complex games as I learned more of the language.

The point is you need to be in the mindset of, “Great, I have learned this and am now capable of performing loops, branches, comparisons, etc. What kind of game can I make out of this without asking others what kind of game I should make?”

On the one hand there are games so terribly simple that you never need to program anything but “Hello World” followed by nothing but games for the rest of your life.

On the other hand, if you have to ask, “What should I make?”, you don’t have the right mindset for learning—with such an array of things you could make, this is something you should be able to easily answer yourself.

L. Spiro

I restore Nintendo 64 video-game OST’s into HD! https://www.youtube.com/channel/UCCtX_wedtZ5BoyQBXEhnVZw/playlists?view=1&sort=lad&flow=grid

Advertisement

1.) Learn C, I think they teach kids this in school nowadays

2.) Install Visual Studio Express, its free

3.) Start with C++ examples, Google for code and run it in Visual Studio

4.) Voila, you now know C++ :)

Collect as much code as you can and implement it in your game, at first do not try to invent anything yourself, its all on the Internet already. Use a framework like Cocos for more functions.

"Smoke me a kipper i'll be back for breakfast." -- iOS: Science Fiction Quiz

1.) Learn C, I think they teach kids this in school nowadays

2.) Install Visual Studio Express, its free

3.) Start with C++ examples, Google for code and run it in Visual Studio

4.) Voila, you now know C++ smile.png

Collect as much code as you can and implement it in your game, at first do not try to invent anything yourself, its all on the Internet already. Use a framework like Cocos for more functions.

Why C? I see no reason to start with C rather than basic C++.

In C you have to deal with more lower level stuff, there's more fiddling and things are generally a lot less intunitive. Start with C++ and learn the basics. I mean, why would you struggle with char* when you have std::string in C++? And with the standard library, classes and streams, C++ is a lot different from C.

1.) Learn C, I think they teach kids this in school nowadays

2.) Install Visual Studio Express, its free

3.) Start with C++ examples, Google for code and run it in Visual Studio

4.) Voila, you now know C++ smile.png

Collect as much code as you can and implement it in your game, at first do not try to invent anything yourself, its all on the Internet already. Use a framework like Cocos for more functions.

Start at step two and go from there. C++ has evolved enough that the premise of learning C first is no longer worth it. You can certainly go back and learn C if you wish, but if you want to program in C++ then learn C++. I've been programming for a long time and C++ was my second language (BASIC being my first), but I went back and learned other ones just because I love programming languages.

"Why C? I see no reason to start with C rather than basic C++."

C++ at first may be confusing to him. I also started with BASIC first, in primary school then with C in high school. Then pretty much all other languages in university.

"Smoke me a kipper i'll be back for breakfast." -- iOS: Science Fiction Quiz

"Why C? I see no reason to start with C rather than basic C++."

C++ at first may be confusing to him. I also started with BASIC first, in primary school then with C in high school. Then pretty much all other languages in university.

I find C more confusing. In order to use it, you have to deal with pointers. Things like pointer arithmetics is hardly intuitive. And he'll most likely never need it. Having things like std::string will make his life a lot easier, and it's WAY less confusing than using char* with functions like memcpy() and strcpy(). They're both easy to use wrongly and hard to debug.

"Why C? I see no reason to start with C rather than basic C++."

C++ at first may be confusing to him. I also started with BASIC first, in primary school then with C in high school. Then pretty much all other languages in university.

I find C more confusing. In order to use it, you have to deal with pointers. Things like pointer arithmetics is hardly intuitive. And he'll most likely never need it. Having things like std::string will make his life a lot easier, and it's WAY less confusing than using char* with functions like memcpy() and strcpy(). They're both easy to use wrongly and hard to debug.

True. Someone wrote there is no one path to learning, I think he can find good starting points in this thread.

"Smoke me a kipper i'll be back for breakfast." -- iOS: Science Fiction Quiz
I think starting with C is good advice. When I use std::string in C++, I expect the implementation to be something like a struct that has a pointer to the data, a length and a reserved length. It is possible that the implementation uses copy-on-write, or maybe it doesn't. Because I understand what's involved in implementing a std::string class, I can make good judgements as to whether a particular solution to a problem is likely to perform well or not. For similar reasons, I would even recommend getting your feet wet with assembly programming (although this doesn't need to happen in the first year of coding).

In my experience, people that start with higher-level languages rarely achieve that kind of understanding, and they can easily come up with solutions that make terrible use of resources. One example that I have found several times is someone trying to write a chess program (or some other alpha-beta searcher) in Java, with dynamic memory allocation all over the place, a class hierarchy for the different types of pieces, and performance that is 2 or 3 orders of magnitude worse than it should be.

Someone wrote there is no one path to learning, I think he can find good starting points in this thread.

There is no set path to learning C++ (some learn vectors first, others learn arrays, some learn C-style strings first, others learn std::string) just depends on the person learning. It is counter-productive to tell them to learn a different language, especially when the OP never said he was having trouble with C++. We were giving him advice on how to learn C++ without relying on videos, but don't know how that got turned into users thinking he was having trouble with it. The OP was simply asking how to apply what he has learned in C++ to developing a game.


In my experience, people that start with higher-level languages rarely achieve that kind of understanding, and they can easily come up with solutions that make terrible use of resources. One example that I have found several times is someone trying to write a chess program (or some other alpha-beta searcher) in Java, with dynamic memory allocation all over the place, a class hierarchy for the different types of pieces, and performance that is 2 or 3 orders of magnitude worse than it should be.

Sounds more like they are just terrible at problem solving. I know a few guys who have that understanding and still write crap code similar to what you are talking about.

especially when the OP never said he was having trouble with C++. We were giving him advice on how to learn C++ without relying on videos, but don't know how that got turned into users thinking he was having trouble with it. The OP was simply asking how to apply what he has learned in C++ to developing a game.

The argument that C is not used is not why someone should not learn it.

The OP has obviously no knowledge of programming, and from that point, I would recommend him even more deeply restrited language than C. Pascal. He would be able to distingush from abstract solutions of languages (scanf in C, std:: namespace goodies), he would get aware that allocation of variables during runtime is what he wants but it is a loaded pistol of memory leaks, lifetime dilema and incorect design avenue. When he learns C or Pascal, he will be able to absorb other languages with order in his knowledge exponetionaly fast (c++, C#, java), and finaly gain necesary "cubicness".

I would realy not recommend him learn c++ as first entrance to this world and get dependant on some of its frameworks or utilities. Hell, even the inheritance is an infamous topic upon people that produce software themself (I have banned it in my production myself- it was like entering 7th heaven)

This topic is closed to new replies.

Advertisement