Introduction

So you have an idea that you think might be the next great hit in the game world.  How you do you go about creating it?  Finding the way forward on a project can be extremely confusing at first as there are many paths forward and making an informed decision requires speeding a large amount of time exploring and understanding the ins and outs of the options available as they are often complex and have high learning curves.

When you get down to it, there are really 2 broad categories you can choose from, and finding the answer to this is actually pretty straight forward once you know how to evaluate the options.  Option 1 is to build some sort of native game, this may be done with either the platform SDK or native development tools, or a cross platform game engine or framework.  Platforms are diverse and while we are primarily concerned with mobile devices here, it is worth mentioning that some cross platform approaches include the ability to compile native for game consoles and PC’s as well.  Option 2 is to build a web based game that has the majority or the entirety of its code base served over the web.  Hybrid options can be used as part of this option as well, usually to create a simple native wrapper that manages access and presentation of the core application and offers additional hardware control.

Defining the architecture and choosing how to create a mobile game complicated.  The amount of time invested in game development is usually higher when compared to many other types of applications and the requirements on hardware are higher generally as well.  This leads to scenarios that favor native, lower level development or use of proprietary game engines such as Unity or Unreal which effectively get you to the same place using a cross platform approach.  This sometimes complicates use of more universal and platform inclusive development methods when using a native approach, or introduces higher costs to pay for use of or royalties to the frameworks used.  There are some cross platform approaches that are a good middle ground, offering a low or no cost option, such as LibGDX and we will explore those as well.  

The biggest factor leading to a successful result is being objective about your games requirements.  How intense are the graphics?  How much horsepower does the game actually need?  If you can develop in some flavor of web based technologies such as HTML5 CSS and JavaScript, you can then choose your delivery method, weather it is straight web based in a browser, cross platform, hybrid or even PWA.  If creating your application in web based technologies is not the right option for you, there are also cross platform options where you can develop in Java, C# or even C++ and compile to native code.  Some of these such as the LibGDX library will also allow you to create an HTML version of the application based on the same Java codebase.  

If you require more hardware resources for graphics or AI cpu intensive work, your best option would be a cross platform native approach with an established game engine such as Unity or Unreal, or straight native development.  We will look at both approaches here.  While you will get the best results for CPU intensive work, this is going to be the most expensive option.  Both in terms of developer time and / or royalties paid to the game engine vendor if you decide to go that route.

Option 1: Native Development (Really Native)

