Sign in to follow this  

Real World Application of C++

This topic is 2834 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

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.

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
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?

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
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]

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
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]

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
Quote:
Original post by way2lazy2care
[img]http://www.adherents.com/lit/comics/image/WorldsFinest_159.jpg[/img]

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.


I'm not exactly learning the language. I have already been using C++ for about a year now, and I have been making text based games using the concepts that I learned through other books. I feel I have come to a halt with it though and I want to now learn how to make those text games in to real games, 2D or 3D. But before I just bought a random 3D programming book or something I wanted to know if anyone would recommend one that they have read and know is good.

Really 2D or 3D doesn't matter to me right now, which ever is simplest to learn I would probably go with that. The main thing is doing something with grafix rather than just text.

Share this post


Link to post
Share on other sites
Quote:
Original post by Neobomb
Quote:
Original post by way2lazy2care
[img]http://www.adherents.com/lit/comics/image/WorldsFinest_159.jpg[/img]

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.


I'm not exactly learning the language. I have already been using C++ for about a year now, and I have been making text based games using the concepts that I learned through other books. I feel I have come to a halt with it though and I want to now learn how to make those text games in to real games, 2D or 3D. But before I just bought a random 3D programming book or something I wanted to know if anyone would recommend one that they have read and know is good.

Really 2D or 3D doesn't matter to me right now, which ever is simplest to learn I would probably go with that. The main thing is doing something with grafix rather than just text.


roger. I would do 2D. The math involved is just a lot simpler. For the most part the math is really similar in concept, but the amount of operations and the complexity of the operations are a lot simpler in 2D and you'll still get a lot of the basics that will transfer over to 3D.

That said, I've only done 2D in java, flash, and C# so I'm no help with C++ 2D libraries :-/. If you watch a couple of the basic 2D video tutorials on XNA it will tell you most of the concepts you'll need regardless of language though.

Share this post


Link to post
Share on other sites
You should take a look at the allegro library and any tutorials related to it. It's a great way IMO to begin any kind of graphical game programming.

http://www.allegro.cc/

Share this post


Link to post
Share on other sites
I would try google:ing for some online tutorial on a 2d graphics library for c/c++.

These are two I picked at random while google:ing for SDL tutorials.

http://www.lazyfoo.net/SDL_tutorials/index.php

http://cone3d.gamedev.net/cgi-bin/index.pl?page=tutorials/gfxsdl/index

SDL is a commonly used 2d graphics library, ported to almost any platform you can think of.

Share this post


Link to post
Share on other sites
the biggest problem with jumping from text based to graphics is the lack of an easy path, i personally use sfml, but in order to understand it you need to understand event based programming, have a good handling of pointers and object inheritance, from there sfml will work fine.

the book i started out on was an old teach your self c++ in 24hrs book (i started something like 12 years ago) and then game programming all in one. it started out in console then moved to direct draw, and finally direct3d 7 and all the other components of it like direct input and sound

there is a new edition of the game programming all in one that may have what you are looking for



Share this post


Link to post
Share on other sites
Quote:
Original post by Neobomb
Quote:
Original post by way2lazy2care
[img]http://www.adherents.com/lit/comics/image/WorldsFinest_159.jpg[/img]

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.


I'm not exactly learning the language. I have already been using C++ for about a year now, and I have been making text based games using the concepts that I learned through other books. I feel I have come to a halt with it though and I want to now learn how to make those text games in to real games, 2D or 3D. But before I just bought a random 3D programming book or something I wanted to know if anyone would recommend one that they have read and know is good.

Really 2D or 3D doesn't matter to me right now, which ever is simplest to learn I would probably go with that. The main thing is doing something with grafix rather than just text.

Sounds like you want to have a look at this book then:
Data Structures for Game Programmers by Ron Penton
It's the best book I've ever come across that clearly shows, using plenty of examples, why you would bitvector, array, stack, queue, linked lists, classes, etc using C++ and 2D graphics using SDL.
If you look at the table of contents there are even some sections labeled "Tying it all together" that blatantly show how it all fits together.
Most other books I've come across seem to either assume that a lot of the idioms and patterns using in making a game, like using a stack for a game menu for example, is something you've already come across on your own or self-evident.


[Edited by - daviangel on March 15, 2010 7:50:38 PM]

Share this post


Link to post
Share on other sites
Quote:

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.


Well heres the only issue with that. Thoes text based games have all the elements that graphic games have at the core programming level. The idea is that your learning how your chosen language actually works and learning the very basics that all games need from the language side. After you have some udnerstanding of thoes, THEN move on a learn a graphics API (Such as Allegro/SDL for 2d, and DirectX/OpenGL for 3d). In my experience (I am a begginer myself), trying to start out learning the basics of C++ while also learning a graphics API is a bad idea because most learning resources for thoes APIs mentioned above assume you know the C++ basics.

Peronally I tried jumping strait to SDL when I only had a very very basic C++ understanding, and while I was able to read tutorials and do them fine... once I tried to do things on my own I sank like a stone, and ended up starting over complealy. If you really really want to skip ahead to 3D give it a try... but the odds of success are slim, and it will likely take you more time then if you just work your way there.

Quote:
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 personally don't know any tutorials or books that explain the C++ basics while teaching 3D programming... and the reason is they are two different things. Learning DirectX for example, is something you should only do when you have a solid understanding of all the core C++ concepts and have actually applyed them.

For example, you don't know why you would use pointers? Thats very understandable. Pointers are probably one of the hardest parts of C++ to learn, and can be a real pain... but to get into 2D or 3D programming you really need to understand why you need them, and how to use them. When you go to learn an API, I haven't really seen any learning resources for DirectX/SDL/Allegro that sit down and explain Pointers (or any other C++ concepts for the matter) in the middle of teaching you the API as well.

Quote:

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?


A good book is Beggining C++ Through Game Programming. Its going to be all console text apps that you seem to hate. But again, you need to learn how C++ works before you start learning a graphics API. Just because a game is text based, doesn't make it less of a game. For example, I just finished writeing a texted based RPG as a console app. It has everything a fully graphic game would have at the programming level... it just doesn't have graphics other then letters.

Personally I also like The Game Institutes online classes. I know some people will say you can find the same learning info on the net... but its nice to have it in one structured area, writen by professionals. The first course will just be more text apps that apply what you learn. The second course is mostly Win32 programming, which involves grapics and the final project is a 2D airhockey game thats kinda nifty. After that there courses move on to DirectX and 3D programming. If thats where you really want to end up... you should really look into it.

Take what I say with a grain of salt because Im a begginer myself whos currently working my way throuhg 2d, and dabbling in DirectX... but I was in your boat at one time, and learned the hard way there are no short cuts, and if you ever want to be a game programmer you need to learn to program correctly, and not cut corners.

Share this post


Link to post
Share on other sites

This topic is 2834 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

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

Sign in to follow this