<?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>gamepoetry &#187; Science</title>
	<atom:link href="http://www.gamepoetry.com/blog/category/science/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.gamepoetry.com/blog</link>
	<description>The art, science and business of independent game development</description>
	<lastBuildDate>Sun, 14 Jun 2009 18:58:05 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.8.4</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Best Practices With Version Control</title>
		<link>http://www.gamepoetry.com/blog/2009/05/15/best-practices-with-version-control/</link>
		<comments>http://www.gamepoetry.com/blog/2009/05/15/best-practices-with-version-control/#comments</comments>
		<pubDate>Fri, 15 May 2009 18:49:47 +0000</pubDate>
		<dc:creator>urbansquall</dc:creator>
				<category><![CDATA[Featured]]></category>
		<category><![CDATA[Science]]></category>
		<category><![CDATA[best practices]]></category>
		<category><![CDATA[code]]></category>

		<guid isPermaLink="false">http://www.gamepoetry.com/blog/?p=557</guid>
		<description><![CDATA[

In the past, I&#8217;ve discussed the importance of using version control and also ways for structuring your subversion repository. Today, I&#8217;d like to cover an important best practices with version control whether you are a lone wolf developer or you frequently travel in a pack. 

After you&#8217;ve wrapped your head around version control (and I&#8217;ll [...]]]></description>
			<content:encoded><![CDATA[<p><img src="http://www.gamepoetry.com/blog/wp-content/uploads/2008/12/subversion_logo-200x173.png" alt="subversion_logo-200x173" title="subversion_logo-200x173" width="200" height="173" class="aligncenter size-full wp-image-67" /></p>

<p>In the past, I&#8217;ve discussed the <a href="http://www.gamepoetry.com/blog/2008/06/20/effortless-development-and-version-control/">importance of using version control</a> and also <a href="http://www.gamepoetry.com/blog/2008/12/05/trunks-tags-and-branches-in-subversion/">ways for structuring your subversion repository</a>. Today, I&#8217;d like to cover an important best practices with version control whether you are a lone wolf developer or you frequently travel in a pack. <span id="more-557"></span></p>

<p>After you&#8217;ve wrapped your head around version control (and I&#8217;ll be honest, it baffled me the first time I was forced to use it), there&#8217;s only a couple more best practices you need to be aware of to get the most out it.</p>

<h3>Don&#8217;t Commit Conflict Bait</h3>

<p>Conflict Bait is basically something that&#8217;s going to generate conflicts pretty much any time a team member updates from the repository. A good example of Conflict Bait is the swf file that your project generates when you build, or intermediate build files that your IDE might generate. Don&#8217;t put these in the repository, because you will publicly mocked by your more senior team members when they are forced to remove them.</p>

<p>Exceptions: This one isn&#8217;t such a big deal if you&#8217;re the only person working on a particular project. When you are rocking it solo, it can sometimes be useful (read: lazy) to let version control track your builds so can look up old versions without checking out a fresh copy of the whole repository.</p>

<h3>Write Comments In Your Commit Message</h3>

<p>This one is a bit of a &#8220;Duh, really?&#8221; When you&#8217;re going back over a log of 1,000 commits, you&#8217;re going to be sorry you didn&#8217;t leave the breadcrumbs to help you track down that bug in that feature you haven&#8217;t tested in over 3 months.</p>

<h3>Only Commit Verified Builds</h3>

<p>Don&#8217;t commit code that breaks trunk. If you do, you will be shot and beaten. Resist the urge to commit that untested feature right before you sign off for the day. This is the absolutely WRONG thing to do. Perhaps your fellow coders were planning a code binge that night and your last minute tweak sends them on a 4 hour bug hunt instead. Don&#8217;t do this to your teammates.</p>

<p>Exceptions: This again is more applicable in a team environment.</p>

<h3>Close Your Open Files Before Updating</h3>

<p>Sure, Flash Develop or Flex Builder will usually warn you when a file has been externally updated and ask you if you want to reload. Usually. In my life, I&#8217;ve wasted at least 2 day&#8217;s work undoing the damage caused by accidental overwrites after the IDE failed to recognize an update changed a file. Close your open files, then update. Don&#8217;t be that guy, really.</p>

<h3>Make Your Commit As Small As Possible</h3>

<p>You might think you&#8217;re awesome by making monolithic commits, but you&#8217;re really just overcompensating. The best commits are ones that are as granular as possible. This is a good practice for numerous reasons, and one that helps support many of the other best practices already mentioned.</p>

<ol>
<li>It keeps your project manager informed of your progress. If you&#8217;re making commits every 5 days, it doesn&#8217;t matter how big they are, you still look like you are not pulling your weight when your project manager gets his daily commit log and your name isn&#8217;t on it.</li>
<li>Your commit becomes easy to refer to because of its unique revision ID. It becomes an entity that can be referred to, entered into bug databases, etc.</li>
<li>When you&#8217;re digging through logs that have one succinct change applied to a single file, it is far more useful than a commit log that is 9 pages long and involved 30 files, which may or may not be related to your current search.</li>
<li>Your commit becomes easy to undo. Let&#8217;s say you really screwed things up and totally broke a feature (and then went to bed for the night). Your team members can see quickly from your commit log that revision 324 was a granular commit related to that feature and is likely the source of the issue. They can roll back the change and move forward while just cursing you briefly.</li>
</ol>

<p>I&#8217;ve been using version control in a team environment for about a decade now. Hopefully this helps you benefit from some of that experience. <img src='http://www.gamepoetry.com/blog/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
]]></content:encoded>
			<wfw:commentRss>http://www.gamepoetry.com/blog/2009/05/15/best-practices-with-version-control/feed/</wfw:commentRss>
		<slash:comments>5</slash:comments>
		</item>
		<item>
		<title>For-Loop Defeats Copy/Paste</title>
		<link>http://www.gamepoetry.com/blog/2009/04/23/for-loop-defeats-copy-paste/</link>
		<comments>http://www.gamepoetry.com/blog/2009/04/23/for-loop-defeats-copy-paste/#comments</comments>
		<pubDate>Fri, 24 Apr 2009 05:30:47 +0000</pubDate>
		<dc:creator>urbansquall</dc:creator>
				<category><![CDATA[General]]></category>
		<category><![CDATA[Science]]></category>
		<category><![CDATA[best practices]]></category>
		<category><![CDATA[code]]></category>
		<category><![CDATA[coding]]></category>

		<guid isPermaLink="false">http://www.gamepoetry.com/blog/?p=543</guid>
		<description><![CDATA[Copy/pasted code is evil. It can get you into all sorts of trouble. There are a lot of situations in which you might be tempted to perform the dreaded ctrl-c + ctrl-v. You must resist this urge! In certain situations you can write code that is significantly more robust than copy/pasted code and you can [...]]]></description>
			<content:encoded><![CDATA[<p>Copy/pasted code is evil. It can get you into all sorts of trouble. There are a lot of situations in which you might be tempted to perform the dreaded ctrl-c + ctrl-v. You must resist this urge! In certain situations you can write code that is significantly more robust than copy/pasted code and you can probably type it up quicker too. <span id="more-543"></span></p>

<p>One case where you might be tempted to copy/paste code is when you&#8217;re performing some logic on a group of related objects. In the following example, we test the neighbors of our tile to see if we are surrounded by sea. This technique can be applied effectively to many other scenarios, however, like initializing a set of buttons, or aligning a bunch of logos.</p>

<pre><code>var isSurroundedBySea : Boolean = false;

var leftTile : Tile = map.getTile( m_currentX - 1, m_currentY );
if( leftTile != null &amp;&amp; !leftTile.isSea() )
{
    isSurroundedBySea = false;
}

var rightTile : Tile = map.getTile( m_currentX + 1, m_currentY );
if( rightTile != null &amp;&amp; !rightTile.isSea() )
{
    isSurroundedBySea = false;
}

var upTile : Tile = map.getTile( m_currentX, m_currentY - 1 );
if( upTile != null &amp;&amp; !upTile.isSea() )
{
    isSurroundedBySea = false;
}

var downTile : Tile = map.getTile( m_currentX, m_currentY + 1 );
if( downTile != null &amp;&amp; !downTile.isSea() )
{
    isSurroundedBySea = false;
}
</code></pre>

<p>Copy/pasting has bloated the size of the code and made it incredibly brittle. If we need to modify the basic logic of the query (like perhaps testing for a modifier called &#8220;Sea&#8221; instead), we have to hope we remember to do it in all 4 places, and to do it correctly.</p>

<p>Never fear, though, Mr. For-Loop is here to save us. What I like to do in this particular case is plug all the objects into an array and then use a for-loop to make sure the code is written only once:</p>

<pre><code>var isSurroundedBySea : Boolean = false;

var neighbors : Array = [
    map.getTile( m_currentX - 1, m_currentY ),
    map.getTile( m_currentX + 1, m_currentY ),
    map.getTile( m_currentX, m_currentY + 1),
    map.getTile( m_currentX, m_currentY - 1 ) ];

for( var n : int = 0; n &lt; neighbors.length; n++ )
{
    var neighbor : Tile = neighbors[ n ];
    if( neighbor != null &amp;&amp; !neighbor.isSea() )
    {
        isSurroundedBySea = false;
        break;
    }
 }
</code></pre>

<p>Not only is it faster to write this code than it is to copy/paste all that junk up there, the code is significantly more robust because we&#8217;ve converted 4 potential sources of failure into (basically) one.</p>

<p>You have to be able to write bug free for-loops to use this trick effectively. But I&#8217;m pretty sure you can handle that. <img src='http://www.gamepoetry.com/blog/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
]]></content:encoded>
			<wfw:commentRss>http://www.gamepoetry.com/blog/2009/04/23/for-loop-defeats-copy-paste/feed/</wfw:commentRss>
		<slash:comments>5</slash:comments>
		</item>
		<item>
		<title>4KPillars Post Mortem Added</title>
		<link>http://www.gamepoetry.com/blog/2009/03/30/4kpillars-post-mortem-added/</link>
		<comments>http://www.gamepoetry.com/blog/2009/03/30/4kpillars-post-mortem-added/#comments</comments>
		<pubDate>Tue, 31 Mar 2009 02:24:36 +0000</pubDate>
		<dc:creator>urbansquall</dc:creator>
				<category><![CDATA[Science]]></category>

		<guid isPermaLink="false">http://www.gamepoetry.com/blog/?p=496</guid>
		<description><![CDATA[I just attached Filippo&#8217;s post mortem for his Audience Choice winning 4kPillars to the 4K Flash Game Post Mortems article.
]]></description>
			<content:encoded><![CDATA[<p>I just attached <a href="http://www.gamepoetry.com/blog/2009/03/20/4k-flash-game-post-mortems/6/">Filippo&#8217;s post mortem</a> for his Audience Choice winning <a href="http://www.gamepoetry.com/blog/4k-flash-4kpillars/">4kPillars</a> to the <a href="http://www.gamepoetry.com/blog/2009/03/20/4k-flash-game-post-mortems/">4K Flash Game Post Mortems article</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.gamepoetry.com/blog/2009/03/30/4kpillars-post-mortem-added/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Essential Open Source Actionscript</title>
		<link>http://www.gamepoetry.com/blog/2009/03/27/essential-open-source-actionscript/</link>
		<comments>http://www.gamepoetry.com/blog/2009/03/27/essential-open-source-actionscript/#comments</comments>
		<pubDate>Fri, 27 Mar 2009 23:02:17 +0000</pubDate>
		<dc:creator>urbansquall</dc:creator>
				<category><![CDATA[Featured]]></category>
		<category><![CDATA[Science]]></category>
		<category><![CDATA[code]]></category>
		<category><![CDATA[flash]]></category>
		<category><![CDATA[open source]]></category>

		<guid isPermaLink="false">http://www.gamepoetry.com/blog/?p=477</guid>
		<description><![CDATA[

There are a few Open Source Actionscript projects that Urbansquall relies on for most of its games. Here&#8217;s an overview of the three open source tools that we&#8217;ve found essential to Flash game development. 

BulkLoader

For any project where we need to load external files, we&#8217;ve come to rely on BulkLoader. If you&#8217;ve ever tried to [...]]]></description>
			<content:encoded><![CDATA[<p><img src="http://www.gamepoetry.com/blog/wp-content/uploads/2009/03/open_source.jpg" alt="open_source" title="open_source" width="330" height="60" class="aligncenter size-full wp-image-478" /></p>

<p>There are a few Open Source Actionscript projects that Urbansquall relies on for most of its games. Here&#8217;s an overview of the three open source tools that we&#8217;ve found essential to Flash game development. <span id="more-477"></span></p>

<h1>BulkLoader</h1>

<p>For any project where we need to load external files, we&#8217;ve come to rely on <a href="http://code.google.com/p/bulk-loader/">BulkLoader</a>. If you&#8217;ve ever tried to load a few hundred files at once with AS3, you know that at some point Flash will fail fairly silently and just refuse to load the data you require. That&#8217;s where BulkLoader fits in. When you try to load something with BulkLoader, if its there it will arrive. No exceptions.</p>

<h1>Box2D</h1>

<p><a href="http://www.box2d.org/">Box2D</a> is quickly becoming our de facto solution for anything related to 2D collision detection and resolution. There&#8217;s not much to say about Box2D except that it was the first Flash physics engine that did it right, and it quickly destroyed all the competition. We &lt;3 Box2D.</p>

<h1>Tweener</h1>

<p>I feel dirty every time I use <a href="http://code.google.com/p/tweener/">Tweener</a>, but its ease of use and raw power makes it the most common open source actionscript we rely on here at Urbansquall. Even the most stale UI can be made to pop after a few hours in bed with Tweener.</p>

<h1>Others?</h1>

<p>There are plenty of open source Actionscript projects out there, here are some we hope we get to play with sometime in the future:</p>

<ul>
<li><a href="http://code.google.com/p/papervision3d/">Papervision3d</a> &#8211; 3D Engine</li>
<li><a href="http://www.flashapi.org/">SPAS</a> &#8211; UI framework</li>
<li><a href="http://www.aswing.org/">AsWing</a> &#8211; Another UI framework</li>
<li><a href="http://code.google.com/p/vanrijkom-flashlibs/">FAR</a> &#8211; zip support</li>
</ul>

<p>Of course we rely on the <a href="http://code.google.com/p/gamepoetry/">gamepoetry</a> open source resources more than anything else. <img src='http://www.gamepoetry.com/blog/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
]]></content:encoded>
			<wfw:commentRss>http://www.gamepoetry.com/blog/2009/03/27/essential-open-source-actionscript/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>Better Programmer Art</title>
		<link>http://www.gamepoetry.com/blog/2008/12/30/better-programmer-art/</link>
		<comments>http://www.gamepoetry.com/blog/2008/12/30/better-programmer-art/#comments</comments>
		<pubDate>Tue, 30 Dec 2008 19:33:51 +0000</pubDate>
		<dc:creator>urbansquall</dc:creator>
				<category><![CDATA[Art]]></category>
		<category><![CDATA[Science]]></category>

		<guid isPermaLink="false">http://www.gamepoetry.com/blog/?p=146</guid>
		<description><![CDATA[GameDev.net has an excellent article on improving programmer art. 

The article has some great suggestions (like stealing poses from existing sprite sheets), but I can&#8217;t help but feel the author is discounting his natural artistic talent. Either way, it&#8217;s worth tackling the full article.
]]></description>
			<content:encoded><![CDATA[<p><a href="http://www.gamedev.net">GameDev.net</a> has an excellent article on improving programmer art. <span id="more-146"></span></p>

<p>The article has some great suggestions (like stealing poses from existing sprite sheets), but I can&#8217;t help but feel the author is discounting his natural artistic talent. Either way, it&#8217;s worth tackling the <a href="http://www.gamedev.net/reference/art/features/CoderGameArt/">full article</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.gamepoetry.com/blog/2008/12/30/better-programmer-art/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Flash Develop 3.0 RC1</title>
		<link>http://www.gamepoetry.com/blog/2008/12/24/flash-develop-30-rc1/</link>
		<comments>http://www.gamepoetry.com/blog/2008/12/24/flash-develop-30-rc1/#comments</comments>
		<pubDate>Wed, 24 Dec 2008 18:07:15 +0000</pubDate>
		<dc:creator>urbansquall</dc:creator>
				<category><![CDATA[Science]]></category>
		<category><![CDATA[flash develop]]></category>

		<guid isPermaLink="false">http://www.gamepoetry.com/blog/?p=135</guid>
		<description><![CDATA[Especially important for Vista users, there is a new release of Flash Develop.
]]></description>
			<content:encoded><![CDATA[<p>Especially important for Vista users, there is a new release of <a href="http://www.flashdevelop.org/community/viewtopic.php?f=11&amp;t=4041">Flash Develop</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.gamepoetry.com/blog/2008/12/24/flash-develop-30-rc1/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Entity State Machine in 60 Seconds or Less</title>
		<link>http://www.gamepoetry.com/blog/2008/12/12/entity-state-machine-in-60-seconds-or-less/</link>
		<comments>http://www.gamepoetry.com/blog/2008/12/12/entity-state-machine-in-60-seconds-or-less/#comments</comments>
		<pubDate>Fri, 12 Dec 2008 22:28:12 +0000</pubDate>
		<dc:creator>urbansquall</dc:creator>
				<category><![CDATA[Featured]]></category>
		<category><![CDATA[Science]]></category>
		<category><![CDATA[code]]></category>
		<category><![CDATA[flash]]></category>

		<guid isPermaLink="false">http://www.gamepoetry.com/blog/?p=91</guid>
		<description><![CDATA[

Every now and then you come across a solution to a problem you never knew existed. Squize over at Gaming Your Way blew my mind this week when he posted a quick overview of how he supports the concept of state machines in his code. The solution is so simple and quick that I couldn&#8217;t [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://www.gamepoetry.com/blog/wp-content/uploads/2008/12/state_machine.png"><img src="http://www.gamepoetry.com/blog/wp-content/uploads/2008/12/state_machine.png" alt="" title="state_machine" width="350" height="288" class="alignright size-full wp-image-77" /></a></p>

<p>Every now and then you come across a solution to a problem you never knew existed. Squize over at <a href="http://blog.gamingyourway.com/">Gaming Your Way</a> blew my mind this week when he posted a quick overview of how he supports the concept of state machines in his code. The solution is so simple and quick that I couldn&#8217;t help but just say &#8220;Wow!&#8221; when I read it. <span id="more-91"></span></p>

<p>You can learn about his implementation <a href="http://blog.gamingyourway.com/PermaLink,guid,8c079942-1647-4393-a7fc-fab8d014e24b.aspx">here</a>. There are a number of things I like about this solution:</p>

<ol>
<li>It uses built-in language functionality. This means you don&#8217;t have to do any fancy imports or copy paste code from old projects because there are no external dependencies. This can help make your code more maintainable and portable.</li>
<li>It can be incorporated into existing code with minimal effort.</li>
<li>It is simple to understand and discuss.</li>
</ol>

<p>The biggest draw back I have with this particular implementation is there is no concise way to manage state-specific data. For example, if you have two entity states, idle and attack, the attack state would need a target but the idle would not. In a more engineered solution (which doesn&#8217;t necessarily make it better), each state would track and manage its data, so that the idle functionality didn&#8217;t share logical space with the attack functionality, which has this distinct target data. It&#8217;s not a deal breaker by any means, and I think that for all but the most complicated state machine functionality, even with this drawback, this solution wins out because of the reasons stated above.</p>

<p>Thanks Squize and <a href="http://blog.gamingyourway.com/">Gaming Your Way</a>!</p>
]]></content:encoded>
			<wfw:commentRss>http://www.gamepoetry.com/blog/2008/12/12/entity-state-machine-in-60-seconds-or-less/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Trunks, Tags and Branches in Subversion</title>
		<link>http://www.gamepoetry.com/blog/2008/12/05/trunks-tags-and-branches-in-subversion/</link>
		<comments>http://www.gamepoetry.com/blog/2008/12/05/trunks-tags-and-branches-in-subversion/#comments</comments>
		<pubDate>Fri, 05 Dec 2008 16:10:43 +0000</pubDate>
		<dc:creator>urbansquall</dc:creator>
				<category><![CDATA[Featured]]></category>
		<category><![CDATA[Science]]></category>
		<category><![CDATA[best practices]]></category>
		<category><![CDATA[coding]]></category>
		<category><![CDATA[tools]]></category>

		<guid isPermaLink="false">http://www.gamepoetry.com/wpress/?p=98</guid>
		<description><![CDATA[

As I mentioned before, Subversion is critical to daily development at Urbansquall. Subversion has a lot of really fancy features that can help make development a lot less stressful even for a lone developer. Today I&#8217;m going to go over one of the features that we&#8217;ve found particularly useful working in a team, and that [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://www.gamepoetry.com/blog/wp-content/uploads/2008/12/subversion_logo-200x173.png"><img src="http://www.gamepoetry.com/blog/wp-content/uploads/2008/12/subversion_logo-200x173.png" alt="" title="subversion_logo-200x173" width="200" height="173" class="alignright size-full wp-image-67" /></a></p>

<p>As I <a href="http://www.gamepoetry.com/blog/2008/06/20/effortless-development-and-version-control/">mentioned before</a>, Subversion is critical to daily development at <a href="http://www.urbansquall.com">Urbansquall</a>. Subversion has a lot of really fancy features that can help make development a lot less stressful even for a lone developer. Today I&#8217;m going to go over one of the features that we&#8217;ve found particularly useful working in a team, and that is the concept of Trunks, Tags and Branches in a repository. <span id="more-49"></span></p>

<p>The simplest way to use Subversion is simply to dump everything into some sort of structure in your repository and then to go about your business. The reality is that this is more than sufficient for a lot of projects. But, particularly for projects that will be evolving as they are reused over several years, like a networking library for example, or a larger game that is being worked on by 4 people at any given time, the concept of Trunks, Tags and Branches can make it a little easier to keep people from stepping on each other&#8217;s toes as they are going about their business.</p>

<h3>Trunks</h3>

<p>Trunks is the easiest part of the TTB paradigm to understand. The Trunk is basically equivalent to what your repository would have been without using TTB. Trunk represents the active state of development shared by the majority of the team, and is assumed to be a non-official release that is in a buildable state.</p>

<h3>Tags</h3>

<p>Tags are most useful when you want to flag a specific state of the Trunk. Let&#8217;s say you&#8217;ve officially hit 1.0 and you are ready to do a public release. You might Tag trunk at 1.0 as you do the release, and then start development on some 1.5 features that you want to include. In this case, a user might find a bug in 1.0. You can&#8217;t patch your pre-1.5 version trunk because your 1.5 features are incomplete and shouldn&#8217;t be released. Because you tagged 1.0, you can check out that specific tag, make your bug fix, and then cut a 1.0.1 build that fixes that bug but doesn&#8217;t introduce any of the messiness of your partially implemented 1.5 features.</p>

<p>Tags are essentially a stamp for a noteworthy state of the Trunk that might be useful to return to in the future.</p>

<h3>Branches</h3>

<p>Branches are the trickiest part of the TTB paradigm, but they are probably the most useful. Branches come into play when we are considering actions that would disturb the Trunk or make the Trunk otherwise unbuildable. A good example we had recently on a project was that we had to recode the vast majority of the networking layer that a game was using. The game was working fine with the current networking layer, but the new networking layer would deal with a lot of the lag issues we were experiencing. The problem was that this networking layer rewrite was going to take weeks and would affect at least as much as 40 source files in the game engine itself. We used branching here for the following reasons:</p>

<ol>
<li>The rewrite was complicated and would require many iterations, and we wanted the benefit provided by SVN in terms of being able to revert or inspect the revision history.</li>
<li>The game was undergoing active development from other developers at the same time the engine rewrite was occurring. We needed to make sure that all these updates would be merged into our rewrite so that no work was lost and also that we didn&#8217;t prevent these other developers from working while the networking engine was in a half-working state.</li>
<li>We weren&#8217;t sure that the rewrite would even work, so we wanted to be able to throw it away if failed.</li>
</ol>

<p>So, we branched the code, rewrote the networking engine, and made sure we updated against Trunk frequently to keep up with everyone else&#8217;s commits. When the new networking engine was stable enough to replace the old networking engine, we could simply merge the Branch back into the Trunk without affecting the other developers who had been working on the project.</p>

<h3>Structure</h3>

<p>It&#8217;s easiest to put TTB into your project at the start. SVN actually makes this almost stupidly easy. At the root of your repository, just create three directories: trunk, branches, tags. Leave branches and tags empty and then put everything (source code, docs, art, etc.) into trunk like you would have done before. When you do your checkout, instead of doing &#8220;url.com/my_repository&#8221; you would now just checkout &#8220;url.com/my_repository/trunk&#8221; and you can forget about it until you find you need it one day. That&#8217;s pretty much it, if you find you need to do a Tag or a Branch in the future, you simply right-click on your Trunk folder (assuming you are using TortoiseSVN), and choose Tag or Branch as appropriate.</p>

<p>The specifics of Branching can get a little more complicated, so I suggest you do a little more in depth reading into the topic when you think you might need it just so you can make sure you do it correctly. It&#8217;s not complicated but there are some gotchas that you will want to understand first.</p>

<h3>Conclusion</h3>

<p>The TTB paradigm is not a complicated one. It stays out of your way until you need it, and it only requires a moment of effort to set up when you are first getting a project going. If you think you may have some use for it, it might be worth doing a little more reading on the subject, as SVN supports TTB quite well. It is very efficient at storing Tags and Branches, and you can typically do both while adding only a fractional increase to the size of the stored repository because SVN is smart about storing only the changes between the Trunk and the Tags or Branches (rather than an actual deep copy).</p>
]]></content:encoded>
			<wfw:commentRss>http://www.gamepoetry.com/blog/2008/12/05/trunks-tags-and-branches-in-subversion/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>Make the Smart Choice So That Your User Doesn&#8217;t Have To (3/3)</title>
		<link>http://www.gamepoetry.com/blog/2008/11/21/make-the-smart-choice-so-that-your-user-doesnt-have-to-part-3/</link>
		<comments>http://www.gamepoetry.com/blog/2008/11/21/make-the-smart-choice-so-that-your-user-doesnt-have-to-part-3/#comments</comments>
		<pubDate>Fri, 21 Nov 2008 14:02:39 +0000</pubDate>
		<dc:creator>urbansquall</dc:creator>
				<category><![CDATA[Featured]]></category>
		<category><![CDATA[General]]></category>
		<category><![CDATA[Science]]></category>
		<category><![CDATA[best practices]]></category>
		<category><![CDATA[coding]]></category>
		<category><![CDATA[design]]></category>
		<category><![CDATA[flash]]></category>

		<guid isPermaLink="false">http://www.gamepoetry.com/wpress/2008/11/21/make-the-smart-choice-so-that-your-user-doesnt-have-to-part-3/</guid>
		<description><![CDATA[This is final part of a three part series. You may want to check out part 1 and part 2. 

API Design

As a Flash game developer, you&#8217;ll find yourself interacting with all sorts of APIs designed and implemented by third parties. Because most libraries aspire to being popular, they generally strive to include as many [...]]]></description>
			<content:encoded><![CDATA[<p>This is final part of a three part series. You may want to <a href="http://www.gamepoetry.com/blog/2008/11/07/make-the-smart-choice-so-that-your-user-doesnt-have-to-part-1/">check out part 1</a> and <a href="http://www.gamepoetry.com/blog/2008/11/14/make-the-smart-choice-so-that-your-user-doesnt-have-to-part-2/">part 2</a>. <span id="more-47"></span></p>

<h3>API Design</h3>

<p>As a Flash game developer, you&#8217;ll find yourself interacting with all sorts of APIs designed and implemented by third parties. Because most libraries aspire to being popular, they generally strive to include as many features as possible, and support all manner of possible interactions with their API. Few API designers take the time to consider what primary motivation drives the user of their API. Programmers are elitist snobs. Generally speaking, the only time we are willing to consider dirtying our pretty code with someone else&#8217;s, is if its going to save us time (and therefore money).</p>

<p>When I began this article, I intended to point to some specific APIs that I use regularly whose designers failed to take this into account. Being that I still use these APIs on a regular basis, I decided it was best not to ruffle any feathers and instead just talk about how to apply this strategy instead. For fun, though, I&#8217;ll post some DirectX code here that I&#8217;ve always thought was a particularly heinous trespasser in this regard.</p>

<pre><code>
void initInput(HINSTANCE hInstance, HWND hWnd)
{
    DirectInput8Create(hInstance,
                       DIRECTINPUT_VERSION,
                       IID_IDirectInput8,
                       (void**)&#038;din,
                       NULL);

    din->CreateDevice(GUID_SysKeyboard,
                      &#038;dinkeyboard,
                      NULL);

    dinkeyboard->SetDataFormat(&#038;c_dfDIKeyboard);

    dinkeyboard->SetCooperativeLevel(hWnd,
                                     DISCL_NONEXCLUSIVE | DISCL_BACKGROUND);

      return;
}</code></pre>

<p><em>Note: I&#8217;m not saying this code is necessarily bad. Instead I&#8217;m trying to illustrate that there really is no good reason to require an application to specify much more than a single line of code that requests an initialized keyboard object. Sure I might sometimes care about all that other crap, but why make me bother with it every time I want keyboard controls? Also, Hungarian notation! So much fun!</em></p>

<p>A reasonable rule of thumb when approaching your API&#8217;s design is this: If I am trying to accomplish a single task, give me an opportunity to do that with one action, or at most two if reasonable technical restraints require it (like an asynchronous interaction). As soon as you want me to create 15 different interrelated objects that all require special customization, listeners and handlers, just to accomplish a single task, you&#8217;ve just eaten into the main reason I decided to use your API in the first place, and that is to get where I want to go quicker.</p>

<p>Because flexibility is so important to most API designs, I don&#8217;t want to suggest that we can get away with simple APIs. Instead, I want to suggest that the API assume that the defaults are sufficient unless the client code specifies otherwise.</p>

<p>To further illustrate the point, here are some basic examples of where we might want to make assumptions to simplify our API:</p>

<ol>
<li>Assume that I want the mass of my physics shape to be proportional to its size, <em>unless I say otherwise.</em></li>
<li>Assume that I want to connect using the most efficient protocol possible, <em>unless I say otherwise.</em></li>
<li>Assume that I don&#8217;t care about being notified about the completion of an event, <em>unless I say otherwise.</em></li>
<li>Assume I don&#8217;t care about hidden files, <em>unless I say otherwise.</em></li>
<li>Assume I want you to save the file when I write to it, <em>unless I say otherwise.</em></li>
<li>Assume that I&#8217;d rather use the file system to manage my assets than some convoluted proprietary library, <em>unless I say otherwise.</em></li>
</ol>

<p>What I&#8217;m trying to get at here, is that by making assumptions and providing smart default choices for our API, we eliminate the number of things the user needs to learn (and just as often relearn) when working with our code. We are qualified to make the smart choice for our user because we know what we&#8217;re doing, which is why we built this API to begin with. Sure, the user is entitled to override our default choices with something that&#8217;s more specifically tuned to his application. But our defaults are invisible to the user. We can potentially eliminate one more thing the user needs to learn for every part of the application where we can put in a smart default choice rather than relying on the user to get involved.</p>

<h3>API Design Trumps</h3>

<p>There are really so many trumping situations here that it is not worth getting into. The reality is that each API is going to be drastically different, and that certain APIs are going to lend themselves to utilizing this mantra more than others. At the end of the day, though, as you&#8217;re designing your API, you need to ask yourself, how often will the user need to customize this? If its every application, then its not a candidate. If the majority of applications can use a suitable default and be fine, then there is no good reason to require the user to explicitly choose that option. The default smart choice is there to make his life easier so that he can go about getting his work done.</p>

<h3>Conclusion</h3>

<p>That concludes the series &#8220;Make the Smart Choice So That Your User Doesn&#8217;t Have To&#8221;. Don&#8217;t forget to read <a href="http://www.gamepoetry.com/blog/2008/11/07/make-the-smart-choice-so-that-your-user-doesnt-have-to-part-1/">Part 1</a> which deals with Preferences and <a href="http://www.gamepoetry.com/blog/2008/11/15/make-the-smart-choice-so-that-your-user-doesnt-have-to-part-2/">Part 2</a> that deals with User Interfaces.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.gamepoetry.com/blog/2008/11/21/make-the-smart-choice-so-that-your-user-doesnt-have-to-part-3/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Make the Smart Choice So That Your User Doesn&#8217;t Have To (1/3)</title>
		<link>http://www.gamepoetry.com/blog/2008/11/07/make-the-smart-choice-so-that-your-user-doesnt-have-to-part-1/</link>
		<comments>http://www.gamepoetry.com/blog/2008/11/07/make-the-smart-choice-so-that-your-user-doesnt-have-to-part-1/#comments</comments>
		<pubDate>Fri, 07 Nov 2008 14:17:09 +0000</pubDate>
		<dc:creator>urbansquall</dc:creator>
				<category><![CDATA[Art]]></category>
		<category><![CDATA[Science]]></category>
		<category><![CDATA[best practices]]></category>
		<category><![CDATA[coding]]></category>
		<category><![CDATA[design]]></category>
		<category><![CDATA[flash]]></category>

		<guid isPermaLink="false">http://www.gamepoetry.com/wpress/2008/11/07/make-the-smart-choice-so-that-your-user-doesnt-have-to-part-1/</guid>
		<description><![CDATA[
This is one of those high level rules that applies across a wide range of topics. It has application in everything from how you approach your user-interface, to your attitudes towards options screens and even as far reaching as API design. The basic premise is that developers often hide their inability to make the smart [...]]]></description>
			<content:encoded><![CDATA[<p><img src='http://www.gamepoetry.com/blog/wp-content/uploads/2008/10/brain.jpg' alt='Smart Choices!' align='right' />
This is one of those high level rules that applies across a wide range of topics. It has application in everything from how you approach your user-interface, to your attitudes towards options screens and even as far reaching as API design. The basic premise is that developers often hide their inability to make the smart choice by delegating that choice to the user. Spend the time and the effort to make the smart choice so that your users don&#8217;t have to and your product will be significantly stronger as a result. <span id="more-45"></span></p>

<h3>Credit</h3>

<p>I have to credit this wonderful insight to the chapter <a href="http://gettingreal.37signals.com/ch06_Avoid_Preferences.php">Avoid Preferences</a> in 37 Signal&#8217;s awesome book <a href="http://gettingreal.37signals.com/toc.php">Getting Real</a>. The whole book is worth (several) readings, and I can&#8217;t recommend it enough.</p>

<h3>Preferences</h3>

<p>Some developers pride themselves on all the customization options they offer their players. They let them adjust everything from graphical quality to which key combination fires a particular action. Who is better qualified to make these decisions? You or the player? Generally speaking, you have the skills and ability to make better decisions about player preferences than they can make themselves, so instead of delegating the choice to the player, make the right decision so that they don&#8217;t have to. I&#8217;m not against exposing the ability to let the player override this default choice, but your goal as a developer is to create the game your players want to play, not the game they need to customize to enjoy.</p>

<p><em>Case 1: Controls</em></p>

<p>Look inversion in First Person Shooters is a topic as divisive as some of today&#8217;s hottest political issues. Up until very recently, a game would make a decision, either inverted or not inverted, and (hopefully), players would be forced to dig through a bunch of settings to if their personal preference did not match that of the developer.</p>

<p>Recently though, several FPSes, like Bungie&#8217;s Halo for example, have started using gameplay to determine your inversion preferences. During the first few seconds of play, the game asks you to look at an object in the world. Based on how you interact with the controls to achieve this objective, the game makes assumptions about your control preferences. It even gives you the opportunity to correct it if it guesses wrong. Is that better than forcing your player to spend the important first few seconds of your game digging through menus to find a look inversion setting? Immersion wins when your players aren&#8217;t reminded that they are simply playing a game.</p>

<p><em>Case 2: Playback Quality</em></p>

<p>I am as guilty of this than any other veteran Flash developer out there. In a graphically intensive Flash game it is very tempting to give the player the opportunity to play the game in low quality rendering mode in order to squeeze maximum performance out of the Flash Player. If you think about it, that is completely unforgivable. Using a timer and some basic computations, we can make some quick estimates about the hardware capabilities of player&#8217;s machine and make the right decision far more accurately than the player. How are they supposed to know if they want 3 levels of parallax instead of just 1? The reality is we&#8217;re hard pressed for time so we opt for the easy choice rather than the right choice. In a future article I will tackle a utility class that will handle this computation on our behalf so that we don&#8217;t have any excuse to do this again.</p>

<h3>Preference Trumps</h3>

<p><em>Sound Muting</em></p>

<p>Every good rule has its exceptions. An important trump to the preferences aspect of this rule, in regards to Flash games, relates specifically to sound. There are certain standards that have been established in Flash game design, and typically these are around for good reason. When it comes to muting sound and music in Flash games, we have to understand the context, which why this rule is more of a &#8220;Best Practice&#8221; than it is a real trumping exception. Flash games weren&#8217;t popularized by people who traditionally play PC and console games. Flash games were popularized by people who were supposed to be working or otherwise being productive on their computer. People want to play your Flash game without being fired. If they can&#8217;t turn off the music and sound in your game with the click of a button at any instant, chances are they&#8217;re not going to be able to enjoy your game that much, if they even play it at all.</p>

<p>As I discovered in a recent game release, it is not sufficient to bury this capability in an options menu. On any screen where there is music or sound playing, you must give the player the ability to quickly and effortlessly turn off any and all sounds with a single action.</p>

<h3>Follow Ups</h3>

<p>Next up we will be discussing how this rule applies to user interface design, and then we will wrap it up with how this rule can make your API easier to use.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.gamepoetry.com/blog/2008/11/07/make-the-smart-choice-so-that-your-user-doesnt-have-to-part-1/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
	</channel>
</rss>

<!-- Dynamic Page Served (once) in 0.504 seconds -->
