<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">
  <channel>
    <title>Matt Tuttle</title>
    <description>He writes code.</description>
    <link>http://matttuttle.com/</link>
    <atom:link href="http://matttuttle.com/feed.xml" rel="self" type="application/rss+xml" />
    <pubDate>Thu, 06 Mar 2025 16:51:02 GMT</pubDate>
    <lastBuildDate>Thu, 06 Mar 2025 16:51:02 GMT</lastBuildDate>
    <generator>Metalsmith</generator>
    
    <item>
        <title>Build Configuration Files for HXCPP</title>
        <description><![CDATA[<p>If you&#39;ve ever attempted to write an extension for Haxe using hxcpp you probably hit a wall trying to figure out how to create a Build.xml file. The common &quot;solution&quot; is to copy and paste what other projects have done until something works. However, if you want to really understand the inner workings of hxcpp&#39;s xml format you&#39;ll want to continue reading.</p>
<h2 id="the-most-basic-build-xml-file">The Most Basic Build.xml File</h2>
<p>First, instead of diving in to all of the specifics of the file format let&#39;s look at the bare minimum example of a Build.xml file.</p>
<h4 id="build-xml">Build.xml</h4>
<pre><code class="hljs xml"><span class="hljs-tag">&lt;<span class="hljs-title">xml</span>&gt;</span> <span class="hljs-comment">&lt;!-- Theoretically this tag could be named anything but hxcpp uses "xml" so we'll use that too --&gt;</span>
    <span class="hljs-comment">&lt;!-- A target with the id "default" must be defined or hxcpp will issue a warning --&gt;</span>
    <span class="hljs-tag">&lt;<span class="hljs-title">target</span> <span class="hljs-attribute">id</span>=<span class="hljs-value">"default"</span>&gt;</span><span class="hljs-tag">&lt;/<span class="hljs-title">target</span>&gt;</span>
<span class="hljs-tag">&lt;/<span class="hljs-title">xml</span>&gt;</span></code></pre>

<p>If you created this file it can be &quot;compiled&quot; using the command <code>haxelib run hxcpp Build.xml</code>. If the hxcpp command can&#39;t be found make sure that you have hxcpp installed using <code>haxelib install hxcpp</code>. For now it won&#39;t actually do anything but hxcpp will gladly read this file and not print out any errors or warnings.</p>
<p>Before we cover targets, and how they can be used, let&#39;s take a look at some of the other root level elements that can be defined.</p>
<h2 id="print-information-and-error-handling">Print Information and Error Handling</h2>
<pre><code class="hljs xml"><span class="hljs-tag">&lt;<span class="hljs-title">echo</span> <span class="hljs-attribute">value</span>=<span class="hljs-value">"Can anyone hear me?"</span> /&gt;</span></code></pre>

<p>Echo is only allowed at the base level of the xml file. It&#39;s useful for printing out detailed information about what is being compiled.</p>
<pre><code class="hljs xml"><span class="hljs-tag">&lt;<span class="hljs-title">error</span> <span class="hljs-attribute">value</span>=<span class="hljs-value">"This message will self destruct in... NOW."</span> /&gt;</span></code></pre>

<p>You can cause an intentional error to occur in hxcpp with this element. Why would you want to do that? Perhaps you don&#39;t want to support certain build conditions so instead you decide to show a useful error message to the person compiling your project.</p>
<h2 id="define-variables">Define Variables</h2>
<pre><code class="hljs xml"><span class="hljs-tag">&lt;<span class="hljs-title">set</span> <span class="hljs-attribute">name</span>=<span class="hljs-value">"foo"</span> <span class="hljs-attribute">value</span>=<span class="hljs-value">"bar"</span> /&gt;</span> <span class="hljs-comment">&lt;!-- define "foo" with the value "bar" --&gt;</span>
<span class="hljs-tag">&lt;<span class="hljs-title">unset</span> <span class="hljs-attribute">name</span>=<span class="hljs-value">"foo"</span> /&gt;</span> <span class="hljs-comment">&lt;!-- remove the "foo" define --&gt;</span>

<span class="hljs-tag">&lt;<span class="hljs-title">setenv</span> <span class="hljs-attribute">name</span>=<span class="hljs-value">"foo"</span> <span class="hljs-attribute">value</span>=<span class="hljs-value">"bar"</span> /&gt;</span> <span class="hljs-comment">&lt;!-- define "foo" again and set an environment variable --&gt;</span></code></pre>

<p>I decided to combine <code>set</code> and <code>setenv</code> because they are easy to get mixed up. First, <code>set</code> and <code>unset</code> are used to assign and remove defined values. These are useful for conditional checks as we will see in a moment. The difference between <code>set</code> and <code>setenv</code> is that the latter not only defines a value but also sets it in the operating system environment variables. Note that all of the attributes shown above are <em>required</em> and hxcpp will fail if you forget them.</p>
<pre><code class="hljs xml"><span class="hljs-comment">&lt;!-- <span class="hljs-doctag">NOTE:</span> this uses the "name" attribute and not "value" like you may expect --&gt;</span>
<span class="hljs-tag">&lt;<span class="hljs-title">path</span> <span class="hljs-attribute">name</span>=<span class="hljs-value">"/path/to/binaries"</span> /&gt;</span> <span class="hljs-comment">&lt;!-- append to PATH variable --&gt;</span></code></pre>

<p>The <code>path</code> element works almost identically to <code>setenv</code> with one major difference. It <strong>appends</strong> to the PATH variable instead of replacing it.</p>
<h2 id="conditional-attributes">Conditional Attributes</h2>
<p>Every element in the build.xml file can have conditional attributes applied to it. These will help customize the build for each operating system you may be targeting. There are only a handful so let&#39;s take a look at each one.</p>
<h3 id="if">If</h3>
<pre><code class="hljs xml"><span class="hljs-tag">&lt;<span class="hljs-title">set</span> <span class="hljs-attribute">name</span>=<span class="hljs-value">"on_boat"</span> <span class="hljs-attribute">value</span>=<span class="hljs-value">"yep"</span> /&gt;</span>
<span class="hljs-comment">&lt;!-- only checks for the definition of a variable not the actual value --&gt;</span>
<span class="hljs-tag">&lt;<span class="hljs-title">echo</span> <span class="hljs-attribute">value</span>=<span class="hljs-value">"I'm on a boat"</span> <span class="hljs-attribute">if</span>=<span class="hljs-value">"on_boat"</span> /&gt;</span>
<span class="hljs-comment">&lt;!-- multiple conditions can be chained together with or statements "||" --&gt;</span>
<span class="hljs-tag">&lt;<span class="hljs-title">echo</span> <span class="hljs-attribute">value</span>=<span class="hljs-value">"Apple fanboys forever!"</span> <span class="hljs-attribute">if</span>=<span class="hljs-value">"macos || ios"</span> /&gt;</span>
<span class="hljs-comment">&lt;!-- separating values by spaces means that both must be defined to pass the condition check --&gt;</span>
<span class="hljs-tag">&lt;<span class="hljs-title">echo</span> <span class="hljs-attribute">value</span>=<span class="hljs-value">"Compiling for a 64-bit linux machine"</span> <span class="hljs-attribute">if</span>=<span class="hljs-value">"linux HXCPP_M64"</span> /&gt;</span></code></pre>

<p>You can add the <code>if</code> attribute to an element to check when values have been defined.</p>
<h3 id="unless">Unless</h3>
<pre><code class="hljs xml"><span class="hljs-tag">&lt;<span class="hljs-title">set</span> <span class="hljs-attribute">name</span>=<span class="hljs-value">"have_pants"</span> <span class="hljs-attribute">value</span>=<span class="hljs-value">"false"</span> /&gt;</span>
<span class="hljs-comment">&lt;!-- this will not execute because the condition passes, note that the value doesn't matter --&gt;</span>
<span class="hljs-tag">&lt;<span class="hljs-title">echo</span> <span class="hljs-attribute">value</span>=<span class="hljs-value">"I can't find my pants"</span> <span class="hljs-attribute">unless</span>=<span class="hljs-value">"have_pants"</span> /&gt;</span>
<span class="hljs-comment">&lt;!-- multiple conditions can be chained together with or statements "||" --&gt;</span>
<span class="hljs-tag">&lt;<span class="hljs-title">echo</span> <span class="hljs-attribute">value</span>=<span class="hljs-value">"We don't like Apple fanboys!"</span> <span class="hljs-attribute">unless</span>=<span class="hljs-value">"macos || ios"</span> /&gt;</span></code></pre>

<p><code>unless</code> is the &quot;everything but&quot; condition. Useful for when you want to exclude certain portions of your build configuration.</p>
<h3 id="ifexists">IfExists</h3>
<pre><code class="hljs xml"><span class="hljs-tag">&lt;<span class="hljs-title">echo</span> <span class="hljs-attribute">value</span>=<span class="hljs-value">"Phew, it exists."</span> <span class="hljs-attribute">ifExists</span>=<span class="hljs-value">"path/to/file.txt"</span> /&gt;</span></code></pre>

<p>This is a special condition for checking if a file exists in the file system.</p>
<h2 id="grouping-configurations-and-including-other-files">Grouping Configurations and Including Other Files</h2>
<pre><code class="hljs xml"><span class="hljs-tag">&lt;<span class="hljs-title">section</span> <span class="hljs-attribute">if</span>=<span class="hljs-value">"windows"</span>&gt;</span>
    <span class="hljs-tag">&lt;<span class="hljs-title">echo</span> "<span class="hljs-attribute">I</span>'<span class="hljs-attribute">m</span> <span class="hljs-attribute">in</span> <span class="hljs-attribute">another</span> <span class="hljs-attribute">section</span>!" /&gt;</span>
<span class="hljs-tag">&lt;/<span class="hljs-title">section</span>&gt;</span>
<span class="hljs-comment">&lt;!-- You can identify sections with an id attribute. This is useful for including in other xml files --&gt;</span>
<span class="hljs-tag">&lt;<span class="hljs-title">section</span> <span class="hljs-attribute">id</span>=<span class="hljs-value">"my-section"</span>&gt;</span><span class="hljs-tag">&lt;/<span class="hljs-title">section</span>&gt;</span></code></pre>

<p>You can use the <code>section</code> element to define a group of elements. It can have conditions like all the other elements so it&#39;s a good way to skip large portions of the build file.</p>
<pre><code class="hljs xml"><span class="hljs-tag">&lt;<span class="hljs-title">include</span> <span class="hljs-attribute">name</span>=<span class="hljs-value">"include/more.xml"</span> /&gt;</span>
<span class="hljs-comment">&lt;!-- Adding the noerror attribute will prevent an error if the include file doesn't exist --&gt;</span>
<span class="hljs-tag">&lt;<span class="hljs-title">include</span> <span class="hljs-attribute">name</span>=<span class="hljs-value">"does_not_exist.xml"</span> <span class="hljs-attribute">noerror</span>=<span class="hljs-value">"true"</span> /&gt;</span>
<span class="hljs-comment">&lt;!-- The section attribute lets you restrict the include to a specific section. You must have a coresponding id in the included file. --&gt;</span>
<span class="hljs-tag">&lt;<span class="hljs-title">include</span> <span class="hljs-attribute">name</span>=<span class="hljs-value">"other.xml"</span> <span class="hljs-attribute">section</span>=<span class="hljs-value">"my-section"</span> /&gt;</span></code></pre>

<p>Including other configuration files is a good way to split up your build process as it grows larger. You may also want to split out platform specific configuration details into another file as well.</p>
<h2 id="miscellaneous-top-level-elements">Miscellaneous Top Level Elements</h2>
<p>Before we get to defining targets I want to cover the rest of the other top level elements.</p>
<pre><code class="hljs xml"><span class="hljs-tag">&lt;<span class="hljs-title">copyFile</span> <span class="hljs-attribute">name</span>=<span class="hljs-value">"README.md"</span> <span class="hljs-attribute">from</span>=<span class="hljs-value">"."</span> /&gt;</span>
<span class="hljs-comment">&lt;!-- Normally copyFile will fail if a file doesn't exist. "allowMissing" prevents that error. --&gt;</span>
<span class="hljs-tag">&lt;<span class="hljs-title">copyFile</span> <span class="hljs-attribute">name</span>=<span class="hljs-value">"graphics/logo.png"</span> <span class="hljs-attribute">from</span>=<span class="hljs-value">"assets"</span> <span class="hljs-attribute">allowMissing</span>=<span class="hljs-value">"true"</span> /&gt;</span>
<span class="hljs-comment">&lt;!-- Adding "toolId" only runs copy file on targets where the toolId attributes match --&gt;</span>
<span class="hljs-tag">&lt;<span class="hljs-title">copyFile</span> <span class="hljs-attribute">name</span>=<span class="hljs-value">"logo.png"</span> <span class="hljs-attribute">from</span>=<span class="hljs-value">"assets/graphics"</span> <span class="hljs-attribute">toolId</span>=<span class="hljs-value">"dll"</span> /&gt;</span></code></pre>

<p>Contrary to what you may think this doesn&#39;t copy files immediately, it only happens when a target executes. The <code>name</code> attribute should be a filename and the <code>from</code> attribute is the directory where a file of that name exists. The file will be placed in the target&#39;s output directory with the same filename. <strong>If you include a directory in the name attribute it has the potential to fail because hxcpp does not create folders for you.</strong></p>
<pre><code class="hljs xml"><span class="hljs-comment">&lt;!-- allowed name values (androidNdk, blackberry, msvc, mingw, emscripten) --&gt;</span>
<span class="hljs-tag">&lt;<span class="hljs-title">setup</span> <span class="hljs-attribute">name</span>=<span class="hljs-value">"androidNdk"</span> /&gt;</span></code></pre>

<p>The <code>setup</code> element is used to set defines for specific build environments. It takes a name for a build environment and then passes the currently defined values to that tool.</p>
<pre><code class="hljs xml"><span class="hljs-tag">&lt;<span class="hljs-title">pleaseUpdateHxcppTool</span> <span class="hljs-attribute">version</span>=<span class="hljs-value">"0.1"</span> /&gt;</span></code></pre>

<p>Used by hxcpp when the version is outdated. <strong>I would advise against using this element unless you know what you&#39;re doing.</strong></p>
<h2 id="targets-and-file-groups">Targets and File Groups</h2>
<p>Targets are the bread and butter of hxcpp&#39;s configuration files. Think of a target as a group of executed commands to eventually either build an executable or some other form of output. Let&#39;s go back to the basic example from the beginning of this post for a second.</p>
<pre><code class="hljs xml"><span class="hljs-tag">&lt;<span class="hljs-title">xml</span>&gt;</span>
    <span class="hljs-tag">&lt;<span class="hljs-title">target</span> <span class="hljs-attribute">id</span>=<span class="hljs-value">"default"</span>&gt;</span><span class="hljs-tag">&lt;/<span class="hljs-title">target</span>&gt;</span>
<span class="hljs-tag">&lt;/<span class="hljs-title">xml</span>&gt;</span></code></pre>

<p>So we can see that a target at the most basic sense only requires an id attribute. It&#39;s also worth noting that the &quot;default&quot; target is important because it specifies the starting point for hxcpp. Without a default target hxcpp will display an error message. Let&#39;s add a bit to this example.</p>
<h4 id="hello-cpp">Hello.cpp</h4>
<pre><code class="hljs cpp"><span class="hljs-preprocessor">#<span class="hljs-keyword">include</span> <span class="hljs-string">&lt;iostream&gt;</span></span>
<span class="hljs-function"><span class="hljs-keyword">int</span> <span class="hljs-title">main</span><span class="hljs-params">(<span class="hljs-keyword">int</span> argc, <span class="hljs-keyword">char</span> *argv[])</span>
</span>{
    <span class="hljs-built_in">std</span>::<span class="hljs-built_in">cout</span> &lt;&lt; <span class="hljs-string">"Hello world!"</span> &lt;&lt; <span class="hljs-built_in">std</span>::endl;
    <span class="hljs-keyword">return</span> <span class="hljs-number">0</span>;
}</code></pre>

<h4 id="build-xml">Build.xml</h4>
<pre><code class="hljs xml"><span class="hljs-tag">&lt;<span class="hljs-title">xml</span>&gt;</span>
    <span class="hljs-comment">&lt;!-- This is a file group, it contains a set of source files --&gt;</span>
    <span class="hljs-tag">&lt;<span class="hljs-title">files</span> <span class="hljs-attribute">id</span>=<span class="hljs-value">"common"</span>&gt;</span>
        <span class="hljs-tag">&lt;<span class="hljs-title">file</span> <span class="hljs-attribute">name</span>=<span class="hljs-value">"Hello.cpp"</span> /&gt;</span>
    <span class="hljs-tag">&lt;/<span class="hljs-title">files</span>&gt;</span>
    <span class="hljs-tag">&lt;<span class="hljs-title">target</span> <span class="hljs-attribute">id</span>=<span class="hljs-value">"default"</span> <span class="hljs-attribute">output</span>=<span class="hljs-value">"hello"</span> <span class="hljs-attribute">tool</span>=<span class="hljs-value">"linker"</span> <span class="hljs-attribute">toolid</span>=<span class="hljs-value">"exe"</span>&gt;</span>
        <span class="hljs-tag">&lt;<span class="hljs-title">files</span> <span class="hljs-attribute">id</span>=<span class="hljs-value">"common"</span> /&gt;</span> <span class="hljs-comment">&lt;!-- reference the file group we just created --&gt;</span>
    <span class="hljs-tag">&lt;/<span class="hljs-title">target</span>&gt;</span>
<span class="hljs-tag">&lt;/<span class="hljs-title">xml</span>&gt;</span></code></pre>

<p>If you create a <code>Hello.cpp</code> file with the code above and run <code>haxelib run hxcpp Build.xml</code> you&#39;ll see that it generates an executable file. Run that executable and you will see <code>Hello world!</code> in the console window. You just compiled a C++ program using hxcpp!</p>
<p>Let&#39;s dissect this a bit. First there is a file group, which in this case is just our main C++ file. Following that is our default target but it has a bunch more attributes added to it. The <code>output</code> attribute determines what the final output will be named. If you are on Windows you may have noticed that it automatically adds a &quot;.exe&quot; extension. The <code>tool</code> and <code>toolid</code> attributes work together to determine how hxcpp will compile the code. The only supported value for <code>tool</code> is linker right now and the <code>toolid</code> can be a variety of values (exe, dll, static_link are the most common). You can make your own custom linker tool but I&#39;m not going to cover that in this post.</p>
<h3 id="compiler-flags">Compiler Flags</h3>
<p>If you&#39;ve compiled anything beyond the most basic programs in C++ you&#39;ve probably hit the need to include libraries in your program. Thankfully hxcpp supports external libraries as we&#39;ll see below.</p>
<pre><code class="hljs xml"><span class="hljs-tag">&lt;<span class="hljs-title">target</span> <span class="hljs-attribute">id</span>=<span class="hljs-value">"opengl"</span>&gt;</span>
    <span class="hljs-tag">&lt;<span class="hljs-title">files</span> <span class="hljs-attribute">id</span>=<span class="hljs-value">"opengl"</span> /&gt;</span>
    <span class="hljs-comment">&lt;!-- compiler flags --&gt;</span>
    <span class="hljs-tag">&lt;<span class="hljs-title">flag</span> <span class="hljs-attribute">value</span>=<span class="hljs-value">"-I/usr/local/include"</span> /&gt;</span>
    <span class="hljs-tag">&lt;<span class="hljs-title">lib</span> <span class="hljs-attribute">name</span>=<span class="hljs-value">"-lgl"</span> <span class="hljs-attribute">unless</span>=<span class="hljs-value">"macos"</span> /&gt;</span>
    <span class="hljs-tag">&lt;<span class="hljs-title">vflag</span> <span class="hljs-attribute">name</span>=<span class="hljs-value">"-framework"</span> <span class="hljs-attribute">value</span>=<span class="hljs-value">"OpenGL"</span> <span class="hljs-attribute">if</span>=<span class="hljs-value">"macos"</span> /&gt;</span>
<span class="hljs-tag">&lt;/<span class="hljs-title">target</span>&gt;</span></code></pre>

<p>These flags can get a bit confusing because they all basically do the same thing. The main difference between the flag elements and lib is that the former comes before the objects passed to the compiler and the latter is placed after the objects.</p>
<p>Also, flag and vflag are nearly identical except that vflag takes two values and merges them together with a space. It&#39;s important to note that you <strong>should not add spaces</strong> in these values unless you want them to be wrapped in quotes. Which also means that sometimes you have to use workarounds like add multiple lib elements for flags that require spaces.</p>
<h3 id="directories">Directories</h3>
<pre><code class="hljs xml"><span class="hljs-tag">&lt;<span class="hljs-title">target</span> <span class="hljs-attribute">id</span>=<span class="hljs-value">"directories"</span>&gt;</span>
    <span class="hljs-tag">&lt;<span class="hljs-title">outdir</span> <span class="hljs-attribute">name</span>=<span class="hljs-value">"build"</span> /&gt;</span> <span class="hljs-comment">&lt;!-- directory to place final output --&gt;</span>
    <span class="hljs-tag">&lt;<span class="hljs-title">builddir</span> <span class="hljs-attribute">name</span>=<span class="hljs-value">"source"</span> /&gt;</span> <span class="hljs-comment">&lt;!-- directory where source files are --&gt;</span>
    <span class="hljs-tag">&lt;<span class="hljs-title">dir</span> <span class="hljs-attribute">name</span>=<span class="hljs-value">"obj"</span> /&gt;</span> <span class="hljs-comment">&lt;!-- mentioned in the hxcpp source but never used... --&gt;</span>
<span class="hljs-tag">&lt;/<span class="hljs-title">target</span>&gt;</span></code></pre>

<p>As you can see there are several directory options that can be set. The first is the <code>outdir</code> element that specifies where to put the final output, from the linker step. It should be noted that the <code>outdir</code> name has a forward slash, &quot;/&quot;, appended to it. The <code>builddir</code> can be thought of as the base directory. It is where you will find the files you want to compile and it will set the base for the <code>outdir</code> as well.</p>
<h3 id="dependencies">Dependencies</h3>
<pre><code class="hljs xml"><span class="hljs-tag">&lt;<span class="hljs-title">target</span> <span class="hljs-attribute">id</span>=<span class="hljs-value">"misc"</span>&gt;</span>
    <span class="hljs-tag">&lt;<span class="hljs-title">depend</span> <span class="hljs-attribute">name</span>=<span class="hljs-value">"parent"</span> /&gt;</span> <span class="hljs-comment">&lt;!-- requires another target to finish before this one --&gt;</span>
    <span class="hljs-tag">&lt;<span class="hljs-title">section</span> <span class="hljs-attribute">if</span>=<span class="hljs-value">"linux"</span>&gt;</span> <span class="hljs-comment">&lt;!-- works just like the root section --&gt;</span>
        <span class="hljs-tag">&lt;<span class="hljs-title">ext</span> <span class="hljs-attribute">value</span>=<span class="hljs-value">".so"</span> /&gt;</span> <span class="hljs-comment">&lt;!-- add an extension to the output --&gt;</span>
    <span class="hljs-tag">&lt;/<span class="hljs-title">section</span>&gt;</span>
<span class="hljs-tag">&lt;/<span class="hljs-title">target</span>&gt;</span></code></pre>

<p>Like other parts of the build configuration, targets can have sections as well. This will group target configuration options just like you could group options at the root level. I&#39;ve also added the <code>depend</code> element which tells the build tool that it needs to finish a different target before running the current one. Note that this does not use the <code>id</code> attribute but instead uses <code>name</code>.</p>
<h2 id="using-with-haxe">Using With Haxe</h2>
<p>Up until this point we&#39;ve been using hxcpp to compile a C++ file directly. This is a perfectly viable way to build C++ and could be used in place of makefiles. However, you are probably wondering how this ties in with the Haxe language. So let&#39;s take a look at an example.</p>
<h4 id="main-hx">Main.hx</h4>
<pre><code class="hljs haxe">@:buildXml('&lt;echo value="I added something to Build.xml!" /&gt;
&lt;target id="haxe"&gt;
    &lt;lib name="-lgl" /&gt;
&lt;/target&gt;')
class Main
{
    public static function main() { }
}</code></pre>

<h4 id="build-hxml">build.hxml</h4>
<pre><code class="hljs bash">-cpp out
-main Main</code></pre>

<p>The <code>buildXml</code> metadata allows you to insert additional elements at the bottom of the generated Build.xml file. Take a look at <code>out/Build.xml</code> and scroll to the bottom of the file and you will see what was added. When you compile you should see the echo line show up in the output.</p>
<p>Now you may be wondering why there is a target with the id of &quot;haxe&quot;. This is a special target id that Haxe creates when transpiling to C++. One thing that hasn&#39;t been mentioned so far is that targets can be appended to if they have the same id value.</p>
<h2 id="appending-and-overriding-targets">Appending and Overriding Targets</h2>
<p>If two targets have the same id value they will be appended by default. You can change this by setting an override attribute. See the example below for clarification on how these attributes work.</p>
<pre><code class="hljs xml"><span class="hljs-tag">&lt;<span class="hljs-title">xml</span>&gt;</span>
    <span class="hljs-tag">&lt;<span class="hljs-title">target</span> <span class="hljs-attribute">id</span>=<span class="hljs-value">"foo"</span>&gt;</span><span class="hljs-tag">&lt;/<span class="hljs-title">target</span>&gt;</span>
    <span class="hljs-tag">&lt;<span class="hljs-title">target</span> <span class="hljs-attribute">id</span>=<span class="hljs-value">"foo"</span>&gt;</span>
        <span class="hljs-comment">&lt;!-- append to foo --&gt;</span>
    <span class="hljs-tag">&lt;/<span class="hljs-title">target</span>&gt;</span>
    <span class="hljs-tag">&lt;<span class="hljs-title">target</span> <span class="hljs-attribute">id</span>=<span class="hljs-value">"foo"</span> <span class="hljs-attribute">overwrite</span>=<span class="hljs-value">"true"</span>&gt;</span>
        <span class="hljs-comment">&lt;!-- remove foo's contents and replace them --&gt;</span>
    <span class="hljs-tag">&lt;/<span class="hljs-title">target</span>&gt;</span>
    <span class="hljs-tag">&lt;<span class="hljs-title">target</span> <span class="hljs-attribute">id</span>=<span class="hljs-value">"foo"</span> <span class="hljs-attribute">append</span>=<span class="hljs-value">"true"</span>&gt;</span>
        <span class="hljs-comment">&lt;!-- append to foo (same as not having the attribute) --&gt;</span>
    <span class="hljs-tag">&lt;/<span class="hljs-title">target</span>&gt;</span>
<span class="hljs-tag">&lt;/<span class="hljs-title">xml</span>&gt;</span></code></pre>

<p>You may want to append or override targets when including other build configuration files. This gives you a lot of flexibility in how you compile your project.</p>
<h2 id="what-s-next-">What&#39;s Next?</h2>
<p>This post covered a lot of the basics of hxcpp&#39;s xml file format. The information covered should get you started and hopefully provide a clear explanation on many of the elements found in Build.xml files. In future posts I&#39;ll cover how to use a Build.xml file to compile a Haxe extension and also the inner workings of hxcpp&#39;s linker and compiler elements.</p>
]]></description>
        <pubDate>Mon, 13 Jul 2015 00:00:00 GMT</pubDate>
        <link>http://matttuttle.com/http://matttuttle.com/2015/07/hxcpp-build-xml/</link>
        <guid isPermaLink="true">http://matttuttle.com/http://matttuttle.com/2015/07/hxcpp-build-xml/</guid>
        
        <category>hxcpp</category>
        
        
    </item>
    
    <item>
        <title>HXML Overview for Haxe</title>
        <description><![CDATA[<p>If you&#39;ve just started using Haxe or have been using OpenFL or Kha to build your projects you may not be familiar with Haxe&#39;s built-in build files, hxml. They use the same syntax as the arguments you&#39;d pass to Haxe on the command line with a few other nice features built in. Even if you are a seasoned pro there may be one or two features you didn&#39;t know about in this post.</p>
<h2 id="a-basic-example">A Basic Example</h2>
<p>Haxe can be overwhelming at first because of the number of targets it has available. Instead of trying to cover all of the targets this overview will just cover a few of them. Neko is a good target for command line tools and testing since it can be compiled quickly. To get started you should create a new project folder with the following two files in it.</p>
<h3 id="main-hx">Main.hx</h3>
<pre><code class="hljs haxe"><span class="hljs-class"><span class="hljs-keyword">class</span> <span class="hljs-title">Main</span> </span>{
    <span class="hljs-keyword">public</span> <span class="hljs-keyword">static</span> <span class="hljs-function"><span class="hljs-keyword">function</span> <span class="hljs-title">main</span><span class="hljs-params">()</span> </span>{
        <span class="hljs-keyword">trace</span>(<span class="hljs-string">"hello world"</span>);
    }
}</code></pre>

<h3 id="build-hxml">build.hxml</h3>
<pre><code class="hljs bash">-neko output.n  <span class="hljs-comment"># this is the compiled neko binary</span>
-main Main      <span class="hljs-comment"># your main class (must have static function main defined)</span></code></pre>

<p>To build this example you enter <code>haxe build.hxml</code> on the command line. If everything goes as planned you should end up with a compiled neko binary named <code>output.n</code> in the same folder. To run this file you can enter <code>neko output.n</code> on the command line and it should print &quot;hello world&quot;. If you aren&#39;t getting results you may want to make sure Haxe and Neko have been properly installed and that you typed everything as shown above.</p>
<h2 id="class-paths-and-running-programs">Class Paths and Running Programs</h2>
<p>So far you have a very simple project compiling in Haxe but what if you want to put Main.hx in a different folder? This is where class paths come in. Haxe needs a way to find the classes you create so it can compile them. You should create a <code>source</code> folder now and move Main.hx into it. Now, update the build.hxml file to look like the one below.</p>
<pre><code class="hljs bash">-neko output.n
-main Main
-cp <span class="hljs-built_in">source</span>          <span class="hljs-comment"># this is the root of the new class path you created</span>
-cmd neko output.n  <span class="hljs-comment"># a quick way to run a command after compiling</span></code></pre>

<p>Notice that you add the <code>-cp</code> flag with the same name as the folder you just created. This can be a relative path to any folder including a parent folder using ellipsis, <code>../my_parent</code>. You may have also seen the additional <code>-cmd</code> flag which runs the command <code>neko output.n</code> after compiling the program. There is another way to execute neko code using the <code>-x</code> flag which is demonstrated below. Try it and see what happens.</p>
<pre><code class="hljs bash">-x Main     <span class="hljs-comment"># compiles the class Main into a neko binary file named Main.n and executes it</span>
-cp <span class="hljs-built_in">source</span>  <span class="hljs-comment"># you still need the class path to point to the source folder</span></code></pre>

<p>Hopefully you can see that the <code>-x</code> flag is a quick way to test a class using the neko target in Haxe.</p>
<h2 id="multiple-targets">Multiple Targets</h2>
<p>So by now you should have a better grasp on the neko target and some of the flags you can use to develop for neko. What if you also want to compile to javascript as well? One way would be to create another hxml file and build them separately but wouldn&#39;t it be better if you could do it all in one command?</p>
<pre><code class="hljs bash">-neko output.n
-main Main
-cp <span class="hljs-built_in">source</span>

--next         <span class="hljs-comment"># tell Haxe to start the next task</span>

-js output.js  <span class="hljs-comment"># create a javascript file</span>
-main Main
-cp <span class="hljs-built_in">source</span></code></pre>

<p>You&#39;ve probably noticed there are two new flags that haven&#39;t been used before. The first is <code>--next</code> which tells the Haxe compiler to start a new task which could be a command, another target, or a completely different program. The second flag is <code>-js</code> which will tell the Haxe compiler to build a javascript file.</p>
<p>This works fine but you might not want so much duplication between the two targets. Wouldn&#39;t it be nice if there was a way to specify the <code>-main</code> and <code>-cp</code> flags globally for the hxml file? There is!</p>
<pre><code class="hljs bash">-main Main
-cp <span class="hljs-built_in">source</span>

--each           <span class="hljs-comment"># use the flags above for every task below</span>

-neko output.n

--next

-js output.js

--next

-swf out.swf     <span class="hljs-comment"># compile to a flash swf file</span>
-swf-header <span class="hljs-number">320</span>:<span class="hljs-number">240</span>:<span class="hljs-number">60</span>:FFFFFF <span class="hljs-comment"># defines properties for the swf file (width:height:fps:background color)</span></code></pre>

<p>That&#39;s better. There is even a new target added just for fun. So you can see that the <code>--each</code> flag uses all of the flags above it for all of the tasks below. It&#39;s a bit like copying and pasting the flags multiple times.</p>
<h2 id="defines-and-debug">Defines and Debug</h2>
<p>Errors are bound to happen and trying to figure out where something broke can be a frustrating process. Thankfully Haxe has included stack traces to help you figure out what went wrong. There is one flag that will help improve stack traces while developing and that is <code>-debug</code>.</p>
<h3 id="error-hx">Error.hx</h3>
<pre><code class="hljs haxe"><span class="hljs-class"><span class="hljs-keyword">class</span> <span class="hljs-title">Error</span> </span>{
    <span class="hljs-keyword">public</span> <span class="hljs-keyword">static</span> <span class="hljs-function"><span class="hljs-keyword">function</span> <span class="hljs-title">main</span><span class="hljs-params">()</span> </span>{
        <span class="hljs-keyword">throw</span> <span class="hljs-string">"This is an error"</span>;
    }
}</code></pre>

<h3 id="test-error-hxml">test-error.hxml</h3>
<pre><code class="hljs bash">-x Error
-debug</code></pre>

<p>Now if you build this code with <code>haxe test-error.hxml</code> you can see that Haxe dumps a stack trace where the throw is. If you were to remove this flag you&#39;ll see that the stack trace still occurs but doesn&#39;t have as much useful information. When building a release version you will want to remove this flag.</p>
<p>So that&#39;s all well and good but what if you want to compile something differently based on a defined value? You can do that with the <code>-D</code> flag. Here is an updated version of the Error class that handles a user defined value.</p>
<h3 id="error-hx">Error.hx</h3>
<pre><code class="hljs haxe"><span class="hljs-class"><span class="hljs-keyword">class</span> <span class="hljs-title">Error</span> </span>{
    <span class="hljs-keyword">public</span> <span class="hljs-keyword">static</span> <span class="hljs-function"><span class="hljs-keyword">function</span> <span class="hljs-title">main</span><span class="hljs-params">()</span> </span>{
        <span class="hljs-preprocessor">#<span class="hljs-keyword">if</span> mydefine</span>
        <span class="hljs-keyword">trace</span>(<span class="hljs-string">"this only happens if -D mydefine is included"</span>);
        <span class="hljs-preprocessor">#<span class="hljs-keyword">end</span></span>
        <span class="hljs-preprocessor">#<span class="hljs-keyword">if</span> debug</span>
        <span class="hljs-keyword">trace</span>(<span class="hljs-string">"I'm in debug mode"</span>);
        <span class="hljs-preprocessor">#<span class="hljs-keyword">end</span></span>
        <span class="hljs-keyword">throw</span> <span class="hljs-string">"This is an error"</span>;
    }
}</code></pre>

<pre><code class="hljs bash">-x Error
-debug
-D mydefine</code></pre>

<p>You might have noticed that there is a condition for a debug define. By using the <code>-debug</code> flag it also automatically includes <code>-D debug</code> as well. You can read more about conditional compilation in the <a href="http://haxe.org/manual/lf-condition-compilation.html">Haxe manual</a>.</p>
<h2 id="external-libraries">External Libraries</h2>
<p>Up until now you&#39;ve only been using the standard library for Haxe. What about adding external code from haxelib? There&#39;s a flag for that too! First you should install a library through haxelib.</p>
<pre><code class="hljs bash">haxelib install format</code></pre>

<p>Now you are ready to compile with the format library.</p>
<pre><code class="hljs bash">-x Main      <span class="hljs-comment"># compile and execute the Main class for neko</span>
-cp <span class="hljs-built_in">source</span>
-lib format  <span class="hljs-comment"># include the format library from haxelib</span></code></pre>

<p>Were you expecting something more difficult? Hopefully this is all making sense and you are ready to move on to the next compile target, C++. But first you should learn about reducing the size of your compiled output.</p>
<h2 id="dead-code-elimination">Dead Code Elimination</h2>
<p>When compiling to javascript you may notice that the output can get pretty large. By default Haxe includes a lot of unused functions and classes based on what you import. This is a good thing because it prevents your code from crashing if a class isn&#39;t included in the output. However, Haxe is very smart in that it knows what code can be tossed if a function is never called.</p>
<pre><code class="hljs bash">-x Main
-cp <span class="hljs-built_in">source</span>
-dce full   <span class="hljs-comment"># can be "no", "std", or "full"</span></code></pre>

<p>The new flag is <code>-dce</code> which has a few options. The first is to pass &quot;no&quot;, which is the default, and simply doesn&#39;t perform dead code elimination. The second is &quot;std&quot; which will strip any unused code in the Haxe standard library. The final one is &quot;full&quot; which eliminates all unused code from your compiled output.</p>
<p>One thing to note however is that Haxe can sometimes remove functions that you need if you are using fancy tricks like reflection. There may also be libraries that do not work well with dead code elimination so be careful that you test thoroughly when this flag is turned on. You may want to read more about how to retain functions and classes in the Haxe manual on <a href="http://haxe.org/manual/cr-dce.html">dead code elimination</a>.</p>
<h2 id="c-">C++</h2>
<pre><code class="hljs bash">haxelib install hxcpp</code></pre>

<p>hxcpp is the required library to compile C++ code. It contains a handful of tools and a way to add native extensions with CFFI. Here&#39;s an example of how you can compile to C++.</p>
<pre><code class="hljs bash">-cpp out    <span class="hljs-comment"># slightly different than other targets because this defines a directory</span>
-main Main
-cp <span class="hljs-built_in">source</span></code></pre>

<p>This looks familiar, right? The <code>-cpp</code> flag works almost identical to other targets but instead of naming an output file it names the output directory. If you run <code>haxe build.hxml</code> now you may get an error if no compiler is found on your computer. You can either go through the step to remedy that or use the next method.</p>
<h3 id="cppia">Cppia</h3>
<p>As of writing this Cppia, pronounced &quot;sepia&quot;, is a new feature for Haxe and hxcpp. It is a very quick way to compile C++ code and runs equal to or faster than Neko. That said there are still some early issues especially with null values. So how do you compile for Cppia?</p>
<pre><code class="hljs bash">-cpp out.cppia  <span class="hljs-comment"># unlike before this is actually a file name and not a directory</span>
-D cppia        <span class="hljs-comment"># this is where the magic happens</span>
-main Main
-cp <span class="hljs-built_in">source</span>
-cmd haxelib run hxcpp out.cppia  <span class="hljs-comment"># execute the cppia file</span></code></pre>

<p>There are a few differences you might see. The first is that the <code>-cpp</code> flag no longer takes a directory name but instead it takes a file name. The second is that you need to define a value to tell hxcpp to output Cppia instead of C++. Finally there is a command flag at the bottom which executes the code by passing the newly created cppia file to hxcpp.</p>
<h2 id="where-to-go-from-here">Where to go from here</h2>
<p>There are a lot of flags that were not covered in this post. If you want to find out what they are the first thing to do is to run <code>haxe -help</code> which will return a list of all the supported flags in Haxe. There is also some useful information in the <a href="http://haxe.org/manual/">Haxe manual</a> that may be helpful.</p>
]]></description>
        <pubDate>Mon, 29 Jun 2015 00:00:00 GMT</pubDate>
        <link>http://matttuttle.com/http://matttuttle.com/2015/06/hxml-overview/</link>
        <guid isPermaLink="true">http://matttuttle.com/http://matttuttle.com/2015/06/hxml-overview/</guid>
        
        <category>hxml</category>
        
        <category>hxcpp</category>
        
        <category>cppia</category>
        
        <category>neko</category>
        
        
    </item>
    
    <item>
        <title>OpenGL Resources</title>
        <description><![CDATA[<p>OpenGL has gone through several verions over the years but it seems that many of the tutorials you&#39;ll find on the internet are dated and mostly cover the fixed function pipeline. I wanted to find more information about programable shaders (glsl), framebuffers, vertex buffers, and many of the other newer features found in later versions of OpenGL. So I&#39;ve compiled a list of good tutorials and sites I&#39;ve found that cover these topics.</p>
<h2 id="opengl-tutorials">OpenGL Tutorials</h2>
<p><a href="http://open.gl/">http://open.gl/</a></p>
<p>Start here first. These tutorials are well written and clearly explain some of the details of OpenGL that seemed mystic to me before. I actually understand the difference between a framebuffer and renderbuffer now!</p>
<p><a href="http://learnopengl.com/">http://learnopengl.com/</a></p>
<p>Another great site that covers a wide variety of topics including lighting, shadows, and parallax/normal maps.</p>
<p><a href="http://www.opengl-tutorial.org/">http://www.opengl-tutorial.org/</a></p>
<p>These tutorials include the full source code which is very useful for tinkering.</p>
<p><a href="http://antongerdelan.net/opengl/">http://antongerdelan.net/opengl/</a></p>
<p>Anton Gerdelan has several tutorials on his website as well as a book. He has a good overview of ray picking and cube maps.</p>
<h2 id="heroku-s-glsl">Heroku&#39;s GLSL</h2>
<p>This site is full of mind blowing fullscreen glsl effects. Everything runs in the browser and the source code live reloads. It even lets you tweak anyone&#39;s code and save your own changes.</p>
<p><a href="http://glsl.heroku.com/">http://glsl.heroku.com/</a></p>
<h2 id="opengl-documentation">OpenGL Documentation</h2>
<h3 id="opengl-4-reference-pages">OpenGL 4 Reference Pages</h3>
<p><a href="http://www.opengl.org/sdk/docs/man/">http://www.opengl.org/sdk/docs/man/</a></p>
<p>When you&#39;ve exhausted the above sites this is the official reference for OpenGL. It has complete descriptions on all of the gl functions.
There are probably many others but these gems have helped me immensely. Let me know in the comments if there are other useful sites I missed.</p>
<h3 id="api-docs-for-multiple-versions">API Docs for multiple versions</h3>
<p><a href="http://docs.gl/">http://docs.gl/</a></p>
<p>This is a great site to get information on different versions of gl* function calls.</p>
]]></description>
        <pubDate>Sun, 09 Mar 2014 00:00:00 GMT</pubDate>
        <link>http://matttuttle.com/http://matttuttle.com/2014/03/opengl-resources/</link>
        <guid isPermaLink="true">http://matttuttle.com/http://matttuttle.com/2014/03/opengl-resources/</guid>
        
        <category>OpenGL</category>
        
        <category>tutorials</category>
        
        <category>glsl</category>
        
        
    </item>
    
    <item>
        <title>Haxe Networking and Bonjour</title>
        <description><![CDATA[<p>I&#39;ve been working on a party game for the last few months that requires local networking between iOS and Android. The only problem is that I didn&#39;t want users to have to type in ip addresses. Enter the world of zero configuration networking...</p>
<p>Bonjour has been around for quite a while and primarily works on iOS and OSX, although Apple has provided a Windows library as well. Essentially a program publishes a services over the network that is available to find from any computer on that network. Another running program can then broadcast out a request to find certain types of services and resolve them. If none are found, the program can choose to stop looking or send out another request.</p>
<p>This is all well and good but Android doesn&#39;t have support for Bonjour. Instead someone created jmDNS which is a Java implementation that can talk with Bonjour services, with some minor differences. So now I knew which libraries to use but neither one of them works with Haxe which is the programming language I prefer.</p>
<p>With some help from hxcpp I was able to glue the two libraries together into a single class that can be used on multiple platforms. This solved my problem of finding devices over the network but what about connecting them together?</p>
<p>Haxe has basic socket connection classes, UDP will be in 3.1.0, but no major networking library (that I&#39;m aware of). Using Python&#39;s twisted framework as inspiration I decided to create <a href="https://github.com/MattTuttle/hxnet">hxnet</a>. It has simple Client/Server code for both TCP and UDP as well as basic protocol classes for RPCs and Telnet.</p>
<p>The Bonjour class is included in hxnet and it should be flexible enough to add protocols like HTTP, FTP, etc... I&#39;m not sure I&#39;d consider it production level code yet but it&#39;s solid enough for me to build my game with it. If you want to give it a shot the code is on GitHub and feel free to create pull requests if you find bugs or code up a crazy new feature.</p>
]]></description>
        <pubDate>Wed, 29 Jan 2014 00:00:00 GMT</pubDate>
        <link>http://matttuttle.com/http://matttuttle.com/2014/01/haxe-networking-rpcs-bonjour/</link>
        <guid isPermaLink="true">http://matttuttle.com/http://matttuttle.com/2014/01/haxe-networking-rpcs-bonjour/</guid>
        
        <category>Haxe</category>
        
        <category>networking</category>
        
        <category>twisted</category>
        
        <category>udp</category>
        
        <category>tcp</category>
        
        <category>hxnet</category>
        
        
    </item>
    
    <item>
        <title>Recently Changed Files in git</title>
        <description><![CDATA[<p>When setting up a deployment script from git I needed to know what files were recently changed. Here is a useful script that does exactly that. Just change <code>HEAD~4</code> to whatever commit you want to go back to.</p>
<pre><code class="hljs bash">git <span class="hljs-built_in">log</span> --pretty=oneline --name-only HEAD~<span class="hljs-number">4</span>..HEAD | sed -E <span class="hljs-operator">-e</span> <span class="hljs-string">'/[0-9a-zA-Z]{40} /d'</span> | sort | uniq</code></pre>]]></description>
        <pubDate>Thu, 23 Jan 2014 00:00:00 GMT</pubDate>
        <link>http://matttuttle.com/http://matttuttle.com/2014/01/recently-changed-files-git/</link>
        <guid isPermaLink="true">http://matttuttle.com/http://matttuttle.com/2014/01/recently-changed-files-git/</guid>
        
        <category>git</category>
        
        <category>deployment</category>
        
        <category>script</category>
        
        
    </item>
    
    <item>
        <title>Why you should buy an Ouya</title>
        <description><![CDATA[<p>Do you...</p>
<ul>
<li>develop indie games?</li>
<li>get tired of playing (insert title) (insert version) games?</li>
<li>enjoy tinkering with consoles?</li>
<li>wish you could actually punch your friend while playing a multiplayer game?</li>
<li>like playing flash games but wish they were more complex?</li>
<li>have a need to be a hipster?</li>
<li>feel jaded about the upcoming next-get consoles?</li>
<li>hate everything that is bad and love everything that is good?</li>
<li>want to play your Android games with a controller?</li>
<li>currently have a pulse?</li>
</ul>
<p>If any of these are true you need to stop reading now and purchase an Ouya.</p>
<p>Seriously... now.</p>
<p>What are you waiting for? It&#39;s $99 well spent.</p>
]]></description>
        <pubDate>Tue, 09 Jul 2013 00:00:00 GMT</pubDate>
        <link>http://matttuttle.com/http://matttuttle.com/2013/07/why-you-should-buy-an-ouya/</link>
        <guid isPermaLink="true">http://matttuttle.com/http://matttuttle.com/2013/07/why-you-should-buy-an-ouya/</guid>
        
        <category>Ouya</category>
        
        
    </item>
    
    <item>
        <title>Ouya Review from a Developer&quot;s Perspective</title>
        <description><![CDATA[<p>My Ouya arrived a few weeks ago and I thought I&#39;d post a review of it. My experience so far has been generally positive and the system gets better with every update. For $99 it&#39;s worth the price of admission.</p>
<p><img src="/static/images/posts/little-crane.jpg" alt="Little Crane That Could" width="300" height="168" class="alignright size-medium" /></p>
<p>There are already a good variety of games for it, around 200, and so far one of my favorite games is <em>The Little Crane That Could</em>. The graphics aren&#39;t amazing and while the controls can be frustratingly hard the sense of accomplishment from completing each of the puzzles is exhilarating. I hesitated to download it at first due to the less than stellar promo art but it is a game you absolutely should try out. My other favorites (in no order) are Polarity, Towerfall, Knightmare Tower, A Bit Of A Fist Of Awesome, Beast Boxing Turbo, and Stalagflight.</p>
<p>Which brings me to what I think is a game changer for the industry, the marketplace. On the Ouya you can try every game for free. It&#39;s a little like shareware back in the 80s-90s when you would get a sampler disk of games and later mail in an order for the ones you liked. This was amazing for a kid growing up in a lower income family since I could try lots of different games at a low cost.</p>
<p>The thing about the store that is completely different from any other marketplace, that I&#39;m aware of, is that prices are not listed anywhere. The game might be charging $1 or $20 and I won&#39;t know until I download and play it. This removes the price barrier from trying something out and seeing what I enjoy. It also diminishes the value of discounts that are so prevalent on mobile stores and the, often loathed by developers, $1 price point.</p>
<p><img src="/static/images/posts/ouya-controller.jpg" alt="Ouya Controller" width="560" height="302" class="alignleft size-medium" /></p>
<p>As for the hardware, I am really impressed with the controller design. The triggers feel a bit spongy but overall the controller feels comfortable and evenly weighted. I have larger hands so PlayStation controllers have always irritated me and while I still think the Xbox has a better controller overall I&#39;d say the Ouya comes in a close second (especially given that the D-pad is better). However, if you like the other controllers there are ways to use them on an Ouya. Talk about a win/win.</p>
<p>The actual hardware I&#39;ve heard compared to a turbo-charged PS2. It has more RAM than the current gen consoles which is wonderful for resource loading. The Tegra 3 graphics might not hold up to today&#39;s standards but I&#39;m hoping to see less &quot;realistic&quot; games and more creativity on the Ouya. It really feels like the NES all over again with so many unique games. Except that it&#39;s easier to develop a game now than it was in the past.</p>
<p>Possibly the best &quot;feature&quot; of Ouya is the openness for developers. This is exactly what iOS and Android have provided for mobile and now indie developers have a chance at console development (without selling our souls). The ODK is a bit rough around the edges at the moment but it is no more difficult building a game for the Ouya than it is for Android. I was able to port several of my HaxePunk prototypes over a single weekend. Most of the work was just getting the input to function like I wanted.</p>
<p>Overall my outlook on the Ouya is good. I was one of the last groups to receive my Ouya but I understand how difficult it would be to manufacture that many units as well as plan for a commercial release. That being said, I feel like the Ouya team is fully committed to making this a quality product. The console is well thought out and while there are still rough spots I think that will all get sorted after they are out of the growing pains stage.</p>
]]></description>
        <pubDate>Fri, 05 Jul 2013 00:00:00 GMT</pubDate>
        <link>http://matttuttle.com/http://matttuttle.com/2013/07/ouya-review-developers-perspective/</link>
        <guid isPermaLink="true">http://matttuttle.com/http://matttuttle.com/2013/07/ouya-review-developers-perspective/</guid>
        
        <category>Ouya</category>
        
        
    </item>
    
    <item>
        <title>TestFlight for Haxe</title>
        <description><![CDATA[<p>TestFlight is a great testing tool for iOS apps. I&#39;ve used it a lot at work to distribute builds to multiple devices around the company. It prompts the tester when there is a new update and tracks analytics with checkpoints and crash logs. The only issue is you need to have the SDK installed to get all those goodies.</p>
<p>Since I use Haxe a lot and have been working diligently on the HaxePunk library I knew having TestFlight integration would be a huge benefit. So I finally got the code to a point where it is ready for release and am hoping it proves useful to other people.</p>
<p>The code is located on GitHub at <a href="https://github.com/MattTuttle/nme-testflight">https://github.com/MattTuttle/nme-testflight</a>. You can also get it through <a href="http://haxe.org/doc/haxelib/using_haxelib">haxelib</a> by typing the following in your command prompt.</p>
<pre><code class="hljs bash">haxelib install testflight</code></pre>]]></description>
        <pubDate>Fri, 25 Jan 2013 00:00:00 GMT</pubDate>
        <link>http://matttuttle.com/http://matttuttle.com/2013/01/testflight-for-haxe/</link>
        <guid isPermaLink="true">http://matttuttle.com/http://matttuttle.com/2013/01/testflight-for-haxe/</guid>
        
        <category>Haxe</category>
        
        <category>TestFlight</category>
        
        
    </item>
    
    <item>
        <title>My entry for Ludum Dare #23</title>
        <description><![CDATA[<p>I participated in Ludum Dare #23 this past weekend with over 1000 others. It was a fun experience and I was able to chat with some great guys on the HaxePunk forums/IRC. Unfortunately my time was divided between LD and several other events over the weekend but I&#39;m happy with what I ended up with. <a href="http://www.ludumdare.com/compo/ludum-dare-23/?action=preview&amp;uid=3934">Check it out!</a></p>
<h2 id="what-went-right">What went right</h2>
<ul>
<li>Built on a simple concept</li>
<li>Used tools I was familiar with (HaxePunk, MilkyTracker, Sublime Text 2)</li>
<li>Had a working game with objective in the first few hours</li>
<li>Used a real mouse for drawing instead of a touchpad</li>
</ul>
<h2 id="what-could-have-been-better">What could have been better</h2>
<ul>
<li>My power was out for 2 hours</li>
<li>I had several other events to attend over the weekend (besides church)</li>
<li>The sound effects were last minute</li>
</ul>
<h2 id="next-time">Next time</h2>
<ul>
<li>Have a laptop with a good battery (mine lasts 20 minutes...)</li>
<li>Participate more in topic selection and blog posts</li>
</ul>
]]></description>
        <pubDate>Mon, 23 Apr 2012 00:00:00 GMT</pubDate>
        <link>http://matttuttle.com/http://matttuttle.com/2012/04/ld48-enzyme-frenzy/</link>
        <guid isPermaLink="true">http://matttuttle.com/http://matttuttle.com/2012/04/ld48-enzyme-frenzy/</guid>
        
        <category>HaxePunk</category>
        
        <category>ludum dare</category>
        
        
    </item>
    
    <item>
        <title>What Happened to Text Adventures?</title>
        <description><![CDATA[<p>I came into possession of an Apple IIc that was in great condition this past year. It has several programs and a bunch of games with it. Having grown up with a DOS computer as a kid I wasn&#39;t entirely familiar with the Apple II but it was simple enough to boot up. The screen flickered and gave off a green tint, no color, but I realized quickly there wasn&#39;t an operating system... So I started sifting through the stack of 5 1/2&quot; floppy disks to find the game I wanted to play, Zork.</p>
<p>In terms of quality, Zork is not the best text adventure, but it is probably the most well known. This was the first time I had played the game and what better way to experience it than on an old piece of hardware. You start out in front of a house and have the options of going several directions. I type in the direction I want to go, and within a few turns find myself lost. I&#39;m in a forest somewhere and start to think the house has vanished. I guess it&#39;s time to practice my cartography skills.</p>
<p>Grabbing a fresh sheet of paper I start drawing boxes with the names of each location in them. There are lines shooting out of each rectangle in all directions and it looks more like a plate of spaghetti than a map. So I pull out another sheet of paper and clean up the lines. Now it&#39;s starting to make more sense... and I found the house!!</p>
<p>I open the side window and climb through to the kitchen. Hopefully no one cares that I&#39;m breaking in. I go up to the attic to look around but there isn&#39;t much to see because it is dark and I don&#39;t have a light. A couple more turns and I end up dead, eaten by a grue if you want to get specific. Death is a bit strange in Zork because you can still explore but there is no way to interact with the world. So I restart the game and find myself in front of the house again. At least I know where it is now.</p>
<p><a href="http://en.wikipedia.org/wiki/Zork_I">
  <img class="alignright" title="Zork 1" src="http://upload.wikimedia.org/wikipedia/en/a/ac/Zork_I_box_art.jpg" alt="Zork I box art" width="300" height="358" />
</a>
Back in the house I reveal a trap door under a rug. Of course it takes several minutes to move the rug by typing every verb I can think of. After opening the trap door I descend into a cavern and turn my light on to begin exploring. There are a ton of rooms and a thief frequently pops his head in a room from time to time. He doesn&#39;t seem to bother me much but he did nick a painting from under my nose. I wander around for a bit before confronting a troll. He takes a couple swings at me and BAM! I&#39;m dead again.</p>
<p>This time I was smart enough to save so I manage somehow to defeat the troll, by typing attack repeatedly, and make my way into a maze. After a bit of walking around I realize I am really lost and start dropping my stuff in each room to try and figure out where I&#39;m at. The only problem with that plan is the thief has the bright idea to pick up my stuff. Isn&#39;t he lost too? I think I&#39;d better reload and go down a different path.</p>
<p>Several hours later I end up draining a body of water, stop myself from exploding, and find myself in front of the house again. This game is like a really big loop. I sweep through a couple of time to grab stuff I missed and end up finishing the game. I&#39;m not sure I actually won but there isn&#39;t much else to do at the end.</p>
<p>I feel quite satisfied with my experience and I am fascinated by how rich the world seemed when in reality it was just a bunch of text on a screen. Most modern games fail to provide this deep of an experience although I would say Bioware and a few other companies have come a long way in telling rich stories. Why don&#39;t text adventures exist today?</p>
<!--nextpage-->
<p>You could argue that gamers today are lazy and don&#39;t want to read anything. This may be true to some extent but I think it is an outcome of how games have evolved. You might come from a different angle and tell me that interactive fiction is <a href="http://ifdb.tads.org/">still</a> <a href="http://www.ifarchive.org/">being</a> <a href="http://ifcomp.org/">written</a> today and that it&#39;s not dead at all. But let&#39;s be serious, how many people are really playing these games? They have the exact same flaws that existed 30 years ago.</p>
<p>I&#39;m not claiming to have a silver bullet but I do believe that interactive fiction, or IF for short, would have a larger audience if we threw out some of the antiquated elements. Think of all the people who enjoy reading literature, whether on paper or in digital form, and how many of that group are aware that IF even exists. But we&#39;re getting ahead of ourselves, just what killed text adventures?</p>
<h2 id="the-parser">The Parser</h2>
<p>Anyone who has ever played an IF game, used voice recognition software, or any other form of natural language parsing will know how infuriating it is to get a computer to understand you. Even if NLP improved ten-fold there will still be subtext it won&#39;t understand. Think of how many ways you can say the work &quot;pick up&quot;. (Take, retrieve, lift, grab, swipe, etc...) Not to mention the multitude of ways you can form a sentence.</p>
<p>What I don&#39;t understand is why the parser is such a sacred cow in IF. When text adventures were first written the only input device was a keyboard. Graphics were primitive and slow. Mice existed but were the ball kind that used to get sticky and stop working. It is no wonder Infocom and others decided to use the keyboard to input commands in the form of simple sentences. But why are we still doing that today?</p>
<p>You could argue it has to do with immersion. Although when I read a book, which requires no typing that I&#39;m aware of, I feel more immersed in the story than if I&#39;m writing a sentence for the eighteenth time because the computer didn&#39;t fully understand what I was saying. Unless it&#39;s a story about how I throw the computer out the window.</p>
<p>Amazingly enough we have a medium that is perfect for text adventures, the web. Imagine highlighted text you can click to get a list of applicable verbs. The advantage to this approach is that I instantly know what I can interact with and what I can do with the object. This may not be a new idea but the best part is we can get rid of the generic feedback systems that are commonly found in IF games.</p>
<h2 id="directional-movement-filler-rooms">Directional Movement / Filler rooms</h2>
<p>The standard movement in interactive fiction games is to specify which cardinal direction you want to go. The player will then exit the room in that direction, if possible, and be given the description of the next room. While this form of movement certainly works, it has its flaws.</p>
<p>This is actually more of a design flaw than actually technical. Early IF games had a tendency to create mazes by connecting exits going north to exits going southwest, instead of direct opposites. Normal people assume that going north would mean that you could then get back to that room by going south. This could further be circumvented by simply listing the name of the next area and traveling to it. How many times in books does it say that someone went north from the kitchen to the living room? Can&#39;t we just go directly there instead of having to specify the direction?</p>
<p>The other issue with cardinal directions is when designers try their best to keep everything to a grid. This ends up creating a bunch of filler rooms that have identical descriptions to the last four areas you&#39;ve been in. Note to IF designers: if there isn&#39;t any purpose to the room, leave it out. Heck, this rule is followed by most decent modern games.</p>
<h2 id="unsolvable-puzzles">Unsolvable puzzles</h2>
<p>Actually I was surprised that most of the puzzles in Zork were fairly simple and only a few times did I have to look up how to do something. But I feel it is worth mentioning because this is the same reason I feel point-and-click adventure games died. Puzzles can still be hard but at least be realistic, there are some really ridiculous puzzles put into adventure games.</p>
<!--nextpage-->
<p>I honestly think that this genre can be revitalized and there is already a niche group of people who play IF games. The problem is, the genre has been stagnant for at least 20 years. It doesn&#39;t mean we have to reinvent the wheel but look what indie developers have done with platformers, there are tons of various FPS games, role playing used to be strictly turn based but now even Final Fantasy is more of a hybrid.</p>
<p>Graphics have come a really long way through the years but it doesn&#39;t leave much to the imagination. Written words still have the power to evoke strong emotions and maybe the addition of voice overs would lower the barrier. One of the most interesting game experiences I&#39;ve seen in a while was Dear Esther which was purely a discovery game.</p>
<p>I will step off my soap box now and let you decide what you think. What other improvements could be made to the genre to make it appeal to a new audience. I would especially love to see an opportunity for mobile games, or even Nook/Kindle. Am I just blowing hot air or do you think text adventures have a chance in the modern world of gaming? Feel free to leave your own comments.</p>
]]></description>
        <pubDate>Wed, 04 Apr 2012 00:00:00 GMT</pubDate>
        <link>http://matttuttle.com/http://matttuttle.com/2012/04/what-happened-to-text-adventures/</link>
        <guid isPermaLink="true">http://matttuttle.com/http://matttuttle.com/2012/04/what-happened-to-text-adventures/</guid>
        
        <category>games</category>
        
        <category>text adventure</category>
        
        <category>Zork</category>
        
        
    </item>
    
  </channel>
</rss>
