Jump to content
Search In
  • More options...
Find results that contain...
Find results in...

Regarding C++


zeph77
 Share

Recommended Posts

Hey guys its me again but this time I want to ask if anyone knows a specific book that is good for game programming. Atm since I'm a beginner I am reading a book called (Beginning C++ through Game Programming, Third Edition) just to learn what I need to know and the final project it asks at the end is to make a black jack game but anyways. I plan on working for a company that makes 2d or 2.5D mmorpg games cause thats where my interest lies. Can anyone who knows C++ refer anything to me that maybe helped you on the learning process cause I'm really serious about learning C++ to program games. I want to be able to add graphics, animation, and sound related files but I know that is more advance. Please since there are many programmers here, is there anything that is a helpful resource?
Should I take C++ classes or a game development class?

thanks for all those who can help, i'm trying to learn C++ on my own so.
Link to comment
Share on other sites

C++ class and game development class will most likely be one and the same. You will probably start with c++ then move your way up to game development over the course of a few years. I have the book Teach Yourself c++ in one hour a day. Starting reading it and it was alright though i mostly just use it as a reference.

Check out dark gdk it is a pretty simple to use and makes fun games and learn c++ in the process. The mana world looks pretty kickass if you can figure out how to use it.

http://themanaworld.org/
Link to comment
Share on other sites

@Zonova:

> Well, this is for C(which is pretty similar to C++), but Lazyfoo.com has nice game making tutorials. I'd recommend C over C++ anyways, for programming and game making.
>
> inb4Stephankicksmyass

The only thing I dislike about lazyfoo is it not teaching how to programme properly. It's a neat introduction to SDL 1.2 nevertheless.

@Admiral:

> I second this, and would consider dropping object-oriented design in general, ideally for data-oriented design in C.

Basically:

