SFML Blueprints
eBook - ePub

SFML Blueprints

Maxime Barbier

Share book
  1. 298 pages
  2. English
  3. ePUB (mobile friendly)
  4. Available on iOS & Android
eBook - ePub

SFML Blueprints

Maxime Barbier

Book details
Book preview
Table of contents
Citations

Frequently asked questions

How do I cancel my subscription?
Simply head over to the account section in settings and click on “Cancel Subscription” - it’s as simple as that. After you cancel, your membership will stay active for the remainder of the time you’ve paid for. Learn more here.
Can/how do I download books?
At the moment all of our mobile-responsive ePub books are available to download via the app. Most of our PDFs are also available to download and we're working on making the final remaining ones downloadable now. Learn more here.
What is the difference between the pricing plans?
Both plans give you full access to the library and all of Perlego’s features. The only differences are the price and subscription period: With the annual plan you’ll save around 30% compared to 12 months on the monthly plan.
What is Perlego?
We are an online textbook subscription service, where you can get access to an entire online library for less than the price of a single book per month. With over 1 million books across 1000+ topics, we’ve got you covered! Learn more here.
Do you support text-to-speech?
Look out for the read-aloud symbol on your next book to see if you can listen to it. The read-aloud tool reads text aloud for you, highlighting the text as it is being read. You can pause it, speed it up and slow it down. Learn more here.
Is SFML Blueprints an online PDF/ePUB?
Yes, you can access SFML Blueprints by Maxime Barbier in PDF and/or ePUB format, as well as other popular books in Computer Science & Programming Games. We have over one million books available in our catalogue for you to explore.

Information

Year
2015
ISBN
9781784398477

SFML Blueprints


Table of Contents

SFML Blueprints
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. Preparing the Environment
C++11
SFML
Installation of a C++11 compiler
For Linux users
For Mac users
For Windows users
For all users
Installing CMake
For Linux users
For other operating systems
Installing SFML 2.2
Building SFML yourself
Installing dependencies
Linux
Other operating systems
Compilation of SFML
Linux
Windows
Code::Blocks and SFML
A minimal example
Summary
2. General Game Architecture, User Inputs, and Resource Management
General structure of a game
The game class
Game loops
The frame rate
Fixed time steps
Variable time steps
Minimum time steps
Move our player
The player class
Managing user inputs
Polling events
Real-time events
Handling user inputs
Using the Action class
Action target
Event map
Back to action target
Keeping track of resources
Resources in SFML
The texture class
The image class
The font class
The shader class
The sound buffer class
The music class
Use case
RAII idiom
Building a resources manager
Changing the player's skin
Summary
3. Making an Entire 2D Game
Turning our application to an Asteroid clone
The Player class
The levels
The enemies
The meteors
The flying saucers
Modifying our application
The World class
The hierarchical entity system
The entity component system
Designing our game
Prepare the collisions
The Entity class
The Player class
The Enemy class
The Saucer class
The Meteor class
The Shoot class
Building a Tetris clone
The Stats class
The Piece class
The Board class
The Game class
Summary
4. Playing with Physics
A physics engine – késako?
3D physics engines
2D physics engines
Physics engine comparing game engine
Using Box2D
Preparing Box2D
Build
Install
Pairing Box2D and SFML
Box2D, how does it work?
Adding physics to a game
The Piece class
The World class
The Game class
The Stats class
Summary
5. Playing with User Interfaces
What is a GUI?
Creating a GUI from scratch
Class hierarchy
The Widget class
The Label class
The Button class
The TextButton class
The Container class
The Frame class
The Layout class
The VLayout class
Adding a menu to the game
Building the main menu
Building the pause menu
Building the configuration menu
Using SFGUI
Installing SFGUI
Using the features of SFGUI
Building the starting level
Summary
6. Boost Your Code Using Multithreading
What is multithreading?
The fork() function
The exec() family functions
Thread functionality
Why do we need to use the thread functionality?
Using threads
Adding multithreading to our games
Summary
7. Building a Real-time Tower Defense Game from Scratch – Part 1
The goal of the game
Building animations
The Animation class
The AnimatedSprite class
A usage example
Building a generic Tile Map
The Geometry class as an isometric hexagon
VLayer and Layer classes
VMap and Map classes
Dynamic board loading
The MapViewer class
A usage example
Building an entity system
Use of the entity system
Advantages of the entity system approach
Building the game logic
Building our components
Creating the different systems
The level class
The game class
The Team GUI class
Summary
8. Build a Real-time Tower Defense Game from Scratch – Part 2, Networking
Network architectures
Peer-to-peer architecture
Client-server architecture
Client
Server
Network communication using sockets
UDP
TCP
Selector
The Connection class
The goal of the Connection class
Creating a communication protocol
Using the sf::Packet class
RPC-like protocol
The NetworkEvent class
Modifying our game
Server
Building the Server entry point
Reacting to players' actions during a match
Synchronization between clients and the server
The Client class
Connection with the server
The Level class
Adding data persistence to the game
What is ORM?
Using cpp-ORM
Turning our object persistent
Saving an object in a database
Loading an object from the database
Summary
Index

SFML Blueprints

Copyright © 2015 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: May 2015
Production reference: 1220515
Published by Packt Publishing Ltd.
Livery Place
35 Livery Street
Birmingham B3 2PB, UK.
ISBN 978-1-78439-847-7
www.packtpub.com

Credits

Author
Maxime Barbier
Reviewers
Nolwenn Bauvais
Jason Bunn
Tom Ivanyo
Vittorio Romeo
Richa Sachdeva
Michael Shaw
Commissioning Editor
Edward Bowkett
Acquisition Editor
Shaon Basu
Content Development Editor
Akashdeep Kundu
Technical Editors
Tanmayee Patil
Shiny Poojary
Mohita Vyas
Copy Editors
Trishya Hajare
Aditya Nair
Shambhavi Pai
Merilyn Pereira
Aarti Saldanha
Project Coordinator
Milton Dsouza
Proofreaders
Safis Editing
Jonathan Todd
Indexer
Tejal Soni
Graphics
Abhinash Sahu
Production Coordinator
Aparna Bhagat
Cover Work
Aparna Bhagat

About the Author

Maxime Barbier has recently finished his studies and is now a software engineer in Strasbourg, France. He loves programming crazy things and has been experimenting and sharing them with the open source community on GitHub since 2010. Also, he really likes game programming.
As his favorite technology is C++, he has become an expert in it because of his work. He has also developed several libraries with this language, and some of them are used in this book. Game programming is his hobby, and he really likes the challenges involved in such a project. He also loves sharing his knowledge with other people, which was the main reason he wrote this book and also the reason for his activity in the open source community.
Since 9 years, he has been working on different projects such as Anka Dreles, which is a pen and paper role-playing game, and is putting in effort to convert it into a computer game.
He also loves sailing and was a sailing teacher for several years while studying. His dream is to be able to combine sailing and computer sciences by traveling around the world.
Before sta...

Table of contents