Subscribe to GameFromScratch on YouTube Support GameFromScratch on Patreon Join the GFS Discord Server!
27. May 2020


In one of the biggest game development Humble Bundle, the RPG Game Development Assets 2D Art, Music and Sound Effects bundle is live now.  As always it is split into tiers:

1$ Tier

  • 7Souls RPG Graphics - Desert Tileset
  • 7Soul's RPG Graphics – Sprites
  • Dialogue Boxes
  • Inventory Sound Pack
  • Japanese Bar Interior Assets
  • Osaka City Game Assets
  • RPG Inventory – Fantasy Battle Axes
  • RPG Inventory – Fantasy Bows
  • RPG Inventory – Fantasy Daggers
  • RPG Inventory – Fantasy Potions
  • RPG Inventory – Fantasy Spears
  • RPG Inventory – Fantasy Swords
  • Warrior Adventure Game Characters

15$ Tier

  • 2D Characters Male
  • 2D Hand Painted Mine Tileset
  • 2D Hand Painted Snowland Tileset
  • 7Souls RPG Graphics – Town Tileset
  • Clean City Game Assets
  • Dark RPG Chiptune Soundtrack Bundle
  • Dwarves vs Elves RPG Sprites
  • Hand Painted Extra Objects Tileset
  • Japanese City Game Assets
  • JRPG Character Pack
  • Pixel Art Beach Tile Set
  • Pixel Art Town
  • Side View Animated RPG Battlers
  • Spells and Abilities Icons
  • Fantasy Character Bundle
  • Forest Isometric Block Tileset
  • Frozen Village Isometric Block Tileset

30$ Tier

  • 7Souls RPG Graphics Tiles- Grasslands
  • Over 80RPG Characters with Animations
  • Ancient Game SFX Pack
  • Elemental Magic Sound Effects Vol 1
  • Elemental Magic Sound Effects Vol 2
  • Fantasy RPG Items Vol 2
  • Farm & Fort Tilesets and Icons
  • Human Fantasy Animated Pack
  • Interface SFX
  • JRPG Music Pack
  • Lighthearted RPG Location Soundtrack Bundle
  • Lighthearted RPG Soundtrack Bundle
  • Medieval RPG UI Kit
  • Monster Creature Animated Pack
  • Pixel Art Medieval Interiors
  • RPG Music Pack – Complete Collection
  • Survival Icons
  • Tyler Warrens RPG Battlers Pixel Style
  • MMORPG UI Kit
  • Monster Creature Super Mix
  • Pixel Art Medieval Fantasy Characters
  • Pixel Art Medieval UI Pack
  • Cute RPG UI Kit
  • Pixel Art Forest Road
  • Pixel Art Old Castle
  • 58 Fantasy RPG Items


… yeah, this one is BIG!  The GameDev Marketplace license details are available here.  As with all Humble Bundles, you decide how your money is allocated, including (and thanks so much if you do!) to support GFS if purchased using this link.  Learn more in the video below.

GameDev News Art


26. May 2020


If you follow Gamefromscratch on Twitter, you may have already seen this tweet I put out last night about a blackmail demand that was made against our YouTube channel:

image


First off, I really want to give a gigantic shout out to all of the people that helped get the message out, the tweets, retweets and even Reddit post.  You are an amazing community and hopefully if we yell loud enough, YouTube will here and fix this!

Basically it started with a message in the GFS Discord server claiming to have taken down my Animate CC video.  This video unfortunately has been taken down and reinstated 4 times in the last two months, this happened after YouTube turned up the bots responsibility due to Covid-19, so I had written it off as bots malfunctioning.  Each time it was taken down, I appealed and it would be restored.  After I didn’t pay the $50 in bitcoin, I started getting Circumvention of Technology notices for 3 of my videos.  That ultimately resulted in a community strike and loss of access to my channel for a week (or until appealed).  Thankfully those  three takedowns were reversed in about 2 hours and channel privileges were restored.

Today I was just waiting for YouTube to restore my 2 year old Animate CC video… then to my shock, it was reviewed and found to be in violation!  Even after multiple previous reviews, as you can see from these email snippets!

YTEmailThread

So that is where things stand now.  My channel is back, 3 out of 4 of my videos are returned.  Thing is, anyone that wants can do this exact same attack whenever they want.  It was reported to YouTube and frankly they did nothing.  Any YouTube creator you love can have their channel taken down by spamming Circumvention of Technology claims, and there really isn’t anything you can do about it.  YouTube assumes your guilt and until the review clears you name, your video is down.  As you can see from the above emails, your video doesn’t always come back.

The single biggest piece of advice I can give to any YouTube creator, make sure your content is mirrored on another network!   After my Animate CC video was taken down the second time, I started mirroring to Lbry.tv and I recommend you do to!  Thanks to mirroring to Lbry, my Animate CC video lives on!  So if you want to try to spot the copyright circumvention YouTube reviewers “found”, you can!

Hopefully if we yell loud enough, YouTube will hear and creators will be protected from insanity like this in the future!  You can learn much more in the video below.  Once again, thank you to everyone that helped amplify my voice, it was and is much appreciated!

Totally Off Topic


25. May 2020


Epic Games are running their Annual Unreal Engine Spring Marketplace sale.  You can get a collection of 5000+ asset store items for up to 70% off, which 2k+ being at the maximum discounted amount.

Details from the Unreal Engine blog:

With up to 70% off more than 5,000 select Unreal Engine Marketplace products during the Spring Sale, the Marketplace is teeming with content to make development a breeze. Now through Wednesday, June 3 discover discounted construction kits, character collections, captivating countrysides, and so much more!

Uncover a treasure trove of products to help you construct lavish hotels and lively low-poly campsites, or vast solar systems with starry skyboxes and advanced sci-fi spaceships. Don’t miss out on ambient sounds and tracks to envelop your audience, explosive effects, and handy tools to tidy up your projects.
Sale lasts now through June 3 at 11:59 PM EDT. Happy shopping!

Please not the above Marketplace link was editing to the correct location.  You can also access the sale in the Epic Game Launcher.  You can learn more about the sale and assets available in the video below.


GameDev News


25. May 2020


