Start reading Programming 2D Games on your Kindle in under a minute. Don't have a Kindle? Get your Kindle here or start reading now with a free Kindle Reading App.

Deliver to your Kindle or other device


Try it free

Sample the beginning of this book for free

Deliver to your Kindle or other device

Anybody can read Kindle books—even without a Kindle device—with the FREE Kindle app for smartphones, tablets and computers.
Programming 2D Games

Programming 2D Games [Print Replica] [Kindle Edition]

Charles , Kelly
3.0 out of 5 stars  See all reviews (3 customer reviews)

Print List Price: £40.99
Kindle Price: £36.99 includes VAT* & free wireless delivery via Amazon Whispernet
You Save: £4.00 (10%)
* Unlike print books, digital books are subject to VAT.


Amazon Price New from Used from
Kindle Edition £36.99  
Hardcover £38.94  
Kindle Summer Sale: Over 500 Books from £0.99
Have you seen the Kindle Summer Sale yet? Browse selected books from popular authors and debut novelists, including new releases and bestsellers. Learn more

Special Offers and Product Promotions

  • Purchase any Kindle Book sold by and receive £1 credit to try out our Digital Music Store. Here's how (terms and conditions apply)

Customers Who Bought This Item Also Bought

Product Description

Product Description

Most of today's commercial games are written in C++ and are created using a game engine. Addressing both of these key elements, this text provides a complete, up-to-date introduction to game programming. As game programming techniques are introduced, readers learn how to incorporate them into their own game engine and discover how to use the game engine to create a complete game. Every topic is explained theoretically and with working code examples. The example programs for each chapter are available online.

Enables Students to Create 2D GamesThe text covers sprites,
animation, collision detection, sound, text display, game dashboards,
special graphic effects, tiled games, and network programming. It
systematically explains how to program DirectX applications and
emphasizes proper software engineering techniques. Every topic is
explained theoretically and with working code examples. The example
programs for each chapter are available at

About the Author

Charles Kelly is an associate professor at Monroe County Community College, where he teaches game programming and other computer science courses. He is also the project lead of and major contributor to the open source assembler/simulator "EASy68K." He earned a master’s degree in computer science from the University of Michigan-Dearborn, where he is also an adjunct instructor.

Product details

  • Format: Kindle Edition
  • File Size: 7381 KB
  • Print Length: 438 pages
  • Publisher: A. K. Peters (9 July 2012)
  • Sold by: Amazon Media EU S.à r.l.
  • Language: English
  • ASIN: B008NF849S
  • Text-to-Speech: Not enabled
  • X-Ray:
  • Average Customer Review: 3.0 out of 5 stars  See all reviews (3 customer reviews)
  • Amazon Bestsellers Rank: #371,210 Paid in Kindle Store (See Top 100 Paid in Kindle Store)
  •  Would you like to give feedback on images?

More About the Author

Discover books, learn about writers, and more.

What Other Items Do Customers Buy After Viewing This Item?

Customer Reviews

5 star
3 star
2 star
3.0 out of 5 stars
3.0 out of 5 stars
Most Helpful Customer Reviews
3 of 4 people found the following review helpful
4.0 out of 5 stars Great book with only a few things missing 26 Feb 2013
Format:Hardcover|Verified Purchase
This is a great book for learning to make 2D games. It does assume you already know some C++, you can get through the book without knowing much C++ but the more you know the easier it is.

The book starts by teaching you basic Windows programming that is needed to set up a window for the game to play in.
It then shows you how to setup DirectX to work with Visual Studio 2010 and get your first DirectX window rendering.

By the end of it you will have a working 2D game which supports mouse and keyboard input as well as Xbox 360 controller input.
You will learn scrolling backgrounds, parallax scrolling, sprite rendering, animation, sprite transparency, collision detection, tile maps and more.

You will have your own 2D game engine to take away and make your own 2D games with.

The engine itself is set up in an easy to follow manner and it makes it easy for you to use it to setup your own game, loading in sound and graphics and using them in the game is easy to do.

There is only a few issues with this book. First of all it doesn't talk about game states. Game states are really helpful for when you want to transition from title screen to level or level to level. The second issue is that there is no collision detection for tile maps, however, the professor who wrote the book is extremely helpful and always happy to help you on his forum. Me and a friend asked him for help on collision detection for tile maps and he setup a new example for us to use which worked great, hopefully he will add this new example and more to the next edition of his book and will make it THE book to have for making 2D games.

