Book Image

SFML Essentials

By : Milcho G. Milchev
Book Image

SFML Essentials

By: Milcho G. Milchev

Overview of this book

<p>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.</p> <p>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.</p> <p>This book contains a set of fast-paced tutorials about the core features of SFML.</p>
Table of Contents (14 chapters)

Getting started with sf::Text


Text is one of the most overlooked features of a game, but it is sometimes essential to the gaming experience—for example, using the correct font and size, displaying the appropriate amount of information, and so on. Yes, there are games where text is not used at all, but those are quite rare. If you make a game, you'll need to render text at some point during the development process (even for debugging data). In this section, we will talk about text and fonts.

Remember the SpriteTexture and SoundSoundBuffer relation? Take a guess which other part of SFML uses the same model. Yes, you're right—the sf::Font and sf::Text classes. In this case, the Font class is the resource which we want to keep safe while the Text class uses it. You should probably be able to picture the process of loading fonts and creating texts based on the fact that this is the third time that we've come across it. If you can't—don't worry, this is what this book is for. Let's start by...