Jump to content

  • Log In with Google      Sign In   
  • Create Account

Using C++


Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

  • This topic is locked This topic is locked
34 replies to this topic

#1 KB Toys   Members   -  Reputation: 110

Like
0Likes
Like

Posted 12 April 2014 - 04:27 PM

So I have recently watched several videos on C++. I understand the basics, but how can I apply this into developing a game? 

 

Thanks



Sponsor:

#2 Ectara   Crossbones+   -  Reputation: 3058

Like
3Likes
Like

Posted 12 April 2014 - 05:03 PM

The way I look at it, any language is simply a tool. If you can describe how you want the game to work in terms of conditional logic and mathematical expressions on paper, you can then write it in C++ and run it. So, I believe that the more appropriate question is "How can I express a game in a strictly logical set of rules and interactions?" Translating to a programming language will follow.



#3 Álvaro   Crossbones+   -  Reputation: 13912

Like
1Likes
Like

Posted 12 April 2014 - 05:22 PM

Why is this in the "Artificial Intelligence" forum? There is a "For Beginners" forum.

#4 KB Toys   Members   -  Reputation: 110

Like
1Likes
Like

Posted 12 April 2014 - 06:28 PM

Why is this in the "Artificial Intelligence" forum? There is a "For Beginners" forum.

Sorry wasn't sure which to put it in.



#5 KB Toys   Members   -  Reputation: 110

Like
1Likes
Like

Posted 12 April 2014 - 06:29 PM

The way I look at it, any language is simply a tool. If you can describe how you want the game to work in terms of conditional logic and mathematical expressions on paper, you can then write it in C++ and run it. So, I believe that the more appropriate question is "How can I express a game in a strictly logical set of rules and interactions?" Translating to a programming language will follow.

Do you know any good videos I can watch to extend my knowledge on C++?



#6 Ectara   Crossbones+   -  Reputation: 3058

Like
2Likes
Like

Posted 12 April 2014 - 07:38 PM

 

The way I look at it, any language is simply a tool. If you can describe how you want the game to work in terms of conditional logic and mathematical expressions on paper, you can then write it in C++ and run it. So, I believe that the more appropriate question is "How can I express a game in a strictly logical set of rules and interactions?" Translating to a programming language will follow.

Do you know any good videos I can watch to extend my knowledge on C++?

 

I'm afraid not; the only thing that videos help for me is higher level math.

 

Programming is something that has always been a reading and hands-on experience kind of thing for me. Keep reading whatever you find, and learn to separate the good advice from the bad (prefer ones that quote the C++ standard). Make projects that become incrementally greater. Have you done the common "guess the number", tic-tac-toe, blackjack, and poker programming projects? Those are good starts.


Edited by Ectara, 12 April 2014 - 07:38 PM.


#7 shadowisadog   Crossbones+   -  Reputation: 2563

Like
24Likes
Like

Posted 12 April 2014 - 07:50 PM

The path to learning how to program is to program. There are no tricks, no shortcuts, and no videos that will replace experience.

 

To learn any language to any degree of proficiency you must use them to write programs.

 

To learn C++ you start learning by creating console programs. You may wonder what writing a console program has to do with creating a game. You may say "but I want to make a game with graphics!". My response is that you must start from the basics and learn the data structures and design patterns involved with programming things.

 

Games are software. When you are ready to make a game with graphics you can pick a API or game engine and go to town, however if you must ask how to do so then you are not quite ready to make the leap.

 

So you start by writing a guess the number game or something like that. You have the computer say "Guess a number between 1 and 10!" and it selects a random number. You guess a number and the computer responds back if you are too high or too low.

 

Then you could make a text adventure game. The first attempt people have at doing this typically is quite terrible. Soon you have hundreds of if statements and you realize there must be a better way. You learn about data driven design practices.

 