* Use ANSI C89/C99.
* Use Microsoft Visual C++ on Microsoft Windows and GCC everywhere else.
* Only use object-oriented design where applicable (if you don't know when that is, then simply don't bother).
* Use Assembly for performance optimisation (where redesign isn't going to be beneficial, otherwise go redesign your code structure).
* Programme cache-obliviously [focus on data access: group your data, sort it by size (descending), use structures, minimise the amount of data in your structure (get rid of anything non-essential, use pointers to other structures that require no direct access) and make sure you process the same data as much as possible, i.e. reduce cache misses].
* Programme with cache-awareness (get to know your processor, and make your code scalable to the processor).

As a beginner, start out with any random book or website about C89/C99, study it thoroughly, and skip any practical non-sense. Once you know how C works you should continue getting to know the libraries you want to use. Read documentation, tutorials, etc. Getting game development books whilst being a beginner is a waste of money and time. The majority of the information you need is to be found all over the internet.

Regards,
  Stephan.
Link to comment
Share on other sites

cplusplus.com helped me a heap when I was learning it. The documentation on there is good and they have a pdf file which is full of tutorial goodness. I think they had a section for networking and one for graphics too, but I could be thinking of something else. Give it a read though, it is pretty good.
Link to comment
Share on other sites

  • 1 month later...
So should I learn C first and C++ after, are they similar cause I remember one guy just said the (++) means C with more added to it. I want to do this on my own as make games solo but I do plan to work in the game industry but as a 3d CGI animator, some areas though say programming is good to have so I want to be able to have some programming knowledge and make a game.

Is C easier to understand or can you link me a good C tutorial video, the one I'm watching for C++ is antiRTFM's video c++ n00b spoonfeed or whatever its called. I need something similar to that probably and do they use C in the game industry, other then c++ as in is it widely used? thanks if you can answer this and thanks for actually putting out good information and encouragement. I was able to learn from the video series above how to make functions,classes, transfer variables from a function to main, I learned a bit about arrays and how they can store data and I think they are used to make the grid for making a level, I learned a little bit about pointers but I guess I can learn that if anyone can provide a simple easy to understand C video. I can always google it but you guys know this stuff so any resource that helped you please do post.

-Zepher-
Link to comment
Share on other sites

To be honest, I, myself, wouldn't ever bother with C++ again. The language has constructs like object orientation, virtual functions, templates, etc. which not only tend to cause some trouble between compilers, but they also tend to change your philosophy dramatically, as you will try to encapsulate everything into an object, even where you aren't supposed to. This is just one of the reasons why I dropped C++ for all my work, and now only use C89 and Assembly.

A huge difference between the two languages is that C, compared to C++, is way more simplistic. It doesn't introduce object-oriented programming, and that can be a big plus, since it isn't needed, even though some people think it does improve their workflow (in my case, it made mine worse, because C++ is horribly complex at object-oriented programming and everything else it provides, or actually doesn't provide). And on top of that, if you really need it for something, you can use a more simplified method to get it done, even concepts like inheritance are possible, if you know how.

If you are aiming for the industry, then optimisation should be one of your major concerns when programming. Therefore using object-oriented programming should be used with care. I don't encourage using it, but if you really want to, I'm not going to stop you. The big problem with object-oriented programming is that it doesn't mix well with data-oriented programming, which is a requirement for proper optimisation. Data-oriented programming generally revolves around keeping your data together tightly, so that it is all accessible from the same cache line (preventing slow reads from and writes back to RAM; and yes, those are horribly slow).

Another reason why not to bother such a programming language is low-level optimisations, which can be easier to perform in C89 or Assembly as they don't have complex language constructs that obfuscate your code. You will have to use SIMD to perform mathematics related to vectors, pixels and anything else that uses multiple dimensions of integers or real numbers, which is only to be used through (inline) Assembly. On top of that, Assembly provides access to several other low-level constructs as well, which you can't access in C or C++ directly.

But there are other optimisations to care about as well: most of them involve graphics, memory and disk access.

A major reason why I would use C instead of C++ is the fact that more programmers tend to write their libraries in C for C. Even if you use C++, you'll end up using C libraries for almost everything (the only exception being Boost, which may be considered bloatware). The reason why most programmers write their libraries in C is because there is some added complexity when you want to support C++ well, especially when you are aiming to support object-oriented programming, and C libraries are far better accessible from other programming languages compare to C++.

And in the end the only company that seems to try to enforce C++ is Microsoft, which are now heading towards promoting C# instead.

As for learning either C or C++, I wouldn't ever recommend video tutorials. Most of the people who record those have no clue about actual programming and generally tend to do things the way they shouldn't be done, like most people who write tutorials for either languages. The best way is to grab a book, read through it, and start practising with libraries (so you can actually produce actual applications and so forth).

Programming isn't just about learning how to write in a certain programming language. It also requires a good understanding of both existing hardware and software, of how to solve certain problems in the most efficient (to using hardware and software, not in writing it in as less time as possible) manner and of various subjects such as graphical rendering, audio mixing, etc. Therefore programming is a tedious task on its own, and next to game design, pixel art, concept art, producing textures, modelling, graphics design, audio creation and so further, it is a lot to do for a lone-wolf developer.

Even I have a friend who actually does the audio creation for me, because I don't have as much knowledge as him on that specific subject. Although, I do have some knowledge, which is always important. But I discourage you from doing _everything_ by yourself.

Yours faithfully
  Stephan.
Link to comment
Share on other sites

Thanks for the great, detailed information on this subject Stephan. I think as of now I may switch to C since I mostly see programs and games created in C. C++ seemed kinda easy to me at one point but I don't want to deal with all its flaws it has. As for now all I need to do is get a compiler unless I should keep using MSVC++, but really thanks for the info. and now I need to go and find a good C book since I only have a c++ one.

Once again thanks and thanks to those who encourage me to at least get into programming.

~Zepher~
Link to comment
Share on other sites

@zeph77:

> Thanks for the great, detailed information on this subject Stephan. I think as of now I may switch to C since I mostly see programs and games created in C. C++ seemed kinda easy to me at one point but I don't want to deal with all its flaws it has. As for now all I need to do is get a compiler unless I should keep using MSVC++, but really thanks for the info. and now I need to go and find a good C book since I only have a c++ one.
>
> Once again thanks and thanks to those who encourage me to at least get into programming.
>
> ~Zepher~

For Microsoft Windows you should only use Microsoft Visual C++ (MinGW is a broken gcc port and I don't know why people keep using it, your best results are to be coming from Microsoft Visual C++) which also supports C89 (C99 is supported, but not well, so I wouldn't bother using that). For GNU/Linux, Solaris, BSD, IRIX, AIX, QNX, etc. you should be using gcc (if you care about anything else UNIX, then use a cross-compiler), Make and your favourite editor (e.g. Gedit, vi, nano, etc.). For Apple Mac OS X you should be using Xcode, which uses gcc, goc (ObjC is required on Apple Mac OS X) and Make.

I encourage you to try and learn cross-platform programming, as it really does pay off (people who use GNU/Linux or Apple Mac OS X love it when game developers actually care about anything but Microsoft Windows). The easiest way to start out with this is through a library like SDL, Allegro or GLFW for C89/C99 and SFML for C++.

As for software, in the industry both C and C++ are equally popular actually. Some games are written in C, some games are written in C++ without all the language constructs to resemble C (which is possible, because it is all optional), and some games are written in C++ with all those language constructs (object-oriented programming et al.). Assembly is used often for 3D, as C/C++ both don't allow easy access to SIMD (unless you want to use compiler-specific methods), which is required for certain parallel computations as I've said before.

Assembly was also important for shader programmes, but most of that is standardised now and you can now just programme them in a C-like language. This is going to be interesting when you start using OpenGL (2.0+) and/or DirectX (8.0+).

Yours faithfully
  Stephan.
Link to comment
Share on other sites

Yeah I only have a windows at the moment since I don't have money to buy a mac. I don't know if I made the right choice of buying the right book but I bought a book called "The C programming language" by Kernighan and Ritchie, who I heard invented C or at least people say, i don't know really but it is a C book and it seems pretty basic but chapter one which is a tutorial gets right into the whole thing like "Hello World", and then it gets into arrays and pointers but then again its just a tutorial so idk if I need to be reading it or just skip to chapter 2 which talks about Types, Operators, and Expressions. The cover says "ANSI C" which I heard is some sort of required standard so thats one reason why I chose to buy this book, the others were Objective-C which I have no idea what that is but I guess it would have worked since C is just C.

The book isn't as big of a book as my C++ one but i think its a good start. Once again thanks and I think Ill stick with VC++ since I tried using bloodshed Dev C++ and its just wierd and complicated to just compile simple code.
Link to comment
Share on other sites

@zeph77:

> Yeah I only have a windows at the moment since I don't have money to buy a mac. I don't know if I made the right choice of buying the right book but I bought a book called "The C programming language" by Kernighan and Ritchie, who I heard invented C or at least people say, i don't know really but it is a C book and it seems pretty basic but chapter one which is a tutorial gets right into the whole thing like "Hello World", and then it gets into arrays and pointers but then again its just a tutorial so idk if I need to be reading it or just skip to chapter 2 which talks about Types, Operators, and Expressions. The cover says "ANSI C" which I heard is some sort of required standard so thats one reason why I chose to buy this book, the others were Objective-C which I have no idea what that is but I guess it would have worked since C is just C.
>
> The book isn't as big of a book as my C++ one but i think its a good start. Once again thanks and I think Ill stick with VC++ since I tried using bloodshed Dev C++ and its just wierd and complicated to just compile simple code.

C is generally invented at Bell Labs by K&R, so that book is a good resource. I forgot what one I have though, but yours should be all right. Also, you can skip anything practical (like compiling and testing code), just read through the book and make sure you understand the language well. And ANSI C is exactly what C89, C90 and C99 are (they are released in '89, '90 and '99 respectively, hence the numbers), so the book will be great.

ObjC is something you shouldn't really bother with, it's also based on C, but only really used by Apple (in which case you can just wrap all of their interfaces and use your wrappers in C instead).

C++ books are quite big because of all the useless language constructs you won't really need. Object-oriented programming is just a way to overcomplicate things. Try to keep it simple, therefore avoid useless language constructs.

Also, Bloodshed's Dev-C++ is out-dated and may be considered obsolete, and obsolete software is generally bad, unless you are a nostalgic prick.

Yours faithfully
  Stephan.
Link to comment
Share on other sites

@Admiral:

> Trivia: Why is the C programming language named "C"?  Because it was based off of the B Programming Language, which got its name from Bell Labs (I think).

It actually began with the development of Speedcoding by IBM and John Backus in '53, then John Backus designed Fortran in '57 based on the design of Speedcoding. Then ALGOL 58 was developed by several persons in '58 and eventually superseded by ALGOL 60 in '60, the ALGOL language being based on Fortran's design. In '63 the CPL language appeared, which was based on ALGOL 60, and which was developed at the University of Cambridge and London by Christopher Strachey and various others. Then Martin Richards developed the BCPL language in '66, which was obviously based on the CPL language.

K&R developed B in '69 at Bell Labs, which was based on **B**CPL, although the name might also come from Ken Thompson's prior language Bon, which was named after his wife Bonnie. Then C got developed by K&R in '73.

Yours faithfully
  Stephan.
Link to comment
Share on other sites

@S.J.R.:

> K&R developed B in '69 at Bell Labs, which was based on **B**CPL, although the name might also come from Ken Thompson's prior language Bon, which was named after his wife Bonnie. Then C got developed by K&R in '73.

Yeah, I read that on the wiki afew hours after posting.

Could have sworn it got its name "C" since it came after B though.
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...