SDL Game Development
eBook - ePub

SDL Game Development

Shaun Mitchell

Condividi libro
  1. 256 pagine
  2. English
  3. ePUB (disponibile sull'app)
  4. Disponibile su iOS e Android
eBook - ePub

SDL Game Development

Shaun Mitchell

Dettagli del libro
Anteprima del libro
Indice dei contenuti
Citazioni

Informazioni sul libro

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.

Domande frequenti

Come faccio ad annullare l'abbonamento?
È semplicissimo: basta accedere alla sezione Account nelle Impostazioni e cliccare su "Annulla abbonamento". Dopo la cancellazione, l'abbonamento rimarrà attivo per il periodo rimanente già pagato. Per maggiori informazioni, clicca qui
È possibile scaricare libri? Se sì, come?
Al momento è possibile scaricare tramite l'app tutti i nostri libri ePub mobile-friendly. Anche la maggior parte dei nostri PDF è scaricabile e stiamo lavorando per rendere disponibile quanto prima il download di tutti gli altri file. Per maggiori informazioni, clicca qui
Che differenza c'è tra i piani?
Entrambi i piani ti danno accesso illimitato alla libreria e a tutte le funzionalità di Perlego. Le uniche differenze sono il prezzo e il periodo di abbonamento: con il piano annuale risparmierai circa il 30% rispetto a 12 rate con quello mensile.
Cos'è Perlego?
Perlego è un servizio di abbonamento a testi accademici, che ti permette di accedere a un'intera libreria online a un prezzo inferiore rispetto a quello che pagheresti per acquistare un singolo libro al mese. Con oltre 1 milione di testi suddivisi in più di 1.000 categorie, troverai sicuramente ciò che fa per te! Per maggiori informazioni, clicca qui.
Perlego supporta la sintesi vocale?
Cerca l'icona Sintesi vocale nel prossimo libro che leggerai per verificare se è possibile riprodurre l'audio. Questo strumento permette di leggere il testo a voce alta, evidenziandolo man mano che la lettura procede. Puoi aumentare o diminuire la velocità della sintesi vocale, oppure sospendere la riproduzione. Per maggiori informazioni, clicca qui.
SDL Game Development è disponibile online in formato PDF/ePub?
Sì, puoi accedere a SDL Game Development di Shaun Mitchell in formato PDF e/o ePub, così come ad altri libri molto apprezzati nelle sezioni relative a Informatik e Programmierung in C++. Scopri oltre 1 milione di libri disponibili nel nostro catalogo.

Informazioni

Anno
2013
ISBN
9781849696821
Edizione
1
Argomento
Informatik

SDL Game Development


Table of Contents

SDL Game Development
Credits
About the Author
About the Reviewers
www.PacktPub.com
Support files, eBooks, discount offers and more
Why Subscribe?
Free Access for Packt account holders
Preface
What this book covers
What you need for this book
Who this book is for
Conventions
Reader feedback
Customer support
Downloading the example code
Errata
Piracy
Questions
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
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
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
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
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
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
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
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
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
Index

SDL Game Development

Copyright © 2013 Packt Publishing
All rights reserved. No part of this book may be reproduced, stored in a retrieval system, or transmitted in any form or by any means, without the prior written permission of the publisher, except in the case of brief quotations embedded in critical articles or reviews.
Every effort has been made in the preparation of this book to ensure the accuracy of the information presented. However, the information contained in this book is sold without warranty, either express or implied. Neither the author, nor Packt Publishing, and its dealers and distributors will be held liable for any damages caused or alleged to be caused directly or indirectly by this book.
Packt Publishing has endeavored to provide trademark information about all of the companies and products mentioned in this book by the appropriate use of capitals. However, Packt Publishing cannot guarantee the accuracy of this information.
First published: June 2013
Production Reference: 1170613
Published by Packt Publishing Ltd.
Livery Place
35 Livery Street
Birmingham B3 2PB, UK.
ISBN 978-1-84969-682-1
www.packtpub.com
Cover Image by Shaun Mitchell ()

Credits

Author
Shaun Ross Mitchell
Reviewers
Luka Horvat
Mårten Möller
Acquisition Editor
Edward Gordon
Lead Technical Editor
Savio Jose
Chalini Snega Victor
Technical Editors
Jeeten Handu
Kaustubh S. Mayekar
Anita Nayak
Project Coordinator
Hardik Patel
Proofreader
Bernadette Watkins
Indexer
Rekha Nair
Graphics
Ronak Dhruv
Production Coordinator
Prachali Bhiwandkar
Cover Work
Prachali Bhiwandkar

About the Author

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.

Indice dei contenuti