So once again know that games are software, and learn how to write programs. Write small programs and then write more complicated programs. Write LOTS and LOTS of programs. Pick something you want to program and figure out how to do it! Then you will not need to ask the question of how to expand your knowledge of C++ towards game programming... because you will know.

 

Programming is essentially all problem solving. You have a problem and you break it into smaller problems. You break the problem down enough until you have something you can Google. Then you put all of the pieces together and you have a program. Then the program doesn't work and you have to figure out why. That is programming.


Edited by shadowisadog, 12 April 2014 - 07:54 PM.


#8 Ryan_001   Prime Members   -  Reputation: 1459

Like
2Likes
Like

Posted 13 April 2014 - 01:33 PM

Think of console programming like a king-fu master telling you to hit a bowl of water again and again.  It seems silly to you at the time, and ever so boring.  You want to be making engines and games with cool graphics, and here you are wasting your time with yet another console tutorial.  Yet there is good reason the master has given you those instructions...

 

 

Programming is essentially all problem solving. You have a problem and you break it into smaller problems. You break the problem down enough until you have something you can Google. Then you put all of the pieces together and you have a program. Then the program doesn't work and you have to figure out why. That is programming.

hehe... so true ;)



#9 Álvaro   Crossbones+   -  Reputation: 13912

Like
6Likes
Like

Posted 14 April 2014 - 11:22 AM

Programming is essentially all problem solving. You have a problem and you break it into smaller problems. You break the problem down enough until you have something you can Google. Then you put all of the pieces together and you have a program. Then the program doesn't work and you have to figure out why. That is programming.

 
Let me insert one piece of advice: As you put the program together, do it in a way which allows you to compile and test many times along the way. This trick dramatically reduces frustration when the program invariably doesn't work, because you will be confident most of your code is working, and the problem is most likely in the parts you added since the last compile-and-test point.
 
As an example, to write a program that plays checkers:
 * Write a struct called Board that contains the description of a board position.
 * Write code to initialize a board to a particular configuration and to print it out on the console.
 * Test.
 * Write a class called Move, with code to construct a Move and to perform a Move on a Board.
 * Test.
 * Write code to undo a Move.
 * Test.
 * Write code to generate valid moves from a position.
 * Test (a lot).
 * Write a very simple evaluation function.
 * Test.
 * Implement minimax search to a fixed depth.
 * Test.
 * Write a reasonable interface so we can play games against the engine.
 * Test.
 * Implement alpha-beta pruning.
 * Test.
 * ...
 
 
 
 

Think of console programming like a king-fu master telling you to hit a bowl of water again and again. It seems silly to you at the time, and ever so boring. You want to be making engines and games with cool graphics, and here you are wasting your time with yet another console tutorial. Yet there is good reason the master has given you those instructions...

 
I don't really like the analogy, because you can have a fulfilling programming career without ever writing anything other than console programs.

#10 BitMaster   Crossbones+   -  Reputation: 4432

Like
8Likes
Like

Posted 17 April 2014 - 01:03 AM

The adaptation of the NeHe's codes of 2000 to Visual C++ MS VS pro 2010-2012:   NeHe's demo and codes OpenGL summary


What good is that supposed to do? Exposing someone new to programming in general and C++ in particular to OpenGL is doing them a great disservice. Even if OpenGL information were relevant, NeHe code is simply too old and outdated to be of use to someone learning it today. The NeHe tutorials were a great and important source a decade ago. Nowadays they do more harm than good for a newcomer.

#11 Mats1   Members   -  Reputation: 312

Like
4Likes
Like

Posted 17 April 2014 - 02:55 AM

Then you could make a text adventure game. The first attempt people have at doing this typically is quite terrible.

 

I think this is also bad advice. After seeing beginners trying text adventures for three years now, I'm yet to see any of them finish a particularly good one or learn very much from their attempt.

