{"id":1496,"date":"2020-09-11T17:05:00","date_gmt":"2020-09-11T17:05:00","guid":{"rendered":"https:\/\/xplicity.com\/?p=1496"},"modified":"2025-01-03T14:44:20","modified_gmt":"2025-01-03T11:44:20","slug":"a-long-rant-on-game-engines-part-2","status":"publish","type":"post","link":"https:\/\/xplicity.com\/a-long-rant-on-game-engines-part-2\/","title":{"rendered":"A long rant on Game Engines (Part 2)"},"content":{"rendered":"\n<p class=\"wp-block-paragraph\">In the\u00a0<strong><a href=\"https:\/\/xplicity.com\/a-long-rant-on-game-engines-part-1\/\" data-type=\"post\" data-id=\"1499\">Part <\/a><a href=\"https:\/\/xplicity.com\/technology\/game-engines\/\">1<\/a><\/strong>\u00a0I have reviewed what a game engine actually is. Also, when it&#8217;s reasonable to use it, what are the strengths and weaknesses. As I have mentioned previously, sometimes it&#8217;s worth to consider another way and write your own engine.\u00a0<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">So, what are the advantages of writing a custom game engine? When it&#8217;s worth to think twice before you start, because it might be too inefficient or too complicated? What mistakes should you avoid? Let me share with you my personal findings there.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Pros of writing a custom game engine<\/h2>\n\n\n\n<ol class=\"wp-block-list\">\n<li>Probably the best part about writing a game engine yourself is the&nbsp;<strong>complete freedom<\/strong>. You want something unique or specific in your game? You implement it. Is there something useless? Then you just omit it. There are only the things that you have written yourself. Also, that\u2019s useful when you have a very specific way of organizing everything within the game. Sometimes it might be that your game idea just dictates a certain hierarchy within the game world. Well, you can implement it as easily as the other thing \u2013 you will be building your game engine from the ground up either way.&nbsp;<\/li>\n\n\n\n<li>The next point that stems directly from this is the&nbsp;<strong>complete control<\/strong>. If you are a control freak, a commercial game engine might be your worst enemy. There are a lot of default hidden quirky behaviors in 3rd party game engines. They are all good and fun until you suddenly realize that you need to change it. And then follows the frustration of finding it, understanding it and rewriting or working around it so, that it matches your particular needs. Game engines of today are quite flexible, but\u2026 That\u2019s a lot of time and effort wasted, instead of implementing it the way that was needed from the very beginning. So, if you want to have the complete control and the complete understanding of your game engine, maybe it\u2019s a good idea to write it yourself?&nbsp;<\/li>\n\n\n\n<li>When you do it on your own and you really know what you\u2019re doing, the&nbsp;<strong>performance<\/strong>&nbsp;within the custom game engine&nbsp;<strong>might be absurdly good<\/strong>. You only allow it to perform tasks that are needed, nothing out of the scope, nothing wasted. You can sometimes even make use of very esoteric specific and extremely performant quirks within the API itself.&nbsp;<\/li>\n\n\n\n<li>Also, one of the byproducts of creating everything from scratch in such a complex environment is that the rendering&nbsp;<strong>algorithms<\/strong>&nbsp;will&nbsp;<strong>inevitably<\/strong>&nbsp;end up being&nbsp;<strong>different<\/strong>&nbsp;from everyone\u2019s else. Trust me, there are a great lot of moving parts involved. And even miniscule changes or mistakes (a blessing in disguise) when added create the drastic differences. So, that means that your game will look and feel quite different from the rest.&nbsp;<\/li>\n\n\n\n<li>A super nice thing about custom engine is that a&nbsp;<strong>footprint can be very small<\/strong>. You can create nice expansive games that occupy a fraction of the disk space to compare with something created using a commercial engine. Basically, because you have the option of not adding ANYTHING you don\u2019t need. If you go to extreme absurdities, you can even create a 3D game with all bells and whistles: different weapons, enemies, textures, level design, VFX, particles, music and SFX. All totaling in\u2026 wait for it\u2026 96KB! Yes, you have read it right: ninety-six kilobytes. The game I\u2019m talking about is called \u201c.kkrieger\u201d. As one comment under the demo video said \u2013 a screenshot of this game in action weighs more than 96k. All this was achieved by procedurally generating content when the game starts up and using other clever optimizations wherever possible.<\/li>\n<\/ol>\n\n\n\n<p class=\"wp-block-paragraph\">Now one part of this approach that is kind of neutral is the usage of external libraries. For example, many of the commercial engines come with some form of physics simulations. Graphics API has no concept of physics within it. So, if you would be building a custom game engine, you\u2019d now have to build a physics engine too. Or you could use an external library instead \u2013 something like Havok or ODE. This also goes for anything else you might need \u2013 video playback, content loader helpers, advanced spatial sound libraries. This is a mixed bag, as it always is with external libraries. And that does not necessarily mean that 3rd party engine users would never use an external library either.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Cons of writing a custom game engine<\/h2>\n\n\n\n<ol class=\"wp-block-list\">\n<li><strong>If you start from<\/strong>&nbsp;the absolute&nbsp;<strong>zero<\/strong>, it might be really discouraging and inspiration killing when&nbsp;<strong>you don\u2019t see anything popping up on your screen for quite some time<\/strong>. Up to a week for simple shapes. And months upon months until you can get something looking like the original image in your head. These terms get a lot longer if you are new. You should be aware of the fact, that it can demotivate you really quickly if you were not expecting to work on it that long. Just compare that to several hours of work for the same result, when are using a commercial engine!<br><\/li>\n\n\n\n<li>As mentioned previously,&nbsp;<strong>you\u2019d have to write EVERYTHING yourself<\/strong>.&nbsp;And I mean it. Even if you use external libraries, you will need to create some adaptors to be able to utilize them. So, be prepared for huge work overheads.<br><\/li>\n\n\n\n<li><strong>One of the biggest issues<\/strong>&nbsp;and the reason why people often get discouraged and go for commercial engines&nbsp;<strong>is<\/strong>&nbsp;the&nbsp;<strong>multiplatformity<\/strong>. When you write a game engine from scratch, chances are that you\u2019d be targeting something very specific \u2013 for example DirectX on Windows or Gnm on PlayStation. And those low-level specifics would not be transferrable. Now, you could abstract that specific low-level layer, thus decoupling your \u201cbusiness logic\u201d to be transferrable and reusable among all platform implementations. And that would be exactly what other game engines do to achieve this miraculous \u201cruns on everything\u201d tagline. But, again, you will have to do that for every platform you want to target. That means learning not one low level API, but as many as you\u2019d want to go for.<br><\/li>\n\n\n\n<li>Stemming from the complexity of low-level APIs, the&nbsp;<strong>learning curve&nbsp;<\/strong>here&nbsp;<strong>is very<\/strong>, very&nbsp;<strong>steep<\/strong>.&nbsp;<strong>Knowing how to code is a necessity<\/strong>, not a nice-to-have thing. You will have to learn low-level API like DirectX or OpenGL. You will also have to learn how graphical pipelines work (sometimes across multiple generations of the same API, which can be drastically different from one another). Moreover, you will need to learn a shader language. And all this to pretty much start out \u2013 display a polygon on a screen. I should, however, mention that this highly depends on the technology chosen \u2013 some APIs are a lot more forgiving than others. For example, XNA and MonoGame are a lot more friendly to newcomers, allowing you to skip over certain daunting areas.<br><\/li>\n\n\n\n<li>Now contrary to the popular commercial engines like Unity or Unreal, the amount of<strong>&nbsp;information in the field of custom engine creation&nbsp;<\/strong>might be a bit<strong>&nbsp;too scant<\/strong>. The reason is that the more people are using a technology, the more tutorials you can find. The publicly available APIs are well documented, but quite technical. And when it comes to custom engine building, it often is just an enthusiast hobby or, otherwise a trade secret of a game development company. So, not much information finds it\u2019s way back online. You can find information in enthusiast forums, but this comes with that specific \u201centhusiast flavor\u201d that I, for one, don\u2019t really dig. For really specific platforms and their implementations (think Nintendo and Sony PS) I\u2019d hazard to guess you can only get the documentation if you partner with famous companies themselves. It is not out of the realms of possibility that if you encounter a certain problem when writing your own custom engine, you might be the only person in the whole world that has it. Or at least the problem is so specific, that finding the solution is akin to finding a needle in a haystack.<\/li>\n<\/ol>\n\n\n\n<h2 class=\"wp-block-heading\">My approach<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">If you have read any of my\u00a0<strong><a href=\"https:\/\/xplicity.com\/3d-maze-of-voices\/\" data-type=\"post\" data-id=\"1575\">previous articles<\/a><\/strong>\u00a0you might have noticed that I do like to dig deep into the graphical APIs myself. And being one of those control freaks, who need to know everything that goes under the hood of my game engine, has nothing to do with it. For me the process itself is fun \u2013 its challenging, educational and I am in no hurry to meet any strict deadlines. So, I guess, I pretty much fall into that \u201centhusiast\u201d category.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">The technology stack I use is:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong>MonoGame<\/strong>&nbsp;as the base framework<\/li>\n\n\n\n<li>Physically broken&nbsp;<strong>custom written physics simulation<\/strong>&nbsp;when \/ if I need it<\/li>\n\n\n\n<li><strong>Xamarin<\/strong>&nbsp;and bits of<strong>&nbsp;batch files<\/strong>&nbsp;that allow me to switch between platforms \u2013 Windows \/ iOS \/ Android \/ Windows Phone (sigh).<\/li>\n<\/ul>\n\n\n\n<p class=\"wp-block-paragraph\">To sum up the overall experience of this approach, I\u2019d probably say that it is great on the straights: implementing game loop logic, ability to use clean standard C# and the ability to access the underlying graphics API is absolutely awesome. The power of the MonoGame is beastly and I\u2019d say it is underused in the world of game development.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Now when it comes to the corners \u2013 getting platform specific bits going, finding workarounds, long release cycles of the framework and some parts that are starting to rapidly age (yes mojoshader, I\u2019m looking at you!) it can get quite frustrating. Sometimes the frustration dragging the effort into months of little-to-no progress.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">But in the end, the few chances I get to squeeze an hour or two to work on it \u2013 it\u2019s a blast!<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Conslusion and my advice<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">So, what eventually is the best engine or environment to create games in, so that people would look in awe at the marvel you have created? I guess you already know the answer. The tools don\u2019t really matter if you squeeze the maximum out of them. What matters is an idea, direction, discipline and perseverance. After those four, the selection of the engine and the approach comes just as a matter of your own preference.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Still don\u2019t believe me? Still think there is the one ring to rule them all (editor\u2019s note: ring = game engine)? Let me give you a real-life example. I must come clean and admit that in my youth I smirked at people who used GameMaker for their games. I used to think that it was really low to create games using the tool like this. That all of the games bearing that stigma were trashy and that \u201creal\u201d game makers only used code (of course, only C++). And then I got to play Nuclear Throne.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Ok, I\u2019ll leave you with a rule of thumb:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong>if you don\u2019t know anything<\/strong>&nbsp;and you are just starting out, it is best to start with a game engine. You will learn a lot just by playing around. You will learn it fast. And it will be a fun, painless experience.<br><\/li>\n\n\n\n<li><strong>if you already have quite some experience<\/strong>&nbsp;with low level APIs and game development, you are a moderate studio, or maybe you have a very particular idea \u2013 you might entertain the thought of writing your own engine from scratch. You might want that uniqueness to shine through. And this way you\u2019ll have the most control over it.<br><\/li>\n\n\n\n<li><strong>if you are a big studio<\/strong>&nbsp;that creates triple A titles the answer gets a tad bit murky. You will need to hire a lot of talents that are experienced in the industry standard field. You will probably target various platforms to keep the studio afloat. In that case it is probably a good idea to get back to working with a 3rd party game engine, because you will most likely make a good use of all the deeper features of the engine (or rewrite parts of it that don\u2019t really work for you). It is also likely, that you can decide to create your own engine in-house if you see that such would fit the companies interests better.<\/li>\n<\/ul>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>EXTRA HINT<\/strong>: be smart and don\u2019t make the mistake I made. Don\u2019t start with DirectX as your first introduction to game development.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>In the\u00a0Part 1\u00a0I have reviewed what a game engine actually is. Also, when it&#8217;s reasonable to use it, what are the strengths and weaknesses. As I have mentioned previously, sometimes it&#8217;s worth to consider another way and write your own engine.\u00a0 So, what are the advantages of writing a custom game engine? When it&#8217;s worth [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":1497,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[11],"tags":[],"class_list":["post-1496","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-blog"],"acf":[],"_links":{"self":[{"href":"https:\/\/xplicity.com\/wp-json\/wp\/v2\/posts\/1496","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/xplicity.com\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/xplicity.com\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/xplicity.com\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/xplicity.com\/wp-json\/wp\/v2\/comments?post=1496"}],"version-history":[{"count":3,"href":"https:\/\/xplicity.com\/wp-json\/wp\/v2\/posts\/1496\/revisions"}],"predecessor-version":[{"id":2497,"href":"https:\/\/xplicity.com\/wp-json\/wp\/v2\/posts\/1496\/revisions\/2497"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/xplicity.com\/wp-json\/wp\/v2\/media\/1497"}],"wp:attachment":[{"href":"https:\/\/xplicity.com\/wp-json\/wp\/v2\/media?parent=1496"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/xplicity.com\/wp-json\/wp\/v2\/categories?post=1496"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/xplicity.com\/wp-json\/wp\/v2\/tags?post=1496"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}