Cross Platform Game Engine Development and Game Development

Cross Platform Game Engine Development and Game Development

fb3 da3

If you just want to make a game i.e you are more of a designer use Unreal Engine 4 for 19 USD/month per Developer + 5% of Total Royalties on selling the game, which is absolute best. You can get current version of Unreal Engine 4 for 19USD and then pay 19USD again after 6 months or 1 year when you need some important update. Finally, you need to pay 19USD again only at the time of Publishing your game. You can keep using old version for as long as you want without paying again till, once at publishing. Which is very Cost Effective overall.

https://www.unrealengine.com/

https://nexon7.wordpress.com/2013/09/03/unreal-engine-4-vs-cry-engine-3/

A Game Engine must have following Subsystems which should be developed in following order.

 

Search Google for anything you want to further know about.

First read – Chapter 1 What Is Game Programming Really Like?, in Game Coding Complete 3rd Ed – Mike McShaffry

Does not matter if you are a Indie Developer and Designer. Read on.

Below is the workflow of my own game engine –

All the libraries mentioned are MIT or ZLib, so that you can use them in commercial projects also. (Note: Quake 2, Quake 3, Doom 3 Quake 4, ETQW source code is  GPL so you cannot use them in your engine but you can learn from them.)

You may be tempted to work on whole game or engine at once and many books referred contain all topics for game development, but it is better to work in order focusing on one subsystem and side wise implementing some other interesting system when you get bored with the primary subsystem, but keep focus on primary subsystem. Things done with planning and in right order are faster and better.

Licensing of source code you refer and use

At many places Source Code of Quake 2, Quake 3, Doom 3 is referred. Read it, understand how things are done in it (Code is a bit old but it works). Also You can look at Unreal Engine 4 Source code for 19USD paid once (and once again whenever you want to see the updated version) (And also Unreal Tournament 99, Unreal Tournament 2004, Unreal Tournament 3 games Unreal Script Gameplay Logic). Read the books, and then implement same features in your own engine (Clean room implementation), while learning from existing good source code. The Code will be your copyright, modern and working on platforms you want. Source code of other MIT or ZLib license libraries is also very good and you can use it directly in your game even commercially. You only need to credit the author and keep MIT or ZLib (or BSD, Apache) license for the original code. You can release your own code under your own license (unlike GPL which will make your code also GPL). You can use LGPL in Lib or dll, but do not modify it, like GNU C++ Compiler libraries you use to compile your program.

 

1. CoreLib – (Use STL. Extra features are added with graphics, physics, gameplay)

Learn C++

cb

Books – C++ Complete Reference 4thEd- Herbert Schildt, Beginning Cpp Through Game Programming – Michael Dawson, C How to Program 6th Ed – Harvey Deitel, C++ How to Program 8th Ed – Harvey Deitel, Effective C++ 3rd Ed – Scott Meyers, More Effective C++ – Scott Meyers, Effective STL – Scott Meyers, The C++ 11 Standard Library 2ndEd – Nicolai Josuttis, C++ Concurrency in Action – Anthony Williams, Intel Threading Building Blocks – James Reinders, Cpp for Game Programmers – Noel Llopis, Game Coding Complete 3rd Ed – Mike McShaffry (DirectX9), Game Coding Complete 4th Ed (DirectX11) – Mike McShaffry, deWiTTERS Game Loop article

Make a console for output printing. Make Console Executable. Console Program Windows in Quake 3 source (win_syscon.cpp). Terminal tty in Linux.

Basically CoreLib is for container classes and algorithms. Use STL for this as it is best solution, Available everywhere with c++11 in gcc4.8.2 and VS2013 with good compatibility. Pool Memory allocator will be needed for faster memory allocations in node based classes like list, set or map. The Source code of referred engines you will see does not use STL but that is because when they were develop STL was not mature. But now STL is very Good, stable, Fast and Easy technology and is part of C++ language. There is no point reimplementing a language feature or compiler (use already available popular scripting language).

Use This – http://www.sjbrown.co.uk/2004/05/01/pooled-allocators-for-the-stl/

Arguably minimize use of list(use stl::vector where frequent insertion deletion is not required) and map (use stl::hash_map or stl::hash_set) and you may not need to use Pool allocator even. If it is really necessary for performance use Pool Allocator.

Check and learn Container classes then move forward.

Streaming, System Functions, etc can be implemented now if you learn them, or you can write them while learning Graphics also as they are given in many books and are present in source code also.

Multithreading – It is better to design engine for multithreading from the start. Use Task-Based Multithreading (use Intel TBB), instead of Thread-Based Multithreading. Use SDL for cross platform threads. Multithreading works best when different processor cores are working on different data in parallel, i.e. executing operations in parallel. Identify such portions of your program. Sequential routines are better left to one core as you will not get more speed from multiple cores, instead speed will decrease due to using atomic, lock,  mutex, semaphore, etc.