In summary, great book but would be even better with a few more additions, and for anything that isn't in the book the author is more than happy to help, highly recommended.
Comment | 
Was this review helpful to you?
2 of 3 people found the following review helpful
4.0 out of 5 stars Great book 11 Jan 2013
By ribbs23
Format:Hardcover|Verified Purchase
This book is good for beginners and intermmediate programmers and allows you to start creating a game very quickly. This being because programming 2D games is less challenging than 3D, and in my opinion a better place to start. Other books tend to focus on 3D programming which requires a lot more knowledge and can be a bit overwhelming for beginners. Whereas programming in 2D allows you to be more focused on creativity. I like this book and I like 2D games and once you've got to a good level understanding the mechanics of a 2D game I think the transition to 3D should be less daunting.
Was this review helpful to you?
2 of 4 people found the following review helpful
1.0 out of 5 stars Confusing 29 April 2013
By James
Format:Hardcover|Verified Purchase
This book does what it says it will do. It will show you basic code for most parts of DirectX, and at the end you'll have a working game. As far as the "why's" and the "how's" of the code, you're pretty much on your own there, there's many examples of working code, why it works or how it works? I've no idea, the answers are not in this book.
Throughout, there's seemingly random code just shoved in there, and no indication as to whether you're supposed to be typing it up, just looking at it as an example or downloading the code from the website (it only tells you what code was used from the website at the end of each chapter!?).
I think his philosophy is: "Here's how to use DirectX, go and play!" rather than "This is DirectX, I'm going to show you how to use it step-by-step".
I have a basic understanding of C++ (NOT Visual C++) and if you don't have any experience with programming (which the book says you don't need) you're going to have a very bad time.
You can get the same information and better explanations for free using tutorial websites/video sites, and they will give you free code to play with too. Save your money.
Comment | 
Was this review helpful to you?
Most Helpful Customer Reviews on (beta) 4.4 out of 5 stars  15 reviews
18 of 19 people found the following review helpful
5.0 out of 5 stars Finally, I'm making games! 16 Aug 2012
By Casey Knolla - Published on
Format:Kindle Edition|Verified Purchase
After many years of lame text games and attempts at making graphical games, I finally "get it". The graphical gap is a very wide one to cross, and even with strong programming/logic skill, there's no way to cross it without a proper introduction to the graphics engine (in this case, DirectX). Charles Kelly provides the tools and the explanations you need to use them. I can't claim to know a lot of the underworkings of DirectX, but I don't want or need to either. I only need to understand it well enough to use it. The pace of the book is perfect, and it covers all the essentials for a 2d game, regardless of genre. When I first found out about the book, I looked through the chapter list and immediately knew this was what I had been trying to find. All the tools, taught by example. I couldn't be happier. I've made more progress in 2 weeks than I did over a whole summer struggling with pygame.
I have also gotten thorough answers to problems I've run into directly from the author on the book's forum. He clearly has a passion for the hobby and is great at conveying his knowledge.
10 of 10 people found the following review helpful
5.0 out of 5 stars An excellent introduction to DirectX 9 Aug 2012
By Jack of All Trades - Published on
Format:Kindle Edition
I am a former student of Charles Kelly and took his course on game programming as he was finishing this text. The text is built around a fully functioning game engine example that can allow for the creation of very creative 2D games. Every student in the Winter 12 course did very different and creative things with it. The concepts are explained thoroughly and are easy to grasp. The only problem I had was the abstraction of code away from the core directX language was not always clear and code bits needed more comments, but you can follow the breadcrumbs back through the code examples to see the differences.(these may have been early version problems too) If you understand object oriented C++, you can and will be able to make 2D games with this textbook.
5 of 5 people found the following review helpful
4.0 out of 5 stars Great book for beginning game programmers 11 Jan 2013
By Bear - Published on
Format:Hardcover|Verified Purchase
Before you buy: make sure to at least be acquainted with C++. The author does a tiny little crash course (3 pages) about C++, but if you don't know how to create/define a class, or if you're not sure what a virtual function does, you will have to learn. Search Google for "c++ books stackoverflow", check out the first result, and you'll see a whole list of books for learning c++ . If you don't know at least the basics, then you'll have a tough time understanding what is going on. Don't try to cheat! Build a strong foundation first. No prior DirectX experience is needed, as the author explains the API calls that he uses, and the code is well documented.

General thoughts: I really like this book. Charles Kelly has done a very good job creating an easy to follow guide about creating a game engine using C++ and the DirectX API. It walks you through the initial setup all the way through to a fully functional game of 'Spacewar', complete with networking.

This was my first book on actual game programming. I've read some of the higher-level books about building a game engine (like Jason Gregory's 'Game Engine Architecture'), but I was clueless on how to start building one from scratch. 'Programming 2D Games' was a great guide. Almost all the author's rationale is detailed. The code is very well commented, and it is (mostly) good C++ code. At the end of every chapter, there is a 'summary' section, and some exercises. I found the summaries very helpful, and the exercises were ok. The answers were easy to find, and the 'coding' exercises did a good job reinforcing what was learned. I also learned quite a bit about DirectX, and it was very easy to follow.

