Using C++

Started by
33 comments, last by frob 9 years, 12 months ago

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

Thanks

Advertisement

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.

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

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

Sorry wasn't sure which to put it in.

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++?

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.

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.

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 ;)

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.

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.

This topic is closed to new replies.

Advertisement