Subscribe to GameFromScratch on YouTube Support GameFromScratch on Patreon

2. June 2015


So a lot has happened in the land of SFML since I created my SFML tutorial series and I decided to check out what’s new.  I happen to be on my Macbook, so Visual Studio wasn’t an option.  Time for a bit of a confession… I hate Xcode, especially for C++ development.  I just find it to be a downright unpleasant, disorganized, unintuitive mess and C++ is a third class citizen.  The alternatives such as Code::Blocks never really appealed to me, and Qt Creator always seems to make you jump through half a hundred extra steps.


Thankfully CLion, a cross platform C++ IDE from JetBrains, the makers of IntelliJ, was recently released.  So I decided to kill two birds with one stone…  check out what’s new with SFML and evaluate CLion all at the same time.  This involves setting up the development environment and probably the area where most new C++ game developers fall flat on their faces.


So, if you are interested in developing using SFML on Mac using CLion… this post is for you!  We are going to walk through installing SFML and configuring your very first project.


Installing SFML

First we need to download and install SFML.  There are two ways to go about this…  first you can head to SFML downloads page, download the Mac OS zip package, extra it, and copy the files to the locations specified in the readme file...


… or you can use homebrew.  This is what I did.  Assuming you have homebrew installed, at a terminal simply type:

brew update
brew install sfml

In theory this will download and install all the requisite parts of SFML.  In theory.  If it fails, go back to the manual process.


Creating a new project in CLion 

I’m going to assume at this point you’ve already got CLion installed.  If not, it’s available here and can be installed as a 30 day trial.

Once installed, fire up CLion, it’s time for us to create a new project.





Select new Project




Name however and wherever you wish, just be sure to remember the location.



In the Project panel, locate CMakeList.txt and double click it.  This file is basically your CMake based project file, which CLion uses for it’s project format, as does SFML.


CMakeList.txt will open in the editor, replace with the follow text:


cmake_minimum_required(VERSION 3.2)

set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11")

set(SOURCE_FILES main.cpp)
add_executable(SFMLDemo ${SOURCE_FILES})

find_package(SFML REQUIRED system window graphics network audio)
    target_link_libraries(SFMLDemo ${SFML_LIBRARIES})


If you’re going to screw up, this is the part you will screw up.  Let me point out the critical portions here.


Ss3 5


Make sure your project name is set correctly everywhere I boxed in red.  Also make sure your cmake_modules directory is set right...


Oh yeah, about that… make a directory called cmake_modules.  We need to copy this file (FindSFML.cmake) into that folder.  Be sure you save as Raw if downloading from Github and make sure the extension stays cmake, not cmake.txt as Mac OS is found of doing.  Or you could just create a new file called FindSFML.cmake in CLion and copy/paste the contents.  The choice is yours, but in the end your project should look like:




Creating a Run Configuration


Now we are ready to run our application.  Select the menu Run->Edit Configuration...




Be sure to set the working directory to you project folder ( or wherever you are going to put assets ), and chose your project as the executable, then hit Apply/OK.


You should now be able to run your application using the pulldown at the top of CLion, like so:


Use the play icon to run, the bug icon to debug.


The default application should run and we should see:



Now let’s try with some actual SFML code.  Replace the contents of main.cpp with the following:

#include <SFML/Graphics.hpp>



