<?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>addChild(blog)</title>
	<atom:link href="http://blog.andrewtraviss.com/?feed=rss2" rel="self" type="application/rss+xml" />
	<link>http://blog.andrewtraviss.com</link>
	<description>Flash and Flex Game Development</description>
	<lastBuildDate>Wed, 28 Apr 2010 16:55:53 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.8.6</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>A TOJam 5 Retrospective</title>
		<link>http://blog.andrewtraviss.com/?p=271</link>
		<comments>http://blog.andrewtraviss.com/?p=271#comments</comments>
		<pubDate>Wed, 28 Apr 2010 14:08:33 +0000</pubDate>
		<dc:creator>Andrew</dc:creator>
				<category><![CDATA[Events]]></category>
		<category><![CDATA[Game Development]]></category>
		<category><![CDATA[Reentry]]></category>
		<category><![CDATA[TOJam]]></category>

		<guid isPermaLink="false">http://blog.andrewtraviss.com/?p=271</guid>
		<description><![CDATA[It is done! 180 people this year, 160 of them on-site. And amazingly, with 35 more people than TOJam 3, it actually felt less hectic. The organizers were more sane and better rested, and actually had time to sit and chat more.
Pro Tip:Talking to Jim McGinley for 30 minutes or so when you are exhausted [...]]]></description>
			<content:encoded><![CDATA[<p>It is done! 180 people this year, 160 of them on-site. And amazingly, with 35 more people than TOJam 3, it actually felt less hectic. The organizers were more sane and better rested, and actually had time to sit and chat more.</p>
<p><strong>Pro Tip:</strong>Talking to Jim McGinley for 30 minutes or so when you are exhausted to the point of passing out will generally restore your energy for the remainder of the day. Or at least long enough for the caffeine to take over</p>
<p>As always, I had an awesome time, even if I was more tired this year than previous years. That largely due to the fact that I was up until 3 am the night before the Jam trying to get SVN set up on my machine so that Alex and I could forego the USB time sync. <a href="http://psychology.wikia.com/wiki/Irrational_escalation">Irrational Escalation</a> at its finest.</p>
<p>Alex covered the event really well with some video blogs. Find them <a href="http://www.drunkenmonkeystyle.com/blog/?p=121">here</a>.</p>
<p>There were some fantastic games out there, I sunk quite a bit of time into Michael Todd&#8217;s dogfighting game. Shawn McGrath&#8217;s game would probably conquer XBox Live Arcade if it were to appear there. Some screenshots and description of our game after the cut</p>
<p><span id="more-271"></span></p>
<p>Our game this year was &#8220;Reentry&#8221; a game about misplaced guidance systems and creepy starship pilots. This year had a lot of ups and down for us.</p>
<h2>Good: Sound and music</h2>
<p>This year&#8217;s game used more sound assets than all 4 of the previous games I&#8217;ve worked on put together.</p>
<p><img src="http://blog.andrewtraviss.com/media/reentry-title.jpg" alt="Reentry Title Page" align="right" /></p>
<p>Alex worked with a friend of his to record voice tracks for the main characters who I have dubbed Captain Helium and Lt. Commander Creeper McShady. The voices<br />
add a lot to the experience. The game feels a little dull without them, but that&#8217;s in line with our plan. The characters are a big part of the design.</p>
<p>We also got a great music track from chiptune artist <a href="http://www.oxygenstarpower.com/">OxygenStar</a> and editted it into 3 loops connected by transitions. It turned out great.</p>
<p>For sound effects, we used <a href="http://www.drpetter.se/project_sfxr.html">SFXR</a>, which belongs in every indie developer&#8217;s toolbox. Thanks to Steven Hill for throwing that one our way. All of the sound effects in the game were generated by Alex using this tool. I&#8217;m excited to try out the music creation tool <a href="http://www.drpetter.se/project_musagi.html">Musagi</a> by the same developer</p>
<h2>Bad: Source Control</h2>
<p>If you ever think about trying to set up SVN the night before a 72-hour game development event, and further think about starting at 11 pm, with no prior experience doing so, do yourself a favour and don&#8217;t.</p>
<p><img src="http://blog.andrewtraviss.com/media/reentry-screenshot-1.jpg" alt="Reentry Screenshot" align="left" /></p>
<p>Our hackjob solution made me worry quite a bit but ended up working out. We set up the Flex project on Alex&#8217;s computer in a network share folder and both pointed our environments at that location directly. There were some hiccups where one of us would temporarily break the build for the other, but I don&#8217;t think we lost more than 30 mins over the course of the Jam. That&#8217;s much better than what we wasted with our USB juggling last year.</p>
<p>Next year I&#8217;ll try to get SVN set up again, but this time a month in advance at least.</p>
<h2>Good: Scope Control</h2>
<p>We wanted to aim for a smaller game idea this year. We have trended towards big ideas before, and felt that it didn&#8217;t leave us enough time to refine the gameplay for the actual fun factor. I think we pulled it off this time, despite ignoring a game breaking bug right until the end of the event.</p>
<p><img src="http://blog.andrewtraviss.com/media/reentry-screenshot-2.jpg" alt="Reentry Screenshot" align="right" /></p>
<p>Balancing ship movement to be challenging without killing you was very time consuming You have to click the appropriate thruster and hold the mouse down (not necessarily over the thruster) to keep it firing. There are two thrusters that push your ship side to side, and two more that control your rotation. Figuring out the right amount of force for each engine to apply, as well as turbulence and impacts took up a pretty significant chunk of my time at the event.</p>
<p>Next time I&#8217;m adding some mechanism to adjust these values in the game itself, to make tweaking less time consuming</p>
<h2>Bad: Miscommunication</h2>
<p>This mostly happened prior to the event, but apparently everyone had a different picture in their head of what the game would actually look and play like up until the week of the event.</p>
<p><img src="http://blog.andrewtraviss.com/media/reentry-screenshot-3.jpg" alt="Reentry Screenshot" align="left" /></p>
<p>It wasn&#8217;t until we actually started sketching out the game that everything became clear. Lesson learned. The storyboard comes before everything else. It&#8217;s much harder to have a misunderstanding based on visual information than written or spoken information.</p>
<h2>Things To Change Next Year</h2>
<p>Based on my experience this year, there are several things I want to keep in mind when TOJam 6 rolls around. Some good practices from previous years were not observed, and they proved their value in their absence.</p>
<ol>
<li>Use an engine. Not using Flixel this time made sense, but the decision should have come earlier, and a more appropriate technology selected. The best games every year leverage existing technologies. Motor physics really gave us a leg up last year.</li>
<li>Simple gameplay. We went simpler this year, in terms of number of mechanics, but we didn&#8217;t actually choose a simpler mechanic for the core of the game.</li>
<li>Revive last year&#8217;s formal approach. Alex and I both work better against a well defined schedule. Not having one this year wasn&#8217;t a good change</li>
<li>Prove it&#8217;s fun ahead of time. We took a risk on this one with a small idea and really only one major mechanic that we hadn&#8217;t seen much of elsewhere. I liked doing this, but there should have been some pre-Jam prototyping just to be sure that the idea was actually a good one.</li>
<li>Consider abstract graphics. Every year so far I&#8217;ve worked with representative graphics, and it can be limiting in some ways even if it brings a lot of benefits along with it. Besides, if <a href="http://www.spookysquid.com/">Miguel Sternberg</a> can make a game without developers, we need to show him we can make a game without artists!</li>
</ol>
]]></content:encoded>
			<wfw:commentRss>http://blog.andrewtraviss.com/?feed=rss2&amp;p=271</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>TOJam 5 Approaches</title>
		<link>http://blog.andrewtraviss.com/?p=263</link>
		<comments>http://blog.andrewtraviss.com/?p=263#comments</comments>
		<pubDate>Fri, 16 Apr 2010 13:15:49 +0000</pubDate>
		<dc:creator>Andrew</dc:creator>
				<category><![CDATA[Events]]></category>
		<category><![CDATA[Game Development]]></category>
		<category><![CDATA[IllFate]]></category>
		<category><![CDATA[TOJam]]></category>

		<guid isPermaLink="false">http://blog.andrewtraviss.com/?p=263</guid>
		<description><![CDATA[TOJAM 5 IS UPON US. Once again I am joining my colleague Alex Bethke, and also Andrew Brykczynski, who worked with us on last year&#8217;s game Flip The Beach. Also joining us this year is TOJam newbie Kienan Walker.
I&#8217;ve been really busy lately, had to take a break from my Roguelike development to get life [...]]]></description>
			<content:encoded><![CDATA[<p><strong><a href="http://www.tojam.ca/home/default.asp">TOJAM 5 IS UPON US</a></strong>. Once again I am joining my colleague <a href="http://www.drunkenmonkeystyle.com/">Alex Bethke</a>, and also <a href="http://www.elephinkmedia.com/">Andrew Brykczynski</a>, who worked with us on last year&#8217;s game Flip The Beach. Also joining us this year is TOJam newbie Kienan Walker.</p>
<p>I&#8217;ve been really busy lately, had to take a break from my Roguelike development to get life back in order. Posts should start appearing more regularly now, although I am still holding off on the Roguelike until I have more time to dedicate to it. My first foray into Test Driven Development in a personal project has taught me quite a bit about how unit tests should be written, and what types of things one shouldn&#8217;t try to unit test. Some test refactoring should allow me to make easier progress. I&#8217;ll make a follow up post to discsuss what I learned</p>
<p><a href="http://www.bay12games.com/dwarves/">Dwarf Fortress</a> has now been updated to version 0.31, bringing an overhaul to the combat system and materials handling. There is much delectable modding goodness to be found there. Most my efforts in the short term will be devoted to working Dwarf Fortress modding tools and getting <a href="http://dffd.wimbli.com/file.php?id=794">RantingRodent&#8217;s Graphical Overhaul</a> updated with the new creatures and professions.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.andrewtraviss.com/?feed=rss2&amp;p=263</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Fatal Exceptions in Actionscript 3.0</title>
		<link>http://blog.andrewtraviss.com/?p=212</link>
		<comments>http://blog.andrewtraviss.com/?p=212#comments</comments>
		<pubDate>Sun, 24 Jan 2010 17:08:09 +0000</pubDate>
		<dc:creator>Andrew</dc:creator>
				<category><![CDATA[General Software Development]]></category>
		<category><![CDATA[Actionscript 3]]></category>

		<guid isPermaLink="false">http://blog.andrewtraviss.com/?p=212</guid>
		<description><![CDATA[I&#8217;ve put a lot of thought into best practices for exception handling. The guidelines described here are intended to maximize readability and maintainability of the code, as well as exposing failure information without looking up source code. In professional and personal projects, the experience with this method has been a very positive one.
Summary

Centralize  error [...]]]></description>
			<content:encoded><![CDATA[<p>I&#8217;ve put a lot of thought into best practices for exception handling. The guidelines described here are intended to maximize readability and maintainability of the code, as well as exposing failure information without looking up source code. In professional and personal projects, the experience with this method has been a very positive one.</p>
<h2>Summary</h2>
<ol>
<li>Centralize  error message construction to ensure consistency</li>
<li>Catch generic errors and throw specific errors in their place</li>
<li>Include as much information as possible about the error in the message itself</li>
<li>Exceptions are a tool to help solve problems, they are not problems themselves</li>
<li>Always throw an exception the moment the application state becomes invalid, rather than waiting for it to become a problem</li>
</ol>
<p><span id="more-212"></span></p>
<h2>Error Messages</h2>
<p>It&#8217;s often difficult to maintain a set of clear and consistent error messages. Flash developers are intimately familiar with the frustration of poor wording or vagueness. It&#8217;s difficult to prevent this from happening once the code base exceeds a certain size. A Factory can be employed to centralize the composition of error messages and make it easier to maintain them. Compare these two implementations:</p>

<div class="wp_syntax"><div class="code"><pre class="actionscript3" style="font-family:monospace;"><span style="color: #0033ff; font-weight: bold;">public</span> <span style="color: #339966; font-weight: bold;">function</span> getCell<span style="color: #000000;">&#40;</span>in_x<span style="color: #000000; font-weight: bold;">:</span><span style="color: #004993;">int</span>, in_y<span style="color: #000000; font-weight: bold;">:</span><span style="color: #004993;">int</span><span style="color: #000000;">&#41;</span><span style="color: #000000; font-weight: bold;">:</span>MapCell
<span style="color: #000000;">&#123;</span>
	<span style="color: #0033ff; font-weight: bold;">if</span><span style="color: #000000;">&#40;</span><span style="color: #000000; font-weight: bold;">!</span>_isInitialized<span style="color: #000000;">&#41;</span>
	<span style="color: #000000;">&#123;</span>
		<span style="color: #0033ff; font-weight: bold;">throw</span><span style="color: #000000;">&#40;</span><span style="color: #0033ff; font-weight: bold;">new</span> MapError<span style="color: #000000;">&#40;</span><span style="color: #990000;">&quot;Map not initialized prior to referencing a cell&quot;</span>, MapError.NOT_INITIALIZED<span style="color: #000000;">&#41;</span><span style="color: #000000;">&#41;</span>;
	<span style="color: #000000;">&#125;</span>
	<span style="color: #0033ff; font-weight: bold;">if</span><span style="color: #000000;">&#40;</span>outOfBounds<span style="color: #000000;">&#40;</span>in_x, in_y<span style="color: #000000;">&#41;</span><span style="color: #000000;">&#41;</span>
	<span style="color: #000000;">&#123;</span>
		<span style="color: #0033ff; font-weight: bold;">throw</span><span style="color: #000000;">&#40;</span><span style="color: #0033ff; font-weight: bold;">new</span> MapError<span style="color: #000000;">&#40;</span><span style="color: #990000;">&quot;Requested cell at (&quot;</span><span style="color: #000000; font-weight: bold;">+</span>in_x<span style="color: #000000; font-weight: bold;">+</span><span style="color: #990000;">&quot;,&quot;</span><span style="color: #000000; font-weight: bold;">+</span>in_y<span style="color: #000000; font-weight: bold;">+</span><span style="color: #990000;">&quot;) is out of map bounds&quot;</span>, MapError.OUT_OF_RANGE<span style="color: #000000;">&#41;</span><span style="color: #000000;">&#41;</span>;
	<span style="color: #000000;">&#125;</span>
	<span style="color: #0033ff; font-weight: bold;">return</span> MapCell<span style="color: #000000;">&#40;</span>_map.cells.<span style="color: #0033ff; font-weight: bold;">get</span><span style="color: #000000;">&#40;</span>in_x, in_y<span style="color: #000000;">&#41;</span><span style="color: #000000;">&#41;</span>;
<span style="color: #000000;">&#125;</span></pre></div></div>


<div class="wp_syntax"><div class="code"><pre class="actionscript3" style="font-family:monospace;"><span style="color: #0033ff; font-weight: bold;">public</span> <span style="color: #339966; font-weight: bold;">function</span> getCell<span style="color: #000000;">&#40;</span>in_x<span style="color: #000000; font-weight: bold;">:</span><span style="color: #004993;">int</span>, in_y<span style="color: #000000; font-weight: bold;">:</span><span style="color: #004993;">int</span><span style="color: #000000;">&#41;</span><span style="color: #000000; font-weight: bold;">:</span>MapCell
<span style="color: #000000;">&#123;</span>
	<span style="color: #0033ff; font-weight: bold;">if</span><span style="color: #000000;">&#40;</span><span style="color: #000000; font-weight: bold;">!</span>_isInitialized<span style="color: #000000;">&#41;</span>
	<span style="color: #000000;">&#123;</span>
		<span style="color: #0033ff; font-weight: bold;">throw</span><span style="color: #000000;">&#40;</span>MapErrorFactory.fromNotInitialized<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><span style="color: #000000;">&#41;</span>;
	<span style="color: #000000;">&#125;</span>
	<span style="color: #0033ff; font-weight: bold;">if</span><span style="color: #000000;">&#40;</span>outOfBounds<span style="color: #000000;">&#40;</span>in_x, in_y<span style="color: #000000;">&#41;</span><span style="color: #000000;">&#41;</span>
	<span style="color: #000000;">&#123;</span>
		<span style="color: #0033ff; font-weight: bold;">throw</span><span style="color: #000000;">&#40;</span>MapErrorFactory.fromOutOfBounds<span style="color: #000000;">&#40;</span>in_x, in_y<span style="color: #000000;">&#41;</span><span style="color: #000000;">&#41;</span>;
	<span style="color: #000000;">&#125;</span>
	<span style="color: #0033ff; font-weight: bold;">return</span> MapCell<span style="color: #000000;">&#40;</span>_map.cells.<span style="color: #0033ff; font-weight: bold;">get</span><span style="color: #000000;">&#40;</span>in_x, in_y<span style="color: #000000;">&#41;</span><span style="color: #000000;">&#41;</span>;
<span style="color: #000000;">&#125;</span></pre></div></div>

<p>The code becomes much more readable, and the errors have consistent information every time they are thrown. It is also apparent whether a new error message should be created or an existing message reused, based on the exception name and the parameters provided to it. Here are the MapErrorFactory and MapError classes that accompany this example.</p>

<div class="wp_syntax"><div class="code"><pre class="actionscript3" style="font-family:monospace;"><span style="color: #9900cc; font-weight: bold;">package</span> com.andrewtraviss.illfate.errors
<span style="color: #000000;">&#123;</span>
	<span style="color: #0033ff; font-weight: bold;">public</span> <span style="color: #9900cc; font-weight: bold;">class</span> MapErrorFactory
	<span style="color: #000000;">&#123;</span>
		<span style="color: #0033ff; font-weight: bold;">public</span> static <span style="color: #339966; font-weight: bold;">function</span> fromNotInitialized<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><span style="color: #000000; font-weight: bold;">:</span>MapError
		<span style="color: #000000;">&#123;</span>
			<span style="color: #0033ff; font-weight: bold;">return</span> <span style="color: #0033ff; font-weight: bold;">new</span> MapError<span style="color: #000000;">&#40;</span><span style="color: #990000;">&quot;Mapper has not been initialized&quot;</span>, MapError.NOT_INITIALIZED<span style="color: #000000;">&#41;</span>;
		<span style="color: #000000;">&#125;</span>
		<span style="color: #0033ff; font-weight: bold;">public</span> static <span style="color: #339966; font-weight: bold;">function</span> fromOutOfBounds<span style="color: #000000;">&#40;</span>in_x<span style="color: #000000; font-weight: bold;">:</span><span style="color: #004993;">int</span>, in_y<span style="color: #000000; font-weight: bold;">:</span><span style="color: #004993;">int</span><span style="color: #000000;">&#41;</span><span style="color: #000000; font-weight: bold;">:</span>MapError
		<span style="color: #000000;">&#123;</span>
			<span style="color: #0033ff; font-weight: bold;">return</span> <span style="color: #0033ff; font-weight: bold;">new</span> MapError<span style="color: #000000;">&#40;</span><span style="color: #990000;">&quot;Requested cell at (&quot;</span><span style="color: #000000; font-weight: bold;">+</span>in_x<span style="color: #000000; font-weight: bold;">+</span><span style="color: #990000;">&quot;,&quot;</span><span style="color: #000000; font-weight: bold;">+</span>in_y<span style="color: #000000; font-weight: bold;">+</span><span style="color: #990000;">&quot;) is out of map bounds&quot;</span>, MapError.OUT_OF_RANGE<span style="color: #000000;">&#41;</span>
		<span style="color: #000000;">&#125;</span>
	<span style="color: #000000;">&#125;</span>
<span style="color: #000000;">&#125;</span>
&nbsp;
<span style="color: #9900cc; font-weight: bold;">package</span> com.andrewtraviss.illfate.errors
<span style="color: #000000;">&#123;</span>
	<span style="color: #0033ff; font-weight: bold;">public</span> <span style="color: #9900cc; font-weight: bold;">class</span> MapError extends <span style="color: #004993;">Error</span>
	<span style="color: #000000;">&#123;</span>
		<span style="color: #0033ff; font-weight: bold;">public</span> <span style="color: #339966; font-weight: bold;">function</span> MapError<span style="color: #000000;">&#40;</span>in_message<span style="color: #000000; font-weight: bold;">:</span><span style="color: #004993;">String</span>, id<span style="color: #000000; font-weight: bold;">:</span><span style="color: #004993;">int</span>=<span style="color: #000000; font-weight:bold;">0</span><span style="color: #000000;">&#41;</span>
		<span style="color: #000000;">&#123;</span>
			<span style="color: #0033ff; font-weight: bold;">super</span><span style="color: #000000;">&#40;</span><span style="color: #990000;">&quot;MapError #&quot;</span><span style="color: #000000; font-weight: bold;">+</span><span style="color: #004993;">String</span><span style="color: #000000;">&#40;</span>id<span style="color: #000000;">&#41;</span><span style="color: #000000; font-weight: bold;">+</span><span style="color: #990000;">&quot;: &quot;</span><span style="color: #000000; font-weight: bold;">+</span>in_message, id<span style="color: #000000;">&#41;</span>;
		<span style="color: #000000;">&#125;</span>
		<span style="color: #0033ff; font-weight: bold;">public</span> static const NOT_INITIALIZED<span style="color: #000000; font-weight: bold;">:</span><span style="color: #004993;">int</span> = <span style="color: #000000; font-weight:bold;">100</span>;
		<span style="color: #0033ff; font-weight: bold;">public</span> static const OUT_OF_RANGE<span style="color: #000000; font-weight: bold;">:</span><span style="color: #004993;">int</span> = <span style="color: #000000; font-weight:bold;">101</span>;
	<span style="color: #000000;">&#125;</span>
<span style="color: #000000;">&#125;</span></pre></div></div>

<p>Note that the x and y coordinates of the cell requested are included in the error message, rather than the message simply being &#8220;Requested cell was out of bounds&#8221;. Providing specific information about the failure makes diagnosis much easier. Implementing a distinct error message for every potential failure scenario involving the same data puts a lot of responsibility on the originating code to understand and explain the nature of each failure. It&#8217;s better to just provide the information to the developer to identify the problem. A class also cannot always judge what the meaning of a failure is just based on its own data.</p>
<h2>Generic Exceptions</h2>
<p>The Flash Player generates quite a number of exception on its own. The vast majority of these exceptions are useless for figuring out anything more than the fact that your application is broken. This is also true of generic messages that developers include in data structures, messaging, and other workhorse classes. If the specific impact of a generic exception can be understood by the calling method or class, the exception should be caught, and a new error thrown that describes the specific natuer of the failure, rather than allowing the generic error to be displayed.</p>

<div class="wp_syntax"><div class="code"><pre class="actionscript3" style="font-family:monospace;"><span style="color: #0033ff; font-weight: bold;">private</span> <span style="color: #339966; font-weight: bold;">function</span> fooBar<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><span style="color: #000000; font-weight: bold;">:</span><span style="color: #0033ff; font-weight: bold;">void</span>
<span style="color: #000000;">&#123;</span>
	<span style="color: #009900;">// throws a null object reference error</span>
	foo.bar<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span>;
<span style="color: #000000;">&#125;</span></pre></div></div>


<div class="wp_syntax"><div class="code"><pre class="actionscript3" style="font-family:monospace;"><span style="color: #0033ff; font-weight: bold;">private</span> <span style="color: #339966; font-weight: bold;">function</span> fooBar<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><span style="color: #000000; font-weight: bold;">:</span><span style="color: #0033ff; font-weight: bold;">void</span>
<span style="color: #000000;">&#123;</span>
	<span style="color: #0033ff; font-weight: bold;">if</span><span style="color: #000000;">&#40;</span><span style="color: #000000; font-weight: bold;">!</span>foo<span style="color: #000000;">&#41;</span>
	<span style="color: #000000;">&#123;</span>
		<span style="color: #0033ff; font-weight: bold;">throw</span><span style="color: #000000;">&#40;</span>FooErrorFactory.fromFooNotSet<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><span style="color: #000000;">&#41;</span>;
	<span style="color: #000000;">&#125;</span>
	foo.bar<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span>;
<span style="color: #000000;">&#125;</span></pre></div></div>

<h2>When to Let Everything Crash Down</h2>
<p>Do yourself a favour, if an exception unexpectedly takes down your whole application, <em>let it happen</em>. It&#8217;s far better to track down the root cause and prevent the exception from occurring in the first place. It&#8217;s very tempting to just steamroller over an exception that doesn&#8217;t <em>seem</em> to cause any problems just to get the product out the door, but it a dangerous call to make. I have seen the following more times than I care to count.</p>

<div class="wp_syntax"><div class="code"><pre class="actionscript3" style="font-family:monospace;"><span style="color: #0033ff; font-weight: bold;">private</span> <span style="color: #339966; font-weight: bold;">function</span> fooBar<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><span style="color: #000000; font-weight: bold;">:</span><span style="color: #0033ff; font-weight: bold;">void</span>
<span style="color: #000000;">&#123;</span>
	foo = getFoo<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span>;
	<span style="color: #0033ff; font-weight: bold;">if</span><span style="color: #000000;">&#40;</span>foo <span style="color: #000000; font-weight: bold;">!</span>= <span style="color: #0033ff; font-weight: bold;">null</span><span style="color: #000000;">&#41;</span>
	<span style="color: #000000;">&#123;</span>
		updateCriticalApplicationConfiguration<span style="color: #000000;">&#40;</span>foo<span style="color: #000000;">&#41;</span>;
	<span style="color: #000000;">&#125;</span>
<span style="color: #000000;">&#125;</span></pre></div></div>

<p>Exceptions are only a symptom. Don&#8217;t treat the symptom, treat the illness! If you&#8217;re lucky, several function calls later, some other function is going to throw a null object reference error because this variable was not set properly. If you&#8217;re unlucky, there will be &#8220;unexpected behaviour&#8221; in a loosely related scenario somewhere far down the line. If at all possible, ensure that an exception is thrown immediately when the application becomes invalid; it saves you time versus having to track down the real point of failure from wherever it triggered an even worse failure.</p>
<p>This is most often a problem in the more generic parts of an application. Generic code cannot make a judgement about specific failures and whether or not they are safe. Obviously, there is the occasional case where an exception really is safe to ignore, but generic code should rarely be making that call.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.andrewtraviss.com/?feed=rss2&amp;p=212</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>IllFate Long Term Goals</title>
		<link>http://blog.andrewtraviss.com/?p=164</link>
		<comments>http://blog.andrewtraviss.com/?p=164#comments</comments>
		<pubDate>Sat, 16 Jan 2010 03:04:33 +0000</pubDate>
		<dc:creator>Andrew</dc:creator>
				<category><![CDATA[IllFate]]></category>
		<category><![CDATA[Game Development]]></category>
		<category><![CDATA[Roguelike]]></category>

		<guid isPermaLink="false">http://blog.andrewtraviss.com/?p=164</guid>
		<description><![CDATA[Measuring all of my progress in small verses isn&#8217;t going to work as the project expands, although I will continue to use them to express my immediate goals. I also have some major milestones in mind, such that there is a complete game at each milestone that I can cut a version of and release. [...]]]></description>
			<content:encoded><![CDATA[<p>Measuring all of my progress in small verses isn&#8217;t going to work as the project expands, although I will continue to use them to express my immediate goals. I also have some major milestones in mind, such that there is a complete game at each milestone that I can cut a version of and release. My current target will be called <em>Rooms</em>. Before I move onto to building a larger game world, I need to be able to pack some interesting things into a single room. The following are my high-level goals for <em>Rooms</em> and some details on room types in particular.</p>
<p><span id="more-164"></span></p>
<ol>
<li>Combat system</li>
<li>Basic status effects</li>
<li>Basic room archetypes</li>
<li>Room &#8220;theme&#8221; separate from the room&#8217;s design</li>
</ol>
<h2>Room Archetypes</h2>
<p>I want to have some representation of some basic rooms that I can apply some randomization to. Here is the starting list of archetypes and the inspirations I am pulling them from. This list should expand when they game increases in scope beyond a single room. If you think of a standalone room type I haven&#8217;t covered below, please leave a comment with your idea.</p>
<h3>The Simple Barracks</h3>
<p>Inspiration: Virtually any RPG</p>
<p>A basic room with some enemies and their equipment. Nothing to write home about, but if every room was really interesting, they wouldn&#8217;t stand out.</p>
<h3>The Environmental Hazard Room</h3>
<p>Inspiration: Super Metroid</p>
<p>The room is too hot, and will damage your character over time. The door itself is too hot to touch. Find some heat-protective armour or use a heat protective spell to survive the room and escape.</p>
<h3>The Dormant Room</h3>
<p>Inspiration: Adventures of Lolo</p>
<p>The room contains dormant enemies which will awaken upon finding the key to exit the room. Steps can be taken to destroy the enemies or limit their mobility prior to grabbing the key. Adventures of Lolo was one of my favourite NES games, and I always thought the mechanic was excellent.</p>
<h3>The Laser Room (pew pew)</h3>
<p>Inspiration: Penny Arcade D&#038;D Session</p>
<p>A beam of light must be reflected through the room in order to activate mechanisms and weaken enemies, but it is hazardous to cross the beam yourself. Wax Golems and Ant Men, here we come.</p>
<h3>Shop</h3>
<p>The final version of The Room will drop you from one Room to the next, persisting stats, so a shop level is appropriate. I can insert them after every few rooms to give the player a chance to restock and sell. And give me the chance to implement trade in this version.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.andrewtraviss.com/?feed=rss2&amp;p=164</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>IllFate Verse 1:4 Completed</title>
		<link>http://blog.andrewtraviss.com/?p=156</link>
		<comments>http://blog.andrewtraviss.com/?p=156#comments</comments>
		<pubDate>Fri, 08 Jan 2010 04:07:08 +0000</pubDate>
		<dc:creator>Andrew</dc:creator>
				<category><![CDATA[IllFate]]></category>
		<category><![CDATA[Game Development]]></category>
		<category><![CDATA[Roguelike]]></category>

		<guid isPermaLink="false">http://blog.andrewtraviss.com/?p=156</guid>
		<description><![CDATA[Now that the busy holiday season is over, the steady progression towards being an actual game continues. There is now a single obstacle to escaping The Room; you have to pick up the key from the floor in order to open the exit door. It doesn&#8217;t sound like much, but it required quite a bit [...]]]></description>
			<content:encoded><![CDATA[<p>Now that the busy holiday season is over, the steady progression towards being an actual game continues. There is now a single obstacle to escaping The Room; you have to pick up the key from the floor in order to open the exit door. It doesn&#8217;t sound like much, but it required quite a bit behind the scenes to get it working. Saving and loading are also working now.</p>
<h3>Verse 1:4</h3>
<blockquote><p>Door locked securely<br />
First obstacle encountered<br />
Where did that key go?</p></blockquote>
<p><span id="more-156"></span><br />

<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000"
			id="fm_IllFate_Verse_1_4_1954231588"
			class="flashmovie"
			width="480"
			height="336">
	<param name="movie" value="media/IllFate_Verse_1_4.swf" />
	<!--[if !IE]>-->
	<object	type="application/x-shockwave-flash"
			data="media/IllFate_Verse_1_4.swf"
			name="fm_IllFate_Verse_1_4_1954231588"
			width="480"
			height="336">
	<!--<![endif]-->
		
<p><a href="http://adobe.com/go/getflashplayer"><img src="http://www.adobe.com/images/shared/download_buttons/get_flash_player.gif" alt="Get Adobe Flash player" /></a></p>

	<!--[if !IE]>-->
	</object>
	<!--<![endif]-->
</object>
<p>In addition to the controls in the in-game instructions, you can press Home to save state and End to load state.</p>
<p>This verse forced me to answer some important questions about how to handle interactions between Entities in the game. In the end, Entities remained simple data structures for physical objects. Interactors were created to handle complex interactions separately. Any interaction which occurs at the basic Entity level will be a part of the physical Simulation. Interactors will be used to simulate complex behaviour that is not physically modelled.</p>
<p>Obviously the door falls into this category, but also inventories. The player is carrying a key around, but I am not modelling the key hanging from a belt or in a pocket, it&#8217;s just holistically &#8220;in the player&#8217;s inventory&#8221;. Once I&#8217;ve had time to iron out the whole system, I&#8217;ll post some source code for it and a deeper explanation.</p>
<h3>Verse 1:5</h3>
<blockquote><p>
A woman in robes<br />
&#8220;It&#8217;s dangerous to go alone!&#8221;<br />
&#8220;Take this,&#8221; she insists
</p></blockquote>
]]></content:encoded>
			<wfw:commentRss>http://blog.andrewtraviss.com/?feed=rss2&amp;p=156</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Saving and Loading in IllFate</title>
		<link>http://blog.andrewtraviss.com/?p=128</link>
		<comments>http://blog.andrewtraviss.com/?p=128#comments</comments>
		<pubDate>Tue, 29 Dec 2009 17:52:46 +0000</pubDate>
		<dc:creator>Andrew</dc:creator>
				<category><![CDATA[IllFate]]></category>
		<category><![CDATA[Actionscript 3]]></category>
		<category><![CDATA[Game Development]]></category>
		<category><![CDATA[Roguelike]]></category>

		<guid isPermaLink="false">http://blog.andrewtraviss.com/?p=128</guid>
		<description><![CDATA[Saving and loading the game is potentially a rat&#8217;s nest of bugs for a complex game if it&#8217;s not done right. This is my approach to it in IllFate, complete with source code and some explanation. If you&#8217;ve had experience with similar systems or have any questions about the approach I&#8217;ve taken, I&#8217;d like to [...]]]></description>
			<content:encoded><![CDATA[<p>Saving and loading the game is potentially a rat&#8217;s nest of bugs for a complex game if it&#8217;s not done right. This is my approach to it in IllFate, complete with source code and some explanation. If you&#8217;ve had experience with similar systems or have any questions about the approach I&#8217;ve taken, I&#8217;d like to hear about it.</p>
<p><span id="more-128"></span></p>

<div class="wp_syntax"><div class="code"><pre class="actionscript3" style="font-family:monospace;"><span style="color: #9900cc; font-weight: bold;">package</span> com.andrewtraviss.illfate.<span style="color: #004993;">data</span>
<span style="color: #000000;">&#123;</span>
   <span style="color: #0033ff; font-weight: bold;">import</span> <span style="color: #004993;">flash.utils</span>.<span style="color: #004993;">ByteArray</span>;
&nbsp;
   <span style="color: #0033ff; font-weight: bold;">public</span> <span style="color: #9900cc; font-weight: bold;">class</span> Terrain
   <span style="color: #000000;">&#123;</span>
      <span style="color: #0033ff; font-weight: bold;">public</span> <span style="color: #6699cc; font-weight: bold;">var</span> tileIndex<span style="color: #000000; font-weight: bold;">:</span><span style="color: #004993;">int</span> = <span style="color: #000000; font-weight: bold;">-</span><span style="color: #000000; font-weight:bold;">1</span>;
      <span style="color: #0033ff; font-weight: bold;">public</span> <span style="color: #6699cc; font-weight: bold;">var</span> sheetIndex<span style="color: #000000; font-weight: bold;">:</span><span style="color: #004993;">int</span> = <span style="color: #000000; font-weight: bold;">-</span><span style="color: #000000; font-weight:bold;">1</span>;
      <span style="color: #0033ff; font-weight: bold;">public</span> <span style="color: #6699cc; font-weight: bold;">var</span> friction<span style="color: #000000; font-weight: bold;">:</span><span style="color: #004993;">Number</span> = <span style="color: #000000; font-weight:bold;">1</span>;
      <span style="color: #0033ff; font-weight: bold;">public</span> <span style="color: #6699cc; font-weight: bold;">var</span> passable<span style="color: #000000; font-weight: bold;">:</span><span style="color: #004993;">Boolean</span> = <span style="color: #0033ff; font-weight: bold;">true</span>;
   <span style="color: #000000;">&#125;</span>
<span style="color: #000000;">&#125;</span></pre></div></div>

<p>This is the <strong><span style="color: #993366;">Terrain</span></strong> class that we are saving. This is pretty straightforward. Since IllFate is at an early stage there isn&#8217;t much data to worry about. This is why I wanted to get the system in place now. I am making it a general rule that all game objects store their state information in separate data structure classes. This makes it easier to create scenarios for testing and makes features like this one easier to implement.</p>

<div class="wp_syntax"><div class="code"><pre class="actionscript3" style="font-family:monospace;"><span style="color: #9900cc; font-weight: bold;">package</span> com.andrewtraviss.illfate.factories
<span style="color: #000000;">&#123;</span>
   <span style="color: #0033ff; font-weight: bold;">import</span> com.andrewtraviss.illfate.<span style="color: #004993;">data</span>.Terrain;
&nbsp;
   <span style="color: #0033ff; font-weight: bold;">import</span> <span style="color: #004993;">flash.utils</span>.<span style="color: #004993;">ByteArray</span>;
&nbsp;
   <span style="color: #0033ff; font-weight: bold;">public</span> <span style="color: #9900cc; font-weight: bold;">class</span> TerrainFactory
   <span style="color: #000000;">&#123;</span>
      <span style="color: #0033ff; font-weight: bold;">public</span> static <span style="color: #339966; font-weight: bold;">function</span> fromBytes<span style="color: #000000;">&#40;</span>in_bytes<span style="color: #000000; font-weight: bold;">:</span><span style="color: #004993;">ByteArray</span><span style="color: #000000;">&#41;</span><span style="color: #000000; font-weight: bold;">:</span>Terrain
      <span style="color: #000000;">&#123;</span>
         <span style="color: #6699cc; font-weight: bold;">var</span> terrain<span style="color: #000000; font-weight: bold;">:</span>Terrain = <span style="color: #0033ff; font-weight: bold;">new</span> Terrain<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span>;
         terrain.passable = in_bytes.<span style="color: #004993;">readBoolean</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span>;
         terrain.tileIndex = in_bytes.<span style="color: #004993;">readInt</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span>;
         terrain.sheetIndex = in_bytes.<span style="color: #004993;">readInt</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span>;
         terrain.friction = in_bytes.<span style="color: #004993;">readFloat</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span>;
         <span style="color: #0033ff; font-weight: bold;">return</span> terrain;
      <span style="color: #000000;">&#125;</span>
   <span style="color: #000000;">&#125;</span>
<span style="color: #000000;">&#125;</span></pre></div></div>

<p>The creation code is implemented in a factory.  Why not put it into the <strong><span style="color: #993366;">Terrain</span></strong> class? Creation of the terrain instance should be an atomic operation if at all possible. It makes any code that has to create terrain much more readable. If a <span style="color: #99cc00;"><strong><span style="color: #339966;">configureFromBytes</span></strong></span> method was implemented in <strong><span style="color: #993366;">Terrain</span></strong> itself, that would require two operations every time we needed to create an instance from data. Compare the following.</p>

<div class="wp_syntax"><div class="code"><pre class="actionscript3" style="font-family:monospace;"><span style="color: #6699cc; font-weight: bold;">var</span> terrain = <span style="color: #0033ff; font-weight: bold;">new</span> Terrain<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span>;
terrain.configFromBytes<span style="color: #000000;">&#40;</span>terrainData<span style="color: #000000;">&#41;</span>;</pre></div></div>


<div class="wp_syntax"><div class="code"><pre class="actionscript3" style="font-family:monospace;"><span style="color: #6699cc; font-weight: bold;">var</span> terrain = TerrainFactory.fromBytes<span style="color: #000000;">&#40;</span>terrainData<span style="color: #000000;">&#41;</span>;</pre></div></div>

<p>The abstraction of details will become more important if other subsystems need to get involved with <strong><span style="color: #993366;">Terrain</span></strong> creation. Any time I look at <span style="color: #993366;"><strong>TerrainFactory</strong></span> it&#8217;s going to be because I am interested in the details of creating an instance. Once there are more complex relationships to manage, this will also protect <strong><span style="color: #993366;">Terrain</span></strong> from acquiring new dependencies.</p>

<div class="wp_syntax"><div class="code"><pre class="actionscript3" style="font-family:monospace;"><span style="color: #9900cc; font-weight: bold;">package</span> com.andrewtraviss.illfate.serialization
<span style="color: #000000;">&#123;</span>
   <span style="color: #0033ff; font-weight: bold;">import</span> com.andrewtraviss.illfate.<span style="color: #004993;">data</span>.Terrain;
&nbsp;
   <span style="color: #0033ff; font-weight: bold;">import</span> <span style="color: #004993;">flash.utils</span>.<span style="color: #004993;">ByteArray</span>;
&nbsp;
   <span style="color: #0033ff; font-weight: bold;">public</span> <span style="color: #9900cc; font-weight: bold;">class</span> TerrainSerializer
   <span style="color: #000000;">&#123;</span>
      <span style="color: #0033ff; font-weight: bold;">public</span> static <span style="color: #339966; font-weight: bold;">function</span> toBytes<span style="color: #000000;">&#40;</span>in_terrain<span style="color: #000000; font-weight: bold;">:</span>Terrain<span style="color: #000000;">&#41;</span><span style="color: #000000; font-weight: bold;">:</span><span style="color: #004993;">ByteArray</span>
      <span style="color: #000000;">&#123;</span>
         <span style="color: #6699cc; font-weight: bold;">var</span> bytes<span style="color: #000000; font-weight: bold;">:</span><span style="color: #004993;">ByteArray</span> = <span style="color: #0033ff; font-weight: bold;">new</span> <span style="color: #004993;">ByteArray</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span>;
         bytes.<span style="color: #004993;">writeBoolean</span><span style="color: #000000;">&#40;</span>in_terrain.passable<span style="color: #000000;">&#41;</span>;
         bytes.<span style="color: #004993;">writeInt</span><span style="color: #000000;">&#40;</span>in_terrain.tileIndex<span style="color: #000000;">&#41;</span>;
         bytes.<span style="color: #004993;">writeInt</span><span style="color: #000000;">&#40;</span>in_terrain.sheetIndex<span style="color: #000000;">&#41;</span>;
         bytes.<span style="color: #004993;">writeFloat</span><span style="color: #000000;">&#40;</span>in_terrain.friction<span style="color: #000000;">&#41;</span>;
         bytes.<span style="color: #004993;">position</span> = <span style="color: #000000; font-weight:bold;">0</span>;
         <span style="color: #0033ff; font-weight: bold;">return</span> bytes;
      <span style="color: #000000;">&#125;</span>
   <span style="color: #000000;">&#125;</span>
<span style="color: #000000;">&#125;</span></pre></div></div>

<p>For much the same reason that construction is in a separate class, serialization was implemented by <span style="color: #993366;"><strong>TerrainSerializer</strong></span>. Keeping the underlying data structure classes free of dependencies is one of my general goals with this project as a whole.</p>

<div class="wp_syntax"><div class="code"><pre class="actionscript3" style="font-family:monospace;"><span style="color: #9900cc; font-weight: bold;">package</span> com.andrewtraviss.illfate.tests
<span style="color: #000000;">&#123;</span>
   <span style="color: #0033ff; font-weight: bold;">import</span> com.andrewtraviss.illfate.<span style="color: #004993;">data</span>.Terrain;
   <span style="color: #0033ff; font-weight: bold;">import</span> com.andrewtraviss.illfate.factories.TerrainFactory;
   <span style="color: #0033ff; font-weight: bold;">import</span> com.andrewtraviss.illfate.serialization.TerrainSerializer;
&nbsp;
   <span style="color: #0033ff; font-weight: bold;">import</span> <span style="color: #004993;">flash.utils</span>.<span style="color: #004993;">ByteArray</span>;
&nbsp;
   <span style="color: #0033ff; font-weight: bold;">import</span> flexunit.framework.TestCase;
&nbsp;
   <span style="color: #0033ff; font-weight: bold;">public</span> <span style="color: #9900cc; font-weight: bold;">class</span> SaveLoadTerrainTests extends TestCase
   <span style="color: #000000;">&#123;</span>
      <span style="color: #0033ff; font-weight: bold;">public</span> <span style="color: #339966; font-weight: bold;">function</span> testBasic<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><span style="color: #000000; font-weight: bold;">:</span><span style="color: #0033ff; font-weight: bold;">void</span>
      <span style="color: #000000;">&#123;</span>
         <span style="color: #6699cc; font-weight: bold;">var</span> saveTerrain<span style="color: #000000; font-weight: bold;">:</span>Terrain = <span style="color: #0033ff; font-weight: bold;">new</span> Terrain<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span>;
         saveTerrain.friction <span style="color: #000000; font-weight: bold;">++</span>;
         saveTerrain.passable = <span style="color: #000000; font-weight: bold;">!</span>saveTerrain.passable;
         saveTerrain.sheetIndex <span style="color: #000000; font-weight: bold;">++</span>;
         saveTerrain.tileIndex <span style="color: #000000; font-weight: bold;">++</span>;
         <span style="color: #6699cc; font-weight: bold;">var</span> terrainData<span style="color: #000000; font-weight: bold;">:</span><span style="color: #004993;">ByteArray</span> = TerrainSerializer.toBytes<span style="color: #000000;">&#40;</span>saveTerrain<span style="color: #000000;">&#41;</span>;
         <span style="color: #6699cc; font-weight: bold;">var</span> loadTerrain<span style="color: #000000; font-weight: bold;">:</span>Terrain = TerrainFactory.fromBytes<span style="color: #000000;">&#40;</span>terrainData<span style="color: #000000;">&#41;</span>;
         assertEquals<span style="color: #000000;">&#40;</span>saveTerrain.friction, loadTerrain.friction<span style="color: #000000;">&#41;</span>;
         assertEquals<span style="color: #000000;">&#40;</span>saveTerrain.passable, loadTerrain.passable<span style="color: #000000;">&#41;</span>;
         assertEquals<span style="color: #000000;">&#40;</span>saveTerrain.sheetIndex, loadTerrain.sheetIndex<span style="color: #000000;">&#41;</span>;
         assertEquals<span style="color: #000000;">&#40;</span>saveTerrain.tileIndex, loadTerrain.tileIndex<span style="color: #000000;">&#41;</span>;
      <span style="color: #000000;">&#125;</span>
   <span style="color: #000000;">&#125;</span>
<span style="color: #000000;">&#125;</span></pre></div></div>

<p>And here&#8217;s the unit test, to cap it off. Rather than injecting some magic numbers, all properties are just changed in some way from the default before saving. Numbers are incremented and booleans are inverted. This is enough to ensure that the values are changed from the defaults.</p>
<p>Eventually this approach will become awkward, that&#8217;s plainly obvious. I have to reference every property three times in the testing code, once in the loading code, and once in the saving code. This will add a constant drag as I need to update all of these places whenever I add a property to any game object that must be saved. I will need to generalize it in some way. I&#8217;ll include details with the Verse 1:4 release post if something happens.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.andrewtraviss.com/?feed=rss2&amp;p=128</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>IllFate Verse 1:3 Completed</title>
		<link>http://blog.andrewtraviss.com/?p=79</link>
		<comments>http://blog.andrewtraviss.com/?p=79#comments</comments>
		<pubDate>Sat, 26 Dec 2009 15:46:53 +0000</pubDate>
		<dc:creator>Andrew</dc:creator>
				<category><![CDATA[IllFate]]></category>
		<category><![CDATA[Game Development]]></category>
		<category><![CDATA[Roguelike]]></category>

		<guid isPermaLink="false">http://blog.andrewtraviss.com/?p=79</guid>
		<description><![CDATA[What I expected to be easy turned out to be a rats nest, all because I didn&#8217;t maintain my diligence when completing verse 1:2. I had no tests for velocities higher than one. I knew it would be a problem when I did it, but it turned out much worse than I anticipated. I ended [...]]]></description>
			<content:encoded><![CDATA[<p>What I expected to be easy turned out to be a rats nest, all because I didn&#8217;t maintain my diligence when completing verse 1:2. I had no tests for velocities higher than one. I knew it would be a problem when I did it, but it turned out much worse than I anticipated. I ended up scrapping the entire physics class in favour of something closer to real physics. I will be more diligent about not writing any code that isn&#8217;t satisfying a unit test, even if it means building out features a bit beyond what the current verse requires.</p>
<h3>Verse 1:3</h3>
<blockquote><p>In quite a hurry,<br />
but the ice is treacherous.<br />
The walls are not soft.</p></blockquote>
<p style="text-align: center;"><span id="more-79"></span><br />

<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000"
			id="fm_IllFate_Verse_1_3_192364646"
			class="flashmovie"
			width="480"
			height="336">
	<param name="movie" value="media/IllFate_Verse_1_3.swf" />
	<!--[if !IE]>-->
	<object	type="application/x-shockwave-flash"
			data="media/IllFate_Verse_1_3.swf"
			name="fm_IllFate_Verse_1_3_192364646"
			width="480"
			height="336">
	<!--<![endif]-->
		
<p style="text-align: center;"><a href="http://adobe.com/go/getflashplayer"><img src="http://www.adobe.com/images/shared/download_buttons/get_flash_player.gif" alt="Get Adobe Flash player" /></a></p>
<p style="text-align: center;">
	<!--[if !IE]>-->
	</object>
	<!--<![endif]-->
</object>
<p style="text-align: center;">Hold shift to run. When running, you will slide around on the ice a bit. If you strike a wall hard enough, you can bounce off of it and take some damage.</p>
<h2>Challenge: Physics</h2>
<p>Every time I make a run at my own physics implementation I utterly fail to remember any of my vector math, so that absorbed some time as I reacquainted myself with an old friend. Once I got it working, the result was really ugly. This was the time for TDD to shine. This was the first real test of TDD&#8217;s vaunted ability to make refactoring easier and more comfortable, and it did just that. I didn&#8217;t need to test the actual game until I was done all of the changes, and it worked, which was a nice feeling.</p>
<p>My initial implementation saw the Collider class calculating the forces involved in the collision and then applying the forces to the entities. Once I got this working, I noticed this:</p>
<h3>From PhysicalSimulation.as</h3>

<div class="wp_syntax"><div class="code"><pre class="actionscript3" style="font-family:monospace;"><span style="color: #0033ff; font-weight: bold;">public</span> <span style="color: #339966; font-weight: bold;">function</span> applyForceToEntity<span style="color: #000000;">&#40;</span>in_force<span style="color: #000000; font-weight: bold;">:</span><span style="color: #004993;">Point</span>, in_entity<span style="color: #000000; font-weight: bold;">:</span>Entity<span style="color: #000000;">&#41;</span><span style="color: #000000; font-weight: bold;">:</span><span style="color: #0033ff; font-weight: bold;">void</span>
<span style="color: #000000;">&#123;</span>
   in_entity.xVelocity <span style="color: #000000; font-weight: bold;">+</span>= in_force.<span style="color: #004993;">x</span>;
   in_entity.yVelocity <span style="color: #000000; font-weight: bold;">+</span>= in_force.<span style="color: #004993;">y</span>;
   invalidateEntity<span style="color: #000000;">&#40;</span>in_entity<span style="color: #000000;">&#41;</span>;
<span style="color: #000000;">&#125;</span></pre></div></div>

<h3>From Collider.as</h3>

<div class="wp_syntax"><div class="code"><pre class="actionscript3" style="font-family:monospace;"><span style="color: #0033ff; font-weight: bold;">public</span> <span style="color: #339966; font-weight: bold;">function</span> applyForceToEntity<span style="color: #000000;">&#40;</span>in_force<span style="color: #000000; font-weight: bold;">:</span><span style="color: #004993;">Point</span>, in_entity<span style="color: #000000; font-weight: bold;">:</span>Entity<span style="color: #000000;">&#41;</span><span style="color: #000000; font-weight: bold;">:</span><span style="color: #0033ff; font-weight: bold;">void</span>
<span style="color: #000000;">&#123;</span>
   in_entity.xVelocity <span style="color: #000000; font-weight: bold;">+</span>= in_force.<span style="color: #004993;">x</span><span style="color: #000000; font-weight: bold;">/</span>in_entity.mass;
   in_entity.yVelocity <span style="color: #000000; font-weight: bold;">+</span>= in_force.<span style="color: #004993;">y</span><span style="color: #000000; font-weight: bold;">/</span>in_entity.mass;
<span style="color: #000000;">&#125;</span></pre></div></div>

<p>Not only were these duplicate code, but at the moment, they were working differently. I rolled up my sleeves and updated the Collider class to just calculate and return the force of the collision  instead of actually acting on the objects. The PhysicalSimulation takes care of actually applying the force to the Entities, and now takes mass into account. This involved rewriting most of the unit tests for the Collider class, since my expectations were now based on the returned force rather than inspecting the properties of the entities.</p>
<p>One thing I want to do differently, versus my last Roguelike attempt, is to implement saving very early in development, so that every feature can be developed with game saves as part of the testing. My next goal doesn&#8217;t directly imply this should be done, but I will be tackling it as part of the test implementation.</p>
<h3>Verse 1:4</h3>
<blockquote><p>Door locked securely<br />
First obstacle encountered<br />
Where did that key go?</p></blockquote>
]]></content:encoded>
			<wfw:commentRss>http://blog.andrewtraviss.com/?feed=rss2&amp;p=79</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>IllFate Verse 2 Completed</title>
		<link>http://blog.andrewtraviss.com/?p=51</link>
		<comments>http://blog.andrewtraviss.com/?p=51#comments</comments>
		<pubDate>Mon, 21 Dec 2009 17:49:48 +0000</pubDate>
		<dc:creator>Andrew</dc:creator>
				<category><![CDATA[IllFate]]></category>
		<category><![CDATA[Game Development]]></category>
		<category><![CDATA[Roguelike]]></category>

		<guid isPermaLink="false">http://blog.andrewtraviss.com/?p=51</guid>
		<description><![CDATA[I&#8217;ve completed development to satisfy my second requirements Haiku. When the player reaches the door, they win, and the game is reset to its original state.
Verse 1:2
Walk across the room.
That door looks awfully nice.
I just won the game.


<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000"
			id="fm_IllFate_Verse_1_2_2126964012"
			class="flashmovie"
			width="240"
			height="160">
	<param name="movie" value="media/IllFate_Verse_1_2.swf" />
	<!--[if !IE]>-->
	<object	type="application/x-shockwave-flash"
			data="media/IllFate_Verse_1_2.swf"
			name="fm_IllFate_Verse_1_2_2126964012"
			width="240"
			height="160">
	<!--<![endif]-->
		


	<!--[if !IE]>-->
	</object>
	<!--<![endif]-->
</object>
W, A, S, D keys move the character. Depending on browser [...]]]></description>
			<content:encoded><![CDATA[<p>I&#8217;ve completed development to satisfy my second requirements Haiku. When the player reaches the door, they win, and the game is reset to its original state.</p>
<h3>Verse 1:2</h3>
<blockquote><p>Walk across the room.<br />
That door looks awfully nice.<br />
I just won the game.</p></blockquote>
<p style="text-align: center;"><span id="more-51"></span><br />

<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000"
			id="fm_IllFate_Verse_1_2_1888007472"
			class="flashmovie"
			width="240"
			height="160">
	<param name="movie" value="media/IllFate_Verse_1_2.swf" />
	<!--[if !IE]>-->
	<object	type="application/x-shockwave-flash"
			data="media/IllFate_Verse_1_2.swf"
			name="fm_IllFate_Verse_1_2_1888007472"
			width="240"
			height="160">
	<!--<![endif]-->
		
<p style="text-align: center;"><a href="http://adobe.com/go/getflashplayer"><img src="http://www.adobe.com/images/shared/download_buttons/get_flash_player.gif" alt="Get Adobe Flash player" /></a></p>
<p style="text-align: center;">
	<!--[if !IE]>-->
	</object>
	<!--<![endif]-->
</object>
<p style="text-align: center;">W, A, S, D keys move the character. Depending on browser and operating system, you may need to click on the game before the controls will work.</p>
<p>In order to meet this goal, I had to rough out the physics system just enough to get the player character moving around. I opted for a force-based interface into the physics system; each step action instructs the physics system to apply a force to the player entity in the appropriate direction, rather than directly changing the player&#8217;s position or velocity. The physics system deals with all of the consequences from there on.</p>
<p>Unfortunately, after the first step there is leftover velocity that results in the player flying across the screen. Nothing is slowing the player down. I considered a few different ways to handle this.</p>
<ol>
<li>Remember the previous step and apply an opposing force before stepping again</li>
<li>Scrap force-based physics altogether in favour of just instructing the physics system to move an object from A-to-B</li>
<li>Implement friction</li>
</ol>
<p>Option #1 is not very attractive for many reasons. Rather than working with the here and now, we&#8217;re making decisions based on previous actions. Any changes that occur between the original step and the new step have to be taken into account when determining if a counter-force must be applied, and how much force to necessary.</p>
<p>Option #2 was tempting, as it mirrors my previous Roguelike work more closely. However, working only with forces instead of velocities or actual positions ensures that the physics remains black boxed. This is inconvenient in some ways, but that is far outweighed by the benefit of keeping physics decoupled from the rest of the code base. Previous projects have demonstrated that physics are particularly apt at latching themselves onto everything around them once you decide to open them up.</p>
<p>That leaves me with option #3; as an entity moves across a surface, friction is applied. I&#8217;m currently tracking velocity as an integer, so the one tile velocity of walking is rounded to 0 by friction after one calculation. This puts me in a great position to implement a couple of features. The character can run by applying more force per action, and icy surface jut needs a low friction coefficient. I&#8217;ve set my next goal with this in mind. Testing out how the physics implementation handles different situations will tell me whether or not I made the right choice.</p>
<h3>Verse 1:3</h3>
<blockquote><p>In quite a hurry,<br />
but the ice is treacherous.<br />
The walls are not soft.</p></blockquote>
]]></content:encoded>
			<wfw:commentRss>http://blog.andrewtraviss.com/?feed=rss2&amp;p=51</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Visual Verification with FlexUnit</title>
		<link>http://blog.andrewtraviss.com/?p=41</link>
		<comments>http://blog.andrewtraviss.com/?p=41#comments</comments>
		<pubDate>Thu, 17 Dec 2009 02:16:43 +0000</pubDate>
		<dc:creator>Andrew</dc:creator>
				<category><![CDATA[How To]]></category>
		<category><![CDATA[Actionscript 3]]></category>
		<category><![CDATA[FlexUnit]]></category>
		<category><![CDATA[Game Development]]></category>

		<guid isPermaLink="false">http://blog.andrewtraviss.com/?p=41</guid>
		<description><![CDATA[A friend of mine wanted to get a look at the visual verification I&#8217;m using to unit test my rendering code, so I figured I might as well give it a spit-shine and share it with anyone that might find it useful. If you are working with pixel art a lot, especially if you are [...]]]></description>
			<content:encoded><![CDATA[<p>A friend of mine wanted to get a look at the visual verification I&#8217;m using to unit test my rendering code, so I figured I might as well give it a spit-shine and share it with anyone that might find it useful. If you are working with pixel art a lot, especially if you are working on a tile-based game, this might be useful. It won&#8217;t work well in most other situations, since it expects pixel-perfect matches.<br />
<span id="more-41"></span></p>

<div class="wp_syntax"><div class="code"><pre class="actionscript3" style="font-family:monospace;"><span style="color: #3f5fbf;">/*
 Copyright (c) 2009 Andrew Traviss
&nbsp;
 Permission is hereby granted, free of charge, to any person
 obtaining a copy of this software and associated documentation
 files (the &quot;Software&quot;), to deal in the Software without
 restriction, including without limitation the rights to use,
 copy, modify, merge, publish, distribute, sublicense, and/or sell
 copies of the Software, and to permit persons to whom the
 Software is furnished to do so, subject to the following
 conditions:
&nbsp;
 The above copyright notice and this permission notice shall be
 included in all copies or substantial portions of the Software.
&nbsp;
 THE SOFTWARE IS PROVIDED &quot;AS IS&quot;, WITHOUT WARRANTY OF ANY KIND,
 EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
 OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
 NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
 HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
 WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
 FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
 OTHER DEALINGS IN THE SOFTWARE.
*/</span>
<span style="color: #9900cc; font-weight: bold;">package</span> com.andrewtraviss.flexunit
<span style="color: #000000;">&#123;</span>
   <span style="color: #0033ff; font-weight: bold;">import</span> <span style="color: #004993;">flash.display</span>.<span style="color: #004993;">BitmapData</span>;
&nbsp;
   <span style="color: #0033ff; font-weight: bold;">import</span> flexunit.framework.TestCase;
&nbsp;
   <span style="color: #0033ff; font-weight: bold;">public</span> <span style="color: #9900cc; font-weight: bold;">class</span> VisualTestCase extends TestCase
   <span style="color: #000000;">&#123;</span>
      <span style="color: #0033ff; font-weight: bold;">public</span> <span style="color: #339966; font-weight: bold;">function</span> VisualTestCase<span style="color: #000000;">&#40;</span>methodName<span style="color: #000000; font-weight: bold;">:</span><span style="color: #004993;">String</span>=<span style="color: #0033ff; font-weight: bold;">null</span><span style="color: #000000;">&#41;</span>
      <span style="color: #000000;">&#123;</span>
         <span style="color: #0033ff; font-weight: bold;">super</span><span style="color: #000000;">&#40;</span>methodName<span style="color: #000000;">&#41;</span>;
      <span style="color: #000000;">&#125;</span>
      <span style="color: #0033ff; font-weight: bold;">protected</span> <span style="color: #339966; font-weight: bold;">function</span> assertBitmapsMatch<span style="color: #000000;">&#40;</span>in_expected<span style="color: #000000; font-weight: bold;">:</span><span style="color: #004993;">BitmapData</span>, in_actual<span style="color: #000000; font-weight: bold;">:</span><span style="color: #004993;">BitmapData</span><span style="color: #000000;">&#41;</span><span style="color: #000000; font-weight: bold;">:</span><span style="color: #0033ff; font-weight: bold;">void</span>
      <span style="color: #000000;">&#123;</span>
         oneAssertionHasBeenMade<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span>;
         <span style="color: #0033ff; font-weight: bold;">if</span><span style="color: #000000;">&#40;</span><span style="color: #000000; font-weight: bold;">!</span>areIdentical<span style="color: #000000;">&#40;</span>in_expected, in_actual<span style="color: #000000;">&#41;</span><span style="color: #000000;">&#41;</span>
         <span style="color: #000000;">&#123;</span>
            failBitmapsMatch<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span>;
         <span style="color: #000000;">&#125;</span>
      <span style="color: #000000;">&#125;</span>
      <span style="color: #0033ff; font-weight: bold;">protected</span> <span style="color: #339966; font-weight: bold;">function</span> assertBitmapsDoNotMatch<span style="color: #000000;">&#40;</span>in_notExpected<span style="color: #000000; font-weight: bold;">:</span><span style="color: #004993;">BitmapData</span>, in_actual<span style="color: #000000; font-weight: bold;">:</span><span style="color: #004993;">BitmapData</span><span style="color: #000000;">&#41;</span><span style="color: #000000; font-weight: bold;">:</span><span style="color: #0033ff; font-weight: bold;">void</span>
      <span style="color: #000000;">&#123;</span>
         oneAssertionHasBeenMade<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span>;
         <span style="color: #0033ff; font-weight: bold;">if</span><span style="color: #000000;">&#40;</span>areIdentical<span style="color: #000000;">&#40;</span>in_notExpected, in_actual<span style="color: #000000;">&#41;</span><span style="color: #000000;">&#41;</span>
         <span style="color: #000000;">&#123;</span>
            failBitmapsDoNotMatch<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span>;
         <span style="color: #000000;">&#125;</span>
      <span style="color: #000000;">&#125;</span>
      <span style="color: #0033ff; font-weight: bold;">private</span> <span style="color: #339966; font-weight: bold;">function</span> areIdentical<span style="color: #000000;">&#40;</span>in_bitmapDataA<span style="color: #000000; font-weight: bold;">:</span><span style="color: #004993;">BitmapData</span>, in_bitmapDataB<span style="color: #000000; font-weight: bold;">:</span><span style="color: #004993;">BitmapData</span><span style="color: #000000;">&#41;</span><span style="color: #000000; font-weight: bold;">:</span><span style="color: #004993;">Boolean</span>
      <span style="color: #000000;">&#123;</span>
         <span style="color: #6699cc; font-weight: bold;">var</span> result<span style="color: #000000; font-weight: bold;">:*</span> = in_bitmapDataA.<span style="color: #004993;">compare</span><span style="color: #000000;">&#40;</span>in_bitmapDataB<span style="color: #000000;">&#41;</span>;
         <span style="color: #0033ff; font-weight: bold;">if</span><span style="color: #000000;">&#40;</span>result <span style="color: #0033ff; font-weight: bold;">is</span> <span style="color: #004993;">BitmapData</span><span style="color: #000000;">&#41;</span>
         <span style="color: #000000;">&#123;</span>
            <span style="color: #0033ff; font-weight: bold;">return</span> <span style="color: #0033ff; font-weight: bold;">false</span>;
         <span style="color: #000000;">&#125;</span>
         <span style="color: #0033ff; font-weight: bold;">else</span>
         <span style="color: #000000;">&#123;</span>
            <span style="color: #0033ff; font-weight: bold;">return</span> <span style="color: #000000;">&#40;</span>result == IDENTICAL<span style="color: #000000;">&#41;</span>;
         <span style="color: #000000;">&#125;</span>
      <span style="color: #000000;">&#125;</span>
      <span style="color: #0033ff; font-weight: bold;">private</span> <span style="color: #339966; font-weight: bold;">function</span> failBitmapsMatch<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><span style="color: #000000; font-weight: bold;">:</span><span style="color: #0033ff; font-weight: bold;">void</span>
      <span style="color: #000000;">&#123;</span>
         fail<span style="color: #000000;">&#40;</span><span style="color: #990000;">&quot;Expected identical bitmaps, actual bitmaps are different.&quot;</span><span style="color: #000000;">&#41;</span>;
      <span style="color: #000000;">&#125;</span>
      <span style="color: #0033ff; font-weight: bold;">private</span> <span style="color: #339966; font-weight: bold;">function</span> failBitmapsDoNotMatch<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><span style="color: #000000; font-weight: bold;">:</span><span style="color: #0033ff; font-weight: bold;">void</span>
      <span style="color: #000000;">&#123;</span>
         fail<span style="color: #000000;">&#40;</span><span style="color: #990000;">&quot;Expected different bitmaps, actual bitmaps are identical.&quot;</span><span style="color: #000000;">&#41;</span>;
      <span style="color: #000000;">&#125;</span>
      <span style="color: #0033ff; font-weight: bold;">private</span> const IDENTICAL<span style="color: #000000; font-weight: bold;">:</span><span style="color: #004993;">int</span> = <span style="color: #000000; font-weight:bold;">0</span>;
   <span style="color: #000000;">&#125;</span>
<span style="color: #000000;">&#125;</span></pre></div></div>

<p>Here&#8217;s a quick usage example from the unit tests for my CellRenderer class. Note that this code has not been spit-shined, so it&#8217;s a bit rougher. I&#8217;ve included just enough of the class to communicate the gist.</p>

<div class="wp_syntax"><div class="code"><pre class="actionscript3" style="font-family:monospace;">override <span style="color: #0033ff; font-weight: bold;">public</span> <span style="color: #339966; font-weight: bold;">function</span> setUp<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><span style="color: #000000; font-weight: bold;">:</span><span style="color: #0033ff; font-weight: bold;">void</span>
<span style="color: #000000;">&#123;</span>
   <span style="color: #0033ff; font-weight: bold;">super</span>.setUp<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span>;
   surface = createSurface<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span>;
   cellRenderer = <span style="color: #0033ff; font-weight: bold;">new</span> CellRenderer<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span>;
   cell = MapCellFactory.createCell<span style="color: #000000;">&#40;</span><span style="color: #000000; font-weight:bold;">0</span>,<span style="color: #000000; font-weight:bold;">0</span><span style="color: #000000;">&#41;</span>;
   terrain = createTestTerrain<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span>;
   testSheet = createTestSheet<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span>;
&nbsp;
   cellRenderer.useSurface<span style="color: #000000;">&#40;</span>surface<span style="color: #000000;">&#41;</span>;
   cell.terrain = terrain;
<span style="color: #000000;">&#125;</span>
<span style="color: #0033ff; font-weight: bold;">public</span> <span style="color: #339966; font-weight: bold;">function</span> testCellTerrain<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><span style="color: #000000; font-weight: bold;">:</span><span style="color: #0033ff; font-weight: bold;">void</span>
<span style="color: #000000;">&#123;</span>
   <span style="color: #004993;">target</span> = <span style="color: #0033ff; font-weight: bold;">new</span> <span style="color: #004993;">BitmapData</span><span style="color: #000000;">&#40;</span>TILE_SIZE, TILE_SIZE, <span style="color: #0033ff; font-weight: bold;">false</span>, 0xff0000<span style="color: #000000;">&#41;</span>;
&nbsp;
   assertBitmapsDoNotMatch<span style="color: #000000;">&#40;</span><span style="color: #004993;">target</span>, surface<span style="color: #000000;">&#41;</span>;
   cellRenderer.renderCellFromSheet<span style="color: #000000;">&#40;</span>cell, testSheet<span style="color: #000000;">&#41;</span>;
   assertBitmapsMatch<span style="color: #000000;">&#40;</span><span style="color: #004993;">target</span>, surface<span style="color: #000000;">&#41;</span>;
<span style="color: #000000;">&#125;</span>
<span style="color: #0033ff; font-weight: bold;">public</span> <span style="color: #339966; font-weight: bold;">function</span> testCellWithActor<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><span style="color: #000000; font-weight: bold;">:</span><span style="color: #0033ff; font-weight: bold;">void</span>
<span style="color: #000000;">&#123;</span>
   <span style="color: #004993;">target</span> = <span style="color: #0033ff; font-weight: bold;">new</span> <span style="color: #004993;">BitmapData</span><span style="color: #000000;">&#40;</span>TILE_SIZE, TILE_SIZE, <span style="color: #0033ff; font-weight: bold;">false</span>, 0xff0000<span style="color: #000000;">&#41;</span>;
   <span style="color: #004993;">target</span>.<span style="color: #004993;">fillRect</span><span style="color: #000000;">&#40;</span><span style="color: #0033ff; font-weight: bold;">new</span> <span style="color: #004993;">Rectangle</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#40;</span>TILE_SIZE<span style="color: #000000; font-weight: bold;">-</span><span style="color: #000000; font-weight:bold;">2</span><span style="color: #000000;">&#41;</span><span style="color: #000000; font-weight: bold;">/</span><span style="color: #000000; font-weight:bold;">2</span>,<span style="color: #000000;">&#40;</span>TILE_SIZE<span style="color: #000000; font-weight: bold;">-</span><span style="color: #000000; font-weight:bold;">2</span><span style="color: #000000;">&#41;</span><span style="color: #000000; font-weight: bold;">/</span><span style="color: #000000; font-weight:bold;">2</span>,<span style="color: #000000; font-weight:bold;">2</span>,<span style="color: #000000; font-weight:bold;">2</span><span style="color: #000000;">&#41;</span>, 0xffffff<span style="color: #000000;">&#41;</span>;
&nbsp;
   <span style="color: #6699cc; font-weight: bold;">var</span> actorSprite<span style="color: #000000; font-weight: bold;">:</span><span style="color: #004993;">BitmapData</span> = <span style="color: #0033ff; font-weight: bold;">new</span> <span style="color: #004993;">BitmapData</span><span style="color: #000000;">&#40;</span>TILE_SIZE, TILE_SIZE, <span style="color: #0033ff; font-weight: bold;">true</span>, 0x00000000<span style="color: #000000;">&#41;</span>;
   actorSprite.<span style="color: #004993;">fillRect</span><span style="color: #000000;">&#40;</span><span style="color: #0033ff; font-weight: bold;">new</span> <span style="color: #004993;">Rectangle</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#40;</span>TILE_SIZE<span style="color: #000000; font-weight: bold;">-</span><span style="color: #000000; font-weight:bold;">2</span><span style="color: #000000;">&#41;</span><span style="color: #000000; font-weight: bold;">/</span><span style="color: #000000; font-weight:bold;">2</span>,<span style="color: #000000;">&#40;</span>TILE_SIZE<span style="color: #000000; font-weight: bold;">-</span><span style="color: #000000; font-weight:bold;">2</span><span style="color: #000000;">&#41;</span><span style="color: #000000; font-weight: bold;">/</span><span style="color: #000000; font-weight:bold;">2</span>,<span style="color: #000000; font-weight:bold;">2</span>,<span style="color: #000000; font-weight:bold;">2</span><span style="color: #000000;">&#41;</span>, 0xffffffff<span style="color: #000000;">&#41;</span>;
&nbsp;
   <span style="color: #6699cc; font-weight: bold;">var</span> actor<span style="color: #000000; font-weight: bold;">:</span>Actor = <span style="color: #0033ff; font-weight: bold;">new</span> Actor<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span>;
   actor.sprite = actorSprite;
   cell.addActor<span style="color: #000000;">&#40;</span>actor<span style="color: #000000;">&#41;</span>;
&nbsp;
   assertBitmapsDoNotMatch<span style="color: #000000;">&#40;</span><span style="color: #004993;">target</span>, surface<span style="color: #000000;">&#41;</span>;
   cellRenderer.renderCellFromSheet<span style="color: #000000;">&#40;</span>cell, testSheet<span style="color: #000000;">&#41;</span>;
   assertBitmapsMatch<span style="color: #000000;">&#40;</span><span style="color: #004993;">target</span>, surface<span style="color: #000000;">&#41;</span>;
<span style="color: #000000;">&#125;</span></pre></div></div>

]]></content:encoded>
			<wfw:commentRss>http://blog.andrewtraviss.com/?feed=rss2&amp;p=41</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>IllFate Project</title>
		<link>http://blog.andrewtraviss.com/?p=15</link>
		<comments>http://blog.andrewtraviss.com/?p=15#comments</comments>
		<pubDate>Wed, 16 Dec 2009 08:08:48 +0000</pubDate>
		<dc:creator>Andrew</dc:creator>
				<category><![CDATA[IllFate]]></category>
		<category><![CDATA[Game Development]]></category>
		<category><![CDATA[Roguelike]]></category>

		<guid isPermaLink="false">http://blog.andrewtraviss.com/?p=15</guid>
		<description><![CDATA[I am starting development of a Roguelike as a way of familiarizing myself with some development practices which I haven&#8217;t had a chance to use professionally yet.The whole project will be developed using Test-Driven Development in very short cycles. Normally Agile techniques seem like overkill for single developer projects, but a long term Roguelike generally [...]]]></description>
			<content:encoded><![CDATA[<p>I am starting development of a <a href="http://en.wikipedia.org/wiki/Roguelike" target="_blank">Roguelike</a> as a way of familiarizing myself with some development practices which I haven&#8217;t had a chance to use professionally yet.<span id="more-15"></span>The whole project will be developed using Test-Driven Development in very short cycles. Normally Agile techniques seem like overkill for single developer projects, but a long term Roguelike generally seems to incur a significant amount of refactoring. Working with a lot of emergent behaviour also justifies heavy unit testing; there really isn&#8217;t any other way to ensure that all the interactions continue to work as expected.</p>
<p>Instead of writing out a bunch of requirements documentation, which would just slow me down, I will be focusing on a single goal at any given time. That goal will be summarized using a haiku. Why a haiku? I was inspired by the way that the Adams brothers use short stories to generate goals and requirements for <a href="http://www.bay12games.com/dwarves/" target="_blank">Dwarf Fortress</a>. I want to keep my release cycles very tight, so I wanted to limit the size of any given change. Using a constrained verse structure seems like a natural way to do it. If I can&#8217;t fit it into a haiku, it&#8217;s probably too much to do at once.</p>
<address></address>
<p>Every time I implement a verse, I will release the latest build and share the next haiku.</p>
<h3>Verse 1:1</h3>
<blockquote><p>An empty room waits.</p>
<p>Only four walls and a floor.</p>
<p>Better than nothing.</p></blockquote>
<p style="text-align: center;">
<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000"
			id="fm_IllFate_Verse_1_1_558533925"
			class="flashmovie"
			width="240"
			height="160">
	<param name="movie" value="media/IllFate_Verse_1_1.swf" />
	<!--[if !IE]>-->
	<object	type="application/x-shockwave-flash"
			data="media/IllFate_Verse_1_1.swf"
			name="fm_IllFate_Verse_1_1_558533925"
			width="240"
			height="160">
	<!--<![endif]-->
		
<p style="text-align: center;"><a href="http://adobe.com/go/getflashplayer"><img src="http://www.adobe.com/images/shared/download_buttons/get_flash_player.gif" alt="Get Adobe Flash player" /></a></p>
<p style="text-align: center;">
	<!--[if !IE]>-->
	</object>
	<!--<![endif]-->
</object>
<p><span style="font-style: normal">This version isn&#8217;t really a game yet. The renderer is operational, and the basic map structures are in place. A single actor is rendered along with a small room. It will be some time before we leave this room. In fact the goal of the game will be to escape the room, until there is enough meat to justify tackling dungeon generation and other large topics.</span></p>
<h3><span style="font-style: normal">Verse 1:2</span></h3>
<blockquote><p><span style="font-style: normal">Walk across the room.</span></p>
<p><span style="font-style: normal">That door looks awfully nice.</span></p>
<p><span style="font-style: normal">I just won the game.</span></p></blockquote>
]]></content:encoded>
			<wfw:commentRss>http://blog.andrewtraviss.com/?feed=rss2&amp;p=15</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
	</channel>
</rss>
