SDL Game Development


SDL Game Development
eBook: $26.99
Formats: PDF, PacktLib, ePub and Mobi formats
$22.94
save 15%!
Print + free eBook + free PacktLib access to the book: $71.98    Print cover: $44.99
$44.99
save 37%!
Free Shipping!
UK, US, Europe and selected countries in Asia.
Also available on:
Overview
Table of Contents
Author
Support
Sample Chapters
  • Create 2D reusable games using the new SDL 2.0 and C++ frameworks
  • Become proficient in speeding up development time
  • Create two fully-featured games with C++ which include a platform game and a 2D side scrolling shooter
  • An engaging and structured guide to develop your own game

 

Book Details

Language : English
Paperback : 256 pages [ 235mm x 191mm ]
Release Date : June 2013
ISBN : 1849696829
ISBN 13 : 9781849696821
Author(s) : Shaun Mitchell
Topics and Technologies : All Books, Game Development, Games, Open Source


Table of Contents

Preface
Chapter 1: Getting Started with SDL
Chapter 2: Drawing in SDL
Chapter 3: Working with Game Objects
Chapter 4: Exploring Movement and Input Handling
Chapter 5: Handling Game States
Chapter 6: Data-driven Design
Chapter 7: Creating and Displaying Tile Maps
Chapter 8: Creating Alien Attack
Chapter 9: Creating Conan the Caveman
Index
  • Chapter 1: Getting Started with SDL
    • Why use SDL?
      • What is new in SDL 2.0?
      • Migrating SDL 1.2 extensions
    • Setting up SDL in Visual C++ Express 2010
      • Using Mercurial to get SDL 2.0 on Windows
        • Cloning and building the latest SDL 2.0 repository
      • I have the library; now what?
    • Hello SDL
      • An overview of Hello SDL
      • SDL initialization flags
      • SDL renderer flags
    • What makes up a game
      • Breaking up the Hello SDL code
      • What does this code do?
    • The Game class
      • Fullscreen SDL
    • Summary
  • Chapter 2: Drawing in SDL
    • Basic SDL drawing
      • Getting some images
      • Creating an SDL texture
    • Source and destination rectangles
      • Animating a sprite sheet
      • Flipping images
    • Installing SDL_image
      • Using SDL_image
    • Tying it into the framework
      • Creating the texture manager
      • Using texture manager as a singleton
    • Summary
  • Chapter 3: Working with Game Objects
    • Using inheritance
    • Implementing polymorphism
    • Using abstract base classes
    • Should we always use inheritance?
      • Could the same thing be achieved with a simpler solution?
      • Derived classes should model the "is a" relationship
      • Possible performance penalties
    • Putting it all together
  • Summary
  • Chapter 4: Exploring Movement and Input Handling
    • Setting up game objects for movement
      • What is a vector?
      • Some common operations
        • Addition of two vectors
        • Multiply by a scalar number
        • Subtraction of two vectors
        • Divide by a scalar number
        • Normalizing a vector
      • Adding the Vector2D class
      • Adding velocity
      • Adding acceleration
    • Creating fixed frames per second
    • Input handling
      • Creating our input handler class
      • Handling joystick/gamepad input
        • SDL joystick events
        • Initializing joysticks
      • Listening for and handling axis movement
      • Dealing with joystick button input
      • Handling mouse events
        • Using mouse button events
        • Handling mouse motion events
      • Implementing keyboard input
      • Wrapping things up
    • Summary
  • Chapter 5: Handling Game States
    • A simple way for switching states
    • Implementing finite state machines
      • A base class for game states
      • Implementing FSM
    • Implementing menu states
      • Function pointers and callback functions
      • Implementing the temporary play state
      • Pausing the game
      • Creating the game over state
    • Summary
  • Chapter 6: Data-driven Design
    • Loading XML files
      • Basic XML structure
    • Implementing Object Factories
      • Using Distributed Factories
    • Fitting the factory into the framework
    • Parsing states from an XML file
    • Loading the menu state from an XML file
    • Loading other states from an XML file
      • Loading the play state
      • Loading the pause state
      • Loading the game over state
    • Summary
  • Chapter 7: Creating and Displaying Tile Maps
    • What is a tile map?
    • Getting familiar with the Tiled application
    • Parsing and drawing a tile map
      • Creating the TileLayer class
      • Creating the LevelParser class
      • Parsing tilesets
      • Parsing a tile layer
      • Drawing the map
    • Scrolling a tile map
    • Parsing object layers
      • Developing the ObjectLayer class
    • Summary
  • Chapter 8: Creating Alien Attack
    • Using the SDL_mixer extension for sound
      • Creating the SoundManager class
    • Setting up the basic game objects
      • GameObject revamped
      • SDLGameObject is now ShooterObject
      • Player inherits from ShooterObject
      • Lots of enemy types
      • Adding a scrolling background
    • Handling bullets
      • Two types of bullets
      • The BulletHandler class
    • Dealing with collisions
      • Creating a CollisionManager class
    • Possible improvements
    • Summary
  • Chapter 9: Creating Conan the Caveman
    • Setting up the basic game objects
      • No more bullets or bullet collisions
      • Game objects and map collisions
      • ShooterObject is now PlatformerObject
      • The Camera class
      • Camera-controlled map
      • The Player class
    • Possible additions
    • Summary

