Subscribe to GameFromScratch on YouTube Support GameFromScratch on Patreon

14. May 2018

Details


orx-project.org

ZLib License

View On YouTube

  

Orx is a cross platform open sourced 2D game framework written in C and available on Github under the permissive ZLib source license.  What makes Orx somewhat unique among it’s peers is the data driven approach that Orx takes.  Instead of storing game data using a collection of objects in code, it is instead split out into data files.  This enables you to quickly change the content of your game without having to do a recompilation.   So for example you make have an entry like the following for defining the camera in your scene:


[Viewport]
Camera            = Camera
BackgroundColor   = (255, 180, 0)

[Camera]
FrustumWidth  = 1024
FrustumHeight = 768
FrustumFar    = 1.0
FrustumNear   = 0.0
Position      = (0.0, 0.0, -1.0)
;Zoom          = 3.0

By editing this config file you can make major alterations to the camera without having to recompile your code.  Chance the FrustrumWidth in the ini file, and the next time you run your game’s window will be smaller.  Now let’s look at the code required to consume the Viewport/Camera data in your C/C++ application:

orxViewport_CreateFromConfig("Viewport");

Yep, that’s it.  This will create the viewport, notice the camera property and create one of them as well, entirely driven by data. 


This approach has a couple of advantages.  First it creates a clean separation of code and data which should in theory make for easier to maintain code.  It also takes these values out of the compilation process, meaning changes do not require you to recompile your code.  Additionally, this data driven approach makes creating tools for you game a cinch, as you are simply writing out simple easily understood text files. 


There are of course disadvantages too.  Since you moved the code out from the compiler, you lose features such as intellisense as well as compile time error checking.  Moving more details off into data files can make hunting down bugs even more difficult.


Let’s take a quick look at one of the samples from the Orx tutorials, with the comments stripped down for brevity.

#include "orx.h"
orxOBJECT *pstSoldier;

orxSTATUS orxFASTCALL EventHandler(const orxEVENT *_pstEvent)
{
  orxANIM_EVENT_PAYLOAD *pstPayload;

  /* Gets event payload */
  pstPayload = (orxANIM_EVENT_PAYLOAD *)_pstEvent->pstPayload;

  /* Depending on event type */
  switch(_pstEvent->eID)
  {
    case orxANIM_EVENT_START:
    {
      /* Logs info */
      orxLOG("Animation <%s>@<%s> has started!", pstPayload->zAnimName, orxObject_GetName(orxOBJECT(_pstEvent->hRecipient)));

      break;
    }

    case orxANIM_EVENT_STOP:
    {
      /* Logs info */
      orxLOG("Animation <%s>@<%s> has stopped!", pstPayload->zAnimName, orxObject_GetName(orxOBJECT(_pstEvent->hRecipient)));

      break;
    }

    case orxANIM_EVENT_CUT:
    {
      /* Logs info */
      orxLOG("Animation <%s>@<%s> has been cut!", pstPayload->zAnimName, orxObject_GetName(orxOBJECT(_pstEvent->hRecipient)));

      break;
    }

    case orxANIM_EVENT_LOOP:
    {
      /* Logs info */
      orxLOG("Animation <%s>@<%s> has looped!", pstPayload->zAnimName, orxObject_GetName(orxOBJECT(_pstEvent->hRecipient)));

      break;
    }

    case orxANIM_EVENT_CUSTOM_EVENT:
    {
       /* Logs info */
       orxLOG("Animation <%s>@<%s> has sent the event [%s]!", pstPayload->zAnimName, orxObject_GetName(orxOBJECT(_pstEvent->hRecipient)), pstPayload->stCustom.zName);

      break;
    }
  }

  /* Done! */
  return orxSTATUS_SUCCESS;
}

/** Update callback
 */
