{"id":37239,"date":"2017-03-14T06:00:01","date_gmt":"2017-03-14T11:00:01","guid":{"rendered":"http:\/\/www.shamusyoung.com\/twentysidedtale\/?p=37239"},"modified":"2017-03-13T20:03:55","modified_gmt":"2017-03-14T01:03:55","slug":"pseudoku-tool-chain","status":"publish","type":"post","link":"https:\/\/www.shamusyoung.com\/twentysidedtale\/?p=37239","title":{"rendered":"Pseudoku: Tool Chain"},"content":{"rendered":"<p><a href=\"?p=37294\">Last week<\/a> I did an informal poll to see how many people could run the game. The failure rate hovered around 4%, which is pretty bad. Bad enough that I don&#8217;t think it would be a good idea to put the game up for sale. If 1,000 people bought it, I&#8217;d end up with 40 people who paid for a game that didn&#8217;t work. And when they emailed me asking for help, I wouldn&#8217;t be able to do anything but shrug.<\/p>\n<p>In the old days, Windows would give you quasi-helpful error messages like, &#8220;Unable to load foo.dll&#8221;.  It wouldn&#8217;t tell you why. Is foo.dll missing? Or corrupted? Or does it depend on some other thing that the user doesn&#8217;t have? Is it for a newer \/ older version of Windows? You don&#8217;t know. But at least you know the problem is with foo.dll, so when the user sends you the bug report you know where to look.<\/p>\n<p>But these newer versions of Windows don&#8217;t like to confuse the peasants with things like <strong>information<\/strong>, and so now Windows spits out a generic &#8220;This program can&#8217;t do the thing.&#8221; message. Great. Now the user enters the useless error message into Google and gets back a million different possible causes. They don&#8217;t know what the problem is or where to look. More importantly, neither does the developer.<\/p>\n<p>All I know is that for some people, one of the many DLL files I depend on isn&#8217;t available. Or it is available, but it&#8217;s the wrong version. I included all the DLLs I know about with the program, but for some reason some things appear to be missing or incompatible. What I have figured out:<\/p>\n<ol>\n<li>Windows version doesn&#8217;t have anything to do with it.\n<li>32bit vs. 64bit seems to be irrelevant.\n<\/ol>\n<p>One of my problems is that I have no experience with deployment. In all the years I spent writing software professionally, I never had to package the software up for the end user. I was either writing in-house tools for myself and my colleagues, or I was adding to an existing codebase where someone else was in charge of deployment. (Also, most of my professional work was a decade ago, and I think deployment has gotten more complex since then.)<\/p>\n<p>Let&#8217;s look at the parts of this game&#8230;<\/p>\n<p><!--more--><\/p>\n<h3>Dependencies<\/h3>\n<p>I program at a pretty raw level. I write stuff in C++ and I don&#8217;t use big fancy game engines. In programming, we call this &#8220;working close to the metal&#8221;. Well, it depends on who you&#8217;re talking to. It&#8217;s all a mater of degrees. To some people, C++ and a bunch of libraries isn&#8217;t anywhere NEAR the metal. The guy who <a href=\"https:\/\/www.reddit.com\/r\/todayilearned\/comments\/131q6b\/til_roller_coaster_tycoon_was_programmed_by_one\/\">wrote Rollercoaster Tycoon in assembly<\/a>? Yeah. THAT guy was close to the metal. In any case, if you&#8217;re close to the metal then you&#8217;re down in the guts of the machine, managing memory and manually handling tasks that would be automated in more robust systems. <\/p>\n<p>But even down here close to the metal, there are still things I don&#8217;t want to do manually. And so I depend on external tools. I depend on software written by other people to get things done, because some problems are tedious and the solution fits nicely into a black box. For example:<\/p>\n<h4>SDL2<\/h4>\n<p>I use SDL for talking to the operating system. It lets me create a window, get keyboard and mouse input, and figure out what joysticks might be connected. This would normally take thousands of lines of messy code, all of which would be linked to just one specific operating system. (Windows, OSX, or Linux.) If I wanted to support other operating systems, I&#8217;d need to write alternate versions of those thousands of lines of code.<\/p>\n<p>But SDL puts all of this interface crap into a black box. In my program, it takes just 300 lines of code to get the job done, and that code will talk to any of the big 3 operating systems.<\/p>\n<h4>OpenGL<\/h4>\n<p>This is where I get really close to the metal. The vast majority of developers out there have some sort of graphics engine (or even a game engine) for talking to the graphics hardware. For example, you might use Unity or Unreal Engine to talk to OpenGL, which talks to the graphics card. But I prefer to talk to OpenGL directly. <\/p>\n<h4>DevIL<\/h4>\n<p>Normally loading PNG images is this enormous task. It&#8217;s a complex format and it normally would require thousands of lines of code to properly support all the different types of PNGs out there. But DevIL<span class='snote' title='1'>DEVeloper Image Library. The author wanted to call it OpenIL but the OpenGL folks complained because they were worried people would think that OpenIL was part of OpenGL.<\/span> lets me reduce that to a single line of code.<\/p>\n<p>&#8220;Here is a PNG file loaded into memory. Figure it out, and give me back the raw rectangle of pixels.&#8221;<\/p>\n<h4>OpenAL<\/h4>\n<p>Open Audio Library. It loads .wav files, plays sound effects, and can even handle things like positional audio and such.<\/p>\n<h4>FreeType<\/h4>\n<p>Font loading is an insanely complex task. Fonts themselves are a really complex file format. Turning a font into a series of readable characters of the desired size is even worse. Without Freetype, I wouldn&#8217;t be able to load fonts and so I&#8217;d be stuck making text-less games. <\/p>\n<p>Well, I could also use bitmap fonts, where you just stick a bunch of letters onto a single image. That&#8217;s a very hack-y solution that doesn&#8217;t scale well to different displays. You can use bitmap fonts if you&#8217;re going to a retro feel with giant chunky pixels, but if readability is important then you need to use proper fonts.<\/p>\n<h4>Visual C++ Redistrubutable<\/h4>\n<p>If you develop using Visual C, then the user will need some redistributable file. I&#8217;m sure you remember hitting &#8220;install&#8221; on a Steam game and it sits there downloading (even though the game package is already downloaded) and installing &#8220;Visual C++ Redistributable Package xxxxx&#8221;. There are a million of these stupid things, and I&#8217;ve never figured out how you&#8217;re supposed to figure out which ones your program needs.<\/p>\n<h3>The Problem<\/h3>\n<p>One of these tools is broken. Sometimes. For some people. On some versions of Windows. For unknown reasons. Something is missing.<\/p>\n<p>My first suspect is the Visual C stuff. Maybe there&#8217;s some redistributable package that some people have and other people don&#8217;t. <\/p>\n<p>My second suspect is the audio Library. I&#8217;m using a SUPER old version of it. Everyone tells you that you MUST upgrade the old version because it&#8217;s terrible and it sucks and you&#8217;re a bad person for using it. But the new version doesn&#8217;t have a tool to load WAV files. And without the ability to load WAV files, what&#8217;s the point? I really need that and I really don&#8217;t have the time or desire to figure out how that works<span class='snote' title='2'>Or to shop around for an existing solution that won&#8217;t add yet ANOTHER library to my project, or bloat the project with a dozen WAV-loading source files, or be encumbered by some stupid licensing, or require yet another library, etc.<\/span>. Doing that properly would be a big job, just to get back to where I am right now. And since the audio works, I don&#8217;t have a lot of incentive to go to all that trouble.<\/p>\n<h3>Shamus, Why Don&#8217;t You&#8230;<\/h3>\n<p>I know how you are, internet. You want me to use that one tool that will solve all my problems. Which just so happens to be your favorite tool.<\/p>\n<p>C# people think I should drop what I&#8217;m doing, learn C#, then translate my entire game to that.<\/p>\n<p>Unity fans think I should drop what I&#8217;m doing, learn Unity, then translate my entire game to that. <\/p>\n<p>Python people think I should drop what I&#8217;m doing, learn Python, then translate my entire game to that. <\/p>\n<p>And so on. <\/p>\n<p>But I&#8217;ve been doing this long enough to know just how insanely expensive it is to learn a new system. I have ten people all promising me that my life will improve if I abandon my years of experience and spend weeks or months painstakingly crawling up a new learning curve. Maybe one of those people is right. There&#8217;s no way to know which one. I could spend weeks teaching myself something new (and thus not getting anything useful done) only to discover some awful restriction or limitation that I just can&#8217;t tolerate. Or maybe I&#8217;ll discover a different problem, just as big and as annoying as the distribution problems I was running away from in C++.<\/p>\n<p>This is an interesting project. I&#8217;m glad I&#8217;m doing this with something simple. Hopefully I can figure out this deployment stuff and get the game up for sale. I&#8217;m thinking of doing a short Early Access period just to catch all the bugs, basically using you folks as my playtesters.  <\/p>\n","protected":false},"excerpt":{"rendered":"<p>Last week I did an informal poll to see how many people could run the game. The failure rate hovered around 4%, which is pretty bad. Bad enough that I don&#8217;t think it would be a good idea to put the game up for sale. If 1,000 people bought it, I&#8217;d end up with 40 [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[66],"tags":[],"class_list":["post-37239","post","type-post","status-publish","format-standard","hentry","category-programming"],"_links":{"self":[{"href":"https:\/\/www.shamusyoung.com\/twentysidedtale\/index.php?rest_route=\/wp\/v2\/posts\/37239","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.shamusyoung.com\/twentysidedtale\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.shamusyoung.com\/twentysidedtale\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.shamusyoung.com\/twentysidedtale\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.shamusyoung.com\/twentysidedtale\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=37239"}],"version-history":[{"count":0,"href":"https:\/\/www.shamusyoung.com\/twentysidedtale\/index.php?rest_route=\/wp\/v2\/posts\/37239\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.shamusyoung.com\/twentysidedtale\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=37239"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.shamusyoung.com\/twentysidedtale\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=37239"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.shamusyoung.com\/twentysidedtale\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=37239"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}