Profiling and Tweaking – Always keep profiling your program for Speed and Memory Usage (simulating conditions in which software will be used by consumer). Then tweak the necessary parts at the end, as 90% of the execution time of a computer program is spent executing 10% of the code (known as the 90/10 law). A good free Open Source Profiler is  – Very Sleepy profiler. Or you can use the MS Visual Studio profiler available in the Ultimate versions of Visual Studio. For Memory Usage checking you can write your own Allocator or Functions to trace memory or use a different allocator like Pool Memory Allocator. Look at EASTL also (STL library implementation by Electronic Arts under LGPL license (using as it is is free without changing license of your own code) for use in games for better memory performance. But it is not standard, it is better to use standard STL with your own custom memory allocator. This is mainly important if you are developing for Gaming Consoles(Ps4, XBox One) or mobiles with limited memory and no virtual memory). You can read books (Cpp for Game Programmers – Noel Llopis), look at source code of Quake3, Doom3 (common.cpp).

 

2. Graphics and Physics

fb3 bf4

Window and Event Management in Operating System

Implement Window creation (windows API and XWindows API or use SDL) and handling first.

Books – Programming Windows 5th Ed – Charles Petzold, Linux Programming Unleashed – Kurt Wall, X Window System The Complete Reference – Robert Scheifler

Graphics

c3 (7)

DirectX (Direct3D part) (On Windows only) and OpenGL(on all platforms).

You can use OpenGL, OpenAL, SDL_Input (or your own), SDL_Net (or your own). See Quake 3 or Doom 3 or SDL Source Code for Linux Input and Networking.

Use MSVC and Code Blocks on Windows. Use Code Blocks on Linux Mint. (Code Blocks will make Linux development lot easy like Windows)

#if defined(EN_USE_DIRECTX)    // Set in project properties. Use macro for conditional compilation
For enabling DirectX in Visual Studio, make a different build configuration
exe uses OpenGL and openAL always. OpenGL, OpenAL Build can be made optional like DirectX also.
no need to use DirectX in Code Blocks which is problematic in Code Blocks.

and Disabled or not declared in Code Blocks    // uses opengl and openal

Make Engine.lib Static to include and use with editor
AI, Physics, Sound may also have separate libs linked in main exe, it still seems to program as one big exe.

Not using dll is good for Multithreading and Memory Stability especially with STL. (See Quake 2 source for kernel + dynamic dll handshake solution but it is lot of hassle to maintain and will slow your engine making progress considerably. You can always use this solution at the end of the project which will be overall faster development. See Fabien Salagard Quake 2 Engine review for understanding)
Allocation of memory in one module an Deallocation in another is a difficult bug to track and correct.
Also speed is fastest.

Keep Linux specific files separate in Linux folder and Windows specific files in win folder of whatever subsystem they are.
May seem odd to put separate subsystem files together, but it is very good for  Cross Platform maintainability.
Use SDL for complete Cross Platform Compatibility. You can also use SFML which is easier but SDL is more mature and widely used.

Books – Focus on SDL – Ernest Pazera, SDL Game Development – Shaun Mitchell,  SFML Game Development – Artur Moreira

Books – Introduction to 3D Game Programming with DirectX 9.0 – Frank D Luna (old non shader API), Introduction To 3D Game Programming With DirectX9.0c A Shader Approach – Frank D Luna, Introduction to 3D Game Programming with DirectX 11 – Frank D Luna, Nehe OpenGL Tutorials, OpenGL Super Bible 4th Ed – Richard S Wright (old non shader API), OpenGL Super Bible 6th Ed – Richard S Wright (OpenGL 4, equal to Direct3D11), OpenGL Programming Guide 8thEd,  3D Math Primer for Graphics and Game Development 2nd Ed, Math for 3D Game Programming Computer Graphics – Eric Lengyel, Computer Graphics Principles and Practice 3rd Ed – John Hughes, GPU Gems Nvidia 1, 2, 3. Physically Based Rendering 2nd Ed – Matt and Greg, ShaderX3 –  Advanced Rendering with DirectX and OpenGL, Programming Vertex Geometry and Pixel Shaders – Wolfgang Engel, Advanced Animation with DirectX9 – Jim Adams, HLSL Development Cookbook, OpenGL 4.0 Shading Language Cookbook, Directx 9 User Interfaces Design and Implementation – Alan Thorn, Refer to source code of Irrlicht3d, Ogre (it is really big), Torque 3D, Sauerbraten

Physics

sr31_resize

Physics is largely tied to Graphics Subsytem so it is include with graphics. Bullet Library is very good for Cross Platform fast physics.

Books – Game Physics Engine Development 2nd Ed – Ian Millington, Real-Time Collision Detection – Christer Ericson

Overall Engine Architecture

a2