void orxFASTCALL Update(const orxCLOCK_INFO *_pstClockInfo, void *_pstContext)
{
  orxVECTOR vScale;

  /* Is walk right active? */
  if(orxInput_IsActive("GoRight"))
  {
    /* Sets walk right as target anim */
    orxObject_SetTargetAnim(pstSoldier, "WalkRight");
  }
  /* Is walk left active? */
  else if(orxInput_IsActive("GoLeft"))
  {
    /* Sets walk left as target anim */
    orxObject_SetTargetAnim(pstSoldier, "WalkLeft");
  }
  /* No walk active */
  else
  {
    /* Removes target anim */
    orxObject_SetTargetAnim(pstSoldier, orxNULL);
  }

  /* Is scale up active ? */
  if(orxInput_IsActive("ScaleUp"))
  {
    /* Scales up the soldier */
    orxObject_SetScale(pstSoldier, orxVector_Mulf(&vScale, orxObject_GetScale(pstSoldier, &vScale), orx2F(1.02f)));
  }
  /* Is scale down active? */
  if(orxInput_IsActive("ScaleDown"))
  {
    /* Scales down the soldier */
    orxObject_SetScale(pstSoldier, orxVector_Mulf(&vScale, orxObject_GetScale(pstSoldier, &vScale), orx2F(0.98f)));
  }
}


/** Inits the tutorial
 */
orxSTATUS orxFASTCALL Init()
{
  orxCLOCK       *pstClock;
  orxINPUT_TYPE   eType;
  orxENUM         eID;
  orxINPUT_MODE   eMode;
  const orxSTRING zInputWalkLeft;
  const orxSTRING zInputWalkRight;
  const orxSTRING zInputScaleUp;
  const orxSTRING zInputScaleDown;

  /* Gets input binding names */
  orxInput_GetBinding("GoLeft", 0, &eType, &eID, &eMode);
  zInputWalkLeft  = orxInput_GetBindingName(eType, eID, eMode);

  orxInput_GetBinding("GoRight", 0, &eType, &eID, &eMode);
  zInputWalkRight = orxInput_GetBindingName(eType, eID, eMode);

  orxInput_GetBinding("ScaleUp", 0, &eType, &eID, &eMode);
  zInputScaleUp   = orxInput_GetBindingName(eType, eID, eMode);

  orxInput_GetBinding("ScaleDown", 0, &eType, &eID, &eMode);
  zInputScaleDown = orxInput_GetBindingName(eType, eID, eMode);

  /* Displays a small hint in console */
  orxLOG("\n- '%s' & '%s' will change the soldier's animations\n- '%s' & '%s' will scale the soldier", zInputWalkLeft, zInputWalkRight, zInputScaleUp, zInputScaleDown);

  /* Registers event handler */
  orxEvent_AddHandler(orxEVENT_TYPE_ANIM, EventHandler);

  /* Creates viewport */
  orxViewport_CreateFromConfig("Viewport");

  /* Creates soldier */
  pstSoldier = orxObject_CreateFromConfig("Soldier");

  /* Gets main clock */
  pstClock = orxClock_FindFirst(orx2F(-1.0f), orxCLOCK_TYPE_CORE);

  /* Registers our update callback */
  orxClock_Register(pstClock, Update, orxNULL, orxMODULE_ID_MAIN, orxCLOCK_PRIORITY_NORMAL);

  /* Done! */
  return orxSTATUS_SUCCESS;
}

/** Run function
 */
orxSTATUS orxFASTCALL Run()
{
  orxSTATUS eResult = orxSTATUS_SUCCESS;

  /* Should quit? */
  if(orxInput_IsActive("Quit"))
  {
    /* Updates result */
    eResult = orxSTATUS_FAILURE;
  }

  /* Done! */
  return eResult;
}

/** Exit function
 */
void orxFASTCALL Exit()
{
  /* We're a bit lazy here so we let orx clean all our mess! :) */
}

/** Main function
 */
int main(int argc, char **argv)
{
  /* Executes a new instance of tutorial */
  orx_Execute(argc, argv, Init, Run, Exit);

  return EXIT_SUCCESS;
}


#ifdef __orxMSVC__

// Here's an example for a console-less program under windows with visual studio
int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow)
{
  // Inits and executes orx
  orx_WinExecute(Init, Run, Exit);

  // Done!
  return EXIT_SUCCESS;
}

#endif // __orxMSVC__

This example illustrates a simple animation.  The game loop itself consists of implementing 3 simple functions, Init(), Run() and Exit() for handling various stages of the lifecycle.  The actual game loop itself is the Update callback function which is called continuously as your game is run.  Speaking of which, here is the code running.  The left and right arrow keys toggle between the animations, while up and down scale accordingly.

GIF


Now the “guts” of this example is actually in the ini file containing the data.  Let’s take a look:

