<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>STRd6</title>
	<atom:link href="http://strd6.com/feed/" rel="self" type="application/rss+xml" />
	<link>http://strd6.com</link>
	<description>Occasionally I solve problems using computers</description>
	<lastBuildDate>Sun, 21 Apr 2013 02:24:23 +0000</lastBuildDate>
	<language>en-US</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.5.1</generator>
		<item>
		<title>Array#minimum and Array#maximum</title>
		<link>http://strd6.com/2013/04/arrayminimum-and-arraymaximum/</link>
		<comments>http://strd6.com/2013/04/arrayminimum-and-arraymaximum/#comments</comments>
		<pubDate>Sun, 21 Apr 2013 02:20:49 +0000</pubDate>
		<dc:creator>Daniel X Moore</dc:creator>
				<category><![CDATA[256 JavaScript Game Extensions]]></category>
		<category><![CDATA[Programming]]></category>

		<guid isPermaLink="false">http://strd6.com/?p=1032</guid>
		<description><![CDATA[Time for the next installment in 256 JS Game Extensions. It&#8217;s been a while hasn&#8217;t it? Well don&#8217;t worry because here are four new crazy cool additions to the Array class. This brings us up to 40! Array::maxima = &#40;valueFunction=Function.identity&#41; &#8230; <a href="http://strd6.com/2013/04/arrayminimum-and-arraymaximum/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
				<content:encoded><![CDATA[<p>Time for the next installment in 256 JS Game Extensions. It&#8217;s been a while hasn&#8217;t it? Well don&#8217;t worry because here are four new crazy cool additions to the <code>Array</code> class. This brings us up to 40!</p>

<div class="wp_syntax"><table><tr><td class="code"><pre class="coffeescript" style="font-family:monospace;">Array<span style="color: #66cc66;">::</span>maxima = <span style="color: black;">&#40;</span>valueFunction=Function.<span style="color: black;">identity</span><span style="color: black;">&#41;</span> <span style="color: #66cc66;">-&gt;</span>
  <span style="color: #66cc66;">@</span>inject<span style="color: black;">&#40;</span><span style="color: black;">&#91;</span><span style="color: #66cc66;">-</span><span style="color: #0000cd;">Infinity</span><span style="color: #66cc66;">,</span> <span style="color: black;">&#91;</span><span style="color: black;">&#93;</span><span style="color: black;">&#93;</span><span style="color: #66cc66;">,</span> <span style="color: black;">&#40;</span>memo<span style="color: #66cc66;">,</span> item<span style="color: black;">&#41;</span> <span style="color: #66cc66;">-&gt;</span>
    value = valueFunction<span style="color: black;">&#40;</span>item<span style="color: black;">&#41;</span>
    <span style="color: black;">&#91;</span>maxValue<span style="color: #66cc66;">,</span> maxItems<span style="color: black;">&#93;</span> = memo
&nbsp;
    <span style="color: #ff7700;font-weight:bold;">if</span> value <span style="color: #66cc66;">&gt;</span> maxValue
      <span style="color: black;">&#91;</span>value<span style="color: #66cc66;">,</span> <span style="color: black;">&#91;</span>item<span style="color: black;">&#93;</span><span style="color: black;">&#93;</span>
    <span style="color: #ff7700;font-weight:bold;">else</span> <span style="color: #ff7700;font-weight:bold;">if</span> value <span style="color: #008000;">is</span> maxValue
      <span style="color: black;">&#91;</span>value<span style="color: #66cc66;">,</span> maxItems.<span style="color: black;">concat</span><span style="color: black;">&#40;</span>item<span style="color: black;">&#41;</span><span style="color: black;">&#93;</span>
    <span style="color: #ff7700;font-weight:bold;">else</span>
      memo
  <span style="color: black;">&#41;</span>.<span style="color: black;">last</span><span style="color: black;">&#40;</span><span style="color: black;">&#41;</span>
&nbsp;
Array<span style="color: #66cc66;">::</span>maximum = <span style="color: black;">&#40;</span>valueFunction<span style="color: black;">&#41;</span> <span style="color: #66cc66;">-&gt;</span>
  <span style="color: #66cc66;">@</span>maxima<span style="color: black;">&#40;</span>valueFunction<span style="color: black;">&#41;</span>.<span style="color: black;">first</span><span style="color: black;">&#40;</span><span style="color: black;">&#41;</span>
&nbsp;
Array<span style="color: #66cc66;">::</span>minima = <span style="color: black;">&#40;</span>valueFunction=Function.<span style="color: black;">identity</span><span style="color: black;">&#41;</span> <span style="color: #66cc66;">-&gt;</span>
  inverseFn = <span style="color: black;">&#40;</span>x<span style="color: black;">&#41;</span> <span style="color: #66cc66;">-&gt;</span>
    <span style="color: #66cc66;">-</span>valueFunction<span style="color: black;">&#40;</span>x<span style="color: black;">&#41;</span>
&nbsp;
  <span style="color: #66cc66;">@</span>maxima<span style="color: black;">&#40;</span>inverseFn<span style="color: black;">&#41;</span>
&nbsp;
Array<span style="color: #66cc66;">::</span>minimum = <span style="color: black;">&#40;</span>valueFunction<span style="color: black;">&#41;</span> <span style="color: #66cc66;">-&gt;</span>
  <span style="color: #66cc66;">@</span>minima<span style="color: black;">&#40;</span>valueFunction<span style="color: black;">&#41;</span>.<span style="color: black;">first</span><span style="color: black;">&#40;</span><span style="color: black;">&#41;</span></pre></td></tr></table></div>

<p><code>Array#maxima</code> is the core of this set, all the other methods are implemented based upon it. <code>maxima</code> returns a list of the elements that have the maximum value for a given value function. The default value function is the identity function which returns the item itself. This will work great for integers or strings: anything that correctly works with the <code>&gt;</code> operator.</p>
<p>The value function can be overridden for example if you want to compute the maximum length word in a list you could pass in <code>(word) -&gt; word.length</code></p>
<p>The special case <code>maximum</code> delegates to <code>maxima</code> and returns only the first result. Similarly <code>minima</code> delegates to <code>maxima</code> but inverts the value function.</p>
<p>With these methods many problems that seem complex actually become quite a lot simpler by picking a value function and whether you want to maximize it or minimize it.</p>
]]></content:encoded>
			<wfw:commentRss>http://strd6.com/2013/04/arrayminimum-and-arraymaximum/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Red Ice Launched</title>
		<link>http://strd6.com/2013/03/red-ice-launched/</link>
		<comments>http://strd6.com/2013/03/red-ice-launched/#comments</comments>
		<pubDate>Thu, 28 Mar 2013 01:30:07 +0000</pubDate>
		<dc:creator>Daniel X Moore</dc:creator>
				<category><![CDATA[Game Development]]></category>
		<category><![CDATA[Internet Adventures]]></category>

		<guid isPermaLink="false">http://strd6.com/?p=1025</guid>
		<description><![CDATA[Red Ice is Launched! Two years in the making, an amazing beat-em-up hockey game that will blow your socks off. Check it out. Buy it now: https://chrome.google.com/webstore/detail/red-ice/booheljepkdmiiennlkkbghacgnimbdn Stay up to date on Facebook: https://www.facebook.com/redicegame]]></description>
				<content:encoded><![CDATA[<p>Red Ice is Launched! Two years in the making, an amazing beat-em-up hockey game that will blow your socks off. Check it out.</p>
<p>Buy it now: <a href="https://chrome.google.com/webstore/detail/red-ice/booheljepkdmiiennlkkbghacgnimbdn">https://chrome.google.com/webstore/detail/red-ice/booheljepkdmiiennlkkbghacgnimbdn</a></p>
<p>Stay up to date on Facebook: <a href="https://www.facebook.com/redicegame">https://www.facebook.com/redicegame</a></p>
]]></content:encoded>
			<wfw:commentRss>http://strd6.com/2013/03/red-ice-launched/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Red Ice Premortem &#8211; Hard Lessons in HTML5</title>
		<link>http://strd6.com/2013/02/red-ice-premortem/</link>
		<comments>http://strd6.com/2013/02/red-ice-premortem/#comments</comments>
		<pubDate>Mon, 11 Feb 2013 02:18:28 +0000</pubDate>
		<dc:creator>Daniel X Moore</dc:creator>
				<category><![CDATA[Programming]]></category>

		<guid isPermaLink="false">http://strd6.com/?p=1010</guid>
		<description><![CDATA[Over the past two years I&#8217;ve been developing a multiplayer hockey game in CoffeeScript. What follows is a rough list of some things that I&#8217;ve learned. And let&#8217;s be clear, these are all the mistakes I made before I got &#8230; <a href="http://strd6.com/2013/02/red-ice-premortem/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
				<content:encoded><![CDATA[<p>Over the past two years I&#8217;ve been developing a multiplayer hockey game in CoffeeScript. What follows is a rough list of some things that I&#8217;ve learned.</p>
<p>And let&#8217;s be clear, these are all the mistakes I made before I got to the part where I built the game.</p>
<p><strong>JavaScript</strong><br />
CoffeeScript is great as a programming language, but it&#8217;s still built on top of JavaScript. JavaScript has a few crippling problems when it comes to reusable libraries, like the lack of a require statement in the language itself. There are many tools that try to address this, falling mostly into two separate groups: compile/build tools and runtime tools.</p>
<p>Since I use CoffeeScript, a compile time tool fits well into my pipeline. For websites, generally I use Sprockets where you can explicitly require other files using special comments:</p>

<div class="wp_syntax"><table><tr><td class="code"><pre class="coffeescript" style="font-family:monospace;"><span style="color: #808080; font-style: italic;">#= require player</span>
<span style="color: #808080; font-style: italic;">#= require map</span>
<span style="color: #808080; font-style: italic;">#= ...</span></pre></td></tr></table></div>

<p>This is good. Dependencies can be made explicit and you can require files from other files. The disadvantage is that this all happens during build time, so Sprockets itself doesn&#8217;t provide any way to require files at runtime. For rapid development some sort of guard script is needed to recompile all your files when any change. In practice this takes less than a second and changes are immediately available when refreshing the page.</p>
<p>Requirejs is an alternative that provides support for requiring additional files at runtime. This approach is great for development, but still requires a compilation step for optimizing distribution.</p>
<p>Either of these approaches work fine and the correct one to choose depends mostly on how well they integrate with the rest of your toolchain.</p>
<p>These problems would be mitigated greatly by a reliable and robust, game development-specific framework similar to Rails. There are many JS web development frameworks. There are even some that fit certain definitions of robust and reliable. I&#8217;ve even spent years trying to create one with its own crippling problems, but that&#8217;s a tale for another time.</p>
<p>As of yet I haven&#8217;t found any that I could recommend, and that&#8217;s coming from someone who spent three years building one. The features that I think are essential are:</p>
<ul>
<li>Command line support</li>
<li>Packaging for web/download deployment</li>
<li>Rapid development environment</li>
<li>First-class testing environment</li>
<li>Extensions to core JavaScript libraries</li>
<li>Additional libraries specific to games</li>
<li>Dependency management as good as Bundler</li>
</ul>
<p>Many people are working on these issues. For each one there are many attempts, but there isn&#8217;t yet an opinionated framework that brings them all together in a way that developers can get started with quickly and easily. The biggest problem is that even by choosing the most popular tool for each issue, you rapidly become the only person in the world who has used each of those tools together.</p>
<p><strong>Distribution</strong></p>
<p>HTML games provide a great multi-platform distribution mechanism: a website that players can go to and play the game directly in the browser. For selling a direct download, a zip file with a run.html file is easy to create &#8211; it&#8217;s pretty much the same as a zip of the website. Linux/Mac/Windows compatibility is practically free, though the major issue would be the player&#8217;s choice of browser. If it is extremely important that the game be played in a quality browser, Chrome Portable can be bundled with the game or provided as a separate install step.</p>
<p>Sharing with testers is also easy, just send a zip or link to the page where you&#8217;re developing your game. You could even host everything on Github Pages.</p>
<p><strong>Gamepads</strong></p>
<p>Gamepad support is now quite good in Chrome, but needs support from other major browsers. There are native plugins available that will enable all browsers on all platforms to provide equivalent gamepad support, but it&#8217;s too much trouble to assume players will install a plugin and too much additional work for developers to implement as well. Maybe if a plugin matched the API more exactly it would mitigate this from a developer perspective, but asking players to install native plugins defeats much of the gains from an HTML experience.</p>
<p>On the bright side, when playing Red Ice using Chrome, the gamepad support is better than most popular indie games. (Binding of Isaac, I&#8217;m looking at you!)</p>
<p><strong>Multi Player</strong></p>
<p>In an attempt to alienate all potential players, I originally designed Red Ice to be played 3v3 locally using XBox controllers. As you can see from this chart, number of friends drops rapidly when owning more than three controllers.</p>
<p><img src="http://strd6.com/wp-content/uploads/2013/02/lonely_bros.png" alt="" width="703" height="397" class="alignnone size-full wp-image-1011" /></p>
<p>Right now Red Ice is 2v2, and that&#8217;s probably correct. I do want to do more experimental games with more than four players locally, but with six or more players, screen real estate starts to become an issue.</p>
]]></content:encoded>
			<wfw:commentRss>http://strd6.com/2013/02/red-ice-premortem/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Using Multiple Cloudfront Domains with Paperclip</title>
		<link>http://strd6.com/2013/01/using-multiple-cloudfront-domains-with-paperclip/</link>
		<comments>http://strd6.com/2013/01/using-multiple-cloudfront-domains-with-paperclip/#comments</comments>
		<pubDate>Sun, 06 Jan 2013 02:27:59 +0000</pubDate>
		<dc:creator>Daniel X Moore</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[Programming]]></category>

		<guid isPermaLink="false">http://strd6.com/?p=998</guid>
		<description><![CDATA[In order to speed up asset loading using a CDN is generally regarded as a good idea. It is also recommended to split up requests among separate hostnames to allow the browser to parallelize loading. Enabling this in Rails with &#8230; <a href="http://strd6.com/2013/01/using-multiple-cloudfront-domains-with-paperclip/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
				<content:encoded><![CDATA[<p>In order to speed up asset loading using a CDN is generally regarded as a good idea. It is also recommended to split up requests among separate hostnames to allow the browser to parallelize loading.</p>
<p>Enabling this in Rails with Paperclip is pretty easy, though the documentation isn&#8217;t extremely rich.</p>
<p>You&#8217;ll want to set the s3_host_alias option to a proc which determines the correct domain alias based on the id of the object the attachment is for.</p>

<div class="wp_syntax"><table><tr><td class="code"><pre class="ruby" style="font-family:monospace;">  has_attached_file <span style="color:#ff3333; font-weight:bold;">:image</span>, S3_OPTS.<span style="color:#9900CC;">merge</span><span style="color:#006600; font-weight:bold;">&#40;</span>
    <span style="color:#ff3333; font-weight:bold;">:s3_host_alias</span> <span style="color:#006600; font-weight:bold;">=&gt;</span> <span style="color:#CC0066; font-weight:bold;">Proc</span>.<span style="color:#9900CC;">new</span> <span style="color:#006600; font-weight:bold;">&#123;</span><span style="color:#006600; font-weight:bold;">|</span>attachment<span style="color:#006600; font-weight:bold;">|</span> <span style="color:#996600;">&quot;images#{attachment.instance.id % 4}.pixieengine.com&quot;</span> <span style="color:#006600; font-weight:bold;">&#125;</span>, 
    <span style="color:#ff3333; font-weight:bold;">:styles</span> <span style="color:#006600; font-weight:bold;">=&gt;</span> <span style="color:#006600; font-weight:bold;">&#123;</span>
      ...
    <span style="color:#006600; font-weight:bold;">&#125;</span>
  <span style="color:#006600; font-weight:bold;">&#41;</span></pre></td></tr></table></div>

<p>This sends requests to the following hostnames:</p>
<pre>
images0.pixieengine.com
images1.pixieengine.com
images2.pixieengine.com
images3.pixieengine.com
</pre>
<p>The best part is that the same image will always have the same hostname. I&#8217;ve seen some people suggest randomly choosing a domain, but that reduces caching potential as the same item could be requested from multiple different domains over time.</p>
]]></content:encoded>
			<wfw:commentRss>http://strd6.com/2013/01/using-multiple-cloudfront-domains-with-paperclip/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Capistrano cached copy takes a long time to copy during a deploy</title>
		<link>http://strd6.com/2012/12/capistrano-cached-copy-takes-a-long-time-to-copy-during-a-deploy/</link>
		<comments>http://strd6.com/2012/12/capistrano-cached-copy-takes-a-long-time-to-copy-during-a-deploy/#comments</comments>
		<pubDate>Fri, 28 Dec 2012 00:14:02 +0000</pubDate>
		<dc:creator>Daniel X Moore</dc:creator>
				<category><![CDATA[Programming]]></category>

		<guid isPermaLink="false">http://strd6.com/?p=991</guid>
		<description><![CDATA[If you&#8217;re using Capistrano to deploy your Rails projects it&#8217;s common knowledge to use a cached copy to prevent downloading your entire project from git or svn with every deploy. What I didn&#8217;t know was that by default Capistrano copies &#8230; <a href="http://strd6.com/2012/12/capistrano-cached-copy-takes-a-long-time-to-copy-during-a-deploy/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
				<content:encoded><![CDATA[<p>If you&#8217;re using Capistrano to deploy your Rails projects it&#8217;s common knowledge to use a cached copy to prevent downloading your entire project from git or svn with every deploy.</p>
<p>What I didn&#8217;t know was that by default Capistrano copies over the .git directory when deploying. This was causing a 90 second delay in our deploys. Outrageous!</p>
<p>Fortunately the fix is simple, just cram this into your <code>deploy.rb</code> file.</p>

<div class="wp_syntax"><table><tr><td class="code"><pre class="ruby" style="font-family:monospace;">set <span style="color:#ff3333; font-weight:bold;">:copy_exclude</span>, <span style="color:#006600; font-weight:bold;">&#91;</span> <span style="color:#996600;">'.git'</span> <span style="color:#006600; font-weight:bold;">&#93;</span></pre></td></tr></table></div>

]]></content:encoded>
			<wfw:commentRss>http://strd6.com/2012/12/capistrano-cached-copy-takes-a-long-time-to-copy-during-a-deploy/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>DSLs In CoffeeScript</title>
		<link>http://strd6.com/2012/12/dsls-in-coffeescript/</link>
		<comments>http://strd6.com/2012/12/dsls-in-coffeescript/#comments</comments>
		<pubDate>Mon, 17 Dec 2012 03:05:47 +0000</pubDate>
		<dc:creator>Daniel X Moore</dc:creator>
				<category><![CDATA[Programming]]></category>

		<guid isPermaLink="false">http://strd6.com/?p=985</guid>
		<description><![CDATA[When programming if something is hard it means that you are not programming at the correct level of abstraction. Remember your ABCs (Always Be Coding-at-the-correct-level-of-abstraction). What is the correct level of abstraction? The correct level of abstraction is the level &#8230; <a href="http://strd6.com/2012/12/dsls-in-coffeescript/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
				<content:encoded><![CDATA[<p>When programming if something is hard it means that you are not programming at the correct level of abstraction. Remember your ABCs (Always Be Coding-at-the-correct-level-of-abstraction).</p>
<p>What is the correct level of abstraction? The correct level of abstraction is the level that perfectly matches your problem domain. If you are creating an application about painting and geometry then you&#8217;ll probably be using points, lines, colors, areas, blending and more. Be sure to use those in your code as well, because doing cross products by hand is for mathletes, not painters.</p>
<p>I recently put this into practice when I was creating the menu screen for Red Ice:</p>

<div class="wp_syntax"><table><tr><td class="code"><pre class="coffeescript" style="font-family:monospace;">gamestate <span style="color: #483d8b;">&quot;Tournament&quot;</span><span style="color: #66cc66;">,</span> MapState
gamestate <span style="color: #483d8b;">&quot;Versus&quot;</span><span style="color: #66cc66;">,</span> MatchSetupState
submenu <span style="color: #483d8b;">&quot;Mini-Games&quot;</span><span style="color: #66cc66;">,</span>
  minigame <span style="color: #483d8b;">&quot;Zamboni Defense&quot;</span>
  minigame <span style="color: #483d8b;">&quot;PushOut&quot;</span>
  minigame <span style="color: #483d8b;">&quot;Paint&quot;</span>
submenu <span style="color: #483d8b;">&quot;Options&quot;</span><span style="color: #66cc66;">,</span>
  item <span style="color: #483d8b;">&quot;Config&quot;</span><span style="color: #66cc66;">,</span> <span style="color: #66cc66;">-&gt;</span></pre></td></tr></table></div>

<p>The structure looks like a menu, with submenus being obvious by their indentation. There&#8217;s not a lot of extra syntax junk in the trunk. It&#8217;s clean an to the point.</p>
<p>I knew that I wanted the menu to be a simple list of strings and functions. I started out by just using object literals, but noticed much redundancy. In the natural process of drying up the code by removing redundancy and naming functions simply I ended up creating a DSL. </p>
<p>The starting point was creating a function called <code>item</code>.</p>

<div class="wp_syntax"><table><tr><td class="code"><pre class="coffeescript" style="font-family:monospace;">  item = <span style="color: black;">&#40;</span>text<span style="color: #66cc66;">,</span> fn<span style="color: black;">&#41;</span> <span style="color: #66cc66;">-&gt;</span>
    text<span style="color: #66cc66;">:</span> text.<span style="color: black;">toUpperCase</span><span style="color: black;">&#40;</span><span style="color: black;">&#41;</span>
    action<span style="color: #66cc66;">:</span> fn</pre></td></tr></table></div>

<p>At that point the menu became a list of <code>item</code>s, which was a big improvement, but several of the functions were similar, like opening a submenu or changing game states. So I decided to add more functions whenever anything was duplicated. These new methods were able to build on the <code>item</code> method I had created before, making them simpler as well.</p>

<div class="wp_syntax"><table><tr><td class="code"><pre class="coffeescript" style="font-family:monospace;">  gamestate = <span style="color: black;">&#40;</span>name<span style="color: #66cc66;">,</span> state<span style="color: black;">&#41;</span> <span style="color: #66cc66;">-&gt;</span>
    item name<span style="color: #66cc66;">,</span> <span style="color: #66cc66;">-&gt;</span>
      engine.<span style="color: black;">setState</span><span style="color: black;">&#40;</span>state<span style="color: black;">&#40;</span><span style="color: black;">&#41;</span><span style="color: black;">&#41;</span>
&nbsp;
  minigame = <span style="color: black;">&#40;</span>name<span style="color: black;">&#41;</span> <span style="color: #66cc66;">-&gt;</span>
    item name<span style="color: #66cc66;">,</span> <span style="color: #66cc66;">-&gt;</span>
      engine.<span style="color: black;">setState</span><span style="color: black;">&#40;</span>Minigames<span style="color: black;">&#91;</span>name<span style="color: black;">&#93;</span><span style="color: black;">&#40;</span><span style="color: black;">&#41;</span><span style="color: black;">&#41;</span></pre></td></tr></table></div>

<p>The <code>submenu</code> was a little more interesting. Because I made it a function, it was easy to automatically add a <code>back</code> button to each submenu just by sticking it in the function. Additionally implementing the back button was very simple by using the functions I had previously defined. One benefit of CoffeeScript is that I was able to use splats to allow any length of arguments to the <code>submenu</code> function, with each argument after the name being an item in the submenu.</p>

<div class="wp_syntax"><table><tr><td class="code"><pre class="coffeescript" style="font-family:monospace;">  back = item <span style="color: #483d8b;">&quot;Back&quot;</span><span style="color: #66cc66;">,</span> popSubMenu
&nbsp;
  submenu = <span style="color: black;">&#40;</span>name<span style="color: #66cc66;">,</span> menuOptions...<span style="color: black;">&#41;</span> <span style="color: #66cc66;">-&gt;</span>
    item name<span style="color: #66cc66;">,</span> <span style="color: #66cc66;">-&gt;</span>
      I.<span style="color: black;">menus</span>.<span style="color: black;">push</span> <span style="color: black;">&#91;</span>back<span style="color: black;">&#93;</span>.<span style="color: black;">concat</span><span style="color: black;">&#40;</span>menuOptions<span style="color: black;">&#41;</span></pre></td></tr></table></div>

<p>Making nested submenus is also a breeze, not that you&#8217;d want to nest things deeply, but hey good DSLs make everything easy!</p>

<div class="wp_syntax"><table><tr><td class="code"><pre class="coffeescript" style="font-family:monospace;">submenu <span style="color: #483d8b;">&quot;Mini-Games&quot;</span><span style="color: #66cc66;">,</span>
  submenu <span style="color: #483d8b;">&quot;Survival&quot;</span><span style="color: #66cc66;">,</span>
    minigame <span style="color: #483d8b;">&quot;Zamboni Defense&quot;</span>
    minigame <span style="color: #483d8b;">&quot;Mutant Attack&quot;</span>
    minigame <span style="color: #483d8b;">&quot;PushOut&quot;</span>
  submenu <span style="color: #483d8b;">&quot;Cooperative&quot;</span><span style="color: #66cc66;">,</span>
    minigame <span style="color: #483d8b;">&quot;Paint&quot;</span></pre></td></tr></table></div>

<p>The biggest advantage of DSLs, correct abstractions, and higher-level languages, is that their power compounds. This would have been possible in pure JavaScript, but probably such a pain that it wouldn&#8217;t have been worth doing. Once you have a solid abstraction you can then build on it further and even combine different components in new and interesting ways.</p>
<p>If all you have is a hammer it&#8217;s going to take you a damn long time to build a house.</p>
]]></content:encoded>
			<wfw:commentRss>http://strd6.com/2012/12/dsls-in-coffeescript/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>How to Create a Compass Extension as a RubyGem to Share Sass Mixins</title>
		<link>http://strd6.com/2012/09/how-to-create-a-compass-extension-as-a-rubygem-to-share-sass-mixins/</link>
		<comments>http://strd6.com/2012/09/how-to-create-a-compass-extension-as-a-rubygem-to-share-sass-mixins/#comments</comments>
		<pubDate>Thu, 06 Sep 2012 18:38:02 +0000</pubDate>
		<dc:creator>Daniel X Moore</dc:creator>
				<category><![CDATA[Programming]]></category>

		<guid isPermaLink="false">http://strd6.com/?p=979</guid>
		<description><![CDATA[I was searching for how to include sass mixins in Sprockets projects as a gem dependency. There may be some way to do it but I couldn&#8217;t figure it out. That&#8217;s why I ended up going for a Compass extension, &#8230; <a href="http://strd6.com/2012/09/how-to-create-a-compass-extension-as-a-rubygem-to-share-sass-mixins/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
				<content:encoded><![CDATA[<p>I was searching for how to include sass mixins in Sprockets projects as a gem dependency. There may be some way to do it but I couldn&#8217;t figure it out. That&#8217;s why I ended up going for a Compass extension, since I use Compass anyway.</p>
<p>Create the <a href="http://compass-style.org/help/tutorials/extensions/">compass extension</a>:</p>
<p><code>compass create pixie_sass --using compass/extension</code></p>
<p>Remove the templates directory</p>
<p><code>rm -rf pixie_sass/templates</code></p>
<p><a href="http://railscasts.com/episodes/245-new-gem-with-bundler?view=asciicast">Create the gem via bundler</a>:</p>
<p><code>bundle gem pixie_sass</code></p>
<p>Add compass as a gem dependency:</p>
<p><code>gem.add_dependency "compass"</code></p>
<p>Move the stylesheets folder to be within lib.</p>
<p>Register the plugin in lib/pixie_sass.rb</p>
<p><code><br />
require "compass"</p>
<p>base_directory = File.join(File.dirname(__FILE__))<br />
Compass::Frameworks.register('pixie_sass', :path => base_directory)<br />
</code></p>
<p>Add your sass files and mixins.</p>
<p>Push to github.</p>
<p>Require the gem in your other projects:</p>
<p><code>gem "pixie_sass", :git => "git://github.com/PixieEngine/pixie_sass"</code></p>
<p><a href="https://github.com/PixieEngine/pixie_sass">See the example pixie_sass gem on github</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://strd6.com/2012/09/how-to-create-a-compass-extension-as-a-rubygem-to-share-sass-mixins/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Weekly Recap of 1 Hour Daily Game Jams</title>
		<link>http://strd6.com/2012/04/weekly-recap-of-1-hour-daily-game-jams/</link>
		<comments>http://strd6.com/2012/04/weekly-recap-of-1-hour-daily-game-jams/#comments</comments>
		<pubDate>Sun, 15 Apr 2012 19:50:00 +0000</pubDate>
		<dc:creator>Daniel X Moore</dc:creator>
				<category><![CDATA[Game Development]]></category>

		<guid isPermaLink="false">http://strd6.com/?p=959</guid>
		<description><![CDATA[@mdiebolt and I review our daily 1 hour game jams over the past week. Audio levels in games are still too loud. First 30 Days: Week ending 04-14-2012: I find that doing these 1 hour jams every day really helps &#8230; <a href="http://strd6.com/2012/04/weekly-recap-of-1-hour-daily-game-jams/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
				<content:encoded><![CDATA[<p><a href="https://twitter.com/#!/mdiebolt">@mdiebolt</a> and I review our daily 1 hour game jams over the past week. Audio levels in games are still too loud.</p>
<p>First 30 Days:</p>
<p><iframe width="584" height="438" src="http://www.youtube.com/embed/asskcaLMg0o?fs=1&#038;feature=oembed" frameborder="0" allowfullscreen></iframe></p>
<p>Week ending 04-14-2012:</p>
<p><iframe width="584" height="438" src="http://www.youtube.com/embed/asskcaLMg0o?fs=1&#038;feature=oembed" frameborder="0" allowfullscreen></iframe></p>
<p>I find that doing these 1 hour jams every day really helps to focus my game design skills. Who&#8217;d have thought that practicing something for at least an hour every day will make you better at it? Now when Ludum Dare rolls around 48 hours will seem like a 2 year dev cycle.</p>
]]></content:encoded>
			<wfw:commentRss>http://strd6.com/2012/04/weekly-recap-of-1-hour-daily-game-jams/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Function#debounce Useful JavaScript Game Extension #36</title>
		<link>http://strd6.com/2011/11/function-debounce-useful-javascript-game-extension-36/</link>
		<comments>http://strd6.com/2011/11/function-debounce-useful-javascript-game-extension-36/#comments</comments>
		<pubDate>Mon, 28 Nov 2011 02:56:45 +0000</pubDate>
		<dc:creator>Daniel X Moore</dc:creator>
				<category><![CDATA[256 JavaScript Game Extensions]]></category>
		<category><![CDATA[coffeescript]]></category>
		<category><![CDATA[javascript]]></category>

		<guid isPermaLink="false">http://strd6.com/?p=953</guid>
		<description><![CDATA[I got this from Underscore.js. ###* Calling a debounced function will postpone its execution until after wait milliseconds have elapsed since the last time the function was invoked. Useful for implementing behavior that should only happen after the input has &#8230; <a href="http://strd6.com/2011/11/function-debounce-useful-javascript-game-extension-36/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
				<content:encoded><![CDATA[<p>I got this from <a href="http://documentcloud.github.com/underscore/#debounce">Underscore.js</a>.</p>

<div class="wp_syntax"><table><tr><td class="code"><pre class="coffeescript" style="font-family:monospace;"><span style="color: #808080; font-style: italic;">###*
Calling a debounced function will postpone its execution until after 
wait milliseconds have elapsed since the last time the function was 
invoked. Useful for implementing behavior that should only happen after 
the input has stopped arriving. For example: rendering a preview of a 
Markdown comment, recalculating a layout after the window has stopped 
being resized...
&nbsp;
lazyLayout = calculateLayout.debounce(300)
$(window).resize(lazyLayout)
&nbsp;
@name debounce
@methodOf Function#
@returns {Function} The debounced version of this function.
###</span>
Function<span style="color: #66cc66;">::</span>debounce = <span style="color: black;">&#40;</span>wait<span style="color: black;">&#41;</span> <span style="color: #66cc66;">-&gt;</span>
  timeout = <span style="color: #0000cd;">null</span>
  func = <span style="color: #dc143c;">this</span>
&nbsp;
  <span style="color: #ff7700;font-weight:bold;">return</span> <span style="color: #66cc66;">-&gt;</span>
    context = <span style="color: #dc143c;">this</span>
    args = arguments
&nbsp;
    later = <span style="color: #66cc66;">-&gt;</span>
      timeout = <span style="color: #0000cd;">null</span>
      func.<span style="color: black;">apply</span><span style="color: black;">&#40;</span>context<span style="color: #66cc66;">,</span> args<span style="color: black;">&#41;</span>
&nbsp;
    clearTimeout<span style="color: black;">&#40;</span>timeout<span style="color: black;">&#41;</span>
    timeout = setTimeout<span style="color: black;">&#40;</span>later<span style="color: #66cc66;">,</span> wait<span style="color: black;">&#41;</span></pre></td></tr></table></div>

<p>Already I can see an important use for it. In the code editor we copy out the buffer every keyup. This can lead to a bunch of extra work for the browser when typing. Usually it&#8217;s not a big deal because the files are generally small, but on larger files it can add up and cause some lagging. When using debounce the editor will only trigger after enough milliseconds have elapsed since the end of new keyup events. This will keep the IDE from lagging on larger files while you are typing.</p>
<p>Another place debounce is useful is in a game that implements a Halo style health regeneration. Every time the player takes damage a debounced <code>startRegen</code> function could be called. That way the regen will only start after enough time without taking damage has elapsed. In the game version it would probably be better to constrain it to ticks of the engine, or engine elapsed time for more accuracy.</p>
<p>I&#8217;m always a big fan of <code>Function</code> functions, they are a great way to reduce boilerplate and solve higher-order problems.</p>
]]></content:encoded>
			<wfw:commentRss>http://strd6.com/2011/11/function-debounce-useful-javascript-game-extension-36/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Array#pipeline Useful JavaScript Game Extension #35</title>
		<link>http://strd6.com/2011/11/arraypipeline-useful-javascript-game-extension-35/</link>
		<comments>http://strd6.com/2011/11/arraypipeline-useful-javascript-game-extension-35/#comments</comments>
		<pubDate>Wed, 16 Nov 2011 22:10:38 +0000</pubDate>
		<dc:creator>Daniel X Moore</dc:creator>
				<category><![CDATA[256 JavaScript Game Extensions]]></category>

		<guid isPermaLink="false">http://strd6.com/?p=947</guid>
		<description><![CDATA[###* Pipe the input through each function in the array in turn. For example, if you have a list of objects you can perform a series of selection, sorting, and other processing methods and then receive the processed list. This &#8230; <a href="http://strd6.com/2011/11/arraypipeline-useful-javascript-game-extension-35/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
				<content:encoded><![CDATA[
<div class="wp_syntax"><table><tr><td class="code"><pre class="coffeescript" style="font-family:monospace;"><span style="color: #808080; font-style: italic;">###*
Pipe the input through each function in the array in turn. For example, if you have
a list of objects you can perform a series of selection, sorting, and other 
processing methods and then receive the processed list. This array must contain 
functions that accept a single input and return the processed input. The output of
the first function is fed to the input of the second and so on until the final
processed output is returned.
&nbsp;
@name pipeline
@methodOf Array#
&nbsp;
@param {Object} input The initial input to pass to the first function in the pipeline.
@returns {Object} The result of processing the input by each function in the array.
###</span>
Array<span style="color: #66cc66;">::</span>pipeline = <span style="color: black;">&#40;</span>input<span style="color: black;">&#41;</span> <span style="color: #66cc66;">-&gt;</span>
  <span style="color: #ff7700;font-weight:bold;">for</span> fn <span style="color: #ff7700;font-weight:bold;">in</span> <span style="color: #dc143c;">this</span>
    input = fn<span style="color: black;">&#40;</span>input<span style="color: black;">&#41;</span>
&nbsp;
  <span style="color: #ff7700;font-weight:bold;">return</span> input</pre></td></tr></table></div>

<p>The main use for this is in the PixieEngine cameras module where we need to process the camera transform with a stream of modifiers. This also allows for the game objects list to be z-sorted, filtered to a subset that passes a clip test, or any other arbitrary stream filter.</p>
<p>I think this is probably some sort of fundamental concept of functional programming, but I&#8217;m not sure if `pipeline` is the right name. If anyone has historic info on this please let me know.</p>
]]></content:encoded>
			<wfw:commentRss>http://strd6.com/2011/11/arraypipeline-useful-javascript-game-extension-35/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

<!-- Performance optimized by W3 Total Cache. Learn more: http://www.w3-edge.com/wordpress-plugins/

 Served from: strd6.com @ 2013-06-19 09:38:38 by W3 Total Cache -->