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.
[widgets_on_pages id=”udemy_advert_cpp_1″][widgets_on_pages id=”udemy_code_details”]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.
[widgets_on_pages id=”bcgp_cfgp_gpp”]
Visual Studio
This tutorial has been updated to work with Visual Studio 2017 Community Edition. The SFML setup remains the same except the version number is slightly higher now so I haven’t bothered redoing all the screen-shots, etc, for the SFML part of the tutorial.
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.
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 2017 Community Edition.
Visit this link: https://www.visualstudio.com/en-us/downloads/download-visual-studio-vs.aspx.
Click on Free Download as shown above. There will be a short download. Run the downloaded file.
Next, you have to configure the exact setup. To run all the SFML tutorials select the option highlighted below.
Now you can just wait for the lengthy but hopefully uneventful installation to complete. Let’s move on to the SFML phase.
SFML
[widgets_on_pages id=”udemy_advert_cpp_2″][widgets_on_pages id=”udemy_code_details”]
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.
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.
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.
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.
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!
Hi John,
I have left previous comments but I restarted the whole process so I wanted to ask something I skipped over before.
The step above says to create the two folders in the root of the same directory that you install Visual Studio. And the picture shows the “Visual Studios 2015″ folder in that same place, which I assume is the root of your drive.
For me the root is the C: drive, I assume that’s where you want me to create the two folders, but the Visual Studios 2015 folder is in my documents and no where else.
I do have Visual Studios 14.0 and Visual Studios 12.0 folders in my program files (x86) folder, is that where you want me to create the two folders? Or should it be in the same place that the Visual Studios 2015 folder is, which is Documents? OR, should they be in the root of the C: drive?
I’m sure the are very newbish questions. Thanks for your help!
Separate question: I messed up at one point and had to reinstall Visual Studio, but now every time I do I get a message from Advanced System Care saying some redistributable has some residual files that may affect performance. But I went and uninstalled everything from today, the only day I’ve been working on this, and even went through my program files and removed everything effected today. So how there’s still residual files, idk.
I think the reinstall is causing issues with executing the project. I tried to run the HelloWorld thing and got a bunch of different errors that prompted me to try starting over. Do you have any tips on how to work through these issues?
UPDATE: So regardless of the issues detailed in the above comment, the Hello World project executed correctly this time. And I ended up just putting the two folders in the C: root, even though the Visual Studios 2015 folder is in my documents. But it worked so… MOVING ON!
Wanted to say thank you for making these tutorials!
Thanks for your comments Zrux. Well done for solving this. I have published your comments as they might help someone else.
Is it Imperitive that Visual Studio be used? Can a different IDE such as Dev-C++ be used?
No. And once your preferred IDE is set up with SFML, the same code will work. Good luck.
Must you safe it on the same drive where you have installed Visual Studio, because I work on more then on pc. And I safe all my projects on a Hard Drive.
Hi Tim,
The only reason I am specific about folder names and locations is so the instructions can also be specific. You should have not trouble saving your projects elsewhere. Thanks for your comment.
Hi John ! So when I am installing visual studio and I’m at the point when I’m supposed to choose the installation file, the file path is set to my C:\ and my Documents file by default. The thing is that the file path is grayed out and I have no way of changing it to my D:\ drive like I would like to. Is there any way of changing that or am I doomed to eternal sorrow ?
Also I have tried fiddling with the option in Visual Studio like the path to export and inport projects but there is no way of mooving the Visual Studio 2015 file to my D:\ drive without it being automatically recreated in the Documents folder of my C:\ drive.
I am surprised there is no option. Even when you choose to install on D, Visual Studio will still dump many Gigabytes on C, but you should still have the choice. Hmmm. Will it even let you choose another location on the C drive? Is there a Browse button to the right of the default greyed-out file path? Perhaps Visual Studio has detected “something” about the system and deemed C as the only option. Have you got enough space on C for just Visual Studio because putting SFML and all your projects on D should be less problematic?
Yes the browse button is greyed out with no way of changing the location whatsoever, and there is literally nothing on my D drive so I don’t realy know what would keep Visual Studio from being instaled there. I can put SFML and Visual Studio Stuff on the D drive just fine, but having the Visual Studio 2015 file in the same drive as well would be a hell of a lot easier for me as my C drive is an absolute mess.
I’m also even more surprised at the fact that I’ve seen screenshots of the instalation window with options for the instalation (typical or custom settings) which are absent from the one I get.
I wonder if the second part of this solution might work?
Hello
Have you got any suggestions on how to do this for mac?
Thanks
Hi Laura,
If you can use this tutorial to get SFML setup with Mac then the code from the tutorials on Game Code School should work unaltered, with perhaps the exception of filepaths to assets like fonts and graphics etc.
Hope this helps a bit.
if i just download visual sudio 2015 and then download sfml in the same box does if still work cause it seems to for me but doesnt work when i do it your way…….
If it is working then you are good to go. My way is not the only way to configure things.
Visual Studio Express apparently no longer exists.
Thanks Don,
I am going to update this soon. Community edition is what everyone needs now. The configuration steps remain the same.