Home Page Icon
Home Page
Table of Contents for
Index
Close
Index
by Shaun Mitchell
SDL Game Development
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
Search in book...
Toggle Font Controls
Playlists
Add To
Create new playlist
Name your new playlist
Playlist description (optional)
Cancel
Create playlist
Sign In
Email address
Password
Forgot Password?
Create account
Login
or
Continue with Facebook
Continue with Google
Sign Up
Full Name
Email address
Confirm Email Address
Password
Login
Create account
or
Continue with Facebook
Continue with Google
Prev
Previous Chapter
Summary
Index
A
abstract base classes
using /
Using abstract base classes
Alien Attack game
sound SDL_mixer extension, using /
Using the SDL_mixer extension for sound
basic objects, setting up /
Setting up the basic game objects
bullets, handling /
Handling bullets
collisions, dealing with /
Dealing with collisions
tips /
Possible improvements
AnimatedGraphic class /
Creating the game over state
,
Loading the game over state
B
Base64 decoder /
Parsing a tile layer
base64 encoding /
Getting familiar with the Tiled application
basic game objects
setting up /
Setting up the basic game objects
GameObject base class /
GameObject revamped
SDLGameObject class, renaming to ShooterObject /
SDLGameObject is now ShooterObject
player object /
Player inherits from ShooterObject
enemy types /
Lots of enemy types
scrolling background, adding /
Adding a scrolling background
boolfullscreen parameter /
Fullscreen SDL
Bullet class /
No more bullets or bullet collisions
BulletHandler class /
The BulletHandler class
bullet handling
scrolling background, adding /
Handling bullets
types /
Two types of bullets
BulletHandler class /
The BulletHandler class
C
C++11 standard /
GameObject revamped
camera-controlled map /
Camera-controlled map
Camera class /
The Camera class
checkCollideTile function /
ShooterObject is now PlatformerObject
checkEnemyPlayerBulletCollision functions /
Creating a CollisionManager class
checkPlayerEnemyCollision functions /
Creating a CollisionManager class
clean function /
What does this code do?
CollisionManager Class /
Creating a CollisionManager class
collisions
dealing with /
Dealing with collisions
,
Creating a CollisionManager class
CollisionManager Class, creating /
Creating a CollisionManager class
CollisonManager class /
No more bullets or bullet collisions
Conan the Caveman game
basic game objects, setting up /
Setting up the basic game objects
bullet collisions /
No more bullets or bullet collisions
game objects /
Game objects and map collisions
map collisions /
Game objects and map collisions
ShooterObject, renaming as PlatformerObject /
ShooterObject is now PlatformerObject
Camera class /
The Camera class
camera-controlled map /
Camera-controlled map
Player class /
The Player class
additions /
Possible additions
D
destination rectangle
about /
Source and destination rectangles
sprite sheet, animating /
Animating a sprite sheet
images, flipping /
Flipping images
draw function /
Creating the texture manager
,
Putting it all together
,
The BulletHandler class
E
Enter key /
Implementing FSM
enum attribute /
Using mouse button events
F
FPS
about /
Creating fixed frames per second
FSM
about /
Implementing finite state machines
implementing /
Implementing finite state machines
,
Implementing FSM
game states, base class /
A base class for game states
G
game
structure /
What makes up a game
Hello SDL code, breaking up /
Breaking up the Hello SDL code
code, functioning /
What does this code do?
Game**getGameHeight functions /
Drawing the map
Game**getGameWidth /
Drawing the map
Game**handleEvents function /
Implementing FSM
Game**init function /
Initializing joysticks
,
Implementing FSM
Game**setCurrentLevel function /
Player inherits from ShooterObject
Game class
about /
The Game class
fullscreen SDL /
Fullscreen SDL
/
Using texture manager as a singleton
GameObject* class /
Creating the game over state
GameObject class /
Using inheritance
GameObject classes
altering /
Fitting the factory into the framework
game objects
steps, sumarizing /
Putting it all together
game objects movement
setting up /
Setting up game objects for movement
Cartesian coordinate system /
Setting up game objects for movement
vector /
What is a vector?
Vector2D class, adding /
Adding the Vector2D class
velocity, adding /
Adding velocity
acceleration, adding /
Adding acceleration
game over state
loading /
Loading the game over state
GameOverState class /
Creating the game over state
gamepad input
about /
Handling joystick/gamepad input
GameState.h /
A base class for game states
game states
switching ways /
A simple way for switching states
getButtonState function /
Dealing with joystick button input
getRenderer function /
Putting it all together
H
Hello SDL
about /
Hello SDL
overview /
An overview of Hello SDL
initialisation flags /
SDL initialization flags
renderer flags /
SDL renderer flags
I
inheritance
about /
Using inheritance
functionality example /
Using inheritance
using /
Should we always use inheritance?
result tips /
Could the same thing be achieved with a simpler solution?
derived classes /
Derived classes should model the "is a" relationship
possible performance penalties /
Possible performance penalties
init function /
The Game class
initialisation flags, SDL
about /
SDL initialization flags
SDL_INIT_HAPTIC /
SDL initialization flags
SDL_INIT_AUDIO /
SDL initialization flags
SDL_INIT_VIDEO /
SDL initialization flags
SDL_INIT_TIMER /
SDL initialization flags
SDL_INIT_JOYSTICK /
SDL initialization flags
SDL_INIT_EVERYTHING /
SDL initialization flags
SDL_INIT_NOPARACHUTE /
SDL initialization flags
input handling
about /
Input handling
input handler class, creating /
Creating our input handler class
joystick /
Handling joystick/gamepad input
axis movement, handling /
Listening for and handling axis movement
joystick button input, dealing with /
Dealing with joystick button input
mouse events, handling /
Handling mouse events
summary /
Wrapping things up
Instance function /
Using texture manager as a singleton
int flags parameter /
Fullscreen SDL
J
joy parameter /
Listening for and handling axis movement
joystick button input /
Dealing with joystick button input
Joystick Control Panel property /
SDL joystick events
joysticks
events /
SDL joystick events
initializing /
Initializing joysticks
L
Level class /
Parsing and drawing a tile map
LevelParser**parseLevel /
Dealing with collisions
LevelParser class
creating /
Creating the LevelParser class
load function /
Loading the game over state
,
Creating the SoundManager class
M
MainMenuState class /
Loading the menu state from an XML file
,
Loading other states from an XML file
MenuButton class /
Loading the menu state from an XML file
MenuState.cpp file /
A base class for game states
menu states
implementing /
Implementing menu states
fuction parameters /
Function pointers and callback functions
callback functions /
Function pointers and callback functions
temporary play state, implementing /
Implementing the temporary play state
,
Pausing the game
game over state, creating /
Creating the game over state
mouse events
handling /
Handling mouse events
button events, handling /
Using mouse button events
motion events, handling /
Handling mouse motion events
keyboard input, implementing /
Implementing keyboard input
m_bCanJump variable /
The Player class
m_lastSafePos variable /
The Player class
O
Object Factories
about /
Implementing Object Factories
Distributed Factories, using /
Using Distributed Factories
Object Layer /
Parsing object layers
object layers
parsing /
Parsing object layers
ObjectLayer class, developing /
Developing the ObjectLayer class
onEnter function /
Implementing FSM
,
Creating the game over state
,
Loading the game over state
onExit function /
Implementing FSM
P
parseLevel function /
Creating the LevelParser class
,
Developing the ObjectLayer class
parseObjects function /
Parsing states from an XML file
,
Developing the ObjectLayer class
pause state
loading /
Loading the pause state
PauseState.cpp file /
Pausing the game
Player**update function /
Listening for and handling axis movement
,
The Player class
Player**update function /
Player inherits from ShooterObject
Player class /
The Player class
playSound or playMusic functions /
Creating the SoundManager class
play state
loading /
Loading the play state
PlayState class /
Creating the game over state
polymorphism
about /
Implementing polymorphism
implementing /
Implementing polymorphism
pState parameter /
Implementing FSM
Q
Quadtree /
Possible improvements
quit function /
Initializing joysticks
R
registerType function /
Using Distributed Factories
renderer flags, SDL
SDL_RENDERER_SOFTWARE /
SDL renderer flags
SDL_RENDERER_ACCELERATED /
SDL renderer flags
SDL_RENDERER_PRESENTVSYNC /
SDL renderer flags
SDL_RENDERER_TARGETTEXTURE /
SDL renderer flags
render function /
A simple way for switching states
,
Drawing the map
RTF /
Migrating SDL 1.2 extensions
S
ScrollingBackground class /
Adding a scrolling background
SDL
need for /
Why use SDL?
drawing /
Basic SDL drawing
SDL 1.2
extensions /
Migrating SDL 1.2 extensions
SDL 1.2 extensions /
Migrating SDL 1.2 extensions
SDL_image /
Migrating SDL 1.2 extensions
SDL_net /
Migrating SDL 1.2 extensions
SDL_mixer /
Migrating SDL 1.2 extensions
SDL_ttf /
Migrating SDL 1.2 extensions
SDL_rtf /
Migrating SDL 1.2 extensions
SDL 2.0
about /
What is new in SDL 2.0?
SDL 1.2 extensions /
Migrating SDL 1.2 extensions
SDL 2.0 Roadmap /
What is new in SDL 2.0?
SDL drawing
about /
Basic SDL drawing
images, obtaining /
Getting some images
texture, creating /
Creating an SDL texture
SDL joystick events
SDL_JoyAxisEvent /
SDL joystick events
SDL_JoyButtonEvent /
SDL joystick events
SDL_JoyBallEvent /
SDL joystick events
SDL_JoyHatEvent /
SDL joystick events
about /
SDL joystick events
SDL Mouse Event
SDL_MouseButtonEvent /
Handling mouse events
SDL_MouseMotionEvent /
Handling mouse events
SDL_MouseWheelEvent /
Handling mouse events
SDL setup, in Visual C++ Express 2010
about /
Setting up SDL in Visual C++ Express 2010
library, retrieving /
Setting up SDL in Visual C++ Express 2010
Mercurial, using /
Using Mercurial to get SDL 2.0 on Windows
SDL 2.0 repository, cloning /
Cloning and building the latest SDL 2.0 repository
SDL 2.0 repository, building /
Cloning and building the latest SDL 2.0 repository
linking /
I have the library; now what?
SDL_CreateRenderer function /
An overview of Hello SDL
SDL_CreateWindow function /
Fullscreen SDL
SDL_image
installing /
Installing SDL_image
using /
Using SDL_image
SDL_INIT_AUDIO flag /
SDL initialization flags
SDL_INIT_EVERYTHING flag /
SDL initialization flags
SDL_INIT_HAPTIC flag /
SDL initialization flags
SDL_INIT_JOYSTICK flag /
SDL initialization flags
SDL_INIT_NOPARACHUTE flag /
SDL initialization flags
SDL_INIT_TIMER flag /
SDL initialization flags
SDL_INIT_VIDEO flag /
SDL initialization flags
SDL_JOYAXISMOTION event /
Listening for and handling axis movement
SDL_JoyBallEvent /
SDL joystick events
SDL_JoyButtonEvent /
SDL joystick events
SDL_JoyHatEvent /
SDL joystick events
SDL_MouseButtonEvent /
Handling mouse events
SDL_MouseMotionEvent /
Handling mouse events
SDL_MouseWheelEvent /
Handling mouse events
SDL_RendererFlip value
SDL_FLIP_NONE /
Flipping images
SDL_FLIP_HORIZONTAL /
Flipping images
SDL_FLIP_VERTICAL /
Flipping images
SDL_RENDERER_ACCELERATED flag /
SDL renderer flags
SDL_RENDERER_PRESENTVSYNC flag /
SDL renderer flags
SDL_RENDERER_SOFTWARE flag /
SDL renderer flags
SDL_RENDERER_TARGETTEXTURE flag /
SDL renderer flags
SDL_WasInit() function /
SDL initialization flags
SDL_WindowFlags function /
Fullscreen SDL
SDL_WindowFlags functions
SDL_WINDOW_FULLSCREEN /
Fullscreen SDL
SDL_WINDOW_OPENGL /
Fullscreen SDL
SDL_WINDOW_SHOWN /
Fullscreen SDL
SDL_WINDOW_HIDDEN /
Fullscreen SDL
SDL_WINDOW_BORDERLESS /
Fullscreen SDL
SDL_WINDOW_RESIZABLE /
Fullscreen SDL
SDL_WINDOW_MINIMIZED /
Fullscreen SDL
SDL_WINDOW_MAXIMIZED /
Fullscreen SDL
SDL_WINDOW_INPUT_GRABBED /
Fullscreen SDL
SDL_WINDOW_INPUT_FOCUS /
Fullscreen SDL
SDL_WINDOW_MOUSE_FOCUS /
Fullscreen SDL
SDL_WINDOW_FOREIGN /
Fullscreen SDL
SDL_WINDOW_BORDERLESS function /
Fullscreen SDL
SDL_WINDOW_FOREIGN function /
Fullscreen SDL
SDL_WINDOW_FULLSCREEN flag /
Fullscreen SDL
SDL_WINDOW_FULLSCREEN function /
Fullscreen SDL
SDL_WINDOW_HIDDEN function /
Fullscreen SDL
SDL_WINDOW_INPUT_FOCUS function /
Fullscreen SDL
SDL_WINDOW_INPUT_GRABBED function /
Fullscreen SDL
SDL_WINDOW_MAXIMIZED function /
Fullscreen SDL
SDL_WINDOW_MINIMIZED function /
Fullscreen SDL
SDL_WINDOW_MOUSE_FOCUS function /
Fullscreen SDL
SDL_WINDOW_OPENGL function /
Fullscreen SDL
SDL_WINDOW_RESIZABLE function /
Fullscreen SDL
SDL_WINDOW_SHOWN function /
Fullscreen SDL
setCallbacks function /
Loading the pause state
SoundManager class /
Creating the SoundManager class
sound SDL_mixer extension
using /
Using the SDL_mixer extension for sound
SoundManager class, creating /
Creating the SoundManager class
source rectangle
about /
Source and destination rectangles
sprite sheet, animating /
Animating a sprite sheet
images, flipping /
Flipping images
states, XML file
parsing /
Parsing states from an XML file
menu state, loading /
Loading the menu state from an XML file
play state, loading /
Loading the play state
pause state, loading /
Loading the pause state
game over state, loading /
Loading the game over state
T
texture manager
about /
Creating the texture manager
creating /
Creating the texture manager
using, as singleton /
Using texture manager as a singleton
TextureManager class /
Creating the texture manager
Tiled application
about /
Getting familiar with the Tiled application
tile layer
parsing /
Parsing a tile layer
TileLayer class /
Camera-controlled map
TileLayer update function /
Drawing the map
tile map
about /
What is a tile map?
parsing /
Parsing and drawing a tile map
drawing /
Parsing and drawing a tile map
,
Drawing the map
TileLayer class, creating /
Creating the TileLayer class
LevelParser class, creating /
Creating the LevelParser class
tilesets, parsing /
Parsing tilesets
tile layer, parsing /
Parsing a tile layer
scrolling /
Scrolling a tile map
tilesets
parsing /
Parsing tilesets
TortoiseHg Workbench window /
Cloning and building the latest SDL 2.0 repository
type function /
Creating a CollisionManager class
U
uncompress function /
Parsing a tile layer
update function /
Creating the texture manager
,
Function pointers and callback functions
,
Creating the game over state
,
The BulletHandler class
V
vector
about /
What is a vector?
using /
What is a vector?
two vectors, adding /
Addition of two vectors
muliplying, by scalar number /
Multiply by a scalar number
subtration methods /
Subtraction of two vectors
sclar number, dividing by /
Divide by a scalar number
normalizing /
Normalizing a vector
Visual C++ Express 2010
SDL, setting up /
Setting up SDL in Visual C++ Express 2010
X
Xbox 360 controller /
SDL joystick events
XML file
states, parsing /
Parsing states from an XML file
menu state, loading /
Loading the menu state from an XML file
other states, loading /
Loading other states from an XML file
XML Files
about /
Loading XML files
basic XML structure /
Basic XML structure
Z
zlib compression algorithm /
Getting familiar with the Tiled application
Add Highlight
No Comment
..................Content has been hidden....................
You can't read the all page of ebook, please click
here
login for view all page.
Day Mode
Cloud Mode
Night Mode
Reset