As discovered on BlenderNation, a new plugin for Android was released that makes quickly creating buildings in Blender a breeze.  Building Tools is available for download here in both zip and tar.gz formats.  Simply download the archive and add it as a plugin in the Blender add-ons panel.  Building Tools enables you to rapidly create houses, from simple single story bungalows, to 100 story towers.

Buildings feature the following configurable assets:

  • Floorplans
  • Floors (slabs and walls)
  • Doors
  • Windows
  • Multigroup (door-window combinations)
  • Roof
  • Stairs
  • Balcony

The add-on is also open source under the MIT license on GitHub.  You can see how to create buildings quickly and simply using Building Tools in the video below.

GameDev News Art


23. May 2020


Earlier today, Krita just launched the first beta releases of Krita on Android and Chrome OS.  Unfortunately for now it only works for Android tablets and the UI still has many desktop requirements so it may not work as expected, at least without a mouse and keyboard attached.

Details from the Krita website:

Thanks to the hard work of Sharaf Zaman, Krita is now available in the Google Play Store for Android tablets and Chromebooks (not for Android phones).

This beta, based on Krita 4.2.9, is the full desktop version of Krita, so it doesn’t have a special touch user interface. But it’s there, and you can play with it.

Unlike the Windows and Steam store, we don’t ask for money for Krita in the store, since it’s the only way people can install Krita on those devices, but you can buy a supporter badge from within Krita to support development.

Install
Notes
  • Supports: Android tablets & Chromebooks.
  • Currently not compatible with: Android phones.
  • If you have installed one of Sharaf’s builds or a build you’ve signed yourself, you need to uninstall that first, for all users!

Do to the limited number of Android tablets and the massive size of some Android phones, it’s unfortunate a phone release isn’t also available.  Do keep in mind this is early access software, so expect all the bugs that come with that.

Art GameDev News


