My first C++ game

Started by
6 comments, last by Rectangle 11 years, 7 months ago
Hi. Before I address my questions I'd like to give a small background of my experience. I'm 16 years old, I began programming a year ago and I've been studying C++ every day since then. I have not written anything big, except a tic tac toe game in ASCII which is probably my biggest achievement.

I know I'm not so experienced with the language after a year, but I feel like I can move on from console programs into something better, so I thought "Why not make a game?" so I've been documenting what it involves, and what I need. I figured I need to learn OpenGL but after trying it I just couldn't understand what matrixes are and how it works overall (I do know the language features however)

So I'm going to address a few questions which I hope to get some answers for, in order to make my first game.

1. What framework should I learn to make my first game?
2. Where can I find an easy to follow tutorial? (This includes videos, articles, etc)
3. How can I learn the syntax? When I tried learning OpenGL I found myself forgetting the syntax very easily, even after re-writing it several times, I just kept forgetting it.

4. Is it best to start with a 2D game rather than a complex 3D game?

Thanks in advance for all the replies, and I'm not going to give up the idea of making a game, but I hope some experienced game makers/programmers can get me on the right path.
Advertisement
1. You can start out with freeGLUT to get off the ground. It hides the OS specific stuff like creation a window and GL context, user input.
2. There is Nehe but it is ancient and just teaches GL 1.1 and few things like VBO.
There is the Wiki for GL 3 stuff
http://www.opengl.org/wiki/Tutorials

and all this
http://www.opengl.org/wiki/Getting_started#Tutorials_and_How_To_Guides

3. The same way you learn the syntax for any other API
4. 2D tic tac toe or Pac Man.
Sig: http://glhlib.sourceforge.net
an open source GLU replacement library. Much more modern than GLU.
float matrix[16], inverse_matrix[16];
glhLoadIdentityf2(matrix);
glhTranslatef2(matrix, 0.0, 0.0, 5.0);
glhRotateAboutXf2(matrix, angleInRadians);
glhScalef2(matrix, 1.0, 1.0, -1.0);
glhQuickInvertMatrixf2(matrix, inverse_matrix);
glUniformMatrix4fv(uniformLocation1, 1, FALSE, matrix);
glUniformMatrix4fv(uniformLocation2, 1, FALSE, inverse_matrix);
I used opengl for my first game. The only opengl drawing command I used was: glBegin, glEnd, glColor3f (although deprecated)
And for the window, I used freeglut.

You don't need to know complicated stuff like vbo and matrices for your first game.
Start out with small 2d games like snake and start building up your experience

To learn the syntax, the opengl tutorials on youtube are fine.
An invisible text.
If you are exclusively targetting Windows, I'd actually start out by learning DirectX 9. OpenGL is cross-platform and pretty standard for most OS's and devices, but even with the utility libraries it has a lot of manual labor and gets quite intricate early on for a beginner. Many concepts between them are quite similar, and I do recommend eventually learning both, but DirectX is a better starting point IMO and AFAIK is the only way that you can port your games onto the Xbox360 platform (via the XNA Framework). However, if you haven't familiarized yourself with the basic Win32 API concepts of window creation and GDI graphics, then yes I would definitely recommend starting with OpenGL + utility libs. Alternatively, there are 3rd-party libraries such as SDL which are both cross-platform and fairly high-level, making everything easier, so there's something to think about as well.

Google is your friend. Type in the name of the framework you wish to use + "tutorial" or "example" and you will have nearly everything you will ever need right there.

Matrices are a mathematical structure primarily used in 3D graphics programming, and are a college-level concept derived from linear algebra. For graphics, they aid in the position, scale, rotation and translation of an object in 3D world-space. Before getting involved in them, I would definitely recommend sticking to a 2D environment where simple high-school algebra and trigonometry come into play using 2-dimensional Vectors.

To learn the syntax, just keep checking the API reference docs, samples/demos, and online tutorials. Bookmark the ones you are learning along the way if you need to.
As stated by the previous poster, the same applies for any API you are learning. For Win32 API stuff, check the MSDN.

As suggested above, a good place to start is a simple game of Tic-Tac-Toe or Minesweeper, or a card game like Solitaire. Once you've done that, I'd move on to something that uses 2D sprites, such as Pong, Asteroids or Tetris, and then move up to Tile-based games such as Mario, Zelda or virtually any 2D side-scroller or top-down RPG. By then, you should be prepared to implement 3D effects in a 2D environment (using 3D vectors), and perhaps you could even try a 2.5D isometric game like Starcraft or Diablo. Then, it's finally time to move forward into a fully 3D environment. A good place to start there would be a 3D space-shooter.

