• $19 Game Dev' Courses - Use code "FEBUDEMY"

    Video courses

C++ programming For 2D Games Using SFML

24 lecture video course

Building Games with SFML

4 hour video course.

C++ From Beginner to Expert

Video course for complete beginners.

This is the very first project on the road to building games for desktop operating systems like Windows, Linux and Mac. In these really simple steps we will walk through the process of installing the software applications that we need to start to learn to code for these desktop OS’s.

About this project

Skill level 1
Time to complete 40 minutes (downloads might take longer)

New concepts

  1. Visual Studio Express IDE
  2. SFML SDK

Recommended preparation tutorials

Assumed previous experience

  • Basic proficiency with Windows
  • A free Microsoft account

Getting started

Before we can practice using what we have learnt about coding we need a development environment. This is certainly the least fun of any tutorial you will read on this site but once it is complete we can get straight down to basic game coding and start building up to a full playable game.

  • Beginning C++ Game Programming

    Beginning C++ Game Programming

    This book is all about offering you a very fast and fun introduction to the world of game programming and C++. It will begin by teaching you the programming basics such as variables, loops, and conditions. In this book there is very little theorizing. If you want a deep discussion of all the ins and outs of C++ concepts look elsewhere. If you are starting from a knowledge of zero C++ and want to build great games- fast, take a look at this book.
    • Setup a C++/SFML/Visual Studio development environment
    • Build a fast, fun Timber clone after learning basic C++
    • Discover the fundamentals of C++ object oriented programming and build a multi-level, top-down 2D, scrolling zombie survival/shooter
    • Explore some advanced C++ concepts and make a side scrolling, co-op split-screen multiplayer platform game with directional sound, particle effects and your very own level designs!
    Amazon USA
    Amazon UK
    Amazon CA
    Our Store (US only)
    C++ for Game programmers book

    C++ For Game Programmers

    Already know the basics of C++ but want to dig much deeper in an entirely game-focussed context? C++ for Game Programmers is that book. This best selling title supplements your knowledge by putting everything into perspective from a game-development point of view. The book points out the most effective C++ practices and steers you away from the potentially dangerous ones. It describes common C++ techniques to solve specific problems most game developers face.
    • From a gaming perspective, learn about inheritance, performance, memory management, and STL to object creation, object serialization, and scripting languages
    • Explore C++ Design Patterns and high-level problem-solving constructs that are most commonly found in games
    • Discover custom Structures and algorithms, which provides a detailed hands-on discussion of using C++ to create efficient solutions to difficult problems in a highly structured manner
    Amazon USA
    Amazon UK
    Amazon CA
    Game Programming Patterns book

    Game Programming Patterns

    If you are serious about writing high quality, reusable, efficient code using C++ or indeed any other language, then inevitably you will need to seriously hone your knowledge of game programming patterns. If you don't know what game programming patterns are they are simply the solutions to design problems. If you have programmed even a basic game you will have noticed that the code gets long and hard to manage, very quickly. The more features you add the more sprawling and messy your code gets. In addition to usability/reuse-ability, our game code needs to be efficient enough for the game to run smoothly. That's what this book will do for you.
    • Learn to write a robust game loop, how to organize your entities using components, and take advantage of the CPUs cache to improve your performance
    • Discover how to organize your entities using components, and take advantage of the CPUs cache to improve your performance.
    • Never again wonder what is the "best" way to organize your game code
    Amazon USA
    Amazon UK
    Amazon CA
    Our Store (US only)

Visual Studio

Visual Studio is an Integrated Development Environment (IDE) from Microsoft. It is the app that will allow us to enter our C++ code, compile it and then link it with the SFML code to make our games. If that process sounded complex that’s because it is- but by following a few conventions Visual Studio will handle everything with the click of a button. But first we need to install and configure it.

You can use other IDE’s to make games with SFML but Visual Studio is very easy to set up, the version we need is free and SFML themselves recommend it. Installing Visual Studio is as simple as downloading it and following the instructions. It is vital however to get exactly the right version because there are many!

To use Microsoft Visual Studio you will need a free Microsoft account. If you use XBOX, Windows Live services or have a Hotmail email account then you already have one. If not, you can get one here: https://login.live.com/.

Assuming you have Windows 7 or newer we want to use Visual Studio for desktop Express 2015.

The documentation on the Visual Studio website claims you need around 5GB of hard disk space. This is inaccurate. It is best to assume you need at least 10GB free space. Furthermore if you are planning to install to a secondary hard drive (because it has more space) you will still need up to 5 GB on the primary hard disk because Visual Studio dumps things there too. So in summary it is best to make sure you have a full 10 GB space on the primary hard disk if you are installing it there. If you are installing it to a secondary hard disk make sure you have at least 5 GB on the primary and perhaps up to 10 GB on the secondary. Yeah I know, stupid isn’t it.

Visit this link: https://www.visualstudio.com/en-us/downloads/download-visual-studio-vs.aspx. Click on Visual Studio 2015, then Express 2015 for desk top then the Download button. This image shows the three places to click.

download_visual_studio_2015_express_for_SFML_game_development

Wait for the short download to complete and then run the downloaded file. Simply follow the instructions to install. Just make a note of the folder where you choose to install it. This process will take a while depending on the speed of your Internet connection.

When you see this next screen you can click Launch and enter your Microsoft account login details to proceed.

launch_visual_studio_2015

Let’s move on to the SFML phase.

SFML

Now we need to get hold of all the SFML files that Visual Studio will require to help us build our games. This is known as the SDK or software development kit. Visit this link on the SFML website: http://www.sfml-dev.org/download.php. Click on the button that says Latest Stable Version.

download_sfml_latest_stable_version

By the time you read this guide the actual latest version will almost certainly have changed. That doesn’t matter as long as you do the next step just right.

We want to download the 32bit version for Visual C++ 2014. This might sound counter-intuitive because we have just installed Visual Studio 2015 and you probably(most commonly) have a 64bit PC. The reason we choose the download that we do is because Visual C++ 2014 is part of Visual Studio 2015 (Visual Studio does more than C++) and we will be building games in 32bit so they run on BOTH 32 and 64 bit machines. To be clear click the download indicated below.

download_sfml_latest_stable_32bit_version_for_visual_studio_2015

When the download completes, create a folder at the root of the same drive where you installed Visual Studio and name it SFML. Also create another folder at the root of the drive where you installed Visual Studio and call it Visual Studio Stuff. Now, ready for all the projects we will soon be making create a new folder inside Visual Studio Stuff. Name the new folder Projects. Just to be clear, here is what my hard drive looks like after this step and within the Visual Studio Stuff folder there is another folder; Projects. Obviously the folders you have in between the highlighted three folders in the image will probably be totally different to mine.


sfml_visual_studio_folder_structure

Finally unzip the SFML download, do this on your desktop. When unzipping is complete you can delete the zip folder. You will be left with a single folder on your desktop. Its name will reflect the version of SFML that you downloaded. Mine is called SFML-2.3.2-windows-vc14-32-bit your file name will likely reflect a more recent version. Double click to see the contents of this unzipped folder then double click again into the next folder (mine is called SFML-2.3.2). The image below is what my SFML-2.3.2 folder contents looks like when the entire contents has been selected. Yours should look the same.

sfml_folder_structure

Copy the entire contents of this folder, as seen in the previous image and paste/drag all the contents into the SFML folder you created previously. In future tutorials and projects, I will refer to this folder simply as your SFML folder.

We are ready to build our first SFML game project!