Shaun Mitchell

Shaun Mitchell is a developer at a high profile online gaming company. He holds a BSc in Game Programming and Development from Qantm College / SAE Institute London. Shaun is also a moderator and active member of the <dream.in.code> programming community

Sorry, we don't have any reviews for this title yet.

Code Downloads

Download the code and support files for this book.


Submit Errata

Please let us know if you have found any errors not listed on this list by completing our errata submission form. Our editors will check them and add them to this list. Thank you.


Errata

- 2 submitted: last submission 04 Feb 2014

Errata type: Code | Page number 501

On step d. of "The Game Class" the code reads: Game(); ~Game (); It should be: Game() {} ~Game() {}

 

Errata type: Typo

Page number: 71

After the formula "The preceding figure shows the vector v1(3,-2) which will have a length of √(32+(-22)).",

it should be "The preceding figure shows the vector v1(3,-2) which will have a length of √(3²+(-2²)).

Sample chapters

You can view our sample chapters and prefaces of this title on PacktLib or download sample chapters in PDF format.

Frequently bought together

SDL Game Development +    OpenGL Development Cookbook =
50% Off
the second eBook
Price for both: €20.39

Buy both these recommended eBooks together and get 50% off the cheapest eBook.

What you will learn from this book

  • Draw in SDL and build the SDL_image extension
  • Develop reusable classes
  • Get to grips with game related object-oriented programming
  • Integrate a variety of user inputs into your games, such as joysticks or keyboards
  • Use factories that enable us to create objects dynamically at runtime
  • Create 2D maps through the use of tiles
  • Easily apply the framework to different game genres
  • Understand the scrolling of a tile map using the position of the player and collision detection

In Detail

SDL 2.0 is the latest release of the popular Simple DirectMedia Layer API, which is designed to make life easier for C++ developers, allowing you simple low-level access to various multiplatform audio, graphics, and input devices.

SDL Game Development guides you through creating your first 2D game using SDL and C++. It takes a clear and practical approach to SDL game development, ensuring that the focus remains on creating awesome games.

Starting with the installation and setup of SDL, you will quickly become familiar with useful SDL features, covering sprites, state management, and OOP, leading to a reusable framework that is extendable for your own games. SDL Game Development culminates in the development of two exciting action games that utilize the created framework along with tips to improve the framework.

Approach

Written as a practical and engaging tutorial, SDL Game Development guides you through the development of your own framework and the creation of two exciting, fully-featured games.

Who this book is for

SDL Game Development is aimed at C++ developers who want to learn the fundamentals of SDL for cross-platform game development. This isn't a beginner's guide to C++, so a good knowledge of C++ and object oriented programming is a must.

Code Download and Errata
Packt Anytime, Anywhere
Register Books
Print Upgrades
eBook Downloads
Video Support
Contact Us
Awards Voting Nominations Previous Winners
Judges Open Source CMS Hall Of Fame CMS Most Promising Open Source Project Open Source E-Commerce Applications Open Source JavaScript Library Open Source Graphics Software
Resources
Open Source CMS Hall Of Fame CMS Most Promising Open Source Project Open Source E-Commerce Applications Open Source JavaScript Library Open Source Graphics Software