Now you know a bit more about how we will be making these games, it is time to set up a development environment so we can get coding.
The games that we make can be built to run on Windows, Mac and Linux! The code we use will be identical for each. However, each version does need to be compiled and linked on the platform for which it is intended and Visual Studio will not be able to help us with Mac and Linux.
It would be unfair to say that this book is entirely suited for Mac and Linux users, especially complete beginners. Although, I guess, if you are an enthusiastic Mac or Linux user, and you are comfortable with your operating system, the vast majority of the extra challenges you will encounter will be in the initial setup of the development environment, SFML, and the first project.
To this end, I can highly recommend the following tutorials which will hopefully replace the next 10 pages (approximately), up to the section Planning Timber!!!, when this book should again become relevant to all operating systems.
For Linux, read this for an overview: http://www.sfml-dev.org/tutorials/2.0/start-linux.php .
For Linux, read this for step-by-step guidance: http://en.sfml-dev.org/forums/index.php?topic=9808.0 .
On Mac, read this tutorial as well as the linked out articles: http://www.edparrish.net/common/sfml-.osx.html .
Installing Visual Studio can be almost as simple as downloading a file and clicking a few buttons. It will help us, however, if we carefully run through exactly how we do this. For this reason, I will walk through the installation process a step at a time.
The Microsoft Visual Studio site says that you need 5 GB of hard disk space. From experience, however, I would suggest you need at least 10 GB of free space. In addition, these figures are slightly ambiguous. If you are planning to install it on a secondary hard drive, you will still need at least 5 GB on the primary hard drive because no matter where you choose to install Visual Studio, it will need this space too.
To summarize this ambiguous situation: It is essential to have a full 10 GB space on the primary hard disk, if you intend to install Visual Studio to that primary hard disk. On the other hand, make sure you have 5 GB on the primary hard disk as well as 10 GB on the secondary, if you intend to install to a secondary hard disk. Yep, stupid, I know!
Visual Studio 2015
on your preferred hard disk and install to this folder. This whole process could take a while depending on the speed of your Internet connection.
Now we can turn to SFML.
This short tutorial will take you through downloading the SFML files that allow us to include the functionality contained in the library. In addition, we will see how to use the SFML DLL files that will enable our compiled object code to run alongside SFML:
SFML
. Also create another folder at the root of the drive where you installed Visual Studio and call it Visual Studio Stuff
. We will store all kinds of Visual Studio-related things here so Visual Studio Stuff
seems like a good name. Just to be clear, here is what my hard drive looks like after this step:
Visual Studio Stuff
. Name the new folder Projects
.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 this folder to see the contents, then double-click again into the next folder (mine is called SFML-2.3.2
). The following screenshot shows what my SFML-2.3.2
folder's contents looks like, when the entire contents have been selected. Yours should look the same.
SFML
folder you created in Step 3. For the rest of the book I will refer to this folder simply as your SFML folder.Now we are ready to start using C++ and SFML in Visual Studio.
As setting up a project is a fairly fiddly process, we will create a project and then save it as a Visual Studio template. This will save us quite a significant amount of work each time we start a new game. So, if you find the next tutorial a little tedious, rest assured that you will never need to do this again:
HelloSFML
in the Name: field.Visual Studio StuffProjects
folder that we created in the previous tutorial. This will be the location where all our project files will be kept. All templates are based on an actual project. So, we will have a project called HelloSFML
but the only thing we will do with it is make a template from it.
.hpp
file extension. (All this will become clearer when we eventually start adding our own header files in the second project). In addition, we need to tell Visual Studio where it can find the SFML library files. From the Visual Studio main menu select Project | HelloSFML properties.SFMLinclude
. The full path to type, if you located your SFML
folder on your D drive, is as shown in the screenshot: D:SFMLinclude
. Vary your path if you installed SFML to a different drive.
SFML
folder is, followed by SFMLlib
. So the full path to type if you located your SFML
folder on your D drive is, as shown in the screenshot, D:SFMLlib
. Vary your path if you installed SFML to a different drive.
sfml-graphics-d.lib;sfml-window-d.lib;sfml-system-d.lib;sfml-network-d.lib;sfml-audio-d.lib;
at the indicated place. Again, be really careful to place the cursor precisely, and dont overwrite any of the text that is already there.
HelloSFML
project so we never have to do this slightly mind-numbing task again. Creating a reusable project template is really easy. In Visual Studio select File | Export Template.... Then, in the Export Template Wizard window, make sure the Project template option is selected, and then select HelloSFML project for the From which project do you want to create a template option.Phew, that's it! Next time we create a project, I'll show you how to do it from this template. Now let's build Timber!!!
3.137.170.14