int main() {


    sf::RenderWindow window(sf::VideoMode(640,480,32),"Hello SFML");


    sf::Font font;



    sf::Text text("Hello World",font,11);


    text.setPosition(window.getSize().x/2 - text.getGlobalBounds().width/2,

                     window.getSize().y/2 - text.getGlobalBounds().height/2);





        sf::Event event;

        while(window.pollEvent(event)) {

            if(event.type == sf::Event::Closed){









    return 0;



Finally we need the rtf file used in this example, I downloaded it from right here, and copied the file OpenSans-Bold.ttf to the root of our project directory. It is important this matches the run directory you specified earlier.  When run you should now see:





There you go, a fully configured, really to run SFML project on MacOS, without an Xcode in sight!  There is one thing to be aware of though… right now the line:

find_package(SFML REQUIRED system window graphics network audio)

Is linking in every single SFML module, needed or not.


1. June 2015


Mixamo, the creator of the online self serve animation service of the same name, as well as Mixamo Fuse character creation software, were just acquired by Adobe.


I just received the following email:


Dear Mike,

We are proud to announce that as of today, our company has been acquired by Adobe. Incorporating Mixamo technology into Adobe’s world class software platform means greater ease of use and accessibility for Mixamo’s current and future users.

Over the coming months, Adobe and Mixamo will work on integrating Mixamo products and services into Adobe Creative Cloud.  For detailed answers to your questions read our handy FAQ. Or, visit the Mixamo blog for the full story.

How does this effect your Mixamo account?

  • Mixamo’s products and services will continue to operate normally and you will continue to have full access to any services that were available to your account prior to the transition, with the exception of a la carte purchases.
  • During the transition period, Mixamo will be unable to process payments including refunds, upgrades and a la carte purchases. We look forward to sharing our plans for the future in the coming months.
  • Current plan customers can continue to fully use the Mixamo service, including all its products, until their plan expires. All plans that expire before the end of the year will be automatically extended to December 31, 2015, at no cost.

  • All existing accounts will receive 10 free auto-rigs and 20 free animations in addition to any auto-rigs and animations currently remaining on the account.

There will be a lot of excitement (and questions) in the coming weeks and months, and we will do our best to keep you informed. Please post questions on our community forum or reach out to support.

Thank you for supporting Mixamo and helping us to become a premier provider of high quality characters, rigs and animations. Your artistry for storytelling has inspired us for over six years and all that passion will guide us through the new and even more ambitious challenges ahead.

We are looking forward to seeing what you will create with Mixamo and Adobe as we move forward into the next chapter!

Happy Animating,

Stefano Corazza


Interesting move.  The 20 free animations is nice.  I am not sure how the 10 free auto-rigs collides with the free auto-rigging they just announced with the release of Mixamo 2. 


To be honest, I always liked Mixamo’s business model and generally, I don’t like Adobe’s, so I doubt I am going to like the outcome of this transaction, but hopefully I will be proven wrong.

News, Art

1. June 2015


Today we are going to look at creating 2D maps composed of tiles.  You can think of tiles as re-usable lego block like sprites that are assembled to create a more detailed map.  Tiles are stored in a data structure called a tileset, where collision details can be added.  These tiles and tile sets are then used to “paint” 2D scenes in something called a tilemap.  A tile map itself can contain multiple layers of tiles stacked on top of each other.  Don’t worry, it will make sense once we jump in.



When I wrote this tutorial, the majority of functionality I cover is currently under very active development. In order to follow along with this tutorial you need to have version 4.8 installed. Currently 4.8 is in preview release only, hopefully it will be released soon and I can remove this message. For now however, if you want to work with 2D tilemaps with collision data, you need to install the development release. For details on how to do this please read this post.


So, at this point I assume you either have the developer preview download, enough time has elapsed that this functionality is in the main release or you are simply reading on for future reference.  All the disclaimers out of the way, let’s jump in!


There is an HD video version of this tutorial available here: [Coming Soon].


Creating a Tileset


First start off by loading a sprite sheet texture in Unreal Engine, details of loading a sprite are available here.

For  this particular example, we need some tiles to work with.   Instead of creating my own spritesheets, I am going to use some of the free graphics that makes available, specifically the Platform Pack.  Obviously you can use whatever image you wish, just be sure that the tiles are size the same and ideally that your image is a power of two in size. 

Import the spritesheet you are going to use for your tiles, in my case I selected Spritesheets/spritesheet_ground.png.  Make any changes you wish to the texture, such as disabling mipmaps and turning filtering to nearest.

Now right click your newly created texture and select Sprite Actions->Create Tileset:



This will then create a TileSet object, double click it to open the editor.



The TileSet editor should appear:



Across the left hand side are all of the tiles that are in your imported sprite.  Selecting one will make it visible in the top right window.  The bottom right window has properties for the entire texture set.  The most important to set right away is the Tile Size:



Here you enter the pixel dimensions of each individual tile within your image.  In the spritesheet from, each tile is 128x128 in size.  The remaining settings are for tilesets that have gaps between tiles and aren't applicable in this case.  Both the left and top right window can be zoomed and panned using the regular commands.


Now let’s look at setting up collision shapes for a few tiles.  First select a tile from the left side, like so:



A white rectangle will bound around the selected tile.  It will now appear in the top right window:



We can now define bounding shapes using the toolbar:



In this case, a simple box is the easiest ( and least processing intensive.  So click Add Box:



This will now make it so the entire surface causes a collision.   For non-box shaped tiles, you are often going to want to use the Add Polygon option instead, then define the collision boundary accordingly, like so:



Simply click for each vertices you wish to create.  Once done hit enter to finish your shape.  You can shift click to add new points to an existing shape.

Repeat this action for each tile that has collision data.  If a sprite is able to pass completely through the sprite without collision you don’t need to provide a collision shape at all.  Repeat this step for each tile in your set that can be collided with.

You can easily check which tiles you’ve defined a collision shape for by clicking Colliding Tiles:



When done click Save and we have just created our first TileSet.


Creating a TileMap


Now it’s time to create a Tilemap.   To create a tilemap select Add New –>Paper2D->Tile Map



This will create a new tile map object.  Double click it to bring up the tilemap editor.



Here is the tilemap editor in action:



On the left hand side is a selection of tiles you can paint with.  In the middle is the canvas you paint on, while on the right are your layer controls and the layer properties.  There are a couple critical things you need to configure right away.


First select your tileset.  On the left hand side, drop down the Active Tile Set dialog ( hit the grid icon ) and select the tile set we just created.



Now in the layer properties, we set the size of our tiles and the overall width and height of our layer ( in tiles ):


Start by selecting a base tile to fill the entire map with, select file mode and then click somewhere inside the map grid, like so:


Select base tile:



Choose Fill:



And click:



Now select an individual tile to paint with, click Paint, then draw it on the map, like so:



Quite often you are going to want tiles to appear “over” other tiles.  This can be accomplished using layers.  To add a layer simply click the Add New Layer button:



The order layers are drawn is the same as they are displayed:


You can use the up and down icons to change the layer order.  The layer selected ( the one highlighted ) is the layer that all drawing will occur on.


Adding your Tilemap to the Scene


Now that you’ve created your map, you can use it like you would any Sprite object.  Simply drag it into your scene:



The positioning of the tilemap is important, the Y value is going to determine what is drawn over or under when drawing the scene, just like with sprites.  In this case however, sometimes you want to position your sprite in front of the background, but behind a foreground layer, like so:



This is done using a property called Separation Per Layer in the Tilemap details.


This is the Y coordinate ( confusingly called Z order in the tooltip ) of the layer within the game world.  For example if you position your tilemap at Y= –10 and set Separation Per Layer to 50, the first layer will be at Y=40, the second at Y=90, etc.  Therefore a sprite at 0 will draw in front of the bottom layer, but behind the top layer.

If you want to see a more detailed example showing collisions in action, be sure to watch the video version of this tutorial.


The Video


Coming soon

Programming , ,

1. June 2015


For my most recent tutorial, I am using a feature that is currently under active development.  This means I have to use a developer preview release and I figured I would share a quick post on how to install preview releases.  Of course the standard disclaimer applies…  you should never use preview releases for production work!



Installing a Preview Release

To install a Unreal Engine preview release, launch the Epic Games Launcher.



Select Library



Click Add Versions



A new empty version will be added:



Click the arrow to the top right and select the version you wish to install.  You will note the preview release isn’t available as an option for me ( nor is 4.7.6 ), as they are already installed on my machine.



The preview release should now download and install.  Now the next time you launch Epic Games Launcher, you will have an option over which game engine to launch:



It is safe to install multiple versions side by side, although it will take 5-6GB+ of disk space per install.  However project versions may not be compatible between different engine versions.  When you go to open an existing project, the engine version of each project will be noted, like so:


Programming ,

29. May 2015


Up until this point we’ve covered a ton of the items that go into making a game, but nothing resembling a game… the pieces simply didn’t fit together.  In this tutorial we are going to change that and start bringing everything we learned together.  We are going to be covering a lot today, so if I lose you let me know.  This might be one of those tutorials where the video version comes in very handy.


Once again, I am simply going to assume you’ve gone through all the prior tutorials, so instead of telling you how to make a flipbook, I simply say “Make a flipbook”.  So if you haven’t already, you may want to go back and read or watch the earlier tutorials.  Ok, let’s jump right in.


There is an HD video version of this tutorial available here, or available embedded below.



Actors, Pawns, Characters and Controllers


In the world of Unreal Engine, things that exist in the game world are Actors.  Quite simply an Actor is an object that can be placed into a level.  It contains details like position, rotation and scale.  Most importantly, Actors are containers for Components, or even a hierarchy of components.  Components can be thought of as attributes or properties of an actor…  these are the things the actor is and does, and the Actor->Component relationship is a big part of Unreal’s modular design.


There are a few very important classes derived from Actor that are very important.  The first of which is the Pawn.  Basically a Pawn is an Actor that can be controlled by either the player or the games AI. Each Pawn has a Controller and each Controller has a pawn.


The Controller can control a pawn.  This takes two forms, AI controllers and character controllers.  The AI controller is responsible for the artificial intelligence that controls a pawns movements.  The Player Controller on the other hand is responsible for handling input from the player(s) and applying the results to the character’s pawn.


Finally you have Characters. A Character brings a number of objects together to represent that character.  In the 3D world, the Character class extends Pawn to include a skeletal mesh, a mesh for collision detection and of course whatever components you add.  In the Paper2D world there instead is PaperCharacter, which instead of a mesh instead has a Flipbook.


These key classes all work together to provide the building blocks of your game.  Don’t worry, we are about to see it all in action in a few minutes.


Getting Ready


We are now going to create the skeleton of a game, but this is going to require you to do a few things.  First of course create a new project, I am using these settings:



After loading I want a completely clean slate so I select an delete everything the project included:



Next, we need to import some sprites, both as a background and to create a flipbook for our main character.


I am using a simple three frame animation using this frame, this frame and this frame.   For my world background I am using this image.  Any likeness or similarity to an existing game is purely coincidental…   Obviously you don’t have to use these images, but if you want to follow along exactly you can.


Load all four images in as textures, then make a sprite from each.  Create a new Sprite Flipbook out of our 3 frames of animation and set the frame rate at 2fps. Then drag the fourth sprite in as our scenes background.  Be sure to set the backgrounds Y value to a negative so our game sprite will draw in front of it! 


Ultimately you should have something like this:



With a Flipbook like this:



Creating a Main Character


Now that we have a world and an animation, it’s time to add a character to the game.


To do so, select Add New, then Blueprint Class:



It is going to present a dialog with a number of the options we talked about earlier.  The one we are going to use in this example isn’t actually on the list so select All Classes:



In the filter type “Pap”, then locate PaperCharacter, click it and press Select.



This will create a new Blueprint for you, I immediately renamed mine MyPlayer.



I suppose I should point out, you don’t have to use PaperCharacter, any Pawn derived class is fine, although the process will be slightly different.


In the Content Browser, double click MyPlayer to bring up the Blueprint editor, it should look something like this:



Now we need to set the Flipbook for our Player.  You will notice on the left hand side, several components are already defined:



Select Sprite.


Now with sprite selected, it’s details should appear on the right hand side.  No locate Sprite and select the Flipbook you created earlier:



In the Viewport tab, your Player should now look like:



Now we want to shrink the capsule down to match our sprite.  The capsule container is used for doing collision tests and should be as near an approximation as possible.  Simply select the capsule in the viewport, then in details locate Shape and set the two values until it just fits around your sprite.  I used:



And the end results looks like:




Adding a Camera


Let’s look at the process of adding a component to an actor, in this case a Camera.  This will create a camera centered on the Actor.  To do so, in the Components panel select Add Component, then Camera:



In the viewport you will now see your new Camera component:



Right click select it, hit E to rotate and rotate it 90 degrees.  Then hit W to move it, and move it back along the X axis.  Something like this:



The angle and distance between the camera and the sprite are important, but once you’ve got things configured correctly ( in a few minutes ), you will be able to hit the Play icon and preview the effect of the camera on your player.  If we needed more fine tune control of the relationship between the camera and the sprite, we could add a Swing Arm component and attach the camera to it.  We don’t need this in this particular example though.


Configuring your game


Now that we have our player class, we need to let the game know that it is our player.  This is done by creating a GameMode blueprint.  To do so drop down the Blueprints icon, select GameMode->Create->GameMode, like so:



In the resulting dialog, name it then select OK.  I’m going with the default NewGameMode.



This will create a new Blueprint but the part you are most interested in are the properties.  It is here that you configure a number of important top level classes for your game.  Locate “Default Pawn Class” in the Classes section and select your Player class.



Now when the game starts, and instance of your Player class will automatically be created.


Now we just need to tell the game WHERE the player should be created, and this is done using a Player Start object.  In the Modes dialog, locate or search for Player Start and drag one onto the scene where you want the player pawn to be created.



And position it like so:



Now press play and we see…



Hmmm… that’s not good.


The problem is, our game world has gravity enabled by default and we don’t want this.  The easiest fix is to turn gravity off.


To turn off gravity, in the World Outliner, double click your map to bring World Settings dialog up.  Now locate the Physics section, check Override World Gravity and make sure gravity is set to 0.



Now when we press play we should see:



Much better, we are now one step closer.  We have a world (sorta…  I’ll admit, we are faking that part pretty heavily here), we have a main character… now we just need to add some controls.


Simple Keyboard Controls


Now we are going to jump into some Blueprint programming to add some keyboard controls to our player.  Double click your MyPlayer blueprint to bring it up in the editor, then select the Event Graph task.  Personally I am deleting all of the premades that they provide to keep things a bit cleaner.


Now we are going to add an input handler for when the user presses the Right arrow key.  Simply right click the canvas, type Right and select Key Events –> Right like so:



We create this simple blueprint.



Now when the user releases the right arrow, we move the Character Movement component of our player by 20 along the X axis.


Now through the power of Cut and Paste, we quickly create the following simple control scheme:



All that changes is for each key pressed we move in a different direction, either +/- x for left and right, or +/- z for up and down.


In case you didn’t know, you can rectangle select a region of blueprint and replicate it use the traditional cut/copy/paste hot keys.  Now we we run our game, we have primitive control over our player:



This is a very very very trivial example, and as you can see, it’s missing some logic for left and right as “definitely not PacMan” doesn’t turn to face the direction we are facing.  If you watch the video version of this tutorial I will show a simple way to handle that situation, we are already running pretty long here.


More on Input


The above example was super simple, we simply respond directly to a certain key being pressed.  In your game you probably wont end up using this logic.  Let’s take a quick look at some more advanced control options before moving on.


First, there was additional options for the key handling events that I never showed.  With a Key event selected in the Details panel you will see additional options:



In addition to changing the key handled you can enabled/disable modifier keys like Ctrl and Shift.  You can also control if the keyboard event is handled or will be propagated to the rest of the application by setting Consume Input.


More commonly however, you are going to want to handle Input more generically.  Responding to a single key event is all well and good, but what happens when you want the same code to work on a device without a keyboard?  Or you want a joystick to do the same thing?  Or you want the user to be able to remap their own keys?  Well, good news, there is an answer for that.


First, select Edit->Project Settings:



On the left, under Engine select Input then locate the Bindings section:



This area allows us to create input bindings between controls and either an action, or the axis of a controller ( virtual or otherwise ).  Let’s look at an example of mapping a “Left” axis.


Start by clicking the + next to Axis Mapping, expand the new value and rename it left, then add a key like so:



Now I am going to repeat the task, but also mapping for the left D-pad on a controller and the A key.  The end result looks like:



Now instead of handling each controller/key separately they will all emit the same “LEFT” event.  When you are creating your input handling blueprint, you can now respond to an Input->Axis Events->LEFT event:



You will notice the Event for an axis has one additional parameter:



Axis value is the “amount” along the axis it is.  All of our examples are on/off inputs, but if you had an analog stick, the Axis Value would indicate how far to the left the stick was pressed.  Coincidentally, that is the use of the “Scale” property in the Axis mapping process.  If for example you wanted the Left arrow key to be equivalent of pushing the Left analog stick 50%, you would set the scale value to 0.5.




Programming , , ,

Month List

Popular Comments

Google Announce VR Mode For Android N
Subscribe to GameFromScratch on YouTube Support GameFromScratch on Patreon

19. May 2016 is currently going on, Google’s annual developer conference.  In a world currently dominated with VR announcements, did you really expect no VR announced from Google?  Yeah, me neither.


The following is from the Android developer blog:

Android was built for today’s multi-screen world; in fact, Android powers your phone, your tablet, the watch on your wrist, it even works in your car and in your living room, all the while helping you move seamlessly between each device. As we look to what’s next, we believe your phone can be a really powerful new way to see the world and experience new content virtually, in a more immersive way; but, until this point, high quality mobile VR wasn’t possible across the Android ecosystem. That’s why we’ve worked at all levels of the Android stack in N–from how the operating system reads sensor data to how it sends pixels to the display–to make it especially built to provide high quality mobile VR experiences, with VR Mode in Android. There are a number of performance enhancements designed for developers, including single buffer rendering and access to an exclusive CPU core for VR apps. Within your apps, you can take advantage of smooth head-tracking and stereo notifications that work for VR. Most importantly, Android N provides for very low latency graphics; in fact, motion-to-photon latency on Nexus 6P running Developer Preview 3 is <20 ms, the speed necessary to establish immersion for the user to feel like they are actually in another place. We’ll be covering all of the new VR updates tomorrow at 9AM PT in the VR at Google session, livestreamed from Google I/O.


So basically they are baking much of the functionality required to support VR directly into Android N.  On top, they also released a reference device for developers and manufacturers to build their own Android N powered VR device, including this controller:


It has built-in sensors for helping to determine position along with a a trackpad for fine tuned control.


It appears that Google intends to leave device development up to others.   In an already saturated market, it will be interesting to see if this approach works.  Frankly the only real selling point I see for Android powered VR is the price point ( since the phone provides the CPU, GPU, Screen, etc ), but the GearVR is already in place and is the best selling VR Headset available.

GameDev News

blog comments powered by Disqus

Month List

Popular Comments