I would suggest that to get a book on C++ is the best way to learn, and failing that, to read online. There is a list here of decent C++ books: http://www.pixelstech.net/article/index.php?id=1337796210.
Each time you read how to do something, you should then try to apply it to a real (small) project. Once you have learnt the basics of C++, which I would consider to be:
Variables, control flow, input/output, arrays, strings, functions, structs and classes, inheritence and debugging. If you learn this stuff, you will forever be a significantly better games programmer, if you choose to pursue programming games in C++ or otherwise.

To then make games in C++, you will probably want to use an external library. Popular options are SDL, SFML (my recommendation) and Allegro. This will allow you to start creating 2D games. These have good tutorials on Youtube and other places online. However, you will need to be comfortable using C++ before starting to learn these libraries.

Also, learn any maths that you can. The better you are at maths, the better you will be at programming.



#12 shadowisadog   Crossbones+   -  Reputation: 2563

Like
4Likes
Like

Posted 17 April 2014 - 09:25 AM

 

Then you could make a text adventure game. The first attempt people have at doing this typically is quite terrible.

 

I think this is also bad advice. After seeing beginners trying text adventures for three years now, I'm yet to see any of them finish a particularly good one or learn very much from their attempt.
 

 

I disagree because often the subject of data driven programming gets brought up from the attempt. Failure is perfectly fine in this context, the entire point of the exercise is attempting to create something. Text adventure games are deceptively "simple" and can involve complex data structures, regular expressions, and various forms of file IO.

 

I don't see where we are ones to judge what people learn from attempting to create certain programs.

 

Anyway I have failed at countless things during my programming career so far, including quite a number of text adventure games. I DID learn a good bit from the attempts. I have lots of unfinished projects rotting on my hard drive, but that does not mean that any were a waste of time!


Edited by shadowisadog, 17 April 2014 - 09:32 AM.


#13 BHXSpecter   Members   -  Reputation: 1670

Like
1Likes
Like

Posted 17 April 2014 - 09:14 PM


I don't see where we are ones to judge what people learn from attempting to create certain programs.

I agree because everyone learns differently. What worked for you may not work for others so it is unfair to give a path for something that has no set path to learning.

 


So I have recently watched several videos on C++. I understand the basics, but how can I apply this into developing a game? 

I can understand where he is coming from. I've read many books and done tons of experiment programs as I learned. When I started out, I could set there and help other beginners fix their code no problem, but when it came to mine I couldn't think (I just locked up). Still do lock up on my own projects from time to time and have to force myself to just start typing code in hopes that the block will lift. 

 

Let me add my advice. Books have more detail than a video or tutorial will have and cover more. You can learn from the videos and tutorials, but if you want to know more about a feature in C++ then you need a book for that (I'd recommend Bjarne Stroustrup's The C++ Programming Language for a reference). Just keep programming and trying anything and everything you can and when you hit a snag, ask questions... lots and lots of questions.


"Through vengence I was born.Through war I was trained.Through love I was found. Through death I was released. Through release I was given a purpose."


#14 Jazonxyz   Members   -  Reputation: 138

Like
2Likes
Like

Posted 17 April 2014 - 11:32 PM

You can use C++ along with SDL to make video games.  Why don't you private message me?  I can help you make a Pong game using C++/SDL, and you can go from there :)



#15 parikshit   Members   -  Reputation: 108

Like
1Likes
Like

Posted 18 April 2014 - 02:43 AM

According to me, the best way to learn C++ and proceed to game programming is to first get a book for C++. The best one I know of is Let us C++ by Yashwant Kanetkar or even C++ How to Program is good. Then get a book for Introductions to Data Structures and Algorithms and after these if you still wanna further your knowledge, you can also read Introduction to Cormen. Otherwise you can proceed with game programming using 2D APIs like ClanLib or Allegro for starters and then, move ahead to OpenGL for 3D development. All of these APIs are well documented, so I'm sure you can find a good book for the above. Also, only for the introduction part you can also refer to the book, Introduction to Game Programming Using C++, by Alan Thorn. Happy to help,