It's a long path but if you stick with it and don't skip any steps, you won't regret it later on. Personally, I've had to go back and forth over the years, learning everything out of order, and it's complicated my 3D programming skills to say the least. Good luck!

If you are exclusively targetting Windows, I'd actually start out by learning DirectX 9. OpenGL is cross-platform and pretty standard for most OS's and devices, but even with the utility libraries it has a lot of manual labor and gets quite intricate early on for a beginner. Many concepts between them are quite similar, and I do recommend eventually learning both, but DirectX is a better starting point IMO and AFAIK is the only way that you can port your games onto the Xbox360 platform (via the XNA Framework). However, if you haven't familiarized yourself with the basic Win32 API concepts of window creation and GDI graphics, then yes I would definitely recommend starting with OpenGL + utility libs. Alternatively, there are 3rd-party libraries such as SDL which are both cross-platform and fairly high-level, making everything easier, so there's something to think about as well.

Google is your friend. Type in the name of the framework you wish to use + "tutorial" or "example" and you will have nearly everything you will ever need right there.

Matrices are a mathematical structure primarily used in 3D graphics programming, and are a college-level concept derived from linear algebra. For graphics, they aid in the position, scale, rotation and translation of an object in 3D world-space. Before getting involved in them, I would definitely recommend sticking to a 2D environment where simple high-school algebra and trigonometry come into play using 2-dimensional Vectors.

To learn the syntax, just keep checking the API reference docs, samples/demos, and online tutorials. Bookmark the ones you are learning along the way if you need to.
As stated by the previous poster, the same applies for any API you are learning. For Win32 API stuff, check the MSDN.

As suggested above, a good place to start is a simple game of Tic-Tac-Toe or Minesweeper, or a card game like Solitaire. Once you've done that, I'd move on to something that uses 2D sprites, such as Pong, Asteroids or Tetris, and then move up to Tile-based games such as Mario, Zelda or virtually any 2D side-scroller or top-down RPG. By then, you should be prepared to implement 3D effects in a 2D environment (using 3D vectors), and perhaps you could even try a 2.5D isometric game like Starcraft or Diablo. Then, it's finally time to move forward into a fully 3D environment. A good place to start there would be a 3D space-shooter.

It's a long path but if you stick with it and don't skip any steps, you won't regret it later on. Personally, I've had to go back and forth over the years, learning everything out of order, and it's complicated my 3D programming skills to say the least. Good luck!

This is extremely useful and I appreciate everyone's repplies, especially this one. I thank you kindly for your advice and I'll make sure to follow it! smile.png
I think you should do what you want to do, go with the api you would like to use, and stick with it!
eventualy you will figure stuff out and the problems will be less "wierd"....

But, my choises if i would be creating a game would be going with C# & XNA, you dont have to worry about all the stuff c++ and dx/gl lets you handle.
and XNA is pretty neat when it comes to rapid development!
otherwise, try out a engine, like unity or udk!

If you are more into Engine programming, go with dx/og since that is more or less the only way, or build your own graphics libary tongue.png
"There will be major features. none to be thought of yet"
I think you should start with c# or java and use the built in graphics API as they are pretty straight forward and require little effort to learn. You'll use eclipse/visual studio to write the code and intellisense will remember function names for you so you wont have to bother with
1- Graphics APIs/Frameworks
2- Function details/graphics pipelines
3- Windowing/keyboard-mouse input routines.

You can easily focus on actual game development/algorithms/geometry calculations.
By the time you create a game like snake that actually works you'll have learned a great deal about essentials of game programming.

Then you can move to more professional stuff like OpenGL/DirectX
When it comes down to it, it's pretty much just a matter of opinion. Everyone learns in different ways using different tools in different languages, and many are proud of how far they have come (as they should be).
I was coming here to recommend these tutorials for you, but I think you first need to decide exactly how much "flexibility versus learning curve" you are willing to endure.
If you don't want to hassle yourself with learning how graphics are programmed, then you can use something like the Unreal Development Kit to delve right into simply making a game. But you will lose some flexibility, since you can only do what the SDK or API of your choice allows you to do. OpenGL and DirectX do require a lot of learning, and it practically never ends, but you will have full control over how things are rendered. XNA is a decent middleground, but I only briefly mentioned that earlier because you said that you were working with C++, and XNA requires the use of the .NET framework which means you would have to learn either C# or VB.NET.

So it basically all boils down to deciding exactly what you want, how much time you are willing to spend on it, and how far you want to go from there. You could always try different things if you feel as if something's not working out for you, but also the best piece of advice here is to keep at it until it becomes second nature. Good luck!

This topic is closed to new replies.

Advertisement