Real World Application of C++

Started by
16 comments, last by Neobomb 14 years, 1 month ago
Hi. I am teaching myself C++ in hopes of one day creating my own games, but I am having a little bit of a problem grasping the concepts, or more grasping why I would need/use them. I have read a few books and I understand C++ to a degree, I understand classes, loops, boolian algebra, exc. But I feel as if I haven't learned anything because I don't understand how to apply those concepts to game design. My question is, are there any books out there where they teach you C++ through 3D game design, using DirectX?? I have a book C++ through game design but it is text based games and it isn't really helping me as I already know how to make programs in the DOS prompt fashion. Hope someone can give me some pointers.
Advertisement
What have you programmed so far?
I have programmed a bunch of useless things,

A program that asks questions, stores data, gives different answers based on input. Wont continue if certain things aren't answered correctly, exc. It was kind of my attempt at those early text RPG's

Black Jack Game (Text based)

Hangman game (Text based)

Guess The Number style Game

various different "Hello World" variants

All stuff along these lines, as all the books I have focus on the DOS prompt style of games, so its all text based, which is my problem.

My issue is I want to for instance, take the hangman game they taught me, and make that into something someone of this generation would consider a game, with grafix, sounds, exc.

Some parts of programming really only come into their own when your programs grow in size. It is certainly possible to program without classes many of the smaller programs you mention, but eventually you will need aggregate types of some kind to logically structure your data.

Quote:
I have a book C++ through game design but it is text based games and it isn't really helping me as I already know how to make programs in the DOS prompt fashion.

All the applications you list are still very small. Keep pushing the limits of the programs you write, but don't take too big a step in one go.

For example, writing a "real" application that might do some bulk file operation, such as detect duplicate files recursively in an arbitrary number of folders, building a database of folders which the user can later peruse and choose to delete individual entries or whatever. Something like that, the exact type of application is not important. The point is that building a more complex application will teach you a lot about how to write C++, and some more abstract ideas about how to design larger programs.

Alternatively, you might take this opportunity to delve into graphics programming using something like SDL or SFML, but be warned that these APIs will throw you in the deep end of some of the features of the language you might not be familiar with yet, such as pointers, object ownership, exception safe code and inheritance.