#16 BHXSpecter   Members   -  Reputation: 1670

Like
3Likes
Like

Posted 18 April 2014 - 07:29 AM

I can't say I've heard of any of those books. Personally, when it comes to C++, I would recommend C++ Primer (not to be confused with C++ Primer Plus) for beginners, The C++ Programming Language by Bjarne Stroustrup as a reference. Some can learn game programming while learning the language, but I always recommend learning C++ first before tackling anything else.

 

Learning C++ first makes it so you can focus more on learning to apply what you know to game development. I think it is more stressful for a beginner to learn (I will use Pong as an example) to make Pong and understand everything about making such a simple game while trying to learn functions, classes, pointers, etc. at the same time. If they have a grasp of the language before undertaking any game it will be easier and will be less stressful if they run into something in the language they don't know.


"Through vengence I was born.Through war I was trained.Through love I was found. Through death I was released. Through release I was given a purpose."


#17 catslap   Members   -  Reputation: 35

Like
1Likes
Like

Posted 20 April 2014 - 02:09 AM

start here (for free):

http://www.cplusplus.com/doc/tutorial/

 

then (much later) buy this:

http://www.stroustrup.com/4th.html

 

then (much much later) buy this:

http://www.amazon.com/gp/product/0321334876?ie=UTF8&tag=aristeia.com-20&linkCode=as2&camp=1789&creative=9325&creativeASIN=0321334876

 

all the while writing programs and asking lots of questions. If you're not interested in c++ specifically, and just want to get running with games, something like flash with flashpunk will likely be many times quicker for a basic game, and with lots more examples available. You can always move to c++ later.

 

If you want a basic project in c++ with SDL2 I can post something simple up.



#18 BHXSpecter   Members   -  Reputation: 1670

Like
2Likes
Like

Posted 20 April 2014 - 08:35 AM

Yes, you can start at Cplusplus.com, but should really invest in getting C++ Primer 5th Edition by Stanley B. Lippman, Josee Lajoie, and Barbara E. Moo to learn C++ and The C++ Programming Language 4th Edition by Bjarne Stroustrup for a reference. The one place tutorials fail is that they don't cover nearly enough information to be really valuable which is why they are okay for getting your feet wet, but should be brushed aside for books (especially books that are known to be considered popular by other users). Scott Meyer is also a good author to get from so you should definitely invest in Effective C++, More Effective C++, Effective STL (as they all still cover some points that are still valid even though they are a little outdated) and keep an eye out for his new Effective book that he is calling Effective Modern C++ (but there is no release date mentioned last I knew).

 

I think Primer and Bjarne's book are the best two, but if you want you can also see what ISOCPP recommends ( https://isocpp.org/get-started ).


Edited by BHXSpecter, 20 April 2014 - 02:12 PM.

"Through vengence I was born.Through war I was trained.Through love I was found. Through death I was released. Through release I was given a purpose."


#19 iMalc   Crossbones+   -  Reputation: 2314

Like
5Likes
Like

Posted 20 April 2014 - 11:50 PM

So I have recently watched several videos on C++. I understand the basics, but how can I apply this into developing a game? 

 

Thanks

Let me help put that into perspective for you...

 

You've just watched several videos on how to use a hammer, and now want to build your own home.


"In order to understand recursion, you must first understand recursion."
My website dedicated to sorting algorithms

#20 catslap   Members   -  Reputation: 35

Like
-5Likes
Like

Posted 22 April 2014 - 12:23 PM

 

So I have recently watched several videos on C++. I understand the basics, but how can I apply this into developing a game? 

 

Thanks

Let me help put that into perspective for you...

 

You've just watched several videos on how to use a hammer, and now want to build your own home.

 

Overdramatic twaddle, 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. 

 

Good luck KBToys, I hope you have fun learning, don't be out off at all. There's plenty of people and forums who will help if you get stuck.






Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.



PARTNERS