[Display]
; In this example, we use the same size for the screen display than our camera's frustum so as to obtain a 1:1 ratio
ScreenWidth   = @Camera.FrustumWidth
ScreenHeight  = @Camera.FrustumHeight
Title         = Anim Tutorial
Smoothing     = false
[Resource]
Texture = ../data/object 

[Input]
SetList = MainInput

[MainInput]
KEY_ESCAPE = Quit

KEY_LEFT   = GoLeft
KEY_RIGHT  = GoRight
KEY_UP     = ScaleUp
KEY_DOWN   = ScaleDown

[Viewport]
Camera = Camera

[Camera]
FrustumWidth  = 640
FrustumHeight = 480
FrustumFar    = 1.0
FrustumNear   = 0.0
Position      = (0.0, 0.0, -1.0)

[Pivot]
Pivot = (15.0, 31.0, 0.0)

[[email protected]]
Texture = soldier.png

[Soldier]
Graphic             = Graphic
AnimationSet        = AnimSet
Scale               = 4.0

[AnimSet]
Direction   = right # down
StartAnim   = IdleRight
KeyDuration = 0.1
Digits      = 1
FrameSize   = (32, 32, 0)

Texture     = soldier_full.png
Pivot       = @Pivot

IdleRight   = 1 ; <= We only want one frame
IdleLeft    = 1
WalkRight   = -1 ; <= We want as many frame that can fit in the texture defined by WalkRight
WalkLeft    = -1

IdleRight-> = IdleRight 
IdleLeft->  = IdleLeft 
WalkRight-> = WalkRight 
WalkLeft->  = WalkLeft 

[IdleLeft]
Flip        = x

[WalkLeft]
Flip        = x

[IdleRight]
Direction   = left

[IdleLeft]
Direction   = left # up

[WalkRight1]
KeyEvent    = !!Left!!

[WalkRight4]
KeyEvent    = !!Right!!

[WalkLeft1]
KeyEvent    = !!Right!!

[WalkLeft4]
KeyEvent    = !!Left!!

As you can see, just about every aspect of the game is data driven here, from the animation names, the source graphic files, to the camera, viewport and even keys pressed and the corresponding binding to call for each key.


This post only scratched the service of how Orx works, but should give you an idea of the data driven approach they have taken.  It certainly wont be for everyone, but it could be a great fit for many people.  If you are interested in giving Orx a shot, be sure to check out our video, which is also embedded below, to walk through the installation process and get you up and running.  Then it’s time to jump into the extremely thorough getting started guide and tutorials available on the Orx website.

Programming , ,

12. February 2018


Today Unity have released a very high quality and full featured 2D Game Kit, available here.  The kit is a combination of 2D platformer game with multiple levels, a loading screen etc.  It has been designed in such a way that much of the game content can be customized and configured without ever having to write a single line of code.  Additionally there is a step by step tutorial series as well as comprehensive reference material that show you how to create your own 2D game using the game kit.  The kit is available completely free and can be downloaded from the asset store.


If you are interested in seeing the Unity 2D game kit in action be sure to check out this quick video, which is also embedded below.


Programming, GameDev News , ,

6. February 2018


Today on /r/gamedev a new online tool for generating procedural 2D sprites was just released.  I did a quick video of Spritify in action you can check out here on embedded below.  Spritify is a free browser based tool for generating procedural sprites.   The tool is quite simple but could certainly use some improved documentation ( or… any documentatio for that matter! ) but it is certainly usable now.


Essentially you start by painting on a fat grid pixel display using these controls

image


Draw the contour and your shape, fill the body accordingly with optional mirroring like so:

image


Various controls are available about how your sprites should be generated:

image


And at the bottom of the screen, several different procedural sprites will be generated:

image


Pretty cool tool over all.


Art , ,

22. January 2018


BladeCoder Adventure Engine 2.0 was just released today.  BladeCoder is an adventure game focused game engine that is open source (Apache 2) and built over the LibGDX Java game framework.  I previously featured the BladeCoder engine in the Closer Look series available here.


New changes to this release include:

  • HelpScreen doesn't stretch in 4:3 aspect ratio.
  • InkManager translation files support.
  • Import ink texts in order. Better I18N checks.
  • Add music volume fade support in MusicVolume action.
  • VoiceManager doesn't hide texts, now waits to the calc time.
  • FIX: bug when saving ink cb.

