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)

Capturing time


Time is important. Even in computing we have to deal with it in most applications. However, let's say that Timmy (a friend of ours) does not believe that time is of any importance and, one day, he sits down and builds a multiplayer racing game where cars move by exactly one pixel in every frame. Happy with the result on his machine, Timmy sends the program to his friend Jimmy, who has just bought the latest Super Ultra X CPU for his machine. They get into the race without any problems but, as soon as the green light hits, Jimmy rushes ahead of Timmy, leaving him behind, all dusted and confused. Later on, Timmy realizes that Jimmy's machine executes the code a lot faster than his own machine and therefore, his car was slower. Timmy never overlooked the frame time ever again

Even though the preceding story demonstrates an oversimplified example, it reveals the greatest flaw in ignoring time in any simulation—frames are executed at different speeds on different machines and thus...