Books – 3D Game Engine Architecture – David H Eberly, 3D Game Engine Design – D H Eberly, Game Physics – David H Eberly, Game Engine Architecture – Jason Gregory, 3D Game Engine Programming – Stefan Zerbst, Programming a Multiplayer FPS in DirectX – Vaughan Young, Level of Detail for 3D Graphics – David Luebke, Real-Time 3D Terrain Engines Using Cpp and Directx9 – Greg Snook, Write Portable Code – Brian Hook, Cross Platform Game Programming – Steven Goodwin, Game Programming Gems, Core Techniques and Algorithms in Game Programming – Daniel Sanchez, Multithreaded Game Engine Design – Jonathan Harbour, Refer to Source code of Quake 2, Quake 3, Doom 3 (GPL License) available freely on net

 

3. Scripting – (For setting Dynamic Game Logic)

sk1_resize

Use Squirrel or AngelScript for Scripting. Squirrel is a bit better choice. Lua has odd syntax so I do not recommend it, besides Squirrel is same as Lua with C++ like syntax.

You may use xml files for data input to engine and resources.

Books – Game Scripting Mastery – Alex Varanese

4. Audio – (Need to set sound sources in Editor, for living, breathing world)

swbf2

Use DirectSound or XAudio (Windows only), OpenAL (on all platforms).

Books – Beginning Game Audio Programming (Direct Sound) – Mason McCuskey, OpenAL_Programmers_Guide, OpenAL_PGuide (Programmers Reference), EffectsExtensionGuide

5. Editor – (Create Worlds, Set Sound, Put Characters and Dynamic Objects, Set AI Routines for Creatures)

v1 (8)

Use MFC for Windows only Editor (It will let you make Editor easily and fast). Use wxWidgets for Cross Platform Editor (which is a better choice then MFC)

Use UnrealEd and CryEngine Sandbox Editor to see what features should be in a game editor.

Books – Programming Windows 5th Ed – Charles Petzold, Programming MS Visual Cpp 5th Ed – David Kruglinski, Cross-Platform GUI Programming with wxWidgets

6. AI – (Artificial Intelligence for characters and creatures in game world)

hl2ep2

AI custom code.

Books – Programming Game AI by Example – Mat Buckland, The Quake III Arena Bot – Thesis – JMP Van Waveren, Killzone2AI_Hierarchically-Layered-MP-Bot_System, The Unauthorized Halo 2 Battle Guide,  AI Techniques for Game Programming – Mat Buckland

7. Gameplay – (Scripts)

cr3_1

Use Scripting.

Use Free 3D Models and Textures available on internet for prototyping, or models that come with other games. But use your own 3D Models and Textures in final game.

Books – Focus on Mod Programming in Quake III Arena – Shawn Holmes, Quake 4 Mods For Dummies – Erik Guilfoyle, Refer to Source code of Quake 2, Quake 3, Doom 3 (GPL License), Quake 4, Enemy Territory Quake Wars, Prey, Sauerbraten available freely on net, Secrets of The Game Business – Francois Laramee

For other Game Types read more books, implement different AI.

Books – Programming Role Playing Games with DirectX9 2nd Ed – Jim Adams, Strategy Game Programming with DirectX 9.0 – Todd Barron

8. Networking – (Need to know what to send over network for multiplayer)

ut3

Windows Sockets (windows), Posix (Linux or Linux Specific). SDL_Net for hassle free Cross Platform Networking.

Books – Multiplayer Game Programming – Todd Barron, Refer OpenTNL(Torque Network Library), Quake 2 source code, Quake3 Networking Model, Torque3D engine source, Latency Compensating Methods in Client/Server In-game Protocol Design and Optimization – Yahn W. Bernier, Source Engine Networking Lag Compensation, Tribes 2 Networking Model, The Unreal Networking Model – Tim Sweeney

http://gafferongames.com/2009/01/25/game-networking-resources/

Use SDL_Net or RakNet.

 9. Creating Artwork – (To make Objects and Characters in game world)

ue4 (7)

2D Textures – Adobe Photoshop (or free GIMP). Texture Maker

3D Models – Maya (or free Blender), Z- Brush,  3D Coat, Allegorithmic Substance Designer

Terrains – World Machine

Free Models and Textures are available on internet for prototyping. But use completely free or your own or legally licensed models and textures in final game. (CC (Creative Commons) license art work can be only used in free programs. For commercial use contact the author for another license, since art work is generally available under dual license.)

Books – Ultimate Game Design Building Game Worlds – Tom Meigs

 

ts3

Game Making is a lot of work even if you use a already used famous engine like Unreal Engine 4. It is highly time consuming so decide what you want to do in life and accordingly choose a career. Do the work you enjoy most while Earning Money through it to live a better life. For Business Aspect of Game Development search Google for interviews of famous Game Developers like Tim Sweeney and Indie Developers and accordingly try to do your best.

Congratulations. You now have your own Single-player Multi-Player FPS. Sell it, Open Source the code , Play it.

 

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s