I recorded a video going hands-on with the newest version available here and embedded below.

GameDev News ,

6. December 2017


GameMaker is a seminal game engine, with roots dating back to the late 1990s.  It is a cross platform 2D game engine with tools that run on Windows and Mac machines while capable of targeting both desktop operating systems as well as Ubuntu Linux, Android, iOS, UWP, HTML5, XBox One and PlayStation 4 consoles.  GameMaker is commercial software with a free trial available, we will discuss pricing shortly. 

The closer look series is a combination of overview, review and getting started tutorial aimed at helping you decide if a given engine is the right choice for you.  As always, there is an HD video version available here and embedded below.

Let’s jump right in with GameMaker Studio 2!


The Tools

GameMaker Studio is an all in one integrated environment for creating games.  It includes everything you need in a single application with a tabbed working environment and a unique virtual desktop style approach supporting multiple editing windows at once.  The all in one all tools at hand nature of GameMaker is probably one of it’s greatest selling points.


The Main Interface

image


Side and bottom panels can be collapsed down to give more room:

image


The primary work area is tabbed, supporting multiple open views at once:

image


As mentioned earlier, GMS has a workspace setup that enables you to work with and pan between multiple editors at once, like a giant virtual desktop.

GMSDesktop


The resource panel is commonly used across the various editors and contains the various assets that make up your game.  You can also drag and drop assets onto this window to import them for use in your game.  For example, dropping in an image file will create a new Sprite entity for you.

image


You can also create new entities via the dynamic right click menu.  For example, right clicking the Tile Sets area will bring up this menu:

image


The Room Editor

image

This is your traditional level editor, where you can create various layers of entities that compose your game level.  A top left you have the layers controls, enabling you to create/delete/hide the various layers that make up your game.  Layers can be composed of instances (objects), backgrounds, tile maps and paths.  The editors below the layer controls change dynamically based on what kind of layer is selected.


Selecting a tile layer brings up the tile map editing tools, including a palette of tiles you can paint with.

image

GMS even has support for auto tiling, if your tileset is compatible.


The Sprite Editor

image

This editor enables you to define how a sprite is imported, the various frames of animation if any as well as a preview of the sprite or animation.  Additionally, clicking Edit Image brings up a full blown image editor within GameMaker.

image

This is a full blown sprite editing package with a variety of brushes available, full layer support, the ability to paint across frames, several tools such as text tools, polygon tools, a magic wand selection tool, mirroring tools and more.  Pretty much all the functionality you would expect for creating or editing sprites is available directly in GMS.


Sound Editor

image

You also have control over sound effect details via the sound editor/mixer.  Supported audio files include wav, mp3, wma and ogg.


Tileset Editor

image


As mentioned earlier, the room editor has full support for tileset layers.  There is an editor for defining tilesets as well as defining auto tiling support.  There are also editors for defining tile animations and creating predefined tile brushes.


Path Editor

image

This editor is used to define paths, either straight line or curves.  Often used for AI paths, the generated paths can be used and editing directly in the room editor.


Script Editor

image


This is the built in editor for developing games using GameMaker Script.  It has syntax highlight, code suggestions and a selection of other features.

image

The code editor is also used for shaders.


Drag and Drop Editor

In addition to GMS scripting, GameMaker also provides a drag and drop programming option.

image

You can use drag and drop from the toolbox to script your programs behaviour.  We will cover both programming options in more detail shortly.


Font Editor

image


Enables you to import and preview fonts for use in your game.  Fonts can be in either true type or open font formats.


Object Editor

image

The Object Editor is where you will start to tie your various resources together.  For example, your main character will be an object that connects to a sprite, while handling various different events.  Objects are created in the Object Layers in the room editor and generally represent the entities that make up your world.  We will look at objects in a bit more detail later.


Programming In GameMaker

You may be wondering at this point how exactly you implement gameplay logic in your GameMaker game?  Essentially you attach logic to objects in the game world.  When you edit an object you will notice there is an Events option.

image


Click the Add Event button and you will see the various events you can respond to in your game:

image