I will give one piece of advice from when I was learning. You learn to design larger programs by building them. The flip side of this is that the first few middling to large programs you build will be designed incorrectly. They have a tendency to get so far to the stage that you get some obscure bug that you cannot fix (because you don't know the language well enough to even begin to debug it) and you cannot progress.

For me, I was trying to build a game somewhat like Soldat. I got suprisingly far, until I managed to do something to corrupt memory. That bug pretty much stopped that program. The code was such a mess (retrospectively) that it was impossible to reason about, and my inexperience with C++ and programming and general effectively prevented me from fixing it. At this time I didn't have internet access so I had no real option but to start a new program.

The moral is that you won't be able to build a big game in one go. By building smaller games or programs, you'll make the mistakes but you won't have invested so much into that individual project. This counts double if the project is one close to your heart, like the game you always wanted to make.
Quote:Original post by rip-off
Some parts of programming really only come into their own when your programs grow in size. It is certainly possible to program without classes many of the smaller programs you mention, but eventually you will need aggregate types of some kind to logically structure your data.

Quote:
I have a book C++ through game design but it is text based games and it isn't really helping me as I already know how to make programs in the DOS prompt fashion.

All the applications you list are still very small. Keep pushing the limits of the programs you write, but don't take too big a step in one go.

For example, writing a "real" application that might do some bulk file operation, such as detect duplicate files recursively in an arbitrary number of folders, building a database of folders which the user can later peruse and choose to delete individual entries or whatever. Something like that, the exact type of application is not important. The point is that building a more complex application will teach you a lot about how to write C++, and some more abstract ideas about how to design larger programs.

Alternatively, you might take this opportunity to delve into graphics programming using something like SDL or SFML, but be warned that these APIs will throw you in the deep end of some of the features of the language you might not be familiar with yet, such as pointers, object ownership, exception safe code and inheritance.

I will give one piece of advice from when I was learning. You learn to design larger programs by building them. The flip side of this is that the first few middling to large programs you build will be designed incorrectly. They have a tendency to get so far to the stage that you get some obscure bug that you cannot fix (because you don't know the language well enough to even begin to debug it) and you cannot progress.

For me, I was trying to build a game somewhat like Soldat. I got suprisingly far, until I managed to do something to corrupt memory. That bug pretty much stopped that program. The code was such a mess (retrospectively) that it was impossible to reason about, and my inexperience with C++ and programming and general effectively prevented me from fixing it. At this time I didn't have internet access so I had no real option but to start a new program.

The moral is that you won't be able to build a big game in one go. By building smaller games or programs, you'll make the mistakes but you won't have invested so much into that individual project. This counts double if the project is one close to your heart, like the game you always wanted to make.



Thanks for the reply!

I'm not trying to make a huge game or anything just yet, I just want to learn C++ through 3D (or any kind of grafix orientated) programming. So instead of learning to make a blackjack game that is just letters representing cards, I want to have the actual cards represented via on screen grafix.

That's what I was asking, if anyone could recommend a book, or online tutorial or anything that explains C++ as it would pertain to 3D programming (or something to that effect). I just have a hard time understanding things for instance, pointers... I learned how to make them, I learned they point to the memory location, but what I didn't learn how to use a pointer within a game, or why you would need a pointer.

I feel like all the books I read are just teaching theory and not application.

Were there any books that helped you when you first started you would recommend?

Allegro is a pretty good 2d library, but I strongly advise you that you stay away from trying to do any kind of 3d visuals until you are comfortable with both moderate programming and linear algebra.
Well 3d does take some time to cover, some of the algebraic concepts plus graphics pipeline. It depends on your c++ experience if you have done a lot of system programming then go for directx otherwise to make something fun in 2d allegro or may be similar is a good choice.

[Edited by - knife on March 15, 2010 2:37:32 PM]
Let me backtrack here..

My question was,

Are there any books out there that teach C++ as it pertains to 2D or 3D game programming (Anything with visuals) that anyone would recommend.
http://www.adherents.com/lit/comics/image/WorldsFinest_159.jpg edit: I fail at this forum... what's the image tag or do I have to make it a link?

Why would you want to start in 3d when you are trying to learn the language? That's a really rough way to go.

I really would recommend doing something not real time then moving up (unless you've made games in another language already).

I'm sure everyone would love to jump in and make a 3D game, but it's just not the best way to go about it. You'll waste so much time trying to apply simple concepts to a really complex situation before you truly understand the simple concepts. The lack of knowledge compounds and can make errors extremely hard to find down the road.

It's much easier to learn and understand the simple concepts then apply what you understand to the things you don't understand.

That's completely aside from the fact that even going to 2D from 3D can illustrate the same concepts, but with many many fewer problems and complexities by a couple orders of magnitude.

[Edited by - way2lazy2care on March 15, 2010 2:00:37 PM]
Quote:Original post by Neobomb
That's what I was asking, if anyone could recommend a book, or online tutorial or anything that explains C++ as it would pertain to 3D programming (or something to that effect). I just have a hard time understanding things for instance, pointers... I learned how to make them, I learned they point to the memory location, but what I didn't learn how to use a pointer within a game, or why you would need a pointer.

I feel like all the books I read are just teaching theory and not application.

Were there any books that helped you when you first started you would recommend?

Sad truth is that all books are useless if you don't know exactly what problem you are trying to solve.
You don't need to use pointers if you can solve your problem without using them.

Just keep doing small stuff. If you keep learning at least one new thing a day, after a couple of years you will probably be ready to start 3d game programming.

This topic is closed to new replies.

Advertisement