Already know C++ - where to learn game programming?

Started by
15 comments, last by Serapth 11 years, 5 months ago
Hello! I already know C++ (well, at least the most important parts of it, up to classes and such), and now I'd like to start making simple games to learn the basic concepts of game programming. The problem is I can't find a place to learn how a game is broken down into several source files, how to organise classes amongst the several source files, the logic of header/source file, how to implement the game loop... What I mean is I need guidance on the most pragmatic side of game programming. C++ books/tutorials tend to focus on singlefile coding for pedagogical reasons, so I'm a bit unfamiliar with those multifile techniques...

I've tried to look at open source games to find a "pattern", but it seems each programmer uses his own method and I end up even more confused.

I read somewhere (can't remember the site) that a good checklist of games to make is:
Tetris - basic input/output, game loop, collision detection
Breakout - some physic primers
Pacman - AI implementation
Mario - Level creation, storage and reading

But I can't find a good Tetris tutorial to begin with. I need to know the common method and logistics to program any game!

Can anybody help me?
Advertisement
In order to get started I'd recommend using a widespread and well documented framework such as SDL (short for "Simple Directmedia Layer"). It's free to use and saves you all the tedious work associated with initializing a client window, setting up a graphics device etc.

Here's a step by step guide on creating games with SDL
http://www.sdltutori...tutorial-basics

and the actual homepage of SDL
http://www.libsdl.org/

I can't find a place to learn how a game is broken down into several source files, how to organise classes amongst the several source files, the logic of header/source file,

Those aren't game-specific topics, but you might try organizing code files in C and C++.


how to implement the game loop

Try deWiTTERS game loop and fix your timestep.


I read somewhere (can't remember the site) that a good checklist of games to make is [...]

That's a pretty good check-list, but I would recommend starting with Pong rather than Tetris. Both are relatively simple games that feature much of the functionality found in larger, more complex games, but the block logic in Tetris can be a bit complex for a beginner's first game and isn't something that is likely to continue to be useful unless you're making a very similar game.


Like the above member, I would also recommend choosing an API such as SDL, SFML or Allegro and working on some basic games.


Here's a step by step guide on creating games with SDL
http://www.sdltutori...tutorial-basics

There's also Lazy Foo's SDL Tutorials.


Hope that's helpful! smile.png

- Jason Astle-Adams

C++ by itself does not contain any library to access the video, input, and sound hardware, which is what you need for games. So in order to do that, you'd need to use a 3rd party API. SDL, SFML, as people mentioned are good candidates.

Once you familiarized yourself with the API, then you can start working on the core of the game. There isn't any 'de facto' Tetris tutorial, as there's no one correct way of making a Tetris (or anything else really). How you make it is up to you. Other people's source code should be good as points of reference. Here's one: http://code.google.c...e-tetris-clone/

As a beginner, I wouldn't suggest trying too much organizing your code. Your lack of experience will probably backfire -- chose the wrong patterns, premature optimizations, and all that. Do it as best as you can, but the most important thing is to actually complete your game. After you complete your game, your knowledge of project structure will skyrocket, and you'd know how to do it better next time.
Please try this site .. it shows you how to use SDL starting from the basics, and it has exmples : Pong , Tetris and Breakout

http://www.aaroncox.net/tutorials/arcade/index.html

As a beginner, I wouldn't suggest trying too much organizing your code. Your lack of experience will probably backfire -- chose the wrong patterns, premature optimizations, and all that. Do it as best as you can, but the most important thing is to actually complete your game

This is really invaluable advice. Do your best with what you already know, but don't worry too much about applying things you haven't previously used. Whilst there is value in reading about design patterns, code formatting, etc. you won't really understand a lot of these topics properly until you experience them first-hand. Write a game in any way you're able to make it work, and you'll learn a lot of lessons to improve future projects.

- Jason Astle-Adams

Hi,

The more I look into it, then the more that I see such an amazing variety of game structs. I know that you are looking for standard ways of doing things, but in view of all the endless kinds of games, there are few hard fixed standards in the coding because of the staggering variety of game designs, languages, technology, and needs. Much of the class structure, for example, is a matter of opinion, though there are ways of testing for performance. Considerations besides performance often dominate. Are you looking for formulas for coding success which apply across the board? You will find some.

Much of what you are asking will only be realized with hard work, experience, and deep ponder over a specific game.


Clinton

Personal life and your private thoughts always effect your career. Research is the intellectual backbone of game development and the first order. Version Control is crucial for full management of applications and software. The better the workflow pipeline, then the greater the potential output for a quality game. Completing projects is the last but finest order.

by Clinton, 3Ddreamer

I would advice you to read book "Game coding complete" which describes very well game architecture, but it is not for total beginners.
If you want to see how particular game is built, check out, for example, Doom3 source code (available for free at web).

Of course building simple games is very different from pro gamedev. Try to not "overdesign" classes for breakout or tetris, as it will make most of your code redundant.

If you want to see how particular game is built, check out, for example, Doom3 source code (available for free at web).

I haven't reviewed the source code of doom3 myself, but I would guess it's way too complex as a starting point when trying to learn the basics of game development.
I think u should try learning native Windows api before choosing a game engine or DirectX (Engine Developing).

This topic is closed to new replies.

Advertisement