Unfortunately it getting harder to create native games cross platform using industry standard methods such as C++ and OpenGL.  Android offers excellent support in this area, even offering the Android Native Developer Kit (NDK).  The NDK lets you implement parts of your app in native code, bypassing the SDK and the Android Runtime completely.  Apple however is moving in the other direction, having recently announced they are deprecating support for OpenGL and OpenCL as of OS X 10.14 and iOS 12.  (ref: https://developer.apple.com/macos/whats-new/, https://developer.apple.com/ios/whats-new/).  In combination with the difficulty of building native C++ code for iOS (although there is compatibility and the ability to use C++ libraries with Objective-C)  using low a low level native approach is currently not the path of least resistance if you want to include iOS (which is usually the point).  

That said, straight C++ Development is still an option even if difficult and risky for future support.  It gives you the most control over your program and by far the fastest results when done correctly.  Even if you are using a game engine written in C++ like unity or unreal, you are usually writing your game code in scripts that are interrupted and run by the game engine.  C++ is directly compiled to machine instructions by the compiler which generates native object code after compilation and links to the native libraries.  You also do not have to use garbage collection (although since C++ version 11 you can create and control your own garbage collection).  Having control over garbage collection can be a huge advantage because as the programmer you know what objects you want to retain in memory and can make sure that they are there when needed.  Garbage collectors may remove items from memory that are going to possibly return at a later time.  The act of both reclaiming memory (collection) and creating the objects in memory is time intensive and is a common cause for performance issues in games.  

A great option for managing and creating graphics in your C++ games is the Open Graphics Library (OpenGL).  It is a cross-language, cross-platform application programming interface (API) for rendering 2D and 3D vector graphics [2]. The API is typically used to interact with a graphics processing unit (GPU), to achieve hardware-accelerated rendering.  There is also a newer similar initiative called Vulkan.  Vulkan is a grounds-up redesign effort to unify OpenGL and OpenGL ES into one common API that will not be backwards compatible with existing OpenGL versions [2].  These options have optimizations for specific graphics cards so that they run much more efficiently on specific hardware taking advantage of manufacture specific hardware.  There is a board range of support for many specific specific pieces of hardware.  

As mentioned earlier, Apple has signaled that they are not looking forward with OpenGL, opting instead to promote Metal, their proprietary option.  Metal is a low-level, low-overhead hardware-accelerated 3D graphic and compute shader application programming interface (API) developed by Apple Inc., and which debuted in iOS 8 [3]. Metal combines functions similar to OpenGL and OpenCL under one API (it acts in a similar fashion to openGL, enabling software running on Apple devices to take advantage of optimizations available in the hardware).  Luckily, Unity and Unreal engine take advantage of Metal and OpenGL so they can provide a great experience on either platform.  If you intend to develop your own native solution however and want to incorporate hardware-accelerated rendering on both platforms, you will either have to incorporate metal for iOS or risk incompatibility in future releases.  

Option 1: Native Development (Game Engine / Cross Platform)

The 2 heavy hitters are Unity and Unreal Engine.  Both require you to pay for use but use different payment models.  Unity utilities a tiered pay by the month model, you can find additional information here: https://store.unity.com/.  Unreal has a slightly different approach where the use of Unreal Engine is completely free but once you ship your game or application, you pay Epic 5% of gross revenue after the first $3,000 per product per calendar quarter.  You can read more about licensing for these products: https://www.unrealengine.com/en-US/faq and https://www.unrealengine.com/en-US/blog/ue4-is-free.  

Both Unity and Unreal support a large amount of platforms, Unity has 27 including: iOS, Android, Tizen, Windows, Universal Windows Platform, macOS, Linux, WebGL, PlayStation 4, PlayStation Vita, Xbox One, Wii U, 3DS, Oculus Rift, Google Cardboard, SteamVR, PlayStation VR, Gear VR, Windows Mixed Reality, Daydream, Android TV, Samsung Smart TV, tvOS, Nintendo Switch, Fire OS, Facebook Gameroom, Apple's ARKit, Google's ARCore, and Vuforia [4].  Unreal currently supports: Microsoft Windows, macOS, Linux, SteamOS, HTML5, iOS, Android, Nintendo Switch, PlayStation 4, Xbox One, Magic Leap One and virtual reality (SteamVR/HTC Vive, Oculus Rift, PlayStation VR, Google Daydream, OSVR and Samsung Gear VR [5].  Either of these platforms are a great choice if your game requires fast performance and immersive 3D graphics on many platforms.  Both Unity and Unreal have large developer communities, but Unity is generally perceived to be the leader of the pack in the shear size of community and marketplace assets available.  Unreal offers complete source access to the engine, unity has a limited approach for source access.  Generally speaking Unity is considered slightly more approachable for beginners which is one of the reasons it has attracted a larger community.  It also had a free version available before Unreal which lead to wider adoption.  Unreal however is seen as offering the absolute best when it comes to visuals, either platform is very capable.

A 3rd major option is CryEngine which is a lesser known but very capable engine.  It has lighting and graphics capabilities that are considered to be better than Unity and on par with Unreal.  It has had some changes to licensing recently that make it more attractive, but it is still considered to have a generally more restrictive license.  The documentation is also not as good and while source has been recently made available, it is not an “open source” framework.

If your game does not require a high level of graphics performance, there are alternative game engines that accomplish the job but give you more freedom and can be easier to learn.  A good example is LibGDX.  LibGDX is a free and open-source game-development application framework written in the Java programming language with some C and C++ components for performance dependent code [6]. It allows for the development of desktop and mobile games by using the same code base. It is cross-platform, supporting Windows, Linux, Mac OS X, Android, iOS, BlackBerry and web browsers with WebGL support.  You write your core application code in Java and then add any platform specific code needed in sub-projects for each platform.  An additional benefit of this approach is that you can test the game easily using your development machine, then test on individual platforms for differences and platform specific bugs.  Some frameworks such as LibGDX also have the added benefit of being royalty free.  This is a good option to explore especially for 2D and smaller scale games.

A last option I want to discuss that is more basic in nature called GameMaker Studio.  It is primarily a 2D game engine and supports building for Microsoft Windows, macOS, Ubuntu, HTML5, Android, iOS, Amazon Fire TV, Android TV, Microsoft UWP, PlayStation 4, and Xbox One; support for the Nintendo Switch was announced in March 2018 [7].  GameMaker accommodates the creation of cross-platform and multi-genre video games using a custom drag-and-drop visual programming language or a scripting language known as Game Maker Language, which can be used to develop more advanced games that could not be created just by using the drag and drop features. GameMaker was originally designed to allow novice computer programmers to be able to make computer games without much programming knowledge by use of these actions. Recent versions of software also focus on appealing to advanced developers [7].

Option 2: Web Based

The major alternative approach is centered around having a web based game.  You might have a purely web based game, a hybrid based one with a native wrapper that uses functionally delivered from the web, or even a Progressive Web Application (PWA) that maintains it’s purely web based approach but includes a client side element called a service worker that can manage a local cache, manage asynchronous communications with the web server (both classic and push), and also includes a more native feel, being able to be “installed” and having an icon that and a more native feel not requiring the user to open the devices browser to enter the URL.

Core technologies used for building Web based games include HTML5 canvas which allows you to create drawings using scripts that can be animated in the browser.  JavaScript is commonly used to create and render the drawings along with CSS for styling.  This link shows examples of animations in HTML5 canvas and also provides the HTML, JavaScript and CSS that is used to create them: https://www.sanwebe.com/2015/01/html5-canvas-examples.  Generally speaking, the performance of HTML5 canvas makes it best suited for 2D graphics, but you can also use it to play videos or render hardware-accelerated 3D graphics with WebGL support.

Source: https://www.sanwebe.com/2015/01/html5-canvas-examples

WebGL (Web Graphics Library) is a JavaScript API for rendering interactive 3D and 2D graphics within any compatible web browser without the use of plugins. WebGL does so by introducing an API that closely conforms to OpenGL ES 2.0 that can be used in HTML5 <canvas> elements [8].  It lets you run GPU optimized code from within your JavaScript running in the browser.  It enables your JavaScript to call through WebGL to the operating system to run GPU code and then it will paint the picture back to an HTML5 canvas that you manage with your JavaScript code.

Source: [9] https://www.youtube.com/watch?v=qkDg-Y9iHBA

So using the combination of HTML5 canvases and WebGL, it is possible to create a capable (albeit less capable than a natively compiled solution) game that can be built on the web which ensures that it is highly portable between platforms.  With this freedom comes all the advantages of having a single code base.  If your games requirements are less CPU and graphics intensive building for the web might be a great option for you.

Also worth noting is that there are JavaScript Libraries and Frameworks that have been created on top of the HTML5 canvas and WebGL libraries that can make development a much simpler task.  Two examples of these are Three.js and Phaser.   Three.js is a cross-browser JavaScript library and Application Programming Interface (API) used to create and display animated 3D computer graphics in a web browser that uses WebGL. Phaser is a free software 2D game framework for making HTML5 games for desktop and mobile.  It uses both a Canvas and WebGL renderer internally and can automatically swap between them based on browser support. This allows for fast rendering across desktop and mobile. It uses the Pixi.js library for rendering.  Games can be compiled to iOS, Android and native desktop apps via 3rd party tools like Apache Cordova [10].

Three.js Examples:

Source: https://www.nationalgeographic.com/magazine/2017/06/nodosaur-3d-interactive-dinosaur-fossil/
https://www.nationalgeographic.com/magazine/2017/06/nodosaur-3d-interactive-dinosaur-fossil/

Phaser Examples:

Source: http://oatthegoat.co.nz/
Source: http://oatthegoat.co.nz/ 

Conclusion

Hopefully all of this information will prove useful getting you orientated when starting out developing a game in the modern mobile landscape.  Once you realize that there are really only 2 major directions to move in, some form of native application vs web centric one, and the major advantages and drawbacks to each.  Moving forward with the first decision is relatively easy.  From there you can decide your specific approach, say choosing between Unity, Unreal or native C++ development based on your specific requirements, armed with initial research laid out here.

Links to information on major game engines:

Unity

Unreal

CryEngine

GameMaker Studio:

LibGDX

HTML5 Canvas:

WebGL

Phaser (An open source framework from HTML5 Canvas and WebGL games)

Three.js https://en.wikipedia.org/wiki/Three.js