- •Credits
- •Foreword
- •About the Authors
- •About the Reviewers
- •www.PacktPub.com
- •Table of Contents
- •Preface
- •Introducing SFML
- •Downloading and installation
- •A minimal example
- •A few notes on C++
- •Developing the first game
- •The Game class
- •Game loops and frames
- •Input over several frames
- •Vector algebra
- •Frame-independent movement
- •Fixed time steps
- •Other techniques related to frame rates
- •Displaying sprites on the screen
- •File paths and working directories
- •Real-time rendering
- •Adapting the code
- •Summary
- •Defining resources
- •Resources in SFML
- •Textures
- •Images
- •Fonts
- •Shaders
- •Sound buffers
- •Music
- •A typical use case
- •Graphics
- •Audio
- •Acquiring, releasing, and accessing resources
- •An automated approach
- •Finding an appropriate container
- •Loading from files
- •Accessing the textures
- •Error handling
- •Boolean return values
- •Throwing exceptions
- •Assertions
- •Generalizing the approach
- •Compatibility with sf::Music
- •A special case – sf::Shader
- •Summary
- •Entities
- •Aircraft
- •Alternative entity designs
- •Rendering the scene
- •Relative coordinates
- •SFML and transforms
- •Scene graphs
- •Scene nodes
- •Node insertion and removal
- •Making scene nodes drawable
- •Drawing entities
- •Connecting entities with resources
- •Aligning the origin
- •Scene layers
- •Updating the scene
- •One step back – absolute transforms
- •The view
- •Viewport
- •View optimizations
- •Resolution and aspect ratio
- •View scrolling
- •Zoom and rotation
- •Landscape rendering
- •SpriteNode
- •Landscape texture
- •Texture repeating
- •Composing our world
- •World initialization
- •Loading the textures
- •Building the scene
- •Update and draw
- •Integrating the Game class
- •Summary
- •Polling events
- •Window events
- •Joystick events
- •Keyboard events
- •Mouse events
- •Getting the input state in real time
- •Events and real-time input – when to use which
- •Delta movement from the mouse
- •Playing nice with your application neighborhood
- •A command-based communication system
- •Introducing commands
- •Receiver categories
- •Command execution
- •Command queues
- •Handling player input
- •Commands in a nutshell
- •Implementing the game logic
- •A general-purpose communication mechanism
- •Customizing key bindings
- •Why a player is not an entity
- •Summary
- •Defining a state
- •The state stack
- •Adding states to StateStack
- •Handling updates, input, and drawing
- •Input
- •Update
- •Draw
- •Delayed pop/push operations
- •The state context
- •Integrating the stack in the Application class
- •Navigating between states
- •Creating the game state
- •The title screen
- •Main menu
- •Pausing the game
- •The loading screen – sample
- •Progress bar
- •ParallelTask
- •Thread
- •Concurrency
- •Task implementation
- •Summary
- •The GUI hierarchy, the Java way
- •Updating the menu
- •The promised key bindings
- •Summary
- •Equipping the entities
- •Introducing hitpoints
- •Storing entity attributes in data tables
- •Displaying text
- •Creating enemies
- •Movement patterns
- •Spawning enemies
- •Adding projectiles
- •Firing bullets and missiles
- •Homing missiles
- •Picking up some goodies
- •Collision detection and response
- •Finding the collision pairs
- •Reacting to collisions
- •An outlook on optimizations
- •An interacting world
- •Cleaning everything up
- •Out of view, out of the world
- •The final update
- •Victory and defeat
- •Summary
- •Defining texture atlases
- •Adapting the game code
- •Low-level rendering
- •OpenGL and graphics cards
- •Understanding render targets
- •Texture mapping
- •Vertex arrays
- •Particle systems
- •Particles and particle types
- •Particle nodes
- •Emitter nodes
- •Affectors
- •Embedding particles in the world
- •Animated sprites
- •The Eagle has rolled!
- •Post effects and shaders
- •Fullscreen post effects
- •Shaders
- •The bloom effect
- •Summary
- •Music themes
- •Loading and playing
- •Use case – In-game themes
- •Sound effects
- •Loading, inserting, and playing
- •Removing sounds
- •Use case – GUI sounds
- •Sounds in 3D space
- •The listener
- •Attenuation factor and minimum distance
- •Positioning the listener
- •Playing spatial sounds
- •Use case – In-game sound effects
- •Summary
- •Playing multiplayer games
- •Interacting with sockets
- •Socket selectors
- •Custom protocols
- •Data transport
- •Network architectures
- •Peer-to-peer
- •Client-server architecture
- •Authoritative servers
- •Creating the structure for multiplayer
- •Working with the Server
- •Server thread
- •Server loop
- •Peers and aircraft
- •Hot Seat
- •Accepting new clients
- •Handling disconnections
- •Incoming packets
- •Studying our protocol
- •Understanding the ticks and updates
- •Synchronization issues
- •Taking a peek in the other end – the client
- •Client packets
- •Transmitting game actions via network nodes
- •The new pause state
- •Settings
- •The new Player class
- •Latency
- •Latency versus bandwidth
- •View scrolling compensation
- •Aircraft interpolation
- •Cheating prevention
- •Summary
- •Index
About the Reviewers
Brandon DeRosier is a free software supporter, software engineer, and a hobbyist game developer living in the Greater Boston area. Driven by an early interest
in programming, he took to the reverse engineering of his favorite games of his childhood; he would later write several small augmentation tools to run alongside these games. Over time, he developed his skills as a programmer—as well as an interest in music composition, animation, and interactive media. Currently, he is directing these skills and interests towards game design.
As a member of the Free Software Foundation, he understands that the concealing of source code is unethical and regressive; dedicated to the digital rights of users everywhere, he has actively participated in the development and distribution of free software.
Brandon is currently pursuing a Bachelor of Science degree in Computer
Science at Wentworth Institute of Technology in Boston and takes pride in helping others learn. Occasionally, he gives lectures in classes and clubs, with hopes of encouraging interest in interactive media development with frameworks such as SFML and LWJGL.
I'd like to thank my partner, Yamilah Atallah, for brainstorming game ideas with me, coming up with meaningful concepts and wonderful designs, and changing my life in so many positive ways; with this support, my interest in game development has grown.
www.it-ebooks.info
Karol Gasiński is a programmer, entrepreneur, and traveler living in Poland, Europe. He works as a Graphic Software Engineer at an Intel Research & Development facility, and has worked on 6 generations of Intel graphic cards. As a member of KHRONOS group, Karol contributes to the development of OpenGL and
OpenGL ES Specifications—the industry standard for high-performance graphics.
Outside of his work, Karol's biggest passion is game development and low-level programming. He has been associated with the games industry for over 6 years. In the past, he has worked on mobile versions of games such as Medieval Total War, Pro Evolution Soccer, and Silent Hill. Currently he is the founder and chairman of the Polish Conference on Computer Games Development—the biggest and fastest growing industry event in the country.
Karol gives lectures on most Polish conferences and events for game developers including WGK, GameDay, SWPC, the DigitalFrontier course, IGK, and others. You can also meet him on GDC Europe and GDC San Francisco, where each year he gathers inspiration for his new games.
Eyal Kalderon is a self-taught computer programmer and high school student. Having been introduced to the programming scene at a fairly young age, Eyal developed his early skills in Visual Basic and made a switch to C# early on. Eyal has made himself at home for several years now programming with C and C++ and using shell scripts to automate every task he finds boring. After trying SDL, Eyal switched to SFML in 2010, enjoyed it, and has been following its progress closely ever since.
Understanding the power of print, having gained much from the Internet and professional publications, Eyal chose to erect 'nullpwd' (nullpwd.wordpress.com) in March of 2010, a casual software-centered blog that acts as an unintimidating front for various software topics, such as programming, penetration systems, and the current happenings of the open source community.
www.it-ebooks.info
www.PacktPub.com
Support files, eBooks, discount offers and more
You might want to visit www.PacktPub.com for support files and downloads related to your book.
Did you know that Packt offers eBook versions of every book published, with PDF and ePub files available? You can upgrade to the eBook version at www.PacktPub. com and as a print book customer, you are entitled to a discount on the eBook copy. Get in touch with us at service@packtpub.com for more details.
At www.PacktPub.com, you can also read a collection of free technical articles, sign up for a range of free newsletters and receive exclusive discounts and offers on Packt books and eBooks.
TM
http://PacktLib.PacktPub.com
Do you need instant solutions to your IT questions? PacktLib is Packt's online digital book library. Here, you can access, read and search across Packt's entire library of books.
Why Subscribe?
•Fully searchable across every book published by Packt
•Copy and paste, print and bookmark content
•On demand and accessible via web browser
Free Access for Packt account holders
If you have an account with Packt at www.PacktPub.com, you can use this to access PacktLib today and view nine entirely free books. Simply use your login credentials for immediate access.
www.it-ebooks.info
www.it-ebooks.info