Sunday, October 15, 2017

What is a good book to start programming a 2D C++ game?



I have a degree in Computer Science and while I was in college, I created a simple 2D game in Game Maker. I would like to recreate this game in C++ as a start to learning how to create games in C++. What would be a good book to start out on programming games in C++ for someone who has a bit of C++ experience (My CS Major classes were taught using Java and I had a class in C++ to learn syntax) and knowing the concepts behind objects, methods, inheritance, etc?


This would be a hobby of mine while I build up experience until I one day could work in the Vide Game Industry.



Answer



Seeing as you were using Game maker, I'm assuming you're on Windows, so jump in at the deep end with the direct-x SDK. The samples provide source code, and also give you a taste of the power available to you. Just because you want to do a 2D game doesn't mean you should stick with a 2D library, at some point you'll probably want to do something the library doesn't implement in itself (shaders or rotations or something random that you just NEED for your project).



SDL -and probably SFML and Cinder- provides a high level "got the basics out of the way" approach to being an engine, so you would have all the power of doing it from scratch (so you could have pixel shaders in SDL), but you'd not learn how things got done. You'd then be doing real C++ inside a helper framework, which will help get stuff done, but won't be a great help in teaching you how to develop games if you're ever going to be working at a game dev company.


SDL, SFML, and even Cinder are all clever ways of avoiding learning about the difficult stuff in C++. They normally wrap OpenGL, which is useful to learn if you want to code graphics for non-windows machines, but there's tonnes of resources for getting work done in Direct-X too (probably more as the Windows virus has spread to every corner of the world).


If you don't want to learn the gritty stuff, then fine, but otherwise, don't be afraid to start from a raw Win32 app.


I'd suggest, for comfort, you start out with all the different helper packages you can find, but head towards writing your own rendering engine. Writing an engine is good fun and can provide you with a resource to look back on in your future projects. Nothing creates good code like the wisdom from doing it wrong in the past.


No comments:

Post a Comment

Simple past, Present perfect Past perfect

Can you tell me which form of the following sentences is the correct one please? Imagine two friends discussing the gym... I was in a good s...