These are called at various points by the game engine and are analogous to the game loop in other engines.  Step is called once per pass through the game loop and is most commonly where you will handle update logic.  There are also events for when the object is created, destroyed, etc… as well as various options for responding directly to events such as collisions, touches, etc.


You can also wire up code to be called when a Room is created, via the Creation Code button:

image


Next it’s a matter of deciding HOW you want to program in GameMaker, via Drag and Drop as well as directly using GameMaker scripting.


Scripting

Scripting is done using Game Maker Language, or GML, which is a C like scripting language.  The syntax is fairly simple and if you’ve had any prior C, Python, C++ or similar language experience, picking the language up should be fairly simple.  There are built in methods for most functions you would want to perform such as graphics drawing, audio code, networking, platform specific tasks like in app purchases etc.  There are also built in data types such as Stacks, Lists, Maps and Queues.  Actually teaching GML is beyond the scope of this document but you can access the language reference here.

If functionality is lacking it may be available on the GameMaker Market Place or you can add it yourself by creating a native extension.  You can add new functions to GML in this manner.


Drag And Drop

Programming via drag and drop in GameMaker is your other option and is a great choice for people that just want to jump in and figure things out on their own.  Don't worry too much about performance as the DnD code is ultimately generating GML script so performance should be roughly the same.  In fact, you can switch freely between the two programming methods at will within the same project or call GML directly in your DnD script.

Creating scripts in DnD is as simple as dragging in predefined functions to create a flow chart of sorts that occurs top down, like so:

GMLDnD

Once again, you can freely switch between the two methods.  Additionally, in any script your can right click and select Convert To Drag and Drop.  A reference of all the drag and drop tiles is available here.


The Price

GameMaker is commercial software, so that means there is a price tag attached.  There are multiple versions available for GameMaker as well as addition platforms coming with an additional price tag.  Pricing (as of today, 12/6/17) breaks down as follows:

image

image


In addition to these various different platforms, there is also now a new $39 per year ( most of the above non-console licenses are permanent buy once ) Creator Edition aimed at hobbyist developers.  It is fully featured but requires you to choose Windows or Mac and also requires your game display a splash screen.  There is also a heavily limited free trail available.  For more information on pricing or to download the trial visit here.


Community and Documentation

As you might expect for such a long lived game engine, there is also a very well established community.  The forums are available here.  With almost 20K registered users and 230K posts, the forums are quite active and contain a wealth of knowledge, although much of it is for earlier 1.x versions.  Questions seem to be answered fairly quickly.  In addition to the forums there is also the YoYoGames help desk containing several guides and how-tos.

There is also a fairly comprehensive GameMaker Studio manual available online which can be opened directly within Studio.

Additionally, there are several books available for GameMaker Studio such as:


In addition there are several tutorials and start kits available on the online marketplace, which we will talk about…


Online Marketplace

Quickly becoming the must have feature of modern game engines, GameMaker has an online store available, containing free and commercial assets including demos, scripts, sprites, shaders, extensions and more.

image

You do not need to have GameMaker Studio installed to access the marketplace, you can browse it in your browser here.


Conclusion


At the end of the day, GameMaker Studio faces a challenging new world as it is facing increasing competition from free and free to start game engines.  Is it worth it?  That is impossible for me to answer, as value is very subjective.  Game Maker is certainly a very complete 2D engine with a vibrant community and tons of resources.  Compared to the previous versions, the 2.x editor contains a great deal more polish and most every tool you would need is included out of the box.   Game Maker has certainly proven itself a production capable engine, having powered such titles as Hotline Miami, Undertale and Spelunky, all titles that have seen commercial success.

A proven catalog of game is always a strong selling point.

Personally, if you are working on a 2D title using Windows or Mac, Game Maker is certainly worth considering.  Do keep in mind however that as you add more platforms, you also add more cost.  In many cases though, this means you are ready to commercialize your title, so hopefully cost isn't as much of a concern.  I do think however they are making a mistake in charging for the Creator Edition.  Personally I would do away with the trial completely, make Creator free and charge people to deploy to additional platforms.  If this was the case it would be a great deal easier for me to recommend you check out GameMaker yourself.  Without a free option, its hard to recommend in the face of so many free/free to start options out there.  The engine is great, productive, proven and easy to learn… just saddled with a bit of a dinosaur business model.


The Video

Programming, General, Design , , ,

Month List

Popular Comments