Tag cloud

    AppGameKit Studio

    See More Tutorials on DevGa.me!

    Month List

    Subscribe to GameFromScratch on YouTube Support GameFromScratch on Patreon Join the GFS Discord Server!
    18. July 2016

     

    Last year I featured PlayCanvas in the Closer Look at game engine series.  It’s a power HTML5 powered 3D game engine that was saddled with a rather confusing pricing model.  Pricing previously looked like:

    pricing

    Then on top of these prices there was an additional tier of pricing for “Organizations”.  It certainly wasn’t an ideal setup.  Thankfully they have streamlined from 7 different price points to 3, while increasing the resources of each tier.  The new pricing looks like:

    image

     

    Much better.  The free tier is mostly unchanged.  You still get 200MB, unlimited public and no private projects.  The personal tier now comes with 1GB and unlimited private projects.  The gotcha with this tier is it requires a PlayCanvas splashscreen.  Finally there is the organization tier which has no custom branding, up to 10GB in space and has additional project management options.  Speaking of those options, many are new to this release:

    An organization offers you a convenient way to manage users and projects for businesses or for larger projects. With an organization you can specify multiple administrators who can add and remove users with project based permissions. Additionally, organization plans come with a convenient single invoice for your business.

    GameDev News


    14. July 2016

     

    In the previous tutorial we looked at the basics of creating an application using the Defold engine, part of that included the built in Atlas type for displaying a sprite.  In this tutorial we are going to look further into sprites.  In case you are unaware, a sprite is simply a 2D graphic with position and is pretty fundamental to modern 2D games, even if sprites are actually faked in 3D.

     

    There is an HD video version of this tutorial here.

     

    In the previous tutorial we started with an Atlas created for us.  This time we are going to create one from scratch.  Don’t worry, it’s easy.  So what exactly is an Atlas?  It’s simply a collection of images in a single source.  The Defold engine itself is resposible for determining the ideal layout for the best performance.

     

    Creating and Populating an Atlas

     

    Creating an Atlas is simple.  In the Project Explorer, right click the folder you want to create the Atlas in and select New->Atlas File

    image

     

    Next name your Atlas file.  In this case I’m going with walker.  The extension is predictably enough .atlas.  Then click Finish.

    image

     

    Now we need some Image files to put in our Atlas.  In this case I am using a selection of images I created earlier but you can use whatever images you want.  If you are a Patreon backer, they are available in the Patreon Dropbox in the folder Art\AnimatedCharacter\Spritesheets\Raw\walk.  Whatever images you go with, simply drag and drop them to the images folder inside the main folder.  If you don’t have such a folder, simply right click and create one.

    GIF

     

    Now make sure Walker.Atlas is open in the editor, then go over to the Outline view, right click Atlas and select Add Animation Group. 

    image

     

    In the properties window, name the animation walk and set the default playback mode to Loop Forward.

    image

     

    Now right click the newly created Walk animation group and select Add Images.  In the popup dialog, select all our newly added images.  You can use CTRL or SHIFT to multiselect:

    image

     

    You will see that Defold automatically arranges all of our frames of animation together into a single atlas:

    image

     

    Be sure to save your Atlas before continuing.  You can preview the animation by right clicking “walk” in the Outline then choosing Play/Stop Animation.

    GIF2

     

    Creating a Sprite

    Now that we’ve got our populated Atlas and a walk animation, how do we use it?  We create a Sprite.

    To do so open up your main level .collection file.  In Outline right click Collection then choose Add Game Object:

    image

     

    I personally changed the ID of mine to walker.  Now right click the newly created game object and select Add Component.

    image

     

    In the Add Component dialog, choose Sprite.

    image

     

    With the sprite selected in Outline, we now need to define some properties, specifically Image and Default animation.

    image

     

    For Image, it will bring up a dialog box, select our recently created Atlas.  If the Atlas isnt shown, make sure everything has been saved.

    image

     

    Next select the Walk animation we defined earlier.

     

    Now your game object Sprite will show in Collection.

    image

     

    In this case our sprite is centered about the atlas.  You can move the sprite using the W key.  ( E and R can be used for rotation and scaling as well ).

    image

     

    Each arrow represents the axis it will be moved along.  Or you can position your mouse inside the square and move freely in any direction.  Position your character then run your game (Ctrl + B) and you should see:

    GIF3

     

    Creating a Tile Source

    You can also use a tile source instead of an Atlas.  A tile source is simply a grid of sprites already arranged into a single image.  To use a tile source instead of selecting Atlas, you select Tile source.  I wont be covering it in detail here ( I will cover tile sources later when we get to tile maps ), but if you want more details check the video where I did cover it.

     

    You can also programmatically program the animation, get callbacks when animations complete, etc... but that requires knowledge of message passing... and that’s in the next tutorial!

     

    The Video

    Programming


    13. July 2016

     

    Spine 3.4 was just released.  Spine is a 2D bone based IK animation system I previously covered in depth here if you are looking for more information.  The 3.4 release brings a number of new features including:paths-tank

     

      • improved transform constraints
      • shearing (skew/squash/stretch)
      • paths and path constraints (see image to right)
      • spine-sfml, cocos2dx and objc now 3.4 compatible
      • spine-csharp, unity, xna and monogame all 3.4 compatible
      • cocos2d-x v2 runtime deprecated
      • new example projects illustrating path functionality
      • runtimes for Flash currently in progress
      • introduction of Beta versions

     

     

     

     

    You can read more about the release here.

    GameDev News


    13. July 2016

     

    Another day another Unity patch.  This one adds documentation for the display API and a handful of fixes including:

     

    Improvements
    • Graphics: Documentation for Display API.
    • Lighting: Improved an error message about invalid data when baking probes.
    • Shaders: Removed an outdated comment in UnityStandardCore.cginc
    Fixes
    • (808817, 805086, 801150) - Android: Fixed clip() in ES3 shaders on some Adreno GPUs.
    • (796182) - Android: Screen.dpi always returns densityDpi now.
    • (798640) - Camera: Stop silently disabling cameras that have non-existing target display set on them.
    • (798576) - Editor: Fixed an issue where the Editor would freeze if the user attempted to import a model without normals when the selected graphics API is OpenGL 2.
    • (785131) - Graphics: Fixed Display.main not always being Display.displays[0] in multi-display configurations.
    • (809864) - IL2CPP/PS4: Corrected the exception "System.Net.Sockets.SocketException: System call failed" which could occur when UDP sockets were used.
    • (809995) - IL2CPP: Corrected an exception during code generation with the NPOI library.
    • (808536) - iOS/IL2CPP: Fixed an error in generated C++ code due to duplicate extern declarations when an extern method in C# is overloaded.
    • (800289) - VCS: Updated VCS plugins from Bitbucket with improved support for IPv6 server connections on Windows and OSX and SSL server connections on Windows, OSX and Linux.
    • (810310) - Windows Store: Fixed enlighten crash on startup when Unity splash was used.
    • (810753) - Windows Store: Fixed an issue where plugins marked for .NET scripting backend were still being used even if building to il2cpp scripting backend or vice versa.

     

    You can download the patch here.

    GameDev News


    12. July 2016

     

    Earlier today I somewhat belatedly mentioned the Godot 2.0.4 release.  In that post I mentioned the upcoming 2.1 release... well I should have waited a few hours, as Beta 2.1Godot has just been released.  Keep in mind however, it is a Beta so buyer beware.  If you are working on a production project, you may be wise to wait for the full release.  The 2.1 release has been focused on improving usability.

     

    The features of this release include:

    • New asset sharing platform: Godot has a new platform for sharing assets between users. It's still rough, but it will improve with time. As of now there is almost no content to test it with, but we will upload some plugins and the demos there in the coming days.
    • New plugin API: Downloaded assets can be used as plugins to extend the editor functionalities. Our first attempt at offering an API for this is still probably incomplete, so help us improve it with your feedback.
    • Support for dynamic fonts: Load TTF and OTF font files directly into your projects. This aids enormously with internationalization.
    • Fully internationalized editor UI: Godot can now be used in several languages and displays all unicode characters properly (including CJK). Right-to-left language support is still unimplemented though.
    • Editor visual customization: Change font sizes or set custom fonts, set custom themes, etc.
    • Customizable keybindings: Most keybindings can now be customized and there is a new binding editor in the editor settings.
    • Live script reloading: Saved scripts in the editor will be reloaded in the running game automatically, and tool scripts will also be automatically reloaded.
    • Profiler & frame profiler: Godot has a fully featured profiler (with graph plotting), which allows going back in time and see the performance numbers and most used functions frame by frame.
    • Remote scene inspector: Inspect the scene tree of the running game live, including nodes and resources.
    • HiDPI/Retina support: Godot detects high resolution monitors and offers the editor UI with native resolution. All Godot icons were redone in vector graphics for the occasion, thanks a lot to @drjmwho did almost all of them!
    • Drag & drop support: Godot now supports drag & drop editor-wide. Dragging assets from filesystem explorer to Godot will also open the relevant import dialogs.
    • Contextual menus: Godot now also supports contextual menus where relevant.
    • Script editor usability improvements: Incremental search, better highlighting, smart function matching in code-completion, etc.
    • Improved asset pipeline: Automatic re-import and reload of assets and scenes when changed.
    • Improved thumbnailer: Previews are updated in real-time, and thumbnails of resources will appear in the inspector.
    • New AnimatedSprite features: Labelled animations, and the ability to play animations without an AnimationPlayer.

    You can download the release here, scroll down to locate the beta link.

    GameDev News


    AppGameKit Studio

    See More Tutorials on DevGa.me!

    Month List

    Subscribe to GameFromScratch on YouTube Support GameFromScratch on Patreon Join the GFS Discord Server!
    15. June 2015

     

    In this chapter we are going to look closely at the structure of a typical XNA game.  By the end you should have a better idea of the life cycle of a typical MonoGame application, from program creation, loading content, the game loop, unloading content and exiting.

     

    If you prefer videos to text, you can watch this content in HD video right here.

     

    Let’s start by looking at the code for an automatically generated application, stripped of comments.  There are two code files in the generated project, Program.cs and [YourProjectName].cs.  Let’s start with Program.cs

    using System;
    
    namespace Example1
    {
    #if WINDOWS || LINUX
        public static class Program
        {
            [STAThread]
            static void Main()
            {
                using (var game = new Game1())
                    game.Run();
            }
        }
    #endif
    }
    

    The heart of this code is the creation of our Game object, then calling it’s Run() method, which starts our game executing, kicking off the game loop until the Game execution finishes.  We will talk about the game loop in a bit more detail later on.  Otherwise this is a standard C# style application, with Main() being the applications entry point.  This is true for  Windows and Linux applications at least, which is the reason for the #if  preprocessor directive.  We will discuss the entry point of various other platforms later on, so don’t worry about this too much.  Also note, if you didn’t select Windows as your platform when creating this project, your own Program.cs file contents may look slightly different.  Again, don’t worry about this right now, the most important thing is to realize that Program creates and runs your Game derived class.

    Predefined Platform Values

    One of the major features of MonoGame over XNA is the addition of several other supported platforms. In addition to WINDOWS and LINUX symbols, the following platforms have been defined:

    • ANDROID
    • IOS
    • LINUX
    • MONOMAC
    • OUYA
    • PSM
    • WINDOWS
    • WINDOWS_PHONE
    • WINDOWS_PHONE81
    • WINDOWSRT
    • WEB

    Of course, new platforms are being added all of the time, so this list may not still be current. You can look up the definitions in the MonoGame sources in the file /Build/Projects/MonoGame.Framework.definition in the MonoGame GitHub repository.

    Please note, there are plenty of other defines per platform, for example iOS, Android, MacOS, Ouya and WindowsGL all also define OPENGL. You can use these predefined symbols for implementing platform or library specific code.

    Now let's move on to our Game class

    using Microsoft.Xna.Framework;
    using Microsoft.Xna.Framework.Graphics;
    using Microsoft.Xna.Framework.Input;
    
    namespace Example1
    {
        public class Game1 : Game
        {
            GraphicsDeviceManager graphics;
            SpriteBatch spriteBatch;
    
            public Game1()
            {
                graphics = new GraphicsDeviceManager(this);
                Content.RootDirectory = "Content";
            }
    
            protected override void Initialize()
            {
                base.Initialize();
            }
    
            protected override void LoadContent()
            {
                spriteBatch = new SpriteBatch(GraphicsDevice);
            }
    
            protected override void UnloadContent()
            {
            }
    
            protected override void Update(GameTime gameTime)
            {
                if (GamePad.GetState(PlayerIndex.One).Buttons.Back == 
                    ButtonState.Pressed || Keyboard.GetState().IsKeyDown(
                    Keys.Escape))
                    Exit();
                base.Update(gameTime);
            }
    
            protected override void Draw(GameTime gameTime)
            {
                GraphicsDevice.Clear(Color.CornflowerBlue);
                base.Draw(gameTime);
            }
        }
    }
    

    Our game is derived from the class Microsoft.Xna.Framework.Game and is the heart of our application. The Game class is responsible for initializing the graphics device, loading content and most importantly, running the application game loop. The majority of our code is implemented by overriding several of Game’s protected methods.

     

    Let’s take a look at the code, starting from the top.  We create two member variables, graphics and spriteBatch.  GraphicsDeviceManager requires a reference to a Game instanceWe will cover the GraphicsDeviceManager and SpriteBatch classes shortly in the graphics chapter, so please ignore them for now.

     

    Next we override the Initialize(), LoadContent and UnLoadContent methods.  The most immediate question you’ve probably got is, why have an Initialize() method at all, why not just do initialization in the constructor.  First, behavior of calling a virtual function from a constructor can lead to all kinds of hard to find bugs in a C# application.  Second, you don’t generally want to do any heavy lifting in a constructor.  The existence of LoadContent() however, will often leave you will an empty Initialize() method.  As a general rule, perform inititalizations that are required ( like GraphicsDeviceManager’s allocation ) for the object to be valid in the constructor, perform long running initializations ( such as procedural generation of terrain ) in Initialize() and load all game content in LoadContent().

     

    Next we override Update() and Draw(), which is essentially the heart of your application’s game loop.  Update() is responsible for updating the state of your game world, things like polling input or moving entities, while Draw is responsible for drawing your game world.  In our default Update() call, we check for the player hitting the back button or escape key and exit if they do.  Don’t worry about the details, we will cover Input shortly.  In Draw() we simply clear the screen to CornFlower Blue ( an XNA tradition ).  You will notice in both examples we call the base class as well.

     

    What's a game loop?


    A game loop is essentially the heart of a game, what causes the game to actually run. The following is a fairly typical game loop:

    void gameLoop(){
       while (game != DONE){
          getInput();
          physicsEngine.stepForward();
          updateWorld();
          render();
       }
       cleanup();
    }

     

    As you can see, it's quite literally a loop that calls the various functions that make your game a game.  This is obviously a rather primitive example but really 90% of game loops end up looking very similar to this.

     

    However, once you are using a game engine or framework, things behave slightly different.  All this stuff still happens, it’s just no longer your code’s responsibility to create the loop.  Instead the game engine performs the loop and each iteration it then calls back to your game code. This is where the various overridden function such as update() and draw() are called.  Looking at our sample loop above though, you might notice a physics engine call.  XNA doesn’t have a built in physics engine, so instead of the game loop updating the physics, you will have to do it yourself in your games update() call.

     

    When you run this code you should see:

    image

     

    Please note, depending on what platform you are running on, this window may or may not be created full screen.  On Windows it defaults to windowed, while on MacOS it defaults to full screen.  Hit the Escape key, or Back button if you have a controller installed, to exit the application.

     

    Let’s take a quick look at a program’s lifecycle with this handy graphic.

    programFlow

    In a nutshell the game is created, initialized, content is loaded, the game loop runs until Exit() is called, then the game cleans up and exits.  There are actually a few more methods behind the scenes, such as BeginDraw() and EndDraw(), but for most games, this is sufficient detail.

     

    Our current example isn’t exactly exciting because absolutely nothing happens.  Let’s create a slightly more interesting example, one that draws a rectangle on screen and rolls it across the screen.  Don’t worry about the specifics, we will cover graphics in more detail shortly.

     

    using Microsoft.Xna.Framework;
    using Microsoft.Xna.Framework.Graphics;
    using Microsoft.Xna.Framework.Input;
    
    // This example simply adds a red rectangle to the screen
    // then updates it's position along the X axis each frame.
    namespace Example2
    {
        public class Game1 : Game
        {
            GraphicsDeviceManager graphics;
            SpriteBatch spriteBatch;
            Texture2D texture;
            Vector2 position;
    
            public Game1()
            {
                graphics = new GraphicsDeviceManager(this);
                Content.RootDirectory = "Content";
                position = new Vector2(0, 0);
            }
    
            protected override void Initialize()
            {
                texture = new Texture2D(this.GraphicsDevice, 100, 100);
                Color[] colorData = new Color[100 * 100];
                for (int i = 0; i < 10000; i++)
                    colorData[i] = Color.Red;
    
                texture.SetData<Color>(colorData);
                base.Initialize();
            }
    
            protected override void LoadContent()
            {
                spriteBatch = new SpriteBatch(GraphicsDevice);
            }
    
            protected override void UnloadContent()
            {
            }
    
            protected override void Update(GameTime gameTime)
            {
                if (GamePad.GetState(PlayerIndex.One).Buttons.Back == 
                    ButtonState.Pressed || Keyboard.GetState().IsKeyDown(
                    Keys.Escape))
                    Exit();
    
                position.X += 1;
                if (position.X > this.GraphicsDevice.Viewport.Width)
                    position.X = 0;
                base.Update(gameTime);
            }
    
            protected override void Draw(GameTime gameTime)
            {
                GraphicsDevice.Clear(Color.CornflowerBlue);
    
                spriteBatch.Begin();
                spriteBatch.Draw(texture,position);
                spriteBatch.End();
    
                base.Draw(gameTime);
            }
        }
    }
    

     

    When we run this we will see:

    gif1

     

    Nothing exciting, but at least our game does something now.  Again, don’t worry overly about the details of how, we will cover this all later.  What we want to do is look at a few key topics when dealing about dealing with the game loop. 

     

    Pausing Your Game

     

    Pausing your game is a pretty common task, especially when an application loses focus.  If you take the above example, minimize the application, then restore it and you will notice the animation continued to occur, even when the game didn’t have focus.  Implementing pause functionality is pretty simple though, let’s take a look at how:

            protected override void Update(GameTime gameTime)
            {
                if (IsActive)
                {
                    if (GamePad.GetState(PlayerIndex.One).Buttons.Back == 
                        ButtonState.Pressed || Keyboard.GetState().
                        IsKeyDown(Keys.Escape))
                        Exit();
                    position.X += 1;
                    if (position.X > this.GraphicsDevice.Viewport.Width)
                        position.X = 0;
                    base.Update(gameTime);
                }
            }
    

    Well that was simple enough.  There is a flag set, IsActive, when your game is active or not.  The definition of IsActive depends on the platform it’s running. On a desktop platform, an app is active if its not minimized AND has input focus.  On console it’s active if an overlay like the XBox guide is not being shown, while on phones it’s active if it’s the running foreground application and not showing a system dialog of some kind.  As you can see, the can pause the game by simply not performing Game::Update() calls.

     

    There may be times when you wish to perform some activity when you gain/lose active status.  This can be done with a pair of event handlers:

            public Game1()
            {
                graphics = new GraphicsDeviceManager(this);
                Content.RootDirectory = "Content";
                position = new Vector2(0, 0);
    
                this.Activated += (sender, args) => {  this.Window.Title = 
                                  "Active Application"; };
                this.Deactivated += (sender, args) => { this.Window.Title 
                                    = "InActive Application"; };
            }
    

    Or by overriding the functions OnActivated and OnDeactivated, which is the recommended approach:

            protected override void OnActivated(object sender, System.
                                                EventArgs args)
            {
                this.Window.Title = "Active Application";
                base.OnActivated(sender, args);
            }
    
            protected override void OnDeactivated(object sender, System.
                                                  EventArgs args)
            {
                this.Window.Title = "InActive Application";
                base.OnActivated(sender, args);
            }
    
     

    Controlling the Game Loop

    Another challenge games face is controlling the speed games run at across a variety of different devices.  In our relatively simple example there is no problem for two reasons.  First, it’s a very simple application and not particularly taxing, meaning any machine should be able to run it extremely quickly.  Second, the speed is actually being capped by two factors, we are running at a fixed time step ( more on that later ) and we have vsync enabled, which on many modern monitors, refresh at a 59 or 60hz rate.  If we turn both of these features off and let our game run at maximum speed, then suddenly the speed of the computer it’s running on becomes incredibly important:

            public Game1()
            {
                graphics = new GraphicsDeviceManager(this);
                Content.RootDirectory = "Content";
                position = new Vector2(0, 0);
                this.IsFixedTimeStep = false;
                this.graphics.SynchronizeWithVerticalRetrace = false;
            }
    

     

    By setting IsFixedTimeStep to false and Graphics.SyncronizeWithVerticalRetrace to false, our application will now run as fast as the game is capable.  The problem is, this will result in our rectangle being drawn extremely fast and at different speeds on different machines.  We obviously don’t want this, but fortunately there is an easy fix.  Take a look at Update() and you will notice it is being passed in a GameTime parameter.   This value contains the amount of time that occurred since the last time Update() was called.  You may also notice Draw() also has this parameter.  This value can be used to smooth out motion so it runs at a consistent speed across machines.  Let’s change our update call so position instead of being ++’ed each frame, we now move at a fixed rate, say 200 pixels per second.  That can be accomplished with this change to your Update() position code:

    position.X += 200.0f * (float)gameTime.ElapsedGameTime.TotalSeconds;
    

    TotalSeconds will contain the fraction of a second that have elapsed since Update() was last called, assuming of course your game is running at at least 1 frame a second!  For example, if your game is updating a 60hz ( second times per second ), then TotalSeconds will have a value of 0.016666 ( 1/60 ).  Assuming your stays pretty steady at 60fps, this results in your Update code updating the position by 3.2 pixels per frame ( 200 * 0.016 ).  However, on a computer running at 30fps, this same logic would then update position by 6.4 pixels per frame ( 2000 * (1/30) ).  The end result is the behavior of the game on both machines is identical even though one draws twice as fast as the other.

    The GameTime class contains a couple useful pieces of information:

    image

    ElapsedGameTime holds information on how much time has happened since the last call to Update (or Draw,  completely separate values by the way ).  As you just saw, this value can be used to normalize behavior regardless to how fast the underlying machine actually performs.  The value TotalGameTime on the other hand is the amount of time that elapsed since game started, including time spend paused.  Finally there is the IsRunningSlowly flag, which is set if the game isn’t hitting it’s target elapsed time, something we will discuss momentarily.  Game also has a property called InactiveSleepTime, which along with TotalGameTime can be used to calculate the amount of time a game spent running.

     

    Fixed Vs. Variable TimeStep

     

    Finally let’s discuss using a FixedStep game loop instead.  Instead of messing with all of this frame normalization stuff you can instead say “Hey, Monogame, I want you to run my game at this speed” and it will do it’s best.  Lets look at this process:

            public Game1()
            {
                graphics = new GraphicsDeviceManager(this);
                Content.RootDirectory = "Content";
                position = new Vector2(0, 0);
                this.IsFixedTimeStep = true;
                this.graphics.SynchronizeWithVerticalRetrace = true;
                this.TargetElapsedTime = new System.TimeSpan(0, 0, 0, 0, 33); // 33ms = 30fps
            }
    

    This will then try to call the Update() exactly 30 times per second.  If it can’t maintain this speed, it will set the IsRunningSlowly flag to true.  At the same time, the engine will try to call Draw() as much as possible, but if the machine isn’t fast enough to hit the TargetElapsedTime it will start skipping Draw() frames, calling only Update() until it’s “caught up”.  If your  You can control the maximum amount of draw calls that will be skipped per Update() by setting MaxElapsedTime.  This value is a MonoGame specific extension and is not in the original XNA.  If you don’t specify a TargetElapsedTime, the default is 60fps (1/60).

     

    Ultimately the decision between using a Fixed Step game loop or not is ultimately up to you.  A fixed step game loop has the advantage of being easier to implement and provides a more consistent experience.  A variable step loop is a bit more complicated, but can result in smoother graphics on higher end machines.  The result is more pronounced on a 3D game than a 2D one, resulting in smoother controls and slightly cleaner visuals.  In a 2D game the difference is much less pronounced.

     

    In the next chapter we will move on to the much more exciting topic of 2D graphics.

     

    The Video

    Programming


    14. June 2015

     

    As mentioned recently, I am in the process of compiling the Godot Game Engine Tutorial Series into an e-book format.  Today I just published the 10 chapter, 150 page first draft of the Godot Engine book.

     

    BookCover

    It can currently be downloaded by Patreon backers right here.

     

    It is currently available in the following formats:

    • PDF
    • epub
    • mobi

     

    Due to the large file size (@15mb) to install on a Kindle you will need to install via side-loading, the file is beyond the limits for emailing to Kindle.

     

    Right now, this is mostly just a straight compilation of content available here on GameFromScratch.com.  I will need to do an editorial pass to make sure text makes sense in book format, as well as replacing now static animated gifs with more meaningful images.  If you prefer to read offline, wish to print or want to reader on an e-reader, this book should be perfect for you.

     

    If you are interested in checking it out, Chapter 8: Using Tilemaps can be downloaded here. Of course, if you’ve already read the Godot tutorial series, this is going to be incredibly familiar.

    Programming News


    14. June 2015

     

    Welcome to a brand new series on GameFromScratch.com covering the MonoGame open source game framework.  Over the next several chapters we will cover almost every factor of using MonoGame for game development.  First we are going to start with a bit of a history lesson and introduction to MonoGame; we’ll talk about where it came from and why you should care.  Don’t worry, we will get to the code and the technical bits very soon!

     

    For the more visually inclined there is also an HD video version covering mostly the same material we will discuss here.

     

    So what exactly is MonoGame?  The simple answer is, it’s a cross platform, open source implementation of the XNA game libraries.   XNA in turn was Microsoft’s indie focused 2D/3D game library.  A more complex answer than that requires a bit of a history lesson.

     

    A Brief History of XNA

     

    XNA stands for XNA’s Not Acronymed, a recursive algorithm and very much on vogue at the time (think GNU or WINE).  Although the more likely reason for the name is X’s were really just quite cool at the time, XBox, X Games, XXX the Movie…  XNA was announced at the Game Developer Conference (GDC) in 2004 as a great and accessible way to bring game development to the masses.  At the time however, we instead got (what eventually became) MS Build and they open sourced the source code and all assets for the game MechCommander 2.  However two years later XNA Game Studio was finally released.

     

    So what exactly was XNA Game Studio?  First off, it was a special version of Visual Studio for C# with an integrated pipeline for importing game assets.  On top of that, it was a collection of .NET libraries aimed at making games, covering facets like input handling, graphics, audio and networking.  Finally it was a special .NET runtime capable of running on PC, (eventually) Windows Phone and perhaps most importantly, XBox 360.  That was the big selling point…  XNA enabled basically anybody to make games for a game console.  Outside of the very limited edition ( and much more expensive ) Net Yaroze ( a special version of the PlayStation 1), nobody had ever done this.  You could argue that XNA more than any other single release, gave rise to the burgeoning indie development scene we have today.

     

    What makes XNA even more impressive is realizing the world it was released in.  Game engines certainly existed, Unreal was AAA only and several million dollars per title, Unity was I believe still a Mac only product and several hundred dollars per seat.  Several of the prominent open source libraries of today simply didn’t exist back then.  Plus the IDE XNA itself was based on, Visual Studio,  cost a few thousand dollars.  XNA really did bring console game development to the masses and many of the “big” indie games, titles like Fez, Braid and Terraria were create using XNA.

     

    It wasn’t all roses though, and even though Microsoft basically invented the indie developer market, it quickly pissed it away too.  XNA titles, without a publisher agreement, were confined to Xbox Indie Games channel as well as Windows Phone stores.  The Xbox IG channel quickly became a dumping ground, discovery became a huge factor and very few developers made money.  With the release of XBox One, it seems Sony stole Microsoft’s crown as the place for indie developers to shine.

     

    Worse, and this is a story that could fill a book on it’s own, there was a shake up at Microsoft and several technologies ended up having their plug pulled.  XNA was one of them.  Sadly, in Oct 2011, with XNA Game Studio 4.0 refresh, XNA saw it’s final release. 

     

    So then, a dead and unsupported technology… why the heck should we care?  Simple… XNA was… is good.  Very good.  Plus “unsupported” isn’t exactly the right word to used.  Enter…

     

    A Brief History of MonoGame

     

    So XNA became very popular very quickly.  There was a large and growing community, several books available on the subject and new versions being released.  Hands down the biggest limitation were the supported platforms, XNA was very much tied to Microsoft platforms and a limited subset at that.  This lead to twoimage different projects, SilverSprite and XNA Touch.  The first was an attempt to make a code compatible version of XNA (at least, the 2D bits) that could be run in the browser using Silverlight.  The other was a port of XNA to run on an OpenGL back end on mobile devices.  XNA Touch ended up using the 2D code from Silver Sprite and the two eventually emerged as MonoGame.

     

    This was several years ago and since then MonoGame has grown into a nearly 100% complete implementation of XNA 4 that can be run on several platforms ( Windows DirectX, Windows OpenGL, Mac, Linux, Android, iOS, PlayStation Vita, PlayStation 4, OUYA and more ).  The biggest hanging point has always been the content pipeline.  Until recently you’ve needed to keep an old version ( and a PC ) Game Studio around to convert your assets into the binary XNB format.  However, near the end of 2014 the MonoGame team provided that final missing piece with the release of their own cross platform content pipeline tool.    It will be interesting to see what the future holds now that the MonoGame team have basically implemented 100% of XNA.  The future of XNA is now theirs to determine.

     

     

    Why should I use MonoGame?

     

    So, that was a bit of XNA history for you.  The biggest question you may have now is… “So what?  Why should I use XNA/MonoGame today?”

     

    Sometimes it is often easier to start with why you shouldn’t use something.  The following are the biggest reasons I can think of not to use MonoGame.

    • You want a WYSIWYG environment or integrated game editor
    • You don’t like C#
    • You want a higher level programming experience
    • There is a price tag attached to support iOS and Android

     

    Those are probably the biggest drawbacks of using XNA.  There is no world editor.  In fact, there are very few tools at all, except content importers.   Even the libraries themselves are fairly low level, leaving you to roll your own sprite and animation classes for example.  XNA is also not the easiest library to learn, especially compared to many scripting languages or all in one solutions like GameMaker or Construct.  That coding is done in C# ( or other Mono supported languages like F#, but 99% of examples are in C# ), so if you aren’t a fan of that language, you wont like MonoGame.  Finally, and perhaps worst, targeting iOS or Android requires a Xamarin license, and that costs money.

     

    So that’s why you shouldn’t use MonoGame, now why you should.

     

    First off, because XNA was and is just a great library!  It was well designed, very clean and works well.  Simply put, if you like working in C# ( and I do, very much ), working in XNA is just a very pleasant coding experience.  You work at a lower level of abstraction than many of todays game engines, but after being around for about a decade, there are a huge amount of code samples and libraries to fill those pieces.  The core though, those pieces every game needs, they are all provided.  If you are the type of person that likes to have maximum control, to dig in deep and get your finger nails dirty, you’ll feel right at home!

     

    Also, MonoGame provides access to pretty much every single platform you’d want to target today.  One of the scary things about working with some open source game project is, you never know how well they will work in the real world.  Fortunately, MonoGame has an pretty impressive resume of shipped titles, such as:

    • Bastion
    • Fez
    • Infinite Flight
    • Skulls of the Shogun
    • Transistor

    Some of the biggest selling indie game, from both the past and the present, prove that MonoGame is capable. 

     

    So basically MonoGame is a battle proven cross platform indie friendly code focused C# based game engine built on the bones of Microsoft’s XNA.  Now, let’s jump into the technical aspects and you can see why I am such a big fan of the XNA libraries in the first place.  Along the way we will cover the way MonoGame does things differently, and look at some of the unique concerns that cross platform development bring.  Next however, let’s look at getting MonoGame up and running on your platform of choice.

     

    The Book

     

    While I am compiling this tutorial series on GameFromScratch.com, I am also compiling the entire series for an e-book release.   In the end the tutorial series and the book will contain virtually identical content.  I will be compiling new WIP releases of the book as I go and those will be made available to Patreon backers as a thank you reward.  So if you enjoy this series but would prefer it offline or printed in a PDF or Kindle/Kobo friendly format, or if you simply wish to help support GameFromScratch (or both!), your support is certainly appreciated.  Once the series is “complete”, I will do a formal compilation with proper forward, index and table of contents and make this book available on popular book stores for purchase.  Basically I am publishing a book in the open, while I develop it.  Just instead of the traditional model, this one is available completely free and has a video tutorial series to go along with it!

     

    As always, your feedback is appreciated.  If you have any requests, comments or suggestions, please let me know and I will see what I can do!

     

    The Video

    Programming


    13. June 2015

     

    This is a topic that seems to cause some degree of confusion, especially among new game developers.  We often here the terms “game library”, “game framework” and “game engine” but what is the difference, where does one end and the next begin?  This post attempts to explain the difference as clearly as possible.  It’s important to note, there isn’t a hard and fast definition for each term, basically the meaning prescribed to each is formed by the most popular usage.  I suppose that’s true with most modern words.

     

    Library

    A library is simply put a collection of code and data intended for reuse.  Libraries are often compiled binaries, such as DLLs, but don’t have to be.  Plenty of JavaScript libraries exist for example, while entire template libraries in C++ are pure code.  In game development terms, a library generally is a collection of code for performing tasks from a specific domain.  For example, playing audio, performing physics, handling input.

    Gamedev examples of libraries include FMOD, RakNet, Box2D or Assimp.

    There can be some ambiguity here, as FMOD for example contains some tools and calls itself “middleware”, while Box2D refers to itself as an “engine”, both are still essentially libraries.

     

    Framework

    What happens when you gather a bunch of libraries together, throw in a couple of tools, assembling all the ingredients you need to start creating a game?  Well, you’ve got yourself a framework.  Essentially a framework is a collection of libraries and tools that go together to solve a given task, in this case, making a game.

    Gamedev examples include SFML, OGRE, LibGDX and MonoGame.

    SFML is a good example of the relationship between libraries and frameworks.  SFML is composed of several libraries… graphics, input, window, audio, etc…  Collected together as a whole they become the framework SFML.  LibGDX is a slightly more interesting example as the inclusion of Scene2D straddles the line between framework and game engine a bit closer than most. 

     

    Game Engine

    So, a library is a collection of code to accomplish a task, a framework is a collection of libraries to create a game, we does something become an engine?  This classification is probably the least defined but in my opinion two key things separate a framework from a game engine.  In addition to providing all the various libraries needed to create a game, a game engine must include:

    • a scene graph
    • a world/level editor

    The scene graph is essentially the data structure that  holds a game’s world.   Generally there are a number of supporting functions for managing, searching and saving the scene graph as well, although often these are left to the game itself to implement.  The level/world editor requirement is probably the biggest distinguishing factor, although there exist some game engines (often 2D) that have no editor ( although I would then argue they are in fact frameworks ).

    Game Engine examples include Unity , Unreal, Construct2, GameMaker, HeroEngine and Copperlight.

     

    Quite often however, frameworks and engines will be used interchangeably.  Even here on GameFromScratch, the game engine resource refers to both game engines and frameworks using the same moniker.  This is because frankly, at the end of the day, it’s a matter mostly of semantics.

     

    What about APIs and SDKs

    This is another point of confusion for developers…  what’s the difference between an API, an SDK or simply a library?

    Well an API is generally one or more library, as is an SDK.  An API ( Application Programmer Interface ) is generally a programmatic interface to another product.  That product could be an entire operating system, or an embedded programmable interface within a game.  That interface is generally provided in the form of libraries.

    An SDK (Software Development Kit) is generally the same thing as a framework.  While a framework is a collection of libraries and tools used to create a game, an SDK can be a collection of tools and libraries to create device drivers for your OS, to use or integrate a technology or hardware such as the Oculus Rift or Android phones.  Of course and SDK can also be aimed at creating games, like DirectX or GameKit.  Then of course just to make life even more confusing, you can have a SDK/API/Library combo, like OpenGL.

    Generally where APIs and SDKs vary from everything else discussed today is who provides them.  Quite often these are provided by the OS or hardware manufacturers.

    General


    12. June 2015

     

    So as I announced yesterday, I am currently in the process of reworking some existing GameFromScratch tutorials into book formats.  This presents one particular challenge… animated gifs.

     

    While animated gifs are mostly used these days for memes and cat pics, they can also be extremely useful in tutorials.  If you need to demonstrate short bit of animated process, the animated GIF works perfectly.  They are reasonably small, with ok visual quality, can automatically loop, play automatically and require no plugins. However when it comes to the printed (or virtual printed) page, they simply don’t work.

     

    So I’ve struggled how to deal with converting these animated gifs.  In some cases it’s simply impossible and I will have to re-write the description, especially when I need to show a lot of detail.  However I have come up with a workable solution and I figured I would share it with you.  This is making heavy use of the swiss army knife of image manipulation ImageMagick.  It’s a free, battle tested set of tools and libraries for manipulating images, and it’s amazingly powerful.

     

    Consider this following animated gif:

    Source

     

    How can we represent this as a non-animated gif.  We can easily extract the first frame and display it as a non-animated image, but there is very little value in this.

     

    We can however create a montage and the results do a decent job of demonstrating motion in a static image.  First we need to split out our image into individual frames.  This can be done with ImageMagick using:

    convert -coalesce source.gif frames.png

     

    This splits your image into a sequence of frames like so:

    Ss1

     

    The coalesce command incorporates the background into each frame, otherwise you only get the portions of the animated gif that actually changed.  Now what I am going to do is prune down from 20 frames of animation to about 6 by simply selecting and deleting every other image, twice.  There is certainly a way to automate this process, but with 20 images its faster to just manually select and delete the extra frames.

    Finally we are left with these frames:

    Ss2

    Now let’s assemble them into a single image, ImageMagick comes to the rescue again:

    montage -geometry 256x128 frames-0.png frames-4.png frames-8.png frames-12.png frames-16.png frames-20.png results.png

     

    Again with several images this process could obviously be scripted.  Essentially what you are doing is making a single image out of all of these frames, with each frame being 256x128 in size, resulting in:

    Results

     

    Obviously not as effective as an animated gif, but it conveys the same information in a single image and more importantly, can be printed.

     

    I’ll admit, that had absolutely nothing to do with Gamedev but it took me several hours to figure out how to “unanimate” an animated gif, so I figured I’d share the process for others that might be struggling with the problem.


    Quick Warning to MacOS users

    The above process works flawlessly with Windows, however on MacOS with ImageMagick installed via HomeBrew, when you run the montage command you will get the error:

    unable to read font (null)

    This is because you need to install another package, ghostscript.

     

    When installing simply do:

    brew install imagemagick

    brew install ghostscript

     

    Then it should work just fine.


    Tag cloud

      AppGameKit Studio

      See More Tutorials on DevGa.me!

      Month List

      Defold Engine 1.2.114
      Subscribe to GameFromScratch on YouTube Support GameFromScratch on Patreon Join the GFS Discord Server!
      3. October 2017


      There is a new release of the Lua powered 2D Defold game engine, bringing the version to 1.2.114.  If you’ve never heard of the Defold game engine we have a complete tutorial series to get you started, available here.  This new releases adds support for Facebook’s new GameRoom App Store for Windows platforms only. 



      Details of the release from the release notes:

      Engine

      • DEF-2505- Added: Facebook Gameroom integration
      • DEF-2896 - Fixed: Added more allowed libs when building android (native extensions)
      Work In Progress
      Native Extensions + Linux

      When updating the build server to Ubuntu 16.04, we’re also migrating our own
      CI pipeline to use the same Docker container. We’re doing this to minimize the configuration overhead.

      While doing this, we need to update a lot of smaller things in our pipeline, and also we’re cleaning up
      old technical debt. But, we’re seeing light at the end of of the tunnel now, and we can hopefully release this feature
      to you soon.

      Lazy loading of factory assets

      We’re also reworking how the assets are loaded in the game.
      Instead of loading all assets up front, we’re now loading the assets right before they’re needed.
      This feature should help out the developers that have many and/or large

      Frame throttling

      We’re also making sure the engine respects the “update_frequency” setting while still using VSync.
      This will remove the issue of having the game run too fast.

      GameDev News


      blog comments powered by Disqus

      Tag cloud

        AppGameKit Studio

        See More Tutorials on DevGa.me!

        Month List