There are some issues I had with the code (such as the author's use of macros instead of inline template functions), but they were minor. Another issue I had with the book is that, if you are following along with the book, the author updates other parts of the engine in each chapter, making it hard to keep your own code updated. Major code updates are in the book, but if the author had to reproduce each source file for every chapter, the book would be twice as long. Try to follow along, but if you're engine is not doing what it's supposed to, check out the author's source code from the book's website. Every chapter has multiple 'snapshots' of the engine as it is being built, so it will help you understand what needs updating.

Keep in mind, this book is an introduction to creating game engines. It doesn't teach you how to build a commercial AI engine, or how to make your engine multithreaded, or what game states are. These are 'advanced' topics, and for some of these, whole books are dedicated to detailing their intricacies (rendering, graphics, physics, collisions etc). This book is not a treatise on any one specific game subsystem. The author does gloss over some of the theory behind the graphics and collision, but you won't find anything exhaustive. You will, however, obtain a better knowledge of how to craft a game engine, and how the parts interact, which was a huge eye-opener for me. After you build a sound base, then pick up some books about physics, rendering, and ai. Then you will understand everything more fully. Build on your engine, and give it new features. You'll learn a lot just by giving it a shot. Try integrating the Box2d physics engine into your game engine, or give it some 3d rendering capability for special effects.

After this book, I would start reading 'Advanced 2D Game Development' by Jonathan Harbour. It gives you a somewhat different perspective on building a 2d game engine, with some more advanced features (like incorporating 3d rendering and multithreading). I've just started reading Harbour's book, so I won't be able to comment on it further, but it looks to be promising. I've read about 50 pages and have already gotten some 'ooooh' moments that reinforced what I learned in this book.

Another note: The author doesn't go into the gritty details of the linear algebra behind the scenes, but he explains it so you can have some idea of what is going on. If you were to build on the renderer in this game, I'd suggest picking up a book about linear algebra (perhaps '3D Math Primer for Graphics and Game Development' by Fletcher and Dunn). After you understand the concepts, the theory will be clearer. Then you can tie it together with DirectX with one of Frank D. Luna's books ('Programming 2D Games' uses DirectX 9, fyi). This way, you will have a more complete understanding of how rendering in DirectX happens.

Overall, I'd give this book 4.5 stars, with half a star off due to the small issues I had. The structure of the book is very good, and it helped me get a better low-level understanding of the workings of a game engine. I've nearly finished the book , but I've already started to implement some of my own additions to the engine. This was my first actual intro to 2d game programming, and I really feel like it was worth the money. Soon, I'll be off building a 3d engine and applying what I've learned in this book to a completely custom engine.
11 of 13 people found the following review helpful
4.0 out of 5 stars DirectX 9 2D Games --Fantastic Job! 22 Feb 2013
By Anonymous787 - Published on
4.5 Rating

A well-deserved & probably one of the best 2D Game Programming Books out there today that includes a finale section on Multi-Player Online Networking! Superb! You're in for some exciting & challenging learning.

First, for the Book Errata & all its code Projects please see [...] This site is the best reference. I downloaded all the projects & studied a lot of the code. It's all well-documented. I ran nearly all of programs & they work fine.

Moreover, here are some other Errata TYPOS I found: I corrected it here. I also posted this in the Forum of Charles' website.

pg89. 2nd paragraph: keysPressed
166 under Listing 6.19 at end of paragraph: An entity's position....
188 right above Listing 7.3: xactParams.lookAheadTime =XACT_ENGINE_LOOKAHEAD_DEFAULT
214 Graphics::loadTextureSystemMem: 1 of the parameters should say UINT &width
281 under Listing 9.30: Any function from the MessageDialog class......
282 under 9.7 Section: IDirect3DDevice9::SetDialogBoxMode
302 in next to last bullet mark: Entering the word "next" displays a second dialog.
413 under Chapter Review: UDP/IP

I read this book twice. It's fascinating & enjoyable. I will gladly recommend this book which focuses on 2D Games to any interested gamer. Gaming is easier said & played than done. Charles definitely has a passion for this knowledge & does a excellent job conveying it. The journey Charles takes you is in stages, with each one building upon each other in a educational way to eventually forming a full functioning game for you. You will explore the game engine's thoughtful design that can be re-used on a variety of games you would like to make.
Pre-requisites: C++ which is Object-Oriented Programming Language, Vector Tutorial in case you need more help than what's in the book. Otherwise, anything else like Windows, Directx you'll be able to learn easily. You don't need to know COM but it will help you understand why Interface pointers, or calling Release , Delete Methods are needed for DirectX.
Throughout the book you'll encounter a lot of un-obvious code info. which can't be overlooked because it is important in DirectX & in the game. Take the time to at least know how the code works. To say a little about it, there's initializing the device, maintaining memory, textures, displaying graphics on the screen, checking monitor compatibility, etc. The book defines Graphics terms such as primitives, rendering, textures, mutex, quad, sprites with ease.

In a nut shell you will learn:

Windows Programming Fundamentals - minimum to use DirectX.
Directx Object, Devices - initializing, accessing , maintenance, memory management of them & other info.

Game Engine - fundamental elements

Frametime -the difference between the time of 2 frames. The calculation used is more accurate than compared to other methods because it factors other things Windows does in the game loop. Game items use Update function which has the parameter frametime to regulate the speed & animation which makes everything run in sync.

Graphics Pipeline , Primitives, Textures, Colors to use on Textures as Filters & Transparency, Sprites


Physics: used with Collisions on Objects, Game Screen, apply gravity force to show acceleration, gravitational pull or reversal

KNOW Vectors: It has length & direction & when used in a period of time (speed) is a Velocity Vector. It can be placed anywhere like on a 0,0 coordinate system. It has a variety of uses in game like in Collision Detection & Reaction. Do Study the Vector Diagrams in the errata in the forum & not in the book because some are wrong.

Input - keyboard: 1. for typing info. for the game 2. to control object's movements

XBOX 360 controller: thorough details on how to program all the buttons including the motor vibrations. Watch out for the dead zones!

For both inputs, the Input Class has a list of functions for setting & getting values for these inputs, clearing keys, assigning certain character like ESC to Window's VIRTUAL KEYS, etc..

Audio - learn how to record, save files in a certain format that can be used with XACT. Use XACT in the game & modify certain sound settings without changing code. You don't need to design an audio engine.

TEXT - 3 Types: pre-rendered text -image file, SPRITE vs DirectX Text. There's a nice TextDemo Program that utilizes different features of these texts.

Console Programming- entering commands to change things in the game

Message Box - display info. to the user

InputDialogMessageBox- user can enter info. in a textbox

Scrolling - with object in center & Bitmap background image scrolls in opposite direction of the input you provide, Parallax scrolling

Reflection, Shadows - also can help object position itself onto a surface for dropping a bomb, landing, or other reasons

Parallel projections: (orthogonal, oblique, stagger, isometric) For a 2D Game you probably will mainly use Orthogonal Projection.

Layers - how to apply them in a 2D Game with the parallel projections, painter's algorithm

Making a Dashboard - items that display or control things (with mouse input) on the screen

Tiled Games - creating a Tile Set, Creating Levels, Displaying Tiles, Isometric Terrain, Elevation Layer. One program includes a mapfile text that is loaded into the map tile array which is efficient for modifying your tile maps on the fly.

Game Project Team Management-using a various form of evolutionary prototyping

Network Programming - This is well-rewarding not only because you have come this far, but now this section will teach you how to transform your game to a multi-player online game. WOW! Other books I have come across, unfortunately don't talk about this topic & probably only a few do. I always wanted to learn how to do this so I was happy this was included. The first program lets you exchanges messages between a client & server. The router at both ends would need to be configured for port-forwarding to work beyond the local network. With the current average internet bandwidth speed at home, you can easily have multiple computers each having 2 players connect online with a server & play the SpaceWar Network Game.

The book should have stated at the beginning that it uses Directx9 especially since it was published in 2012. Also it should make it known more that you need to learn C++.

The book uses Visual Studio Ultimate & not the free Express Version I use. My only problem was viewing the Class Diagrams.

The book lacked diagrams like Function, Pseudo-code to explain the entire game engine & the game itself. This would have made it easier to study the several files (header, source) that the projects use & piece everything together.

On certain programs, the way the objects move in response to input didn't work well. The SpaceWar Program, for example, doesn't make it easy to avoid frequently crashing into the planet.

This makes a wonderful gift & should be your top-choice for reading about 2D Game Graphics Programming. ENJOY!!
5 of 5 people found the following review helpful
5.0 out of 5 stars Would Definitely Recommend! 18 Mar 2013
By Tyler - Published on
Format:Hardcover|Verified Purchase
I have read many books on game programming, but this one definitely is the best and most well rounded. I had only worked with Java in the past, but after a couple C++ tutorials I was easily able to work through the chapters. The author does an excellent job at explaining the details that a lot of other books leave out. The examples are clearly laid out, and the code is neat and organized. Another great thing about this book is the forum that comes with it where you can ask questions regarding anything in the book. The book's author is very active on the forum, and is extremely helpful.
Were these reviews helpful?   Let us know
Search Customer Reviews
Only search this product's reviews

Customer Discussions

This product's forum
Discussion Replies Latest Post
No discussions yet

Ask questions, Share opinions, Gain insight
Start a new discussion
First post:
Prompts for sign-in

Search Customer Discussions
Search all Amazon discussions

Look for similar items by category