You are previewing SFML Essentials.
O'Reilly logo
SFML Essentials

Book Description

A fast-paced, practical guide to building functionally enriched 2D games using the core concepts of SFML

In Detail

SFML is a cross-platform, object-oriented multimedia API that is written in C++. It provides a simple interface to ease the development of games and multimedia applications.

This book will guide you through everything you need to know about building a 2D game in SFML. Concepts such as Sprites, Textures, Animation, and Cameras are explored in depth and finally the book ends with advanced topics like shaders and networking. You will also learn how to play sound and music on top of the gameplay. Every step through the journey is filled with examples in C++ to guide you in the right direction. By the end of the book you will feel confident about creating 2D games with SFML, without investing too much time on it.

This book contains a set of fast-paced tutorials about the core features of SFML.

What You Will Learn

  • Render sprites and shapes on the screen

  • Manage multimedia resources correctly and efficiently

  • Open and configure game windows to ensure a better gaming environment

  • Build an animation manager for sprites

  • Facilitate native OpenGL code in your rendering

  • Play sound and music on top of the gameplay

  • Load and use shaders to render special effects

  • Send data packets over a network to create a multiplayer experience

  • Downloading the example code for this book. You can download the example code files for all Packt books you have purchased from your account at http://www.PacktPub.com. If you purchased this book elsewhere, you can visit http://www.PacktPub.com/support and register to have the files e-mailed directly to you.

    Table of Contents

    1. SFML Essentials
      1. Table of Contents
      2. SFML Essentials
      3. Credits
      4. About the Author
      5. About the Reviewers
      6. www.PacktPub.com
        1. Support files, eBooks, discount offers, and more
          1. Why subscribe?
          2. Free access for Packt account holders
      7. Preface
        1. What this book covers
        2. What you need for this book
        3. Who this book is for
        4. Conventions
        5. Reference images
        6. Reader feedback
        7. Customer support
          1. Downloading the example code
          2. Downloading the color images of this book
          3. Errata
          4. Piracy
          5. Questions
      8. 1. Getting Started with SFML
        1. Creating windows
          1. VideoMode
          2. Style
          3. ContextSettings
          4. Disabling the mouse cursor
        2. The game loop
        3. Event handling
          1. Window related events
          2. Keyboard related events
          3. Mouse related events
          4. Joystick related events
          5. Using events
        4. Shape rendering and transformations
          1. The render frame
          2. Shape drawing
          3. Shape transformation
          4. Controlling shapes
        5. Summary
      9. 2. Loading and Using Textures
        1. Loading textures
          1. Images versus textures
          2. Creating images
          3. Creating textures
        2. Rendering shapes with textures
        3. What is a sprite?
          1. Shapes versus sprites
          2. Transformables and drawables
          3. Final facts on sprites
        4. Managing resources
        5. Summary
      10. 3. Animating Sprites
        1. Capturing time
          1. sf::Time and sf::Clock
        2. Sprites in action
          1. The setup
        3. Building an animator
          1. Using the animator
          2. Multiple animations
        4. Summary
      11. 4. Manipulating a 2D Camera
        1. What is a camera?
          1. When should we use a camera?
          2. How does SFML implement a camera?
        2. Manipulating cameras with sf::View
          1. Rotating and scaling a view
          2. Viewports
          3. Mapping coordinates
        3. What is OpenGL?
          1. Should you use OpenGL?
        4. Using OpenGL inside SFML
          1. OpenGL in multiple windows
        5. Summary
      12. 5. Exploring a World of Sound and Text
        1. Audio module – overview
        2. Sound versus music
        3. Audio in action
          1. The sf::Sound class
          2. Introducing AssetManager 2.0
          3. sf::Music and sf::SoundStream
        4. sf::SoundSource and audio in 3D
          1. Common audio features
          2. Audio in 3D
            1. Setting up the listener
            2. Audio sources
            3. Summarizing audio features
        5. Getting started with sf::Text
          1. AssetManager 3.0
        6. Summary
      13. 6. Rendering Special Effects with Shaders
        1. sf::RenderTarget and sf::RenderWindow
        2. Rendering directly to a texture
        3. Shader programming
          1. What is a shader?
          2. Loading shaders
          3. AssetManager 4.0
          4. Using shaders
          5. Setting shader uniforms
          6. sf::Shader and OpenGL
        4. Combining it all together
          1. Setting up RenderTexture
        5. Summary
      14. 7. Building Multiplayer Games
        1. Understanding networking
          1. Networking in games
        2. Transport layer – TCP versus UDP
          1. TCP in SFML
          2. UDP in SFML
        3. Non-blocking sockets
        4. Exchanging packets
          1. Constructing a packet
        5. Putting it all into practice
        6. Summary
      15. Index