C++: Where do I start?

Started by Nine Toes, Sat 15/04/2006 00:24:41

Previous topic - Next topic

Nine Toes

I used to think that coding was easy, because the only programming language that I know is AGS code.  I'm finding out now that C++ is not quite as simple.  I look at it, and I don't even know where to start.  I don't even quite understand what half of these commands do.

I used Borland C++ Builder 5, and I made a small text editor from a tutorial.  But my primary interest is, obviously, making games.  Preferably 2D, I just don't have the capacity to take on learning 3D and C++ at the same time... and 3D is over rated, anyway.

I looked on Amazon.com for some books for beginners... ABSOLUTE BEGINNERS.  According to most of the reviews for most of the books on the site, there aren't too many books that are for people who know next to nothing about coding.  Can anybody recommend a book?  Something that doesn't assume I already have a background in C++, or that I'm a friggin' math whiz.
Watch, I just killed this topic...

Rolf

I have a book that of C++ it is very good.  He liked to use it but I think that he is now it are of the copy.  I wait that you finding can!

Squinky

http://cplus.about.com/od/beginnerctutorial/

I just googled for beginner stuff. You could probably find better, but its out there.

I definately wouldn't recomend C++ for Dummys, because it was well beyond my understanding and I had a basic understanding then. At least enough to compile crappy little text games where you fought crap in a dungeon...

BOYD1981

i used to own C++ For Dummies, i remeber it recommending that i read C For Dummies first or atleast acquire some knowledge of C first.

Limey Lizard, Waste Wizard!
01101101011000010110010001100101001000000111100101101111011101010010000001101100011011110110111101101011

Squinky

Yep, it did. But, just recomending not to get it, as it seems an obvious choice to a lot of people.

scotch

Download the freely available Visual C++ 2005 Express Edition from http://msdn.microsoft.com/vstudio/express/visualc/
Download SDL from http://www.libsdl.org/download-1.2.php

Now you have the best Windows C++ development environment and the most widely used 2d graphics library (which is quite easy to use).

If you know AGS script then you've got a good start, you know how to declare and use variables, and functions.  It works the same in C++.  There's a lot more to learn of course, but you should be able to follow along with basic C++ or SDL tutorials.

Traveler

This is what I recommend:

Herbert Schildt: C++ The complete reference

This is the book I used to learn C++. It was excellent for that and I also used it when I used to teach C++ programming at college (I used a previous edition at the time.)

If you really don't know anything about C++ and/or programming I'd put the most effort in understanding pointers first (the basics will be fairly familiar from AGS, so I assume you'll get through those quickly.)

HTH

The Inquisitive Stranger

Actually, I HAVE worked on a couple of finished games. They just weren't made in AGS.

Radiant

Actually if you already know AGS you should have no problem figuring out C++ as the syntax is very similar (if, while, return, etc). Plenty of helpsites exist on the web for more specific questions (planet source code comes to mind). The most important distinction of C++ is classes and inheritance, I'd recommend you read some tutorial on that (there's plenty on the web).

BOYD1981

a friend of mine just pointed me to this site http://www.learnvisualstudio.net he says it's quite good...

Limey Lizard, Waste Wizard!
01101101011000010110010001100101001000000111100101101111011101010010000001101100011011110110111101101011

MillsJROSS

I'd suggest looking into books that teach you game design with C++. I've seen a few books here and there that are for beginners. Whether that implies begining in programing or just game development, I couldn't tell you. For just programming and getting a handle on C++ itself, I'd suggest the Deitel books, they're fairly comprehensive with a lot of the basics and a bit beyond. However, it is pricey ( about 88 on amazon, though I'm sure you could find cheaper). A class wouldn't be a bad idea, but I feel it would just reinforce what you know through AGS. You might want to become a member of a message board that concentrates on game development or programming, and use them as a source.

-MillsJROSS

The Book

"C++ language" by Bjorne Stroustrup, the very creator of the language.

Alynn

Please don't start with games... I had been making software with java for 4 years before I picked up making games with java... games became a whole new ball of wax... It was almost like I knew nothing of Java when I started...

At least I figured out how to get the game loop working and the pageflipping... now if only I could get the mapengine working... oh well...

seaduck

If you want to start game programming, I don't think C++ is what you're looking for. It's a VERY complicated language with many nasty pitfalls. And it's probably not a good idea to try to learn game programming and objective programming all at the same time.

For most games, you don't really need objective programming, and an imperative language is completely sufficient (C, Pascal,...). And I think you should start with that.

The main good feature of objective programming is inheritance, and that comes in handy when you've got a complicated hierarchy of game objects (characters, tiles etc. in a RPG, for example) many of which share common behavior or properties. This is expressed naturally in terms of inheritance, but once again, this becomes an advantage only for a quite complicated game.

For making a game, you basically need a compiler + an access to the framebuffer, and keyboard input (usually provided by a game SDK).

