 <?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>Tom Davies</title>
	<atom:link href="http://www.tomseysdavies.com/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.tomseysdavies.com</link>
	<description>Freelance flash and flex developer</description>
	<lastBuildDate>Wed, 22 Feb 2012 09:37:20 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
		<item>
		<title>Fluent asynchronous responder for network calls.</title>
		<link>http://www.tomseysdavies.com/2012/02/21/fluent-asynchronous-responder-for-network-calls/</link>
		<comments>http://www.tomseysdavies.com/2012/02/21/fluent-asynchronous-responder-for-network-calls/#comments</comments>
		<pubDate>Tue, 21 Feb 2012 20:32:36 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Blog]]></category>

		<guid isPermaLink="false">http://www.tomseysdavies.com/?p=356</guid>
		<description><![CDATA[<p>Handling asynchronous calls can be a pain. When we make a call like load() there is really only two thing that can happen we get success or failed. For 90% of applications that&#8217;s all we need. The native flash API is unwieldy and messy and overly complex.</p> <p>So lets start with a fresh look at [...]]]></description>
			<content:encoded><![CDATA[<p>Handling asynchronous calls can be a pain. When we make a call like load() there is really only two thing that can happen we get success or failed. For 90% of applications that&#8217;s all we need. The native flash API is unwieldy and messy and overly complex.</p>
<p>So lets start with a fresh look at what I think the API for a loader should look like.</p>
<div class="codecolorer-container actionscript3 default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="actionscript3 codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">&nbsp; <span style="color: #0033ff; font-weight: bold;">public</span> <span style="color: #339966; font-weight: bold;">function</span> Example<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span> <span style="color: #000000;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #6699cc; font-weight: bold;">var</span> xmlLoader<span style="color: #000066; font-weight: bold;">:</span>FluentXMLLoader = <span style="color: #0033ff; font-weight: bold;">new</span> FluentXMLLoader<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; xmlLoader<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">load</span><span style="color: #000000;">&#40;</span><span style="color: #990000;">&quot;http://www.w3schools.com/xml/note.xml&quot;</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">.</span>addSuccessHandler<span style="color: #000000;">&#40;</span>successHandler<span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">.</span>addErrorHandler<span style="color: #000000;">&#40;</span>errorHandler<span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span><br />
&nbsp; &nbsp; <span style="color: #000000;">&#125;</span><br />
<br />
&nbsp; &nbsp; <span style="color: #0033ff; font-weight: bold;">private</span> <span style="color: #339966; font-weight: bold;">function</span> successHandler<span style="color: #000000;">&#40;</span>xml<span style="color: #000066; font-weight: bold;">:</span><a href="http://www.google.com/search?q=xml%20inurl:http://livedocs.adobe.com/flex/201/langref/%20inurl:xml.html"><span style="color: #004993;">XML</span></a><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">:</span><span style="color: #0033ff; font-weight: bold;">void</span><span style="color: #000000;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #004993;">trace</span><span style="color: #000000;">&#40;</span>xml<span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span><br />
&nbsp; &nbsp; <span style="color: #000000;">&#125;</span><br />
<br />
&nbsp; &nbsp; <span style="color: #0033ff; font-weight: bold;">private</span> <span style="color: #339966; font-weight: bold;">function</span> errorHandler<span style="color: #000000;">&#40;</span><span style="color: #004993;">error</span><span style="color: #000066; font-weight: bold;">:</span><a href="http://www.google.com/search?q=ioerrorevent%20inurl:http://livedocs.adobe.com/flex/201/langref/%20inurl:ioerrorevent.html"><span style="color: #004993;">IOErrorEvent</span></a><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">:</span><span style="color: #0033ff; font-weight: bold;">void</span><span style="color: #000000;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #004993;">trace</span><span style="color: #000000;">&#40;</span><span style="color: #990000;">&quot;FAIL!&quot;</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span><br />
&nbsp; &nbsp; <span style="color: #000000;">&#125;</span></div></div>
<p>So the call load() is returning a fluent responder object to which we can add our handler. Its very simple we can added as many handlers of either type as we want or none at all. There is no garbage collection worry about because as soon as the handlers are called its automatically cleans up. Super clean.</p>
<p>So to create a class that uses this our loader look like this</p>
<div class="codecolorer-container actionscript3 default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="actionscript3 codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #0033ff; font-weight: bold;">public</span> <span style="color: #339966; font-weight: bold;">function</span> <span style="color: #004993;">load</span><span style="color: #000000;">&#40;</span><span style="color: #004993;">url</span><span style="color: #000066; font-weight: bold;">:</span><a href="http://www.google.com/search?q=string%20inurl:http://livedocs.adobe.com/flex/201/langref/%20inurl:string.html"><span style="color: #004993;">String</span></a><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">:</span>IFluentResponder<span style="color: #000000;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #6699cc; font-weight: bold;">var</span> responder<span style="color: #000066; font-weight: bold;">:</span>FluentResponder = <span style="color: #0033ff; font-weight: bold;">new</span> FluentResponder<span style="color: #000000;">&#40;</span><a href="http://www.google.com/search?q=xml%20inurl:http://livedocs.adobe.com/flex/201/langref/%20inurl:xml.html"><span style="color: #004993;">XML</span></a><span style="color: #000066; font-weight: bold;">,</span><a href="http://www.google.com/search?q=ioerrorevent%20inurl:http://livedocs.adobe.com/flex/201/langref/%20inurl:ioerrorevent.html"><span style="color: #004993;">IOErrorEvent</span></a><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #6699cc; font-weight: bold;">var</span> request<span style="color: #000066; font-weight: bold;">:</span><a href="http://www.google.com/search?q=urlrequest%20inurl:http://livedocs.adobe.com/flex/201/langref/%20inurl:urlrequest.html"><span style="color: #004993;">URLRequest</span></a> = <span style="color: #0033ff; font-weight: bold;">new</span> <a href="http://www.google.com/search?q=urlrequest%20inurl:http://livedocs.adobe.com/flex/201/langref/%20inurl:urlrequest.html"><span style="color: #004993;">URLRequest</span></a><span style="color: #000000;">&#40;</span><span style="color: #004993;">url</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #6699cc; font-weight: bold;">var</span> <span style="color: #004993;">loader</span><span style="color: #000066; font-weight: bold;">:</span><a href="http://www.google.com/search?q=urlloader%20inurl:http://livedocs.adobe.com/flex/201/langref/%20inurl:urlloader.html"><span style="color: #004993;">URLLoader</span></a> = <span style="color: #0033ff; font-weight: bold;">new</span> <a href="http://www.google.com/search?q=urlloader%20inurl:http://livedocs.adobe.com/flex/201/langref/%20inurl:urlloader.html"><span style="color: #004993;">URLLoader</span></a><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #6699cc; font-weight: bold;">var</span> loadNativeSignal<span style="color: #000066; font-weight: bold;">:</span>NativeSignal = <span style="color: #0033ff; font-weight: bold;">new</span> NativeSignal<span style="color: #000000;">&#40;</span><span style="color: #004993;">loader</span><span style="color: #000066; font-weight: bold;">,</span><a href="http://www.google.com/search?q=event%20inurl:http://livedocs.adobe.com/flex/201/langref/%20inurl:event.html"><span style="color: #004993;">Event</span></a><span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">COMPLETE</span><span style="color: #000066; font-weight: bold;">,</span><a href="http://www.google.com/search?q=event%20inurl:http://livedocs.adobe.com/flex/201/langref/%20inurl:event.html"><span style="color: #004993;">Event</span></a><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #6699cc; font-weight: bold;">var</span> errorNativeSignal<span style="color: #000066; font-weight: bold;">:</span>NativeSignal = <span style="color: #0033ff; font-weight: bold;">new</span> NativeSignal<span style="color: #000000;">&#40;</span><span style="color: #004993;">loader</span><span style="color: #000066; font-weight: bold;">,</span><a href="http://www.google.com/search?q=ioerrorevent%20inurl:http://livedocs.adobe.com/flex/201/langref/%20inurl:ioerrorevent.html"><span style="color: #004993;">IOErrorEvent</span></a><span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">IO_ERROR</span><span style="color: #000066; font-weight: bold;">,</span><a href="http://www.google.com/search?q=ioerrorevent%20inurl:http://livedocs.adobe.com/flex/201/langref/%20inurl:ioerrorevent.html"><span style="color: #004993;">IOErrorEvent</span></a><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; loadNativeSignal<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">add</span><span style="color: #000000;">&#40;</span><span style="color: #339966; font-weight: bold;">function</span><span style="color: #000000;">&#40;</span>event<span style="color: #000066; font-weight: bold;">:</span><a href="http://www.google.com/search?q=event%20inurl:http://livedocs.adobe.com/flex/201/langref/%20inurl:event.html"><span style="color: #004993;">Event</span></a><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">:</span><span style="color: #0033ff; font-weight: bold;">void</span><span style="color: #000000;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; responder<span style="color: #000066; font-weight: bold;">.</span>triggerSuccess<span style="color: #000000;">&#40;</span><a href="http://www.google.com/search?q=xml%20inurl:http://livedocs.adobe.com/flex/201/langref/%20inurl:xml.html"><span style="color: #004993;">XML</span></a><span style="color: #000000;">&#40;</span><span style="color: #004993;">loader</span><span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">data</span><span style="color: #000000;">&#41;</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; loadNativeSignal<span style="color: #000066; font-weight: bold;">.</span>removeAll<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; errorNativeSignal<span style="color: #000066; font-weight: bold;">.</span>removeAll<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000;">&#125;</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; errorNativeSignal<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">add</span><span style="color: #000000;">&#40;</span><span style="color: #339966; font-weight: bold;">function</span><span style="color: #000000;">&#40;</span>event<span style="color: #000066; font-weight: bold;">:</span><a href="http://www.google.com/search?q=ioerrorevent%20inurl:http://livedocs.adobe.com/flex/201/langref/%20inurl:ioerrorevent.html"><span style="color: #004993;">IOErrorEvent</span></a><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">:</span><span style="color: #0033ff; font-weight: bold;">void</span><span style="color: #000000;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; responder<span style="color: #000066; font-weight: bold;">.</span>triggerError<span style="color: #000000;">&#40;</span>event<span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; loadNativeSignal<span style="color: #000066; font-weight: bold;">.</span>removeAll<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; errorNativeSignal<span style="color: #000066; font-weight: bold;">.</span>removeAll<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000;">&#125;</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #004993;">loader</span><span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">load</span><span style="color: #000000;">&#40;</span>request<span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0033ff; font-weight: bold;">return</span> responder<span style="color: #000066; font-weight: bold;">;</span><br />
<span style="color: #000000;">&#125;</span></div></div>
<p>OK bit of native signal closure magic here so we only have local variables but dont let that put you off.</p>
<p>   The first thing to note is the return type is IFluentResponder which gives us the ability to add handlers but not  mess with the other workings. The next thing we do is create our responder object. In the constructor like signals we define the data types expected on success and failure respectively.  The last thing to note is that when we load are file we call responder.triggerSuccess(); and if we fail responder.triggerError(); </p>
<p>    That&#8217;s it, dead easy. All the code is up <a href="https://github.com/tdavies/FluentResponders">here</a> on github. </p>
<p>Update: its been pointed out that this is similar to Shauns <a href="https://github.com/darscan/robotlegs-extensions-Oil">promises</a>. There is a javascript proposal <a href="http://wiki.commonjs.org/wiki/Promises/A">here</a> and a nice JS implementation <a href="https://github.com/cujojs/when">here</a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.tomseysdavies.com/2012/02/21/fluent-asynchronous-responder-for-network-calls/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Samphire</title>
		<link>http://www.tomseysdavies.com/2012/02/07/samphire/</link>
		<comments>http://www.tomseysdavies.com/2012/02/07/samphire/#comments</comments>
		<pubDate>Tue, 07 Feb 2012 21:10:05 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Blog]]></category>

		<guid isPermaLink="false">http://www.tomseysdavies.com/?p=348</guid>
		<description><![CDATA[<p>I&#8217;m going to start with a disclaimer this is not a fully fledged polished game engine more a proof of concept and hopefully something to show the way. If you want more features then please add them </p> <p>So I wanted to create a little demo showing what <a href="http://www.tomseysdavies.com/2011/01/23/entity-systems/" title="Entity Systems">Entity Systems</a> can do [...]]]></description>
			<content:encoded><![CDATA[<p>I&#8217;m going to start with a disclaimer this is not a fully fledged polished game engine more a proof of concept and hopefully something to show the way. If you want more features then please add them <img src='http://www.tomseysdavies.com/wordpress/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<p>So I wanted to create a little demo showing what <a href="http://www.tomseysdavies.com/2011/01/23/entity-systems/" title="Entity Systems">Entity Systems</a> can do for you and why you should care. Now they solve a lot of structural issues but also by there nature are data driven. This means by being a bit clever we can get automated serialisation. A fancy way of saying we can save the game state with out writing any special code. If we are a bit smarter still we can create an Editor that will magically work for any components we add. What&#8217;s more this editor works “in game” as you are playing you can tweak and save you levels. Arrow keys to move and E to bring up the editor.</p>
<p>
<object width="640" height="480">
<param name="movie" value="http://www.tomseysdavies.com/wordpress/wp-content/uploads/2012/02/PlatformDemo.swf"></param>
<param name="quality" value="high"></param>
<param name="wmode" value="window"></param>
<param name="menu" value="false"></param>
<param name="bgcolor" value="#FFFFFF"></param>
<param name="allowScriptAccess" value="always"></param>
<embed type="application/x-shockwave-flash" width="640" height="480" src="http://www.tomseysdavies.com/wordpress/wp-content/uploads/2012/02/PlatformDemo.swf" quality="high" bgcolor="#FFFFFF" wmode="window" menu="false" ></embed>
</object>
</p>
<p>Obviously there is a lot missing both from the editor and the engine. But hopefully for those who don&#8217;t quite know where to start with Entity Systems this will be a nudge in the right direction.</p>
<p>The code for the demo is <a href="https://github.com/tdavies/Samphire-demos">here</a> on git hub. The code for engine is <a href="https://github.com/tdavies/Samphire">here</a> and it uses <a href="http://www.tomseysdavies.com/2011/12/04/ember-2/" title="Ember 2">Ember2</a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.tomseysdavies.com/2012/02/07/samphire/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Ember 2</title>
		<link>http://www.tomseysdavies.com/2011/12/04/ember-2/</link>
		<comments>http://www.tomseysdavies.com/2011/12/04/ember-2/#comments</comments>
		<pubDate>Sun, 04 Dec 2011 11:17:48 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Blog]]></category>

		<guid isPermaLink="false">http://www.tomseysdavies.com/?p=337</guid>
		<description><![CDATA[<p>Well Its been a while but I&#8217;ve been busy in the back ground and finally have something to show for it all. In the shape of <a href="https://github.com/tdavies/Ember2" title="Ember 2" target="_blank">Ember 2</a> first up I need to acknowledge some major contributors. First Alec McEachran @alecmce and his take on things with <a href="https://github.com/alecmce/xember" title="xember" target="_blank">xember</a>. [...]]]></description>
			<content:encoded><![CDATA[<p>Well Its been a while but I&#8217;ve been busy in the back ground and finally have something to show for it all. In the shape of <a href="https://github.com/tdavies/Ember2" title="Ember 2" target="_blank">Ember 2</a> first up I need to acknowledge some major contributors. First Alec McEachran @alecmce and his take on things with <a href="https://github.com/alecmce/xember" title="xember" target="_blank">xember</a>. Second Richard Lord @richard_lord and his clever suggestions in how to get around the performance cost of removing items from a vector. </p>
<p>   Although the new versions API is in many ways familiar although simplified it is a complete rebuild underneath with a much more test driven approach. Also while some of the changes are a bit more subtle there are two biggie&#8217;s. All in all I made the decision that it deserves the version 2 badge. </p>
<p>   So the first  big thing is Ember is now a Robotlegs2 extension. To pre-empt the reaction of some that robotlegs has no place in games it does. Its perfect for the UI and  menu&#8217;s systems etc. the issue is that the MVC doesn&#8217;t fit real time game play which is where Ember steps onto the stage. For Ember2 I wanted something that solved the issues of integrating with the Robotlegs framework  whilst still being able stand alone. I also wanted a way of  being able to add any functionality  required without having to bake it in. Lucky Robotlegs2 appeared and its new context where functionality is constructed from extensions rather than being built in was exactly what I wanted. So rather than doing It my self badly it made sense to use it and save me a lot of work.</p>
<p>  Second on the list is some clever trickery. With some magic behind the scenes I have been able to ditch the cumbersome linked lists and still keep performance practically the same. The best part is the nodes are now in juicy vectors and they can now be injected directly into the systems. No casting and funny loops any more just inject and “for each” you way over them.</p>
<p>  Other more minor changes are that Entities are now objects in them selves. This may sound like a minor thing but it allows for pooling of whole Entities which was previously impossible and can help performance. Also taken for Alec&#8217;s xember is the auto inspection of the node classes so there is now minimal typing required when creating your nodes.  All these things add up to make Ember 2 simpler and neater so it can just get out of the way and allow you to get on and code. If you want to get started check out the <a href="https://github.com/tdavies/Ember2-demos" title="bunnies demo" target="_blank">bunnies demo code</a> on github. Have fun.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.tomseysdavies.com/2011/12/04/ember-2/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Admin Portal</title>
		<link>http://www.tomseysdavies.com/2011/08/19/admin-portal/</link>
		<comments>http://www.tomseysdavies.com/2011/08/19/admin-portal/#comments</comments>
		<pubDate>Fri, 19 Aug 2011 09:26:37 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Portfolio]]></category>

		<guid isPermaLink="false">http://www.tomseysdavies.com/?p=320</guid>
		<description><![CDATA[<p>Administration portal for a payment system. Built a Flex client with the robot legs framework and signals. Also built the corresponding BlazeDS back-end. Features included a skin-able UI for client specific branding. User level permissions and customisable menu settings. Highly customised charts.</p>]]></description>
			<content:encoded><![CDATA[<p>Administration portal for a payment system. Built a Flex client with the robot legs framework and signals. Also built the corresponding BlazeDS back-end. Features included a skin-able UI for client specific branding. User level permissions and customisable menu settings. Highly customised charts.</p>

<a href='http://www.tomseysdavies.com/wordpress/wp-content/uploads/2011/08/community.jpg' rel='shadowbox[sbalbum-320];player=img;' title='community'><img width="150" height="150" src="http://www.tomseysdavies.com/wordpress/wp-content/uploads/2011/08/community-150x150.jpg" class="attachment-thumbnail" alt="community" title="community" /></a>
<a href='http://www.tomseysdavies.com/wordpress/wp-content/uploads/2011/08/home.jpg' rel='shadowbox[sbalbum-320];player=img;' title='home'><img width="150" height="150" src="http://www.tomseysdavies.com/wordpress/wp-content/uploads/2011/08/home-150x150.jpg" class="attachment-thumbnail" alt="home" title="home" /></a>
<a href='http://www.tomseysdavies.com/wordpress/wp-content/uploads/2011/08/mobileTransactions.jpg' rel='shadowbox[sbalbum-320];player=img;' title='mobileTransactions'><img width="150" height="150" src="http://www.tomseysdavies.com/wordpress/wp-content/uploads/2011/08/mobileTransactions-150x150.jpg" class="attachment-thumbnail" alt="mobileTransactions" title="mobileTransactions" /></a>
<a href='http://www.tomseysdavies.com/wordpress/wp-content/uploads/2011/08/products.jpg' rel='shadowbox[sbalbum-320];player=img;' title='products'><img width="150" height="150" src="http://www.tomseysdavies.com/wordpress/wp-content/uploads/2011/08/products-150x150.jpg" class="attachment-thumbnail" alt="products" title="products" /></a>
<a href='http://www.tomseysdavies.com/wordpress/wp-content/uploads/2011/08/transactionsReport.jpg' rel='shadowbox[sbalbum-320];player=img;' title='transactionsReport'><img width="150" height="150" src="http://www.tomseysdavies.com/wordpress/wp-content/uploads/2011/08/transactionsReport-150x150.jpg" class="attachment-thumbnail" alt="transactionsReport" title="transactionsReport" /></a>
<a href='http://www.tomseysdavies.com/wordpress/wp-content/uploads/2011/08/users.jpg' rel='shadowbox[sbalbum-320];player=img;' title='users'><img width="150" height="150" src="http://www.tomseysdavies.com/wordpress/wp-content/uploads/2011/08/users-150x150.jpg" class="attachment-thumbnail" alt="users" title="users" /></a>

]]></content:encoded>
			<wfw:commentRss>http://www.tomseysdavies.com/2011/08/19/admin-portal/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>London Flash User Group talk</title>
		<link>http://www.tomseysdavies.com/2011/08/19/my-talk-at-the-london-flash-user-group/</link>
		<comments>http://www.tomseysdavies.com/2011/08/19/my-talk-at-the-london-flash-user-group/#comments</comments>
		<pubDate>Fri, 19 Aug 2011 08:47:46 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Blog]]></category>

		<guid isPermaLink="false">http://www.tomseysdavies.com/?p=312</guid>
		<description><![CDATA[<p>Tink very kindly let me talk at the FLPUG last month about entity systems. Its now up online and you can watch it here.</p> <p><a href=" http://www.lfpug.com/entity-systems-%E2%80%93-a-better-way-to-develop-games/"></p> <p>http://www.lfpug.com/entity-systems-%E2%80%93-a-better-way-to-develop-games/</a></p> <p>It was a pleasant surprise to meet people that other people are working with these ideas and even using there own versions of Ember. Hopefully I managed [...]]]></description>
			<content:encoded><![CDATA[<p>Tink very kindly let me talk at the FLPUG last month about entity systems. Its now up online and you can watch it here.</p>
<p><a href=" http://www.lfpug.com/entity-systems-%E2%80%93-a-better-way-to-develop-games/"></p>
<p>http://www.lfpug.com/entity-systems-%E2%80%93-a-better-way-to-develop-games/</a></p>
<p>It was a pleasant surprise to meet people that other people are working with these ideas and even using there own versions of Ember. Hopefully I managed put it on the radar of at least a couple more. </p>
]]></content:encoded>
			<wfw:commentRss>http://www.tomseysdavies.com/2011/08/19/my-talk-at-the-london-flash-user-group/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Bunny madness</title>
		<link>http://www.tomseysdavies.com/2011/07/24/bunny-madness/</link>
		<comments>http://www.tomseysdavies.com/2011/07/24/bunny-madness/#comments</comments>
		<pubDate>Sun, 24 Jul 2011 15:07:27 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Blog]]></category>

		<guid isPermaLink="false">http://www.tomseysdavies.com/?p=302</guid>
		<description><![CDATA[<p>The latest version of <a href="http://github.com/tdavies/Ember" title="Ember">Ember</a> comes with a huge increase in speed. The idea came when I was thinking about linked lists and I realised that I could also cache a pointer to the components in the list nodes. So we now have an Entity system with little in the way of processing [...]]]></description>
			<content:encoded><![CDATA[<p>The latest version of <a href="http://github.com/tdavies/Ember" title="Ember">Ember</a> comes with a huge increase in speed. The idea came when I was thinking about linked lists and I realised that I could also cache a pointer to the components in the list nodes. So we now have an Entity system with little in the way of processing overhead. In fact in benchmarks the performance difference compared to standard game engines is negligible.</p>
<p>Here are two benchmark demo&#8217;s complete with source code.</p>
<p><a href='http://www.tomseysdavies.com/dev/blit/BlitDemo.html' target="_blank">5500 bunny blitting Demo</a></p>
<p><a href='http://www.tomseysdavies.com/dev/fountain/BunnyFountainDemo.html' target="_blank">55 per frame bunny fountain Demo</a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.tomseysdavies.com/2011/07/24/bunny-madness/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Getting started with Ember</title>
		<link>http://www.tomseysdavies.com/2011/02/03/getting-started-with-ember/</link>
		<comments>http://www.tomseysdavies.com/2011/02/03/getting-started-with-ember/#comments</comments>
		<pubDate>Thu, 03 Feb 2011 19:30:29 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Blog]]></category>
		<category><![CDATA[Programing]]></category>

		<guid isPermaLink="false">http://www.tomseysdavies.com/?p=219</guid>
		<description><![CDATA[<p> Note:Some of this is a bit out of date. I&#8217;ll do my best to update it ASAP. There are now uptodate demos complete with source code <a href="http://www.tomseysdavies.com/2011/07/24/bunny-madness/" title="here" target="_blank">here</a></p> the Game <p>If your new to entity systems then you may want to read my posts on <a href="http://www.tomseysdavies.com/2011/01/15/game-architecture/">Game Architecture</a> and <a href="http://www.tomseysdavies.com/2011/01/23/entity-systems/">Entity Systems</a> [...]]]></description>
			<content:encoded><![CDATA[<p> Note:Some of this is a bit out of date. I&#8217;ll do my best to update it ASAP. There are now uptodate demos complete with source code <a href="http://www.tomseysdavies.com/2011/07/24/bunny-madness/" title="here" target="_blank">here</a></p>
<h3>the Game</h3>
<p>If your new to entity systems then you may want to read my posts on <a href="http://www.tomseysdavies.com/2011/01/15/game-architecture/">Game Architecture</a> and <a href="http://www.tomseysdavies.com/2011/01/23/entity-systems/">Entity Systems</a> first to get an over view. You can download the code for this example <a href='http://www.tomseysdavies.com/wordpress/wp-content/uploads/2011/03/GettingStarted.zip'>GettingStarted</a></p>
<p>Ok so first step to making games on the <a href="https://github.com/tdavies/Ember">Ember</a> frame work is to create you games main class. This has the same role as an applications context in <a href="http://www.robotlegs.org/" target="_blank">robotlegs</a>.  Its main role is the initialization and tearing-down of you game.</p>
<div class="codecolorer-container actionscript3 default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="actionscript3 codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #9900cc; font-weight: bold;">package</span><span style="color: #000000;">&#123;</span><br />
&nbsp; &nbsp; <span style="color: #0033ff; font-weight: bold;">import</span> com<span style="color: #000066; font-weight: bold;">.</span>tomseysdavies<span style="color: #000066; font-weight: bold;">.</span>ember<span style="color: #000066; font-weight: bold;">.</span>base<span style="color: #000066; font-weight: bold;">.</span>Game<span style="color: #000066; font-weight: bold;">;</span><br />
<br />
&nbsp; &nbsp; <span style="color: #0033ff; font-weight: bold;">public</span> <span style="color: #9900cc; font-weight: bold;">class</span> MyGame <span style="color: #0033ff; font-weight: bold;">extends</span> Game<span style="color: #000000;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; override <span style="color: #0033ff; font-weight: bold;">protected</span> <span style="color: #339966; font-weight: bold;">function</span> startUp<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">:</span><span style="color: #0033ff; font-weight: bold;">void</span><span style="color: #000000;">&#123;</span><br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000;">&#125;</span><br />
&nbsp; &nbsp; <span style="color: #000000;">&#125;</span><br />
<span style="color: #000000;">&#125;</span></div></div>
<p>we can now launch the game from felx like so and pass it a reference to the display object that we want to become the games view.</p>
<div class="codecolorer-container mxml default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="mxml codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #000000;">&lt;?xml version=<span style="color: #ff0000;">&quot;1.0&quot;</span> encoding=<span style="color: #ff0000;">&quot;utf-8&quot;</span>?<span style="color: #7400FF;">&gt;</span></span><br />
<span style="color: #000000;"><span style="color: #7400FF;">&lt;s:Application</span> xmlns:fx=<span style="color: #ff0000;">&quot;http://ns.adobe.com/mxml/2009&quot;</span> </span><br />
<span style="color: #000000;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;xmlns:s=<span style="color: #ff0000;">&quot;library://ns.adobe.com/flex/spark&quot;</span> </span><br />
<span style="color: #000000;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;xmlns:mx=<span style="color: #ff0000;">&quot;library://ns.adobe.com/flex/mx&quot;</span> minWidth=<span style="color: #ff0000;">&quot;955&quot;</span> minHeight=<span style="color: #ff0000;">&quot;600&quot;</span> xmlns:local=<span style="color: #ff0000;">&quot;*&quot;</span><span style="color: #7400FF;">&gt;</span></span><br />
&nbsp; &nbsp; <span style="color: #000000;"><span style="color: #7400FF;">&lt;fx:Declarations</span><span style="color: #7400FF;">&gt;</span></span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000;"><span style="color: #808080; font-style: italic;">&lt;!-- Place non-visual elements (e.g., services, value objects) here --&gt;</span></span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000;"><span style="color: #7400FF;">&lt;local:MyGame</span> contextView=<span style="color: #ff0000;">&quot;{gameView}&quot;</span> <span style="color: #7400FF;">/&gt;</span></span><br />
&nbsp; &nbsp; <span style="color: #000000;"><span style="color: #7400FF;">&lt;/fx:Declarations</span><span style="color: #7400FF;">&gt;</span></span><br />
&nbsp; &nbsp; <span style="color: #000000;"><span style="color: #7400FF;">&lt;mx:UIComponent</span> id=<span style="color: #ff0000;">&quot;gameView&quot;</span> <span style="color: #7400FF;">/&gt;</span></span><br />
<span style="color: #000000;"><span style="color: #7400FF;">&lt;/s:Application</span><span style="color: #7400FF;">&gt;</span></span></div></div>
<h3>Components</h3>
<p>So our game is now launching and has a reference to its view so we can now look at creating our first component. A component is a <a href="http://www.c2.com/cgi/wiki?ValueObject">value object</a> its highly portable and normal has no methods only data. For this tutorial we will need two.</p>
<div class="codecolorer-container actionscript3 default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="actionscript3 codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #9900cc; font-weight: bold;">package</span> components<br />
<span style="color: #000000;">&#123;</span><br />
&nbsp; &nbsp; <span style="color: #0033ff; font-weight: bold;">public</span> <span style="color: #9900cc; font-weight: bold;">class</span> PositionComponent<br />
&nbsp; &nbsp; <span style="color: #000000;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0033ff; font-weight: bold;">public</span> <span style="color: #6699cc; font-weight: bold;">var</span> <span style="color: #004993;">x</span><span style="color: #000066; font-weight: bold;">:</span><a href="http://www.google.com/search?q=number%20inurl:http://livedocs.adobe.com/flex/201/langref/%20inurl:number.html"><span style="color: #004993;">Number</span></a> = <span style="color: #000000; font-weight:bold;">0</span><span style="color: #000066; font-weight: bold;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0033ff; font-weight: bold;">public</span> <span style="color: #6699cc; font-weight: bold;">var</span> <span style="color: #004993;">y</span><span style="color: #000066; font-weight: bold;">:</span><a href="http://www.google.com/search?q=number%20inurl:http://livedocs.adobe.com/flex/201/langref/%20inurl:number.html"><span style="color: #004993;">Number</span></a> = <span style="color: #000000; font-weight:bold;">0</span><span style="color: #000066; font-weight: bold;">;</span><br />
&nbsp; &nbsp; <span style="color: #000000;">&#125;</span><br />
<span style="color: #000000;">&#125;</span></div></div>
<div class="codecolorer-container actionscript3 default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="actionscript3 codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #9900cc; font-weight: bold;">package</span> components<br />
<span style="color: #000000;">&#123;</span><br />
&nbsp; &nbsp; <span style="color: #0033ff; font-weight: bold;">import</span> <span style="color: #004993;">flash.display</span><span style="color: #000066; font-weight: bold;">.</span><a href="http://www.google.com/search?q=bitmap%20inurl:http://livedocs.adobe.com/flex/201/langref/%20inurl:bitmap.html"><span style="color: #004993;">Bitmap</span></a><span style="color: #000066; font-weight: bold;">;</span><br />
<br />
&nbsp; &nbsp; <span style="color: #0033ff; font-weight: bold;">public</span> <span style="color: #9900cc; font-weight: bold;">class</span> GraphicsComponent<br />
&nbsp; &nbsp; <span style="color: #000000;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0033ff; font-weight: bold;">public</span> <span style="color: #6699cc; font-weight: bold;">var</span> asset<span style="color: #000066; font-weight: bold;">:</span><a href="http://www.google.com/search?q=bitmap%20inurl:http://livedocs.adobe.com/flex/201/langref/%20inurl:bitmap.html"><span style="color: #004993;">Bitmap</span></a><span style="color: #000066; font-weight: bold;">;</span><br />
&nbsp; &nbsp; <span style="color: #000000;">&#125;</span><br />
<span style="color: #000000;">&#125;</span></div></div>
<h3>Entities</h3>
<p>Now lets go back to our start up function. So here we first create that our components then next we create an entity and add our components to it.  Think of an entity as an empty container to which we can add components.  We create entities with the entityManager.</p>
<div class="codecolorer-container actionscript3 default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="actionscript3 codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">override <span style="color: #0033ff; font-weight: bold;">protected</span> <span style="color: #339966; font-weight: bold;">function</span> startUp<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">:</span><span style="color: #0033ff; font-weight: bold;">void</span><span style="color: #000000;">&#123;</span><br />
&nbsp; &nbsp; <span style="color: #6699cc; font-weight: bold;">var</span> positionComponent<span style="color: #000066; font-weight: bold;">:</span>PositionComponent = <span style="color: #0033ff; font-weight: bold;">new</span> PositionComponent<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span><br />
&nbsp; &nbsp; positionComponent<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">x</span> = <span style="color: #000000; font-weight:bold;">100</span><span style="color: #000066; font-weight: bold;">;</span><br />
&nbsp; &nbsp; positionComponent<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">y</span> = <span style="color: #000000; font-weight:bold;">100</span><span style="color: #000066; font-weight: bold;">;</span>&nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; <span style="color: #6699cc; font-weight: bold;">var</span> graphicsComponent<span style="color: #000066; font-weight: bold;">:</span>GraphicsComponent = <span style="color: #0033ff; font-weight: bold;">new</span> GraphicsComponent<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span><br />
&nbsp; &nbsp; graphicsComponent<span style="color: #000066; font-weight: bold;">.</span>asset = <span style="color: #0033ff; font-weight: bold;">new</span> Tree<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; <span style="color: #6699cc; font-weight: bold;">var</span> entity<span style="color: #000066; font-weight: bold;">:</span>IEntity = entityManager<span style="color: #000066; font-weight: bold;">.</span>createEntity<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span><br />
&nbsp; &nbsp; entity<span style="color: #000066; font-weight: bold;">.</span>addComponent<span style="color: #000000;">&#40;</span>positionComponent<span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span><br />
&nbsp; &nbsp; entity<span style="color: #000066; font-weight: bold;">.</span>addComponent<span style="color: #000000;">&#40;</span>graphicsComponent<span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span><br />
<br />
<span style="color: #000000;">&#125;</span></div></div>
<h3>Systems</h3>
<p>The final building block in <a href="https://github.com/tdavies/Ember">Ember</a> is the systems these have all the logic for the game that acts on the entities data. Ember uses <a href="https://github.com/tschneidereit/SwiftSuspenders">SwiftSuspenders</a> for its <a href="http://en.wikipedia.org/wiki/Dependency_injection">dependency injection</a> if you have used <a href="http://www.robotlegs.org/">robotlegs</a> then hopefully this should be familiar and its well documented there so I wont cover it into much detail. All systems must implement ISystem and the onRegister and destroy functions that come with that. Any initiation code needs to go in to onRegister which is automatically called after the injection has occurred. The destroy() function is used to clean up any event listeners etc. Have a quick look at the code bellow then I will explain it.</p>
<div class="codecolorer-container actionscript3 default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;height:300px;"><div class="actionscript3 codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #9900cc; font-weight: bold;">package</span> systems<br />
<span style="color: #000000;">&#123;</span><br />
&nbsp; &nbsp; <span style="color: #0033ff; font-weight: bold;">import</span> com<span style="color: #000066; font-weight: bold;">.</span>tomseysdavies<span style="color: #000066; font-weight: bold;">.</span>ember<span style="color: #000066; font-weight: bold;">.</span>base<span style="color: #000066; font-weight: bold;">.</span>EntityManager<span style="color: #000066; font-weight: bold;">;</span><br />
&nbsp; &nbsp; <span style="color: #0033ff; font-weight: bold;">import</span> com<span style="color: #000066; font-weight: bold;">.</span>tomseysdavies<span style="color: #000066; font-weight: bold;">.</span>ember<span style="color: #000066; font-weight: bold;">.</span>core<span style="color: #000066; font-weight: bold;">.</span>IEntity<span style="color: #000066; font-weight: bold;">;</span><br />
&nbsp; &nbsp; <span style="color: #0033ff; font-weight: bold;">import</span> com<span style="color: #000066; font-weight: bold;">.</span>tomseysdavies<span style="color: #000066; font-weight: bold;">.</span>ember<span style="color: #000066; font-weight: bold;">.</span>core<span style="color: #000066; font-weight: bold;">.</span>ISystem<span style="color: #000066; font-weight: bold;">;</span><br />
&nbsp; &nbsp; <br />
&nbsp; &nbsp; <span style="color: #0033ff; font-weight: bold;">import</span> components<span style="color: #000066; font-weight: bold;">.</span>GraphicsComponent<span style="color: #000066; font-weight: bold;">;</span><br />
&nbsp; &nbsp; <span style="color: #0033ff; font-weight: bold;">import</span> components<span style="color: #000066; font-weight: bold;">.</span>PositionComponent<span style="color: #000066; font-weight: bold;">;</span><br />
&nbsp; &nbsp; <br />
&nbsp; &nbsp; <span style="color: #0033ff; font-weight: bold;">import</span> <span style="color: #004993;">flash.display</span><span style="color: #000066; font-weight: bold;">.</span><a href="http://www.google.com/search?q=bitmap%20inurl:http://livedocs.adobe.com/flex/201/langref/%20inurl:bitmap.html"><span style="color: #004993;">Bitmap</span></a><span style="color: #000066; font-weight: bold;">;</span><br />
&nbsp; &nbsp; <span style="color: #0033ff; font-weight: bold;">import</span> <span style="color: #004993;">flash.display</span><span style="color: #000066; font-weight: bold;">.</span><a href="http://www.google.com/search?q=bitmapdata%20inurl:http://livedocs.adobe.com/flex/201/langref/%20inurl:bitmapdata.html"><span style="color: #004993;">BitmapData</span></a><span style="color: #000066; font-weight: bold;">;</span><br />
&nbsp; &nbsp; <span style="color: #0033ff; font-weight: bold;">import</span> <span style="color: #004993;">flash.display</span><span style="color: #000066; font-weight: bold;">.</span><a href="http://www.google.com/search?q=displayobjectcontainer%20inurl:http://livedocs.adobe.com/flex/201/langref/%20inurl:displayobjectcontainer.html"><span style="color: #004993;">DisplayObjectContainer</span></a><span style="color: #000066; font-weight: bold;">;</span><br />
&nbsp; &nbsp; <span style="color: #0033ff; font-weight: bold;">import</span> <span style="color: #004993;">flash.geom</span><span style="color: #000066; font-weight: bold;">.</span><a href="http://www.google.com/search?q=point%20inurl:http://livedocs.adobe.com/flex/201/langref/%20inurl:point.html"><span style="color: #004993;">Point</span></a><span style="color: #000066; font-weight: bold;">;</span><br />
&nbsp; &nbsp; <span style="color: #0033ff; font-weight: bold;">import</span> <span style="color: #004993;">flash.geom</span><span style="color: #000066; font-weight: bold;">.</span><a href="http://www.google.com/search?q=rectangle%20inurl:http://livedocs.adobe.com/flex/201/langref/%20inurl:rectangle.html"><span style="color: #004993;">Rectangle</span></a><span style="color: #000066; font-weight: bold;">;</span><br />
&nbsp; &nbsp; <br />
&nbsp; &nbsp; <span style="color: #0033ff; font-weight: bold;">public</span> <span style="color: #9900cc; font-weight: bold;">class</span> RenderingSystem implements ISystem<br />
&nbsp; &nbsp; <span style="color: #000000;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000;">&#91;</span>Inject<span style="color: #000000;">&#93;</span> <span style="color: #0033ff; font-weight: bold;">public</span> <span style="color: #6699cc; font-weight: bold;">var</span> contextView<span style="color: #000066; font-weight: bold;">:</span><a href="http://www.google.com/search?q=displayobjectcontainer%20inurl:http://livedocs.adobe.com/flex/201/langref/%20inurl:displayobjectcontainer.html"><span style="color: #004993;">DisplayObjectContainer</span></a><span style="color: #000066; font-weight: bold;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000;">&#91;</span>Inject<span style="color: #000000;">&#93;</span> <span style="color: #0033ff; font-weight: bold;">public</span> <span style="color: #6699cc; font-weight: bold;">var</span> entityManager<span style="color: #000066; font-weight: bold;">:</span>EntityManager<span style="color: #000066; font-weight: bold;">;</span>&nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0033ff; font-weight: bold;">private</span> <span style="color: #6699cc; font-weight: bold;">var</span> _family<span style="color: #000066; font-weight: bold;">:</span>IFamily<span style="color: #000066; font-weight: bold;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0033ff; font-weight: bold;">private</span> <span style="color: #6699cc; font-weight: bold;">var</span> _viewPort<span style="color: #000066; font-weight: bold;">:</span><a href="http://www.google.com/search?q=bitmap%20inurl:http://livedocs.adobe.com/flex/201/langref/%20inurl:bitmap.html"><span style="color: #004993;">Bitmap</span></a><span style="color: #000066; font-weight: bold;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0033ff; font-weight: bold;">public</span> <span style="color: #339966; font-weight: bold;">function</span> onRegister<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">:</span><span style="color: #0033ff; font-weight: bold;">void</span><span style="color: #000000;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; _family = entityManager<span style="color: #000066; font-weight: bold;">.</span>getEntityFamily<span style="color: #000000;">&#40;</span>PositionComponent<span style="color: #000066; font-weight: bold;">,</span>GraphicsComponent<span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; _family<span style="color: #000066; font-weight: bold;">.</span>iterator<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">add</span><span style="color: #000000;">&#40;</span>renderEntity<span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; _viewPort = <span style="color: #0033ff; font-weight: bold;">new</span> <a href="http://www.google.com/search?q=bitmap%20inurl:http://livedocs.adobe.com/flex/201/langref/%20inurl:bitmap.html"><span style="color: #004993;">Bitmap</span></a><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; _viewPort<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">bitmapData</span> = <span style="color: #0033ff; font-weight: bold;">new</span> <a href="http://www.google.com/search?q=bitmapdata%20inurl:http://livedocs.adobe.com/flex/201/langref/%20inurl:bitmapdata.html"><span style="color: #004993;">BitmapData</span></a><span style="color: #000000;">&#40;</span><span style="color: #000000; font-weight:bold;">400</span><span style="color: #000066; font-weight: bold;">,</span><span style="color: #000000; font-weight:bold;">400</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; contextView<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">addChild</span><span style="color: #000000;">&#40;</span>_viewPort<span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #004993;">render</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000;">&#125;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0033ff; font-weight: bold;">private</span> <span style="color: #339966; font-weight: bold;">function</span> <span style="color: #004993;">render</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">:</span><span style="color: #0033ff; font-weight: bold;">void</span><span style="color: #000000;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; _viewPort<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">bitmapData</span><span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">fillRect</span><span style="color: #000000;">&#40;</span><span style="color: #0033ff; font-weight: bold;">new</span> <a href="http://www.google.com/search?q=rectangle%20inurl:http://livedocs.adobe.com/flex/201/langref/%20inurl:rectangle.html"><span style="color: #004993;">Rectangle</span></a><span style="color: #000000;">&#40;</span><span style="color: #000000; font-weight:bold;">0</span><span style="color: #000066; font-weight: bold;">,</span><span style="color: #000000; font-weight:bold;">0</span><span style="color: #000066; font-weight: bold;">,</span><span style="color: #000000; font-weight:bold;">400</span><span style="color: #000066; font-weight: bold;">,</span><span style="color: #000000; font-weight:bold;">400</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">,</span>0xFFFFCC<span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; _family<span style="color: #000066; font-weight: bold;">.</span>startIterator<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000;">&#125;</span><br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0033ff; font-weight: bold;">private</span> <span style="color: #339966; font-weight: bold;">function</span> renderEntity<span style="color: #000000;">&#40;</span><span style="color: #004993;">position</span><span style="color: #000066; font-weight: bold;">:</span>PositionComponent<span style="color: #000066; font-weight: bold;">,</span><span style="color: #004993;">graphics</span><span style="color: #000066; font-weight: bold;">:</span>GraphicsComponent<span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">:</span><span style="color: #0033ff; font-weight: bold;">void</span><span style="color: #000000;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; _viewPort<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">bitmapData</span><span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">copyPixels</span><span style="color: #000000;">&#40;</span><span style="color: #004993;">graphics</span><span style="color: #000066; font-weight: bold;">.</span>asset<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">bitmapData</span><span style="color: #000066; font-weight: bold;">,</span><span style="color: #004993;">graphics</span><span style="color: #000066; font-weight: bold;">.</span>asset<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">bitmapData</span><span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">rect</span><span style="color: #000066; font-weight: bold;">,</span><span style="color: #0033ff; font-weight: bold;">new</span> <a href="http://www.google.com/search?q=point%20inurl:http://livedocs.adobe.com/flex/201/langref/%20inurl:point.html"><span style="color: #004993;">Point</span></a><span style="color: #000000;">&#40;</span><span style="color: #004993;">position</span><span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">x</span><span style="color: #000066; font-weight: bold;">,</span><span style="color: #004993;">position</span><span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">y</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">,</span><span style="color: #0033ff; font-weight: bold;">null</span><span style="color: #000066; font-weight: bold;">,</span><span style="color: #0033ff; font-weight: bold;">null</span><span style="color: #000066; font-weight: bold;">,</span><span style="color: #0033ff; font-weight: bold;">true</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000;">&#125;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0033ff; font-weight: bold;">public</span> <span style="color: #339966; font-weight: bold;">function</span> destroy<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">:</span><span style="color: #0033ff; font-weight: bold;">void</span>&nbsp; <span style="color: #000000;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;_family<span style="color: #000066; font-weight: bold;">.</span>iterator<span style="color: #000066; font-weight: bold;">.</span>remove<span style="color: #000000;">&#40;</span>renderEntity<span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; _viewPort<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">bitmapData</span><span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">dispose</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000;">&#125;</span><br />
&nbsp; &nbsp; <span style="color: #000000;">&#125;</span><br />
<span style="color: #000000;">&#125;</span></div></div>
<p>This system as it name suggests renders our entity to the screen. First we we set up a <a href="http://en.wikipedia.org/wiki/Viewport">viewport </a> where we will render our graphics (note contextview is again injected). Next the most important line in onRegister is this(note that the reference to the entityManager is injected above).</p>
<div class="codecolorer-container actionscript3 default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="actionscript3 codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">_family = entityManager<span style="color: #000066; font-weight: bold;">.</span>getEntityFamily<span style="color: #000000;">&#40;</span>PositionComponent<span style="color: #000066; font-weight: bold;">,</span>GraphicsComponent<span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span></div></div>
<p>This allows us to &#8220;look up&#8221; all entities from the entityManager that have all the specified components.  Here we are asking for all entities that have both the PositionComponent and the GraphicsComponent. The entityManager returns a pointer to a family instance. We store a reference to this so we don&#8217;t have to request it every time we render the game. We can listen to <a href="https://github.com/robertpenner/as3-signals">signals</a> dispatched by the family to see if entities have been added or removed or iterate over all entities in the family. We are going to add a handler to the iterator signal. we do that like this</p>
<div class="codecolorer-container actionscript3 default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="actionscript3 codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">_family<span style="color: #000066; font-weight: bold;">.</span>iterator<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">add</span><span style="color: #000000;">&#40;</span>renderEntity<span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span></div></div>
<p>Bellow is what that handler function looks like. Notice it accepts components as arguments in the same order as those that we asked for when we called getEntityFamily. If these don&#8217;t match you will get a runtime error.</p>
<div class="codecolorer-container actionscript3 default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="actionscript3 codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #0033ff; font-weight: bold;">private</span> <span style="color: #339966; font-weight: bold;">function</span> renderEntity<span style="color: #000000;">&#40;</span><span style="color: #004993;">position</span><span style="color: #000066; font-weight: bold;">:</span>PositionComponent<span style="color: #000066; font-weight: bold;">,</span><span style="color: #004993;">graphics</span><span style="color: #000066; font-weight: bold;">:</span>GraphicsComponent<span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">:</span><span style="color: #0033ff; font-weight: bold;">void</span><span style="color: #000000;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; _viewPort<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">bitmapData</span><span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">copyPixels</span><span style="color: #000000;">&#40;</span><span style="color: #004993;">graphics</span><span style="color: #000066; font-weight: bold;">.</span>asset<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">bitmapData</span><span style="color: #000066; font-weight: bold;">,</span><span style="color: #004993;">graphics</span><span style="color: #000066; font-weight: bold;">.</span>asset<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">bitmapData</span><span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">rect</span><span style="color: #000066; font-weight: bold;">,</span><span style="color: #0033ff; font-weight: bold;">new</span> <a href="http://www.google.com/search?q=point%20inurl:http://livedocs.adobe.com/flex/201/langref/%20inurl:point.html"><span style="color: #004993;">Point</span></a><span style="color: #000000;">&#40;</span><span style="color: #004993;">position</span><span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">x</span><span style="color: #000066; font-weight: bold;">,</span><span style="color: #004993;">position</span><span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">y</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">,</span><span style="color: #0033ff; font-weight: bold;">null</span><span style="color: #000066; font-weight: bold;">,</span><span style="color: #0033ff; font-weight: bold;">null</span><span style="color: #000066; font-weight: bold;">,</span><span style="color: #0033ff; font-weight: bold;">true</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span><br />
<span style="color: #000000;">&#125;</span></div></div>
<p>Once iteration has been triggered this will be called once for each entity in the family. It uses the data in the position component to copy the asset in the graphics component to the screen. So now to trigger the iteration we just call</p>
<div class="codecolorer-container actionscript3 default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="actionscript3 codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">_family<span style="color: #000066; font-weight: bold;">.</span>startIterator<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span></div></div>
<p>Our final task is to add our system to the game. So at the end of our games start up function we add</p>
<div class="codecolorer-container actionscript3 default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="actionscript3 codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">systemManager<span style="color: #000066; font-weight: bold;">.</span>addSystem<span style="color: #000000;">&#40;</span>RenderingSystem<span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span></div></div>
<p>OK and that&#8217;s all we need to draw our asset to the screen. Not much use by its self but next post ill show how to send events between systems by injecting <a href="https://github.com/robertpenner/as3-signals">signals</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.tomseysdavies.com/2011/02/03/getting-started-with-ember/feed/</wfw:commentRss>
		<slash:comments>48</slash:comments>
		</item>
		<item>
		<title>Entity Systems</title>
		<link>http://www.tomseysdavies.com/2011/01/23/entity-systems/</link>
		<comments>http://www.tomseysdavies.com/2011/01/23/entity-systems/#comments</comments>
		<pubDate>Sun, 23 Jan 2011 16:27:46 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Blog]]></category>
		<category><![CDATA[Programing]]></category>
		<category><![CDATA[architecture]]></category>
		<category><![CDATA[components]]></category>
		<category><![CDATA[entities]]></category>
		<category><![CDATA[flash]]></category>
		<category><![CDATA[game]]></category>

		<guid isPermaLink="false">http://www.tomseysdavies.com/?p=197</guid>
		<description><![CDATA[<p><a name="search"></a>“Favour composition over inheritance”</p> <p>If you haven&#8217;t already read my previous post on the problems of traditional <a href="http://www.tomseysdavies.com/2011/01/15/game-architecture/" target="_blank">game architecture</a> and why entity systems are needed. I&#8217;m going to cover the basics of an entity system before we look at 3 different implantations and the pro&#8217;s and con&#8217;s of each.</p> What is an [...]]]></description>
			<content:encoded><![CDATA[<p><a name="search"></a>“<em>Favour composition over inheritance</em>”</p>
<p>If you haven&#8217;t already read my previous post on the problems of traditional <a href="http://www.tomseysdavies.com/2011/01/15/game-architecture/" target="_blank">game architecture</a> and why entity systems are needed. I&#8217;m going to cover the basics of an entity system before we look at 3 different implantations and the pro&#8217;s and con&#8217;s of each.</p>
<h2>What is an entity?</h2>
<p>An entity (sometimes called game object) represents something in the game. For every tree,tank or ninja we have an entity. An entity is container to which we can add components (behaviours) that define what it is. e.g  In this rather conceptual example a Ninja gets a Renderer, Physics, Health and Stealth components which together make up a Ninja.</p>
<p><a href="http://www.tomseysdavies.com/wordpress/wp-content/uploads/2011/01/entities.jpg" rel="shadowbox[sbpost-197];player=img;"><img class="alignnone size-full wp-image-199" title="entities" src="http://www.tomseysdavies.com/wordpress/wp-content/uploads/2011/01/entities.jpg" alt="" width="572" height="210" /></a></p>
<p>This is the basics of all Entity systems one of key feature is the ability to create entities and change there components at run time. So a Ninja could become a Tank! (that&#8217;s the hard sell done).</p>
<h2>Spotter guide.</h2>
<p>There are 3 main ways to implement an entity system I have seen and I&#8217;m going to quickly out line them all and take a critical look at the pro&#8217;s and con&#8217;s. I&#8217;m going to call them common, almost and true (yes I&#8217;m bias but I think they are appropriate names)</p>
<h3>&#8220;Common&#8221;</h3>
<p>Most common implantation you are going to come across. Its based on the strategy pattern and its the simplest to understand. The first time I built a entity system this is what I did. There are good example out there in flash like <a href="http://pushbuttonengine.com/" target="_blank">PushButton</a> Engine.</p>
<h4>How it works</h4>
<p>All components have a common interface normal with a function update(). Calling update() on entity causes update() to be called on all its components. Components then update there data for example a render component may copy its graphics to a view port.</p>
<p><a href="http://www.tomseysdavies.com/wordpress/wp-content/uploads/2011/01/common.jpg" rel="shadowbox[sbpost-197];player=img;"><img class="alignnone size-full wp-image-201" title="common" src="http://www.tomseysdavies.com/wordpress/wp-content/uploads/2011/01/common.jpg" alt="" width="175" height="207" /></a></p>
<h4>Pros</h4>
<p>Simple and fast. Better than inheritance.</p>
<h4>Cons</h4>
<p>Scalability and flexibility (how easy it is to make changes).  To explain the issue lets take an example. We have an entity with both  renderer and physics components. Both need to know about the location of the entity in the world. So we have two options</p>
<ol>
<li>push the data up 	into the entity its self.  In complex games this can result inmore and more specialised data gets pushed up into the entity creating a god object.</li>
<li>Allow components 	to access other components data. When one component depends on the data in another component we get a dependency. Component   A can&#8217;t  function unless component B exists. As a game grows so does the complexity of the dependencies.</li>
</ol>
<p>There are work arounds to this issue for example automatically creating component B when A is added but then we need to give it the correct data. We start to lose the ability to mix and match components on the fly that makes an entity system so powerful. Entity to entity communication for example in collision detection is also difficult.</p>
<h3>&#8220;Almost&#8221;</h3>
<p>This was suggest to me by a friend I&#8217;m including it here as its hard to criticise and has a lot of positives points.</p>
<h4>How it works</h4>
<p>This gets the big leap correct it separates the data from the logic. In the common implementation both data and logic are combined in a component here they separated into</p>
<ol>
<li>Data &#8211; Components</li>
<li>Logic – Systems(behaviours)</li>
</ol>
<p>This is counter intuitive and contrary to what&#8217;s drilled into you about OOP. However it solves lots of issues.</p>
<p>A renderer system could require a spacial component (position in the world .etc)  and a graphics component where as a physics system may require just the spacial component. Think of the components as the model and systems as the controller in MVC terms.  Systems normally implement a common interface with a update() function</p>
<p><a href="http://www.tomseysdavies.com/wordpress/wp-content/uploads/2011/01/almost.jpg" rel="shadowbox[sbpost-197];player=img;"><img class="alignnone size-full wp-image-204" title="almost" src="http://www.tomseysdavies.com/wordpress/wp-content/uploads/2011/01/almost.jpg" alt="" width="360" height="207" /></a></p>
<h4>Pros</h4>
<p>More scalable the systems have no dependencies on one another and can share data. Fast.</p>
<h4>Cons</h4>
<p>Systems are still dependent on an entity having specific components. This can be worked around to an extent by implementing it so that when we and a system to an entity any missing components are created automatically. This however means that we have to add a system before we can start setting the components data as they may not exist before that point. The main issue with this system come with entity to entity communication for example in collision detection. A collision  system attached to an entity needs to check its self against all the others entities with collision systems this can be done with events but it also can be a lot simpler as we will see next.</p>
<h3>&#8220;True&#8221;</h3>
<p>“<em>A game is just a real time database with a graphical front end</em>”</p>
<p>- Dave Roderick</p>
<p>This is a blanket statment but its fundamentally true and this architecture is the closest fit to this statement I have found.</p>
<h4>How it works</h4>
<p>Again we separate out the logic and the data. However rather than adding systems to the individual entities we add the systems to the game its self. The systems can the do a real time look up and requests all entities that have the required components for processing. For instance a rendering system will ask every frame for all entities that have Spacial and Graphical components it will then run though the list drawing each one.</p>
<p><a href="http://www.tomseysdavies.com/wordpress/wp-content/uploads/2011/01/true.jpg" rel="shadowbox[sbpost-197];player=img;"><img class="alignnone size-full wp-image-207" title="true" src="http://www.tomseysdavies.com/wordpress/wp-content/uploads/2011/01/true.jpg" alt="" width="368" height="253" /></a></p>
<h4>Pros</h4>
<p>Scalable and easy to make change due to low dependences. Truly data driven. Simple. Collisions etc. are much easier to manage.</p>
<h4>Cons</h4>
<p>Slow(er) looking up the entities we need for each system every frame is going to effect performance. Counter-intuitive and requires you to rethink your approach to programming.</p>
<h2>Conclusion</h2>
<p>All these systems are better that a traditional inheritance hierarchy. I chose the “true” system for my frame work <a href="https://github.com/tdavies/Ember" target="_blank">Ember</a> as I think its pros out way its cons when it comes to the real issues of game development. It can also be implemented so that performance issues can become negligible. you can read how to get started using Ember here<a href="http://www.tomseysdavies.com/2011/02/03/getting-started-with-ember/">.</p>
<p>If you want to read more on entity systems its covered in some depth <a href="http://t-machine.org/index.php/2007/09/03/entity-systems-are-the-future-of-mmog-development-part-1/" target="_blank">here</a> by t-machine blogs.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.tomseysdavies.com/2011/01/23/entity-systems/feed/</wfw:commentRss>
		<slash:comments>9</slash:comments>
		</item>
		<item>
		<title>Game Architecture</title>
		<link>http://www.tomseysdavies.com/2011/01/15/game-architecture/</link>
		<comments>http://www.tomseysdavies.com/2011/01/15/game-architecture/#comments</comments>
		<pubDate>Sat, 15 Jan 2011 16:52:21 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Blog]]></category>
		<category><![CDATA[Programing]]></category>
		<category><![CDATA[architecture]]></category>
		<category><![CDATA[components]]></category>
		<category><![CDATA[entities]]></category>
		<category><![CDATA[flash]]></category>
		<category><![CDATA[game]]></category>

		<guid isPermaLink="false">http://www.tomseysdavies.com/?p=185</guid>
		<description><![CDATA[<p>In all the games I have made I have never been that happy with the architecture. Using <a href="hhttp://puremvc.org/" target="_blank">PureMVC</a> and more recently <a href="http://www.robotlegs.org/" target="_self">Robotlegs</a> on a more or less daily basis has shown me the benefits of a well designed common framework. The down side of MVC which both are based on is [...]]]></description>
			<content:encoded><![CDATA[<p>In all the games I have made I have never been that happy with the architecture. Using <a href="hhttp://puremvc.org/" target="_blank">PureMVC</a> and more recently <a href="http://www.robotlegs.org/" target="_self">Robotlegs</a> on a more or less daily basis has shown me the benefits of a well designed common framework. The down side of MVC which both are based on is that its not suitable for game development it&#8217;s ideal for the into screens and menus and perhaps even the UI but its not designed for problems found in game development.</p>
<p>So what do you do? Well if you like me then you will probably come up with something like this.</p>
<p><a href="http://www.tomseysdavies.com/wordpress/wp-content/uploads/2011/01/gameInheritance.png" rel="shadowbox[sbpost-185];player=img;"><img class="alignnone size-full wp-image-186" title="gameInheritance" src="http://www.tomseysdavies.com/wordpress/wp-content/uploads/2011/01/gameInheritance.png" alt="" width="415" height="317" /></a></p>
<p>OK  details may vary but it should be familiar to most people who have built games. So we have a nice inheritance tree and its all looking pretty straight forward. But then may be you decide actually what your game needs is moveable platforms. OK no real problem just change Platform to inherit from Movable and were done. Well some still don&#8217;t move so we need a boolean to flag the movable ones but that not to difficult.</p>
<p>So what&#8217;s the issue? Well perhaps now we decide we need a enemy that doesn&#8217;t move. What&#8217;s the simple solution to that?  The point I&#8217;m trying to make is inheritance sucks. Its fine if everything is predetermined and well designed but games are not like that. Even if you have designed you game by some freak in-site to the n&#8217;th degree when you start on you next game how much code are you going to be able to reuse? Finally what if you want to make these changes at run time with out having to recompile?</p>
<p>Let me put another way would it be better if you could pick and choose the attributes you want for  each item in your game.</p>
<p><a href="http://www.tomseysdavies.com/wordpress/wp-content/uploads/2011/01/entities2.png" rel="shadowbox[sbpost-185];player=img;"><img class="alignnone size-full wp-image-189" title="entities" src="http://www.tomseysdavies.com/wordpress/wp-content/uploads/2011/01/entities2.png" alt="" width="528" height="178" /></a></p>
<p>As you can see we could make a moveable platform just by sticking a tick in the correct box.</p>
<p>So this is the ideal how can we do this in practice. Well we can use an “Entity System” also called “Component Systems” and “ Entity Component Systems” and loads of other names. I&#8217;m going to use Entity System as Component has to many meaning especially in flash.  As well as having many different names there are as many interpretations as to how to implement one. Not being happy with any I had come across implemented in flash I have created my own framework <a href="https://github.com/tdavies/Ember" target="_blank">Ember</a> and made it open source. In my <a href="http://www.tomseysdavies.com/2011/01/23/entity-systems/" target="_blank">next</a> post I look at the various ways of implementing entity systems.</p>
<p>Read more:</p>
<p><a href="http://cowboyprogramming.com/2007/01/05/evolve-your-heirachy/" target="_blank">Evlove your Heirarchy</a></p>
<p><a href="http://t-machine.org/index.php/2007/09/03/entity-systems-are-the-future-of-mmog-development-part-1/" target="_self">T-Machines posts on entity systems</a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.tomseysdavies.com/2011/01/15/game-architecture/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Superfun Town</title>
		<link>http://www.tomseysdavies.com/2010/08/05/superfun-town/</link>
		<comments>http://www.tomseysdavies.com/2010/08/05/superfun-town/#comments</comments>
		<pubDate>Thu, 05 Aug 2010 14:36:07 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Portfolio]]></category>

		<guid isPermaLink="false">http://www.tomseysdavies.com/wordpress/?p=54</guid>
		<description><![CDATA[<p style="text-align: right;"><a href="http://www.tomseysdavies.com/wordpress/wp-content/uploads/2010/08/sft1.jpg" rel="shadowbox[sbpost-54];player=img;"></a></p> <p style="text-align: right;">Massively Multilayer Isometric database driven Social Facebook game. In game payment, multi language, fullscreen with Flex user interface.</p> <p style="text-align: right;"><a href="http://www.facebook.com/apps/application.php?id=260692711926" target="_blank">Play on Facebook</a></p>]]></description>
			<content:encoded><![CDATA[<p style="text-align: right;"><a href="http://www.tomseysdavies.com/wordpress/wp-content/uploads/2010/08/sft1.jpg" rel="shadowbox[sbpost-54];player=img;"><img class="size-full wp-image-95 alignleft" title="sft" src="http://www.tomseysdavies.com/wordpress/wp-content/uploads/2010/08/sft1.jpg" alt="Super Fun Town" width="469" height="550" /></a></p>
<p style="text-align: right;">Massively Multilayer Isometric database driven Social Facebook game. In game payment, multi language, fullscreen with Flex user interface.</p>
<p style="text-align: right;"><a href="http://www.facebook.com/apps/application.php?id=260692711926" target="_blank">Play on Facebook</a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.tomseysdavies.com/2010/08/05/superfun-town/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