There are some great free tools to make games.
Compilers:
Ã,  GCC - the free compiler collection, it has a C compiler, a Pascal compiler (FreePascal) etc., it's mainly Unix based, but you can install Cygwin on your windows - it's a unix-like environment running on windows, and this has a GCC port that can create native windows programs! (also there is a DOS port called DJGPP)

Game development kits/libraries: - the easiest way to access graphics in a portable and efficient manner
Ã,  SDL, Allegro - portable, run both under windows and unix
Ã,  ClanLib - another game SDK, more high-level

Under windows, graphics & sound can be accessed also directly using DirectX or GDI/WaveOut, but that is a little more complicated.

You might try to make SDL working with Borland C++ builder, but I've never tried that...

Here's a game I made, it's open source (and quite old, actually). http://blockrage.sf.net/. I wrote it in C. It uses SDL for the framebuffer and keyboard input, but generally could work with any similar library (as it uses just the general framebuffer). I developed it under Linux, but you can also compile it under Cygwin to get a native windows application.

Anyway if you have any questions regarding the mentioned tools (setting them up, using them), or basic game programming concepts, don't hesitate and PM me, I'll be glad to help.

This is a site with plenty tutorials and stuff on game developlent: http://www.gamedev.net/
They also have mailing lists, I think.

BTW It's a common myth that C is "better" than Pascal. This is too simplified. C allows for some very low level access to memory (which can be useful for implementing an OS, for example), and can be more concise at some points, (like the famous {} instead of begin end), but this comes at a cost: C programs are very prone to errors due to unsafe pointer arithmetic and type-unsafe constructs. The pointers can be a real nightmare if the program has some complicated data. (This comes from my own experience, and also look at, say PlaneShift, it crashes more often than not) The Pascal-like syntax is less concise, but more readable, less error-prone, and perhaps a little easier to learn, too.

Languages like Pascal, Ada, (and C# and Java) are much more memory-safe and type-safe.

However, there is a problem with using the other languages from the practical point of view: as most systems and libraries are C-based, you depend on additional language-bindings for the libraries, which may not be available or uip-to-date.

Sometimes the user needs to have the standard libraries for the specific language to play the game, and in some cases on runtime environments (like JavaVM for Java, .NET for C#). This can be very bothering for the user, so it's a problem.

abc123

#14
I recommend you start from the absolute beginning (an absolute beginner should start at the absolute beginning, shouldn't they? :P). Know exactly what is going on at the lowest levels (this is imperative), i.e. up to how the individual opcodes of the CPU work (anything below that, i.e. the electrical internals of the CPU is beyond the scope of programming; but I guess if it truly interests you it wouldn't hurt to know what's going on in there, too: e.g. how Boolean Logic is the most basic machinery in a CPU, etc.). Now don't get frightened by that, you don't need to memorise an entire CPU's instruction set. In fact you don't even have to learn any assembly language to accomplish that goal of knowing the internals (although I recommend you do as it will greatly assist, as it is very simple and easy and when I say "learn", I mean learn the most basic instructions and concepts: what is a CPU register? What is an address space? Learn perhaps how to add the contents, and multiply the contents of a few registers. Perhaps write a basic program in C/C++, then observe the assembly output of your compiler and see how it's doing things...). Know how operating systems manage system resources, and how they work in general.

Additionally, when you learn any language, make sure you know the official and complete definitions of as many things as you can, as there is ambiguity quite often (take the keyword "static" in C for instance: when used on a variable inside a procedure it indicates that the variable will not be temporary, but permanent - its contents will not be undefined when the procedure exists - or even more deeply (for the IA32 architecture): it will not be stored on the stack or in a register, it will be stored on the heap. But when the keyword is used on a global variable (a varibale declared outside of any procedure): the variable will only be accessible from procedures inside the current source file). Also not just for ambiguity's sake: simply knowing what a certain part of a language is and isn't capable of will help you avoid pitfalls. I guess learning (the basics) by trial and error is okay when you first start, but avoid it later.

Don't be intimidated by C++, it's not that much of a big fish. If you wish to start with C++, then by all means, do. Just try and follow my advice of knowing proper definitions of things, and understanding the internals; as with my limited experience I have found this to be of utmost importance (with a lot of things, not just programming). Be patient with your computer, and yourself. Keep in mind that it will probably be a bit of a while (depending on how determined you are, and on previous experience) until you have a nice, shiny 2D game coded in C++ to show off; but don't get discouraged like so many do: unless of course you're expecting to see huge results in, say, two weeks - then you'll definitely end up being disappointed. :P

Good luck.

rharpe

Dedicated webforums concerning C++ are also an excellent way to learn. (Just like AGS forum for AGS games!)

Take games out of your mind and work on "Hello World", and simpler programs. Maybe two or three years from now you can tackle larger projects, like games. Learn the basic structure first so that you can build on the foundation of the language... this will help with other languages as well.

Start from the bottom and work your way up!
"Hail to the king, baby!"

SMF spam blocked by CleanTalk