<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/xsl" media="screen" href="/~d/styles/rss2full.xsl"?><?xml-stylesheet type="text/css" media="screen" href="http://feeds.feedburner.com/~d/styles/itemcontent.css"?><rss xmlns:atom="http://www.w3.org/2005/Atom" xmlns:openSearch="http://a9.com/-/spec/opensearch/1.1/" xmlns:georss="http://www.georss.org/georss" xmlns:gd="http://schemas.google.com/g/2005" xmlns:thr="http://purl.org/syndication/thread/1.0" xmlns:feedburner="http://rssnamespace.org/feedburner/ext/1.0" version="2.0"><channel><atom:id>tag:blogger.com,1999:blog-8584570627780730363</atom:id><lastBuildDate>Wed, 01 Feb 2012 10:13:48 +0000</lastBuildDate><category>Design</category><category>Performance</category><category>App Hub</category><category>Agile</category><category>Game</category><category>XNA</category><title>SteveProXNA</title><description>Professional Video Games Programmer and XNA Indie</description><link>http://steveproxna.blogspot.com/</link><managingEditor>noreply@blogger.com (SteveProXNA)</managingEditor><generator>Blogger</generator><openSearch:totalResults>22</openSearch:totalResults><openSearch:startIndex>1</openSearch:startIndex><openSearch:itemsPerPage>25</openSearch:itemsPerPage><atom10:link xmlns:atom10="http://www.w3.org/2005/Atom" rel="self" type="application/rss+xml" href="http://feeds.feedburner.com/SteveProXNA" /><feedburner:info uri="steveproxna" /><atom10:link xmlns:atom10="http://www.w3.org/2005/Atom" rel="hub" href="http://pubsubhubbub.appspot.com/" /><item><guid isPermaLink="false">tag:blogger.com,1999:blog-8584570627780730363.post-3763120184680445445</guid><pubDate>Sun, 01 Jan 2012 12:58:00 +0000</pubDate><atom:updated>2012-01-01T05:51:39.291-08:00</atom:updated><category domain="http://www.blogger.com/atom/ns#">Agile</category><title>Retrospective III</title><description>&lt;span style="font-family:verdana;font-size:85%;"&gt;Last year, I conducted a simple 
&lt;a href="http://steveproxna.blogspot.com/2011/01/retrospective-ii.html"&gt;retrospective&lt;/a&gt; for 2010.  Therefore, here is a retrospective for 2011.
&lt;br /&gt;&lt;br /&gt;&lt;u&gt;2011 Achievements&lt;/u&gt;&lt;br /&gt;&lt;table width="100%"&gt;&lt;tr&gt;&lt;td valign="top"&gt;
&lt;ul&gt;&lt;li&gt;Integrate &lt;a href="http://steveproxna.blogspot.com/2011/02/xna-and-agile-software-development.html"&gt;agile software methodologies&lt;/a&gt; into XNA game development
&lt;/li&gt;&lt;li&gt;Reference to &lt;a href="http://steveproxna.blogspot.com/2011/03/xna-and-unit-testing.html"&gt;XNA and Unit Testing&lt;/a&gt; by George Clingerman on &lt;a href="http://geekswithblogs.net/clingermangw/archive/2011/03/25/144513.aspx"&gt;XNA Notes&lt;/a&gt;&lt;/li&gt;&lt;li&gt;Give presentation on System and Unit testing within game development&lt;/li&gt;&lt;li&gt;Build C++ game engine to extend knowledge of DirectX/XNA interaction&lt;/li&gt;&lt;li&gt;Purchase &lt;a href="http://www.amazon.com/Professional-Windows-Phone-Game-Development/dp/0470922443/ref=sr_1_1?s=books&amp;ie=UTF8&amp;qid=1325092252&amp;sr=1-1"&gt;Windows Phone 7&lt;/a&gt; book.  Begin WP7 and Xbox game project&lt;/li&gt;&lt;li&gt;Assist over 1,000 Indies in 50 regions plus with &lt;a href="http://steveproxna.blogspot.com/2010/04/xna-and-tax.html"&gt;XNA and TAX&lt;/a&gt;&lt;/li&gt;&lt;li&gt;Publish article on XNA and &lt;a href="http://steveproxna.blogspot.com/2011/09/xna-and-breaking-into-games-industry.html"&gt;Breaking into the Games Industry&lt;/a&gt;&lt;/li&gt;&lt;li&gt;Write lots more game code as Independent and Professional&lt;/li&gt;&lt;/ul&gt;Note: receiving acknowledgement by George Clingerman on XNA Notes is an achievement!&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&lt;br /&gt;&lt;u&gt;2012 Objectives&lt;/u&gt;&lt;br /&gt;&lt;table width="100%"&gt;&lt;tr&gt;&lt;td valign="top"&gt;&lt;ul&gt;&lt;li&gt;Promote quality in game development using agile software methodologies&lt;/li&gt;&lt;li&gt;Incorporate three dimensional graphics into game development projects&lt;/li&gt;&lt;li&gt;Monitor the future of &lt;a href="http://en.wikipedia.org/wiki/Microsoft_XNA"&gt;XNA&lt;/a&gt;, &lt;a href="http://en.wikipedia.org/wiki/Xbox_Live_Indie_Games"&gt;XBLIG&lt;/a&gt;, and the Microsoft Indie gaming scene&lt;/li&gt;&lt;li&gt;Explore alternative Indie game development distribution channels&lt;/li&gt;&lt;/ul&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&lt;br /&gt;In 2010, there was much concern from the developer community as Indie Games were hidden under Specialty Shops as part of the Xbox dashboard &lt;a href="http://www.xbox.com/en-US/Support/SystemUpdates"&gt;update&lt;/a&gt;.&lt;br /&gt;&lt;br /&gt;In 2011, independent game developers responded angrily to the latest Xbox 360 dashboard &lt;a href="http://www.develop-online.net/news/39322/Indie-anger-at-new-Xbox-dash"&gt;update&lt;/a&gt;:&lt;br /&gt;many feel that the marketplace is again hidden as Indie Games are now presented as a single list.&lt;br /&gt;&lt;br /&gt;Also in 2011, the announcement: &lt;a href="http://www.mobiletechworld.com/2011/09/19/no-xna-support-for-metro-applications-in-windows-8"&gt;No XNA support&lt;/a&gt; for Metro applications in Windows 8 has prompted much speculation over the future of XNA.&lt;br /&gt;&lt;br /&gt;Quote: &lt;i&gt;
It is correct that XNA is not supported for developing new style Metro applications in Windows 8.  But XNA remains fully supported and recommended for developing on Xbox and Windows Phone, not to mention for creating classic Windows applications (run on XP, Vista, Win7, and Win8 in classic mode).&lt;/i&gt;&lt;br /&gt;&lt;br /&gt;This report appears reminiscent to the XNA Game Studio 4.0 upgrade: &lt;a href="http://news.softpedia.com/news/XNA-Game-Studio-4-0-Not-for-Zune-HD-Just-Windows-Xbox-360-and-Windows-Phone-7-136999.shtml"&gt;Not for Zune HD&lt;/a&gt;.&lt;br /&gt;&lt;br /&gt;
Fortunately, there is some positive news for &lt;a href="http://en.wikipedia.org/wiki/Independent_video_game_development"&gt;Independent game development&lt;/a&gt;, especially now as digital distribution is becoming more prevalent in the games industry; various portals such as &lt;a href="http://en.wikipedia.org/wiki/Big_Fish_Games"&gt;Big Fish Games&lt;/a&gt; and &lt;a href="http://en.wikipedia.org/wiki/Steam_(software)"&gt;Steam&lt;/a&gt; currently distribute the majority of Indie Games on PC and Mac.&lt;br /&gt;&lt;br /&gt;There are also independent games distribution websites, such as &lt;a href="http://www.indiecity.com"&gt;IndieCity&lt;/a&gt;, built to cater exclusively for Indie Games and &lt;i&gt;&lt;a href="http://www.develop-online.net/news/39298/New-indie-PC-platform-ends-discoverability-woes"&gt;end discoverability woes&lt;/a&gt;&lt;/i&gt; for the community.&lt;br /&gt;&lt;br /&gt;Therefore, year 2012 appeals to the future of the Microsoft Indie gaming scene compared to alternative Indie Games distribution channels.&lt;/span&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/8584570627780730363-3763120184680445445?l=steveproxna.blogspot.com' alt='' /&gt;&lt;/div&gt;
&lt;p&gt;&lt;a href="http://feedads.g.doubleclick.net/~a/igAVXRHCX7qvvoOSlJgyjtH-Vl8/0/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/igAVXRHCX7qvvoOSlJgyjtH-Vl8/0/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;br/&gt;
&lt;a href="http://feedads.g.doubleclick.net/~a/igAVXRHCX7qvvoOSlJgyjtH-Vl8/1/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/igAVXRHCX7qvvoOSlJgyjtH-Vl8/1/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;/p&gt;&lt;img src="http://feeds.feedburner.com/~r/SteveProXNA/~4/0lk8XQjh1SM" height="1" width="1"/&gt;</description><link>http://feedproxy.google.com/~r/SteveProXNA/~3/0lk8XQjh1SM/retrospective-iii.html</link><author>noreply@blogger.com (SteveProXNA)</author><thr:total>0</thr:total><feedburner:origLink>http://steveproxna.blogspot.com/2012/01/retrospective-iii.html</feedburner:origLink></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-8584570627780730363.post-8303988160082309925</guid><pubDate>Thu, 15 Sep 2011 07:41:00 +0000</pubDate><atom:updated>2012-01-01T05:48:06.362-08:00</atom:updated><category domain="http://www.blogger.com/atom/ns#">XNA</category><title>XNA and Breaking into the Games Industry</title><description>&lt;span style="font-family:verdana;font-size:85%;"&gt;The video games industry is a multi-billion dollar business.  A recent analyst &lt;a href="http://www.gamasutra.com/view/news/37744/Analyst_Video_Game_Market_Worth_60B_Worldwide_In_2011_80B_By_2014.php"&gt;report&lt;/a&gt; suggests that the worldwide market for video games will exceed $60 billion in 2011.  The report also expects the video games industry to generate more than $80 billion in 2014.&lt;br /&gt;&lt;br /&gt;The video games industry is dynamic, innovative and exciting.  Consequently, game development itself has diversified: capitalizing on digital distribution, mobile devices, new free-to-play business models,&lt;br /&gt;next-generation game consoles and social networking sites.&lt;br /&gt;&lt;br /&gt;Expected growth in the video games industry creates demand for talent, particularly as video games become more complex and require larger development teams.  So, this all sounds great, therefore...&lt;br /&gt;&lt;br /&gt;&lt;b&gt;How do you break into the games industry?&lt;/b&gt;&lt;br /&gt;&lt;br /&gt;
One common theme to help break into the games industry is simple: Just do it.  &lt;a href="http://www.gamesbrief.com/2011/08/want-to-break-into-the-games-industry-just-do-it/"&gt;Go.  Make Games.&lt;/a&gt;&lt;br /&gt;Quote: &lt;i&gt;if you want to make games for a living, start making them for fun now&lt;/i&gt;.&lt;br /&gt;&lt;br /&gt;Making you own game shows initiative.  It showcases your talent and demonstrates commitment:&lt;br /&gt;That you can produce a complete game!  This is where technologies like &lt;a href="http://en.wikipedia.org/wiki/XNA_(Microsoft)"&gt;XNA&lt;/a&gt; can help.&lt;br /&gt;&lt;br /&gt;
XNA is an exciting technology that allows independent game code to be developed and deployed to the Windows PC, Windows Phone 7 and Xbox 360.  The &lt;a href="http://create.msdn.com/en-US"&gt;App Hub&lt;/a&gt; provides tools, information and assistance&lt;br /&gt;to help create games for these devices.&lt;br /&gt;&lt;br /&gt;Completing your own game is a rewarding achievement.  Plus you create opportunities to blog about your experience and take advantage of social networking sites to: promote your work, share information and build reputation as a bone fide game developer.&lt;br /&gt;&lt;br /&gt;
In my experience, the transition from independent to professional is difficult, but not impossible.&lt;br /&gt;Here are some further &lt;a href="http://www.jobprofiles.org/library/guidance/break-into-video-games.htm"&gt;recommendations&lt;/a&gt; on how to break into the games industry:&lt;br /&gt;&lt;br /&gt;&lt;table width="100%"&gt;&lt;tr&gt;&lt;td valign="top" width="30%"&gt;Learn C++:&lt;br /&gt;Play video games:&lt;br /&gt;Focus on skillset:&lt;br /&gt;Subscribe to job sites:&lt;br /&gt;Follow the industry:&lt;br /&gt;Join associations:&lt;br /&gt;Prepare to relocate:&lt;br /&gt;Recommended reading:&lt;br /&gt;&lt;/td&gt;&lt;td valign="top" width="70%"&gt;
C++ is currently the dominant language for game development.&lt;br /&gt;Play tons of games and really get to know the hardware / software.&lt;br /&gt;Target your core strengths and search for jobs with the best fit.&lt;br /&gt;Receive daily &lt;a href="http://www.gamesindustry.biz"&gt;emails&lt;/a&gt; to guage trends in games skillset requirements.&lt;br /&gt;Keep up-to-date with industry events and read online &lt;a href="http://www.develop-online.net"&gt;magazines&lt;/a&gt;.&lt;br /&gt;E.g. &lt;a href="http://www.igda.org"&gt;IDGA&lt;/a&gt; / &lt;a href="http://www.tiga.org"&gt;TIGA&lt;/a&gt;.  Attend conferences and network with professionals.&lt;br /&gt;Consider moving closer to games studios / games related companies.&lt;br /&gt;&lt;a href="http://www.amazon.com/Game-Engine-Architecture-Jason-Gregory/dp/1568814135/ref=sr_1_1?s=books&amp;ie=UTF8&amp;qid=1319883055&amp;sr=1-1"&gt;Game Engine Architecture&lt;/a&gt;, &lt;a href="http://www.amazon.com/Game-Programming-Gems-Adam-Lake/dp/1584507020/ref=sr_1_2?s=books&amp;ie=UTF8&amp;qid=1319883142&amp;sr=1-2"&gt;Game Programming Gems&lt;/a&gt;, &lt;a href="http://www.amazon.com/Effective-Specific-Improve-Programs-Designs/dp/0321334876/ref=sr_1_1?s=books&amp;ie=UTF8&amp;qid=1319883091&amp;sr=1-1"&gt;Effective C++&lt;/a&gt;, &lt;a href="http://www.amazon.com/Scripting-Mastery-Premier-Press-Development/dp/1931841578/ref=sr_1_1?ie=UTF8&amp;qid=1319886010&amp;sr=8-1"&gt;Game Scripting Mastery&lt;/a&gt;, &lt;a href="http://www.amazon.com/Primer-Graphics-Development-Wordware-Library/dp/1556229119/ref=sr_1_1?s=books&amp;ie=UTF8&amp;qid=1319882892&amp;sr=1-1"&gt;3D Math for Graphics / Game Development&lt;/a&gt;.&lt;br /&gt;
&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&lt;br /&gt;In conclusion, the video games industry seems poised for a bright future.  New education policy, company grants and improved Research &amp; Development tax breaks are significant for continued industry growth.&lt;br /&gt;&lt;br /&gt;
Therefore, if breaking into the games industry appeals to you then just do it.  Go.  Make Games.&lt;br /&gt;And, of course, the best of luck to you &lt;span style='font-family:Wingdings'&gt;J&lt;/span&gt;&lt;/span&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/8584570627780730363-8303988160082309925?l=steveproxna.blogspot.com' alt='' /&gt;&lt;/div&gt;
&lt;p&gt;&lt;a href="http://feedads.g.doubleclick.net/~a/CFn0thd4lk72N9K2f60YXL231uA/0/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/CFn0thd4lk72N9K2f60YXL231uA/0/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;br/&gt;
&lt;a href="http://feedads.g.doubleclick.net/~a/CFn0thd4lk72N9K2f60YXL231uA/1/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/CFn0thd4lk72N9K2f60YXL231uA/1/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;/p&gt;&lt;img src="http://feeds.feedburner.com/~r/SteveProXNA/~4/43raMhXCw9A" height="1" width="1"/&gt;</description><link>http://feedproxy.google.com/~r/SteveProXNA/~3/43raMhXCw9A/xna-and-breaking-into-games-industry.html</link><author>noreply@blogger.com (SteveProXNA)</author><thr:total>0</thr:total><feedburner:origLink>http://steveproxna.blogspot.com/2011/09/xna-and-breaking-into-games-industry.html</feedburner:origLink></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-8584570627780730363.post-8926972797408977819</guid><pubDate>Fri, 01 Apr 2011 07:10:00 +0000</pubDate><atom:updated>2012-01-01T05:46:40.659-08:00</atom:updated><category domain="http://www.blogger.com/atom/ns#">Agile</category><title>XNA and Test Driven Development</title><description>&lt;span style="font-family:verdana;font-size:85%;"&gt;In the previous &lt;a href="http://steveproxna.blogspot.com/2011/03/xna-and-unit-testing.html"&gt;post&lt;/a&gt;, we discussed the topic of XNA and Unit Testing.&lt;br /&gt;Now, let's discuss the topic of Test Driven Development with &lt;a href="http://en.wikipedia.org/wiki/XNA_(Microsoft)"&gt;XNA&lt;/a&gt;.&lt;br /&gt;&lt;br /&gt;Note: this post includes complete code sample on &lt;a href="http://steveproxna03ut.codeplex.com"&gt;CodePlex&lt;/a&gt;.&lt;br /&gt;Download code sample &lt;b&gt;&lt;a href="http://steveproxna03ut.codeplex.com/SourceControl/list/changesets"&gt;here&lt;/a&gt;&lt;/b&gt;.&lt;br /&gt;&lt;br /&gt;&lt;u&gt;Test Driven Development (TDD)&lt;/u&gt;&lt;br /&gt;&lt;a href="http://en.wikipedia.org/wiki/Test-driven_development"&gt;Test driven development&lt;/a&gt; (TDD) is similar to &lt;a href="http://en.wikipedia.org/wiki/Unit_testing"&gt;unit testing&lt;/a&gt; except the unit tests are written &lt;i&gt;before&lt;/i&gt; the objects they test.  TDD is gaining as a development best practice because objects are designed with testability in mind: an object and its dependencies must be loosely coupled from the outset.&lt;br /&gt;&lt;br /&gt;TDD practitioners follow these three &lt;a href="http://www2.imm.dtu.dk/pubdb/views/edoc_download.php/5571/pdf/imm5571.pdf"&gt;laws&lt;/a&gt;:&lt;br /&gt;&lt;table width="100%"&gt;&lt;tr&gt;&lt;td valign="top"&gt;First Law:&lt;br /&gt;Second Law:&lt;br /&gt;Third Law:&lt;br /&gt;&lt;/td&gt;&lt;td valign="top"&gt;You may not write production code unless you&amp;#8217;ve first written a failing unit test&lt;br /&gt;You may not write more of a unit test than is sufficient to fail&lt;br /&gt;You may not write more production code than is sufficient to make the failing unit test pass&lt;br /&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&lt;br /&gt;Instead of designing a module, coding then testing, you turn the process around and do the &lt;a href="http://www.codeproject.com/KB/dotnet/tdd_in_dotnet.aspx"&gt;testing&lt;/a&gt; first.&lt;br /&gt;To put it another way, you don't write a single line of production code until you have a test that fails.&lt;br /&gt;&lt;br /&gt;
The typical programming sequence is something like this:&lt;br /&gt;
&amp;nbsp;1. Write a test.&lt;br /&gt; &amp;nbsp;2. Run the test. It fails to compile because the code you're trying to test doesn't even exist yet!&lt;br &gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;i&gt;This is the same thing as failing.&lt;/i&gt;&lt;br /&gt;&amp;nbsp;3. Write a bare-bones stub to make the test compile.&lt;br /&gt; &amp;nbsp;4. Run the test. It should fail.&amp;nbsp;&amp;nbsp;&lt;i&gt;If it doesn't, then the test wasn't very good.&lt;/i&gt;&lt;br /&gt;&amp;nbsp;5. Implement the code to make the test pass.&lt;br /&gt; &amp;nbsp;6. Run the test. It should pass.&amp;nbsp;&amp;nbsp;&lt;i&gt;If it doesn't, back up one step and try again.&lt;/i&gt;&lt;br /&gt;&amp;nbsp;7. Start over with a new test!&lt;br /&gt;&lt;br /&gt;&lt;u&gt;Example&lt;/u&gt;&lt;br /&gt;As an example, let's revise the &lt;a href="http://msdn.microsoft.com/en-us/library/bb203896(v=XNAGameStudio.31).aspx"&gt;Going Beyond&lt;/a&gt; tutorial to demonstrate XNA and Test Driven Development.&lt;br /&gt;&lt;br /&gt;&lt;u&gt;Sample&lt;/u&gt;&lt;br /&gt;The following code sample refactors the tutorial to move a 3D model using input from the controller.
&lt;br /&gt;In order to test the model's rotate and move methods in isolation, the external dependency on the controller must be broken.&lt;br /&gt;&lt;br /&gt;&lt;a href="http://steveproxna02ioc.codeplex.com/SourceControl/list/changesets"&gt;Download&lt;/a&gt; the code sample from XNA and IoC Container &lt;a href="http://steveproxna.blogspot.com/2011/03/xna-and-ioc-container.html"&gt;post&lt;/a&gt;; Unit Tests will be added to this code.&lt;br /&gt;However, this time the unit tests will be written &lt;i&gt;before&lt;/i&gt; the objects they test.&lt;br /&gt;&lt;br /&gt;First, identify the &lt;a href="http://en.wikipedia.org/wiki/System_under_test"&gt;System Under Test&lt;/a&gt;: the component that will drive the unit tests: Game Object Manager&lt;br /&gt;The Game Object Manager is responsible for managing all objects in the game: currently 1x spaceship.
&lt;br /&gt;&lt;br /&gt;Therefore, all unit tests will involve the interaction between the SpaceShip and input from the controller:&lt;br /&gt;&lt;table width="100%"&gt;&lt;tr&gt;
&lt;td valign="top"&gt;&lt;u&gt;Action&lt;/u&gt;&lt;br /&gt;Rotate Left&lt;br /&gt;Rotate Right&lt;br /&gt;Move Forward&lt;br /&gt;Warp Center&lt;br /&gt;&lt;/td&gt;&lt;td valign="top"&gt;&lt;u&gt;Windows PC&lt;/u&gt;&lt;br /&gt;Press left key&lt;br /&gt;Press right key &lt;br /&gt;Press space key&lt;br /&gt;Press enter key&lt;br /&gt;&lt;/td&gt;
&lt;td valign="top"&gt;&lt;u&gt;Windows Phone 7&lt;/u&gt;&lt;br /&gt;Tap screen bottom left&lt;br /&gt;Tap screen bottom  right&lt;br /&gt;Tap screen top right&lt;br /&gt;Tap screen top left&lt;br /&gt;&lt;/td&gt;
&lt;td valign="top"&gt;&lt;u&gt;Xbox 360&lt;/u&gt;&lt;br /&gt;Move controller left&lt;br /&gt;Move controller right&lt;br /&gt;Press right trigger&lt;br /&gt;Press A button&lt;br /&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&lt;br /&gt;
&lt;u&gt;Unit Tests&lt;/u&gt;&lt;br /&gt;Write the unit tests, one for each action: Rotate Left, Rotate Right, Move Forward and Warp Center.&lt;br /&gt;&lt;br /&gt;First, add New Windows Game Library project to the solution; this project will contain the unit tests.&lt;br /&gt;
Next, add references to the following managed libraries: &lt;a href="http://www.nunit.org"&gt;NUnit&lt;/a&gt; Framework and &lt;a href="http://www.ayende.com/projects/rhino-mocks.aspx"&gt;Rhino Mocks&lt;/a&gt;.&lt;br /&gt;&lt;br /&gt;Next, add one test fixture for the system under test: Game Object Manager&lt;br /&gt;Note: external dependencies are broken and replaced by &lt;a href="http://en.wikipedia.org/wiki/Mock_object"&gt;mock objects&lt;/a&gt;:&lt;br /&gt;
&lt;pre class="csharp" name="code"&gt;
[TestFixture]
public class GameObjectManagerTests
{
 // System under test.
 private IGameObjectManager gameObjectManager;

 private ICameraManager cameraManager;
 private IContentManager contentManager;
 private IInputManager inputManager;
 private SpaceShip spaceShip;
 private readonly GameTime gameTime = new GameTime();

 [SetUp]
 public void SetUp()
 {
  cameraManager = MockRepository.GenerateStub&amp;lt;ICameraManager&amp;gt;();
  contentManager = MockRepository.GenerateStub&amp;lt;IContentManager&amp;gt;();
  inputManager = MockRepository.GenerateStub&amp;lt;IInputManager&amp;gt;();
  spaceShip = new SpaceShip();

  gameObjectManager = new GameObjectManager(
   cameraManager,
   contentManager,
   inputManager,
   spaceShip);
 }
}
&lt;/pre&gt;
Test #1: &lt;b&gt;Warp Center&lt;/b&gt;&lt;br /&gt;&lt;table width="100%"&gt;&lt;tr&gt;&lt;td valign="top"&gt;&lt;ul&gt;&lt;li&gt;Simulate input from the controller to return the Warp Center action&lt;/li&gt;
&lt;li&gt;Update the Game Object Manager which updates the SpaceShip&lt;/li&gt;&lt;li&gt;Assert the position of the SpaceShip updates correctly&lt;/li&gt;&lt;/ul&gt;&amp;nbsp;1. Write a test.
&lt;pre class="csharp" name="code"&gt;
[Test]
public void Warp()
{
 // Arrange.
 Vector3 modelPostion = new Vector3(10, 20, 30);
 spaceShip = new SpaceShip(modelPostion);

 gameObjectManager = new GameObjectManager(
  cameraManager,
  contentManager,
  inputManager,
  spaceShip);

 inputManager.Stub(im =&gt; im.Warp()).Return(true);

 // Act.
 gameObjectManager.Update(gameTime);

 // Assert.
 Assert.AreEqual(Vector3.Zero, gameObjectManager.SpaceShip.ModelPosition);
}
&lt;/pre&gt;
&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&amp;nbsp;2. Run the test. It fails to compile because the code you're trying to test doesn't even exist yet!&lt;br /&gt;
&amp;nbsp;3. Write a bare-bones stub to make the test compile.&lt;br /&gt;&lt;br /&gt;
SPACE SHIP
&lt;pre class="csharp" name="code"&gt;
public class SpaceShip
{
 private Model spaceShipModel;
 private Matrix[] transforms;

 public SpaceShip() : this(Vector3.Zero)
 {
 }

 public SpaceShip(Vector3 modelPosition)
 {
  ModelRotation = 0.0f;
  ModelPosition = modelPosition;
  ModelVelocity = Vector3.Zero;
 }

 // Same code as previous post.
}
&lt;/pre&gt;
INPUT MANAGER
&lt;pre class="csharp" name="code"&gt;
public class InputManager : IInputManager
{
 // InputManager has dependency on InputFactory.
 private readonly AInputFactory inputFactory;

 public InputManager(AInputFactory inputFactory)
 {
  this.inputFactory = inputFactory;
 }

 public Boolean Warp() { return inputFactory.Warp(); }
}
&lt;/pre&gt;
INPUT FACTORY
&lt;pre class="csharp" name="code"&gt;
public abstract class AInputFactory
{
 public abstract Boolean Warp();
}

public class PhoneInputFactory : AInputFactory
{
 public override Boolean Warp() { // Logic goes here. }
}

public class WorkInputFactory : AInputFactory
{
 public override Boolean Warp() { // Logic goes here. }
}

public class XboxInputFactory : AInputFactory
{
 public override Boolean Warp() { // Logic goes here. }
}
&lt;/pre&gt;
GAME OBJECT MANAGER
&lt;pre class="csharp" name="code"&gt;
public class GameObjectManager : IGameObjectManager
{
 // GameObjectManager has dependency on CameraManager, ContentManager, InputManager and SpaceShip.
 private readonly ICameraManager cameraManager;
 private readonly IContentManager contentManager;
 private readonly IInputManager inputManager;
 private readonly SpaceShip spaceShip;

 public GameObjectManager(ICameraManager cameraManager, IContentManager contentManager, IInputManager inputManager, SpaceShip spaceShip)
 {
  this.cameraManager = cameraManager;
  this.contentManager = contentManager;
  this.inputManager = inputManager;
  this.spaceShip = spaceShip;
 }

 // Same code as previous post.

 public SpaceShip SpaceShip { get { return spaceShip; } }
}
&lt;/pre&gt;
&amp;nbsp;4. Run the test. It should fail.&lt;br /&gt;
&amp;nbsp;5. Implement the code to make the test pass.&lt;br /&gt;&lt;br /&gt;
GAME OBJECT MANAGER
&lt;pre class="csharp" name="code"&gt;
public class GameObjectManager : IGameObjectManager
{
 // Same code as previous post.

 // Update each game object.
 public void Update(GameTime gameTime)
 {
  Boolean warp = inputManager.Warp();
  spaceShip.Update(warp);
 }
}
&lt;/pre&gt;
SPACE SHIP
&lt;pre class="csharp" name="code"&gt;
public class SpaceShip
{
 // Same code as previous post.

 // Update warp if action is invoked.
 public void Update(Boolean warp)
 {
  // Warp.
  if (warp)
  {
   ModelPosition = Vector3.Zero;
   ModelVelocity = Vector3.Zero;
   ModelRotation = 0.0f;
  }
 }
}
&lt;/pre&gt;
&amp;nbsp;6. Run the test. It should pass.&lt;br /&gt;&amp;nbsp;7. Start over with a new test!
&lt;br /&gt;&lt;br /&gt;Test #2: &lt;b&gt;Rotate Left&lt;/b&gt;&lt;br /&gt;&lt;table width="100%"&gt;&lt;tr&gt;&lt;td valign="top"&gt;&lt;ul&gt;&lt;li&gt;Simulate input from the controller to return the Rotate Left action&lt;/li&gt;&lt;li&gt;Update the Game Object Manager which updates the SpaceShip&lt;/li&gt;
&lt;li&gt;Assert the rotation of the SpaceShip updates correctly&lt;/li&gt;&lt;/ul&gt;&amp;nbsp;1. Write a test.
&lt;pre class="csharp" name="code"&gt;
[Test]
public void Left()
{
 // Arrange.
 inputManager.Stub(im =&gt; im.Rotate()).Return(-1);

 // Act.
 gameObjectManager.Update(gameTime);

 // Assert.
 Assert.AreEqual(0.1f, gameObjectManager.SpaceShip.ModelRotation);
}
&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&amp;nbsp;2. Run the test. It fails to compile because the code you're trying to test doesn't even exist yet!&lt;br /&gt;&amp;nbsp;3. Write a bare-bones stub to make the test compile.&lt;br /&gt;&lt;br /&gt;
INPUT MANAGER
&lt;pre class="csharp" name="code"&gt;
public class InputManager : IInputManager
{
 // InputManager has dependency on InputFactory.
 private readonly AInputFactory inputFactory;

 public InputManager(AInputFactory inputFactory)
 {
  this.inputFactory = inputFactory;
 }

 public Single Rotate() { return inputFactory.Rotate(); }
 public Boolean Warp() { return inputFactory.Warp(); }
}
&lt;/pre&gt;
INPUT FACTORY
&lt;pre class="csharp" name="code"&gt;
public abstract class AInputFactory
{
 public abstract Single Rotate();
 public abstract Boolean Warp();
}

public class PhoneInputFactory : AInputFactory
{
 public override Single Rotate() { // Logic goes here. }
 public override Boolean Warp() { // Logic goes here. }
}

public class WorkInputFactory : AInputFactory
{
 public override Single Rotate() { // Logic goes here. }
 public override Boolean Warp() { // Logic goes here. }
}

public class XboxInputFactory : AInputFactory
{
 public override Single Rotate() { // Logic goes here. }
 public override Boolean Warp() { // Logic goes here. }
}
&lt;/pre&gt;
&amp;nbsp;4. Run the test. It should fail.&lt;br /&gt;&amp;nbsp;5. Implement the code to make the test pass.&lt;br /&gt;&lt;br /&gt;
GAME OBJECT MANAGER
&lt;pre class="csharp" name="code"&gt;
public class GameObjectManager : IGameObjectManager
{
 // Same code as previous post.

 // Update each game object.
 public void Update(GameTime gameTime)
 {
  Single rotate = inputManager.Rotate();
  Boolean warp = inputManager.Warp();

  spaceShip.Update(rotate, warp);
 }
}
&lt;/pre&gt;
SPACE SHIP
&lt;pre class="csharp" name="code"&gt;
public class SpaceShip
{
 // Same code as previous post.

 // Update rotate and warp if actions are invoked.
 public void Update(Single rotate, Boolean warp)
 {
  // Rotate.
  if (rotate != 0)
  {
   const Single scale = 0.10f;
   ModelRotation -= rotate * scale;
  }

  // Warp.
  if (warp)
  {
   ModelPosition = Vector3.Zero;
   ModelVelocity = Vector3.Zero;
   ModelRotation = 0.0f;
  }
 }
}
&lt;/pre&gt;&amp;nbsp;6. Run the test. It should pass.&lt;br /&gt;&amp;nbsp;7. Start over with a new test!&lt;br /&gt;&lt;br /&gt;Test #3: &lt;b&gt;Rotate Right&lt;/b&gt;&lt;br /&gt;&lt;table width="100%"&gt;&lt;tr&gt;
&lt;td valign="top"&gt;&lt;ul&gt;&lt;li&gt;Simulate input from the controller to return the Rotate Right action&lt;/li&gt;&lt;li&gt;Update the Game Object Manager which updates the SpaceShip&lt;/li&gt;
&lt;li&gt;Assert the rotation of the SpaceShip updates correctly&lt;/li&gt;&lt;/ul&gt;&amp;nbsp;1. Write a test.
&lt;pre class="csharp" name="code"&gt;
[Test]
public void Right()
{
 // Arrange.
 inputManager.Stub(im =&gt; im.Rotate()).Return(1);

 // Act.
 gameObjectManager.Update(gameTime);

 // Assert.
 Assert.AreEqual(-0.1f, gameObjectManager.SpaceShip.ModelRotation);
}
&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&amp;nbsp;2. Run the test. It fails to compile because the code you're trying to test doesn't even exist yet!&lt;br /&gt;&amp;nbsp;3. Write a bare-bones stub to make the test compile.&lt;br /&gt; &amp;nbsp;4. Run the test. It should fail.&lt;br /&gt;&amp;nbsp;5. Implement the code to make the test pass.&lt;br /&gt; &amp;nbsp;6. Run the test. It should pass.&lt;br /&gt;&amp;nbsp;7. Start over with a new test!&lt;br /&gt;&lt;br /&gt;Test #4: &lt;b&gt;Move Forward&lt;/b&gt;&lt;br /&gt;&lt;table width="100%"&gt;&lt;tr&gt;&lt;td valign="top"&gt;&lt;ul&gt;&lt;li&gt;Simulate input from the controller to return the Move Forward action&lt;/li&gt;&lt;li&gt;Update the Game Object Manager which updates the SpaceShip&lt;/li&gt;&lt;li&gt;Assert the position of the SpaceShip updates correctly&lt;/li&gt;&lt;/ul&gt;&amp;nbsp;1. Write a test.
&lt;pre class="csharp" name="code"&gt;
[Test]
public void Move()
{
 // Arrange.
 inputManager.Stub(im =&gt; im.Move()).Return(1);

 // Act.
 gameObjectManager.Update(gameTime);

 // Assert.
 Assert.AreEqual(-1.0f, gameObjectManager.SpaceShip.ModelPosition.Z);
}
&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&amp;nbsp;2. Run the test. It fails to compile because the code you're trying to test doesn't even exist yet!&lt;br /&gt;&amp;nbsp;3. Write a bare-bones stub to make the test compile.&lt;br /&gt;&lt;br /&gt;
INPUT MANAGER
&lt;pre class="csharp" name="code"&gt;
public class InputManager : IInputManager
{
 // InputManager has dependency on InputFactory.
 private readonly AInputFactory inputFactory;

 public InputManager(AInputFactory inputFactory)
 {
  this.inputFactory = inputFactory;
 }

 public Single Rotate() { return inputFactory.Rotate(); }
 public Single Move() { return inputFactory.Move(); }
 public Boolean Warp() { return inputFactory.Warp(); }
}
&lt;/pre&gt;
INPUT FACTORY
&lt;pre class="csharp" name="code"&gt;
public abstract class AInputFactory
{
 public abstract Single Rotate();
 public abstract Single Move();
 public abstract Boolean Warp();
}

public class PhoneInputFactory : AInputFactory
{
 public override Single Rotate() { // Logic goes here. }
 public override Single Move() { // Logic goes here. }
 public override Boolean Warp() { // Logic goes here. }
}

public class WorkInputFactory : AInputFactory
{
 public override Single Rotate() { // Logic goes here. }
 public override Single Move() { // Logic goes here. }
 public override Boolean Warp() { // Logic goes here. }
}

public class XboxInputFactory : AInputFactory
{
 public override Single Rotate() { // Logic goes here. }
 public override Single Move() { // Logic goes here. }
 public override Boolean Warp() { // Logic goes here. }
}
&lt;/pre&gt;&amp;nbsp;4. Run the test. It should fail.&lt;br /&gt;&amp;nbsp;5. Implement the code to make the test pass.&lt;br /&gt;&lt;br /&gt;
GAME OBJECT MANAGER
&lt;pre class="csharp" name="code"&gt;
public class GameObjectManager : IGameObjectManager
{
 // Same code as previous post.

 // Update each game object.
 public void Update(GameTime gameTime)
 {
  Single rotate = inputManager.Rotate();
  Single move = inputManager.Move();
  Boolean warp = inputManager.Warp();

  spaceShip.Update(rotate, move, warp);
 }
}
&lt;/pre&gt;
SPACE SHIP
&lt;pre class="csharp" name="code"&gt;
public class SpaceShip
{
 // Same code as previous post.

 // Update rotate, move and warp if actions are invoked.
 public void Update(Single rotate, Single move, Boolean warp)
 {
  // Rotate.
  if (rotate != 0)
  {
   const Single scale = 0.10f;
   ModelRotation -= rotate * scale;
  }

  // Move.
  if (move != 0)
  {
   // Create some velocity if move action invoked.
   Vector3 modelVelocityAdd = Vector3.Zero;

   // Find out thrust direction using rotation.
   Single sin = -(Single)Math.Sin(ModelRotation);
   Single cos = -(Single)Math.Cos(ModelRotation);

   modelVelocityAdd.X = sin;
   modelVelocityAdd.Z = cos;

   // Scale direction by the amount of movement.
   modelVelocityAdd *= move;

   // Finally, add this vector to our velocity.
   ModelVelocity += modelVelocityAdd;
  }

  // Warp.
  if (warp)
  {
   ModelPosition = Vector3.Zero;
   ModelVelocity = Vector3.Zero;
   ModelRotation = 0.0f;
  }

  // Add velocity to position and bleed off velocity over time.
  ModelPosition += ModelVelocity;
  ModelVelocity *= 0.97f;
 }
}
&lt;/pre&gt;&amp;nbsp;6. Run the test. It should pass.&lt;br /&gt;&amp;nbsp;7. All tests complete!&lt;br /&gt;&lt;br /&gt;Download code sample &lt;b&gt;&lt;a href="http://steveproxna03ut.codeplex.com/SourceControl/list/changesets"&gt;here&lt;/a&gt;&lt;/b&gt;.&lt;br /&gt;&lt;br /&gt;&lt;u&gt;Summary&lt;/u&gt;&lt;br /&gt;
The revised &lt;a href="http://msdn.microsoft.com/en-us/library/bb203896(v=XNAGameStudio.31).aspx"&gt;Going Beyond&lt;/a&gt; tutorial demonstrates how to integrate Unit Tests into an existing code &lt;a href="http://steveproxna02ioc.codeplex.com/SourceControl/list/changesets"&gt;base&lt;/a&gt;.
&lt;br /&gt;However, writing the unit tests &lt;i&gt;before&lt;/i&gt; the code helps drive development of the systems under test.&lt;br /&gt;&lt;br /&gt;In conclusion, agile software development does seem to have the potential to scale using XNA:&lt;br /&gt;&lt;table width="100%"&gt;&lt;tr&gt;&lt;td valign="top"&gt;&lt;ul&gt;&lt;li&gt;&lt;a href="http://steveproxna.blogspot.com/2011/02/xna-and-dependency-injection.html"&gt;XNA and Dependency Injection&lt;/a&gt;&lt;/li&gt;&lt;li&gt;&lt;a href="http://steveproxna.blogspot.com/2011/03/xna-and-ioc-container.html"&gt;XNA and an IoC Container&lt;/a&gt;&lt;/li&gt;&lt;li&gt;&lt;a href="http://steveproxna.blogspot.com/2011/03/xna-and-unit-testing.html"&gt;XNA and Unit Testing&lt;/a&gt;&lt;/li&gt;&lt;li&gt;&lt;a href="http://steveproxna.blogspot.com/2011/04/xna-and-test-driven-development.html"&gt;XNA and Test Driven Development&lt;/a&gt;&lt;/li&gt;&lt;/ul&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;
However, in it's current form, dependency injection may be susceptible to circular references:&lt;br /&gt;&lt;table width="100%"&gt;&lt;tr&gt;&lt;td valign="top"&gt;&lt;ul&gt;&lt;li&gt;ComponentA depends on ComponentB&lt;/li&gt;&lt;li&gt;ComponentB depends on ComponentA&lt;/li&gt;&lt;/ul&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;
A better implementation may be to construct a base class component that all subsystems inherit from;&lt;br /&gt;Extract the GameManager into the base to manage interaction between all subsystems in the game:
&lt;pre class="csharp" name="code"&gt;
public abstract class BaseComponent
{
 public GameManager GameManager
 {
  get { return gameManager; }
  set { if (null == gameManager) { gameManager = value;  }}
 }

 private GameManager gameManager;
}

public class ComponentA : BaseComponent
{
 public ComponentA()
 {
  PropertyA = "Hello";
 }
 public void Print()
 {
  PropertyA = GameManager.ComponentB.PropertyB;
 }

 public String PropertyA { get; private set; }
}

public class ComponentB : BaseComponent
{
 public ComponentB()
 {
  PropertyB = "World";
 }
 public void Print()
 {
  PropertyB = GameManager.ComponentA.PropertyA;
 }

 public String PropertyB { get; private set; }
}

public class GameManager
{
 public GameManager(ComponentA componentA, ComponentB componentB)
 {
  ComponentA = componentA;
  ComponentB = componentB;
 }

 public ComponentA ComponentA { get; private set; }
 public ComponentB ComponentB { get; private set; }
}
&lt;/pre&gt;
Once issues such as circular references have been resolved, then there is an opportunity to integrate more complex game code using XNA and agile software development techniques.
&lt;/span&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/8584570627780730363-8926972797408977819?l=steveproxna.blogspot.com' alt='' /&gt;&lt;/div&gt;
&lt;p&gt;&lt;a href="http://feedads.g.doubleclick.net/~a/4_dValWJJ45noaYfoCw2fdK4q2s/0/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/4_dValWJJ45noaYfoCw2fdK4q2s/0/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;br/&gt;
&lt;a href="http://feedads.g.doubleclick.net/~a/4_dValWJJ45noaYfoCw2fdK4q2s/1/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/4_dValWJJ45noaYfoCw2fdK4q2s/1/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;/p&gt;&lt;img src="http://feeds.feedburner.com/~r/SteveProXNA/~4/rBLfJPwUl8Y" height="1" width="1"/&gt;</description><link>http://feedproxy.google.com/~r/SteveProXNA/~3/rBLfJPwUl8Y/xna-and-test-driven-development.html</link><author>noreply@blogger.com (SteveProXNA)</author><thr:total>0</thr:total><feedburner:origLink>http://steveproxna.blogspot.com/2011/04/xna-and-test-driven-development.html</feedburner:origLink></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-8584570627780730363.post-1017048091035306639</guid><pubDate>Thu, 17 Mar 2011 09:17:00 +0000</pubDate><atom:updated>2012-01-01T05:45:38.354-08:00</atom:updated><category domain="http://www.blogger.com/atom/ns#">Agile</category><title>XNA and Unit Testing</title><description>&lt;span style="font-family:verdana;font-size:85%;"&gt;In the previous &lt;a href="http://steveproxna.blogspot.com/2011/03/xna-and-ioc-container.html"&gt;post&lt;/a&gt;, we discussed the topic of XNA and an IoC Container.&lt;br /&gt;Now, let's build on this information to discuss Unit Testing with &lt;a href="http://en.wikipedia.org/wiki/XNA_(Microsoft)"&gt;XNA&lt;/a&gt;.&lt;br /&gt;&lt;br /&gt;Note: this post includes complete code sample on &lt;a href="http://steveproxna03ut.codeplex.com"&gt;CodePlex&lt;/a&gt;.&lt;br /&gt;Download code sample &lt;b&gt;&lt;a href="http://steveproxna03ut.codeplex.com/SourceControl/list/changesets"&gt;here&lt;/a&gt;&lt;/b&gt;.&lt;br /&gt;&lt;br /&gt;&lt;u&gt;Unit Testing&lt;/u&gt;&lt;br /&gt;&lt;a href="http://en.wikipedia.org/wiki/Unit_testing"&gt;Unit testing&lt;/a&gt; is the practice in which individual units of source code are tested in isolation.  Consequently, unit tests do not measure how objects interact with dependent objects; these are integration &lt;a href="http://en.wikipedia.org/wiki/Integration_testing"&gt;tests&lt;/a&gt;.&lt;br /&gt;&lt;br /&gt;In order to successfully unit test an individual game component, external dependencies are broken, and replaced by &lt;a href="http://en.wikipedia.org/wiki/Mock_object"&gt;mock objects&lt;/a&gt;: fake objects that emulate real classes and help test expectations about how that class should function.&lt;br /&gt;&lt;br /&gt;Therefore, clean unit tests should be written &lt;a href="http://java.dzone.com/articles/why-you-should-read-clean-code"&gt;F.I.R.S.T&lt;/a&gt;:&lt;br /&gt;&lt;table width="100%"&gt;&lt;tr&gt;&lt;td valign="top"&gt;Fast&lt;br /&gt;Independent&lt;br /&gt;Repeatable&lt;br /&gt;Self-validating&lt;br /&gt;Timely&lt;br /&gt;&lt;/td&gt;&lt;td valign="top"&gt;Tests should be fast&lt;br /&gt;Tests should not depend on each other&lt;br /&gt;Tests should be repeatable in any environment&lt;br /&gt;Tests should have a Boolean output: either they pass or fail&lt;br /&gt;
Tests should be written in a timely fashion&lt;br /&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&lt;br /&gt;&lt;u&gt;Example&lt;/u&gt;&lt;br /&gt;As an example, let's revise the &lt;a href="http://msdn.microsoft.com/en-us/library/bb203896(v=XNAGameStudio.31).aspx"&gt;Going Beyond&lt;/a&gt; tutorial to demonstrate XNA and Unit Testing.&lt;br /&gt;&lt;br /&gt;&lt;u&gt;Sample&lt;/u&gt;&lt;br /&gt;The following code sample refactors the tutorial to move a 3D model using input from the controller.&lt;br /&gt;In order to test the model's rotate and move methods in isolation, the external dependency on the controller must be broken.&lt;br /&gt;&lt;br /&gt;&lt;a href="http://steveproxna02ioc.codeplex.com/SourceControl/list/changesets"&gt;Download&lt;/a&gt; the code sample from XNA and IoC Container &lt;a href="http://steveproxna.blogspot.com/2011/03/xna-and-ioc-container.html"&gt;post&lt;/a&gt;; Unit Tests will be added to this code.&lt;br /&gt;
Write all code changes first then add unit tests afterwards to assert the correct behavior.&lt;br /&gt;&lt;br /&gt;First, identify the &lt;a href="http://en.wikipedia.org/wiki/System_under_test"&gt;System Under Test&lt;/a&gt;: the component that will drive the unit tests: Game Object Manager&lt;br /&gt;The Game Object Manager is responsible for managing all objects in the game: currently 1x spaceship.
&lt;br /&gt;&lt;br /&gt;Therefore, all unit tests will involve the interaction between the SpaceShip and input from the controller:&lt;br /&gt;&lt;table width="100%"&gt;&lt;tr&gt;
&lt;td valign="top"&gt;&lt;u&gt;Action&lt;/u&gt;&lt;br /&gt;Rotate Left&lt;br /&gt;Rotate Right&lt;br /&gt;Move Forward&lt;br /&gt;Warp Center&lt;br /&gt;&lt;/td&gt;&lt;td valign="top"&gt;&lt;u&gt;Windows PC&lt;/u&gt;&lt;br /&gt;Press left key&lt;br /&gt;Press right key &lt;br /&gt;Press space key&lt;br /&gt;Press enter key&lt;br /&gt;&lt;/td&gt;
&lt;td valign="top"&gt;&lt;u&gt;Windows Phone 7&lt;/u&gt;&lt;br /&gt;Tap screen bottom left&lt;br /&gt;Tap screen bottom  right&lt;br /&gt;Tap screen top right&lt;br /&gt;Tap screen top left&lt;br /&gt;&lt;/td&gt;
&lt;td valign="top"&gt;&lt;u&gt;Xbox 360&lt;/u&gt;&lt;br /&gt;Move controller left&lt;br /&gt;Move controller right&lt;br /&gt;Press right trigger&lt;br /&gt;Press A button&lt;br /&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&lt;br /&gt;All logic to load, update and draw the model can be encapsulated into a single game object:&lt;br /&gt;SPACE SHIP 
&lt;pre class="csharp" name="code"&gt;
public class SpaceShip
{
 private Model spaceShipModel;
 private Matrix[] transforms;

 public SpaceShip() : this(Vector3.Zero)
 {
 }

 public SpaceShip(Vector3 modelPosition)
 {
  ModelRotation = 0.0f;
  ModelPosition = modelPosition;
  ModelVelocity = Vector3.Zero;
 }

 // Load model and set view/projection matrices.
 public void LoadContent(Model theSpaceShipModel, Matrix viewMatrix, Matrix projectionMatrix)
 {
  // Same code as previous post.
 }

 // Update rotate, move and warp if actions are invoked.
 public void Update(Single rotate, Single move, Boolean warp)
 {
  // Rotate.
  if (rotate != 0)
  {
   const Single scale = 0.10f;
   ModelRotation -= rotate * scale;
  }

  // Move.
  if (move != 0)
  {
   // Create some velocity if move action invoked.
   Vector3 modelVelocityAdd = Vector3.Zero;

   // Find out thrust direction using rotation.
   Single sin = -(Single)Math.Sin(ModelRotation);
   Single cos = -(Single)Math.Cos(ModelRotation);

   modelVelocityAdd.X = sin;
   modelVelocityAdd.Z = cos;

   // Scale direction by the amount of movement.
   modelVelocityAdd *= move;

   // Finally, add this vector to our velocity.
   ModelVelocity += modelVelocityAdd;
  }

  // Warp.
  if (warp)
  {
   ModelPosition = Vector3.Zero;
   ModelVelocity = Vector3.Zero;
   ModelRotation = 0.0f;
  }

  // Add velocity to position and bleed off velocity over time.
  ModelPosition += ModelVelocity;
  ModelVelocity *= 0.97f;
 }

 // Draw model.
 public void Draw()
 {
  // Same code as previous post.
 }

 public Single ModelRotation { get; private set; }
 public virtual Vector3 ModelPosition { get; private set; }
 public Vector3 ModelVelocity { get; private set; }
}
&lt;/pre&gt;
Next, update the Game Object Manager: detect input and set the rotate, move and warp values:&lt;br /&gt;
GAME OBJECT MANAGER
&lt;pre class="csharp" name="code"&gt;
public class GameObjectManager : IGameObjectManager
{
 // GameObjectManager has dependency on CameraManager, ContentManager, InputManager and SpaceShip.
 private readonly ICameraManager cameraManager;
 private readonly IContentManager contentManager;
 private readonly IInputManager inputManager;
 private readonly SpaceShip spaceShip;

 public GameObjectManager(ICameraManager cameraManager, IContentManager contentManager, IInputManager inputManager, SpaceShip spaceShip)
 {
  this.cameraManager = cameraManager;
  this.contentManager = contentManager;
  this.inputManager = inputManager;
  this.spaceShip = spaceShip;
 }

 // Load content for each game object.
 public void LoadContent()
 {
  spaceShip.LoadContent(contentManager.SpaceShipModel, cameraManager.ViewMatrix, cameraManager.ProjectionMatrix);
 }

 // Update each game object.
 public void Update(GameTime gameTime)
 {
  Single rotate = inputManager.Rotate();
  Single move = inputManager.Move();
  Boolean warp = inputManager.Warp();

  spaceShip.Update(rotate, move, warp);
 }

 // Draw each game object.
 public void Draw()
 {
  spaceShip.Draw();
 }

 public SpaceShip SpaceShip { get { return spaceShip; } }
}
&lt;/pre&gt;
Finally, input detection: each device will have its own rotate, move and warp implementation:&lt;br /&gt;
INPUT MANAGER
&lt;pre class="csharp" name="code"&gt;
public class InputManager : IInputManager
{
 // InputManager has dependency on InputFactory.
 private readonly AInputFactory inputFactory;

 public InputManager(AInputFactory inputFactory)
 {
  this.inputFactory = inputFactory;
 }

 public Single Rotate() { return inputFactory.Rotate(); }
 public Single Move() { return inputFactory.Move(); }
 public Boolean Warp() { return inputFactory.Warp(); }
}
&lt;/pre&gt;
INPUT FACTORY
&lt;pre class="csharp" name="code"&gt;
public abstract class AInputFactory
{
 public abstract Single Rotate();
 public abstract Single Move();
 public abstract Boolean Warp();
}

public class PhoneInputFactory : AInputFactory
{
 public override Single Rotate() { // Logic goes here. }
 public override Single Move() { // Logic goes here. }
 public override Boolean Warp() { // Logic goes here. }
}

public class WorkInputFactory : AInputFactory
{
 public override Single Rotate() { // Logic goes here. }
 public override Single Move() { // Logic goes here. }
 public override Boolean Warp() { // Logic goes here. }
}

public class XboxInputFactory : AInputFactory
{
 public override Single Rotate() { // Logic goes here. }
 public override Single Move() { // Logic goes here. }
 public override Boolean Warp() { // Logic goes here. }
}
&lt;/pre&gt;
&lt;br /&gt;
&lt;u&gt;Unit Tests&lt;/u&gt;&lt;br /&gt;Write the unit tests, one for each action: Rotate Left, Rotate Right, Move Forward and Warp Center.&lt;br /&gt;&lt;br /&gt;First, add New Windows Game Library project to the solution; this project will contain the unit tests.&lt;br /&gt;Next, add references to the following managed libraries: &lt;a href="http://www.nunit.org"&gt;NUnit&lt;/a&gt; Framework and &lt;a href="http://www.ayende.com/projects/rhino-mocks.aspx"&gt;Rhino Mocks&lt;/a&gt;.&lt;br /&gt;&lt;br /&gt;Next, add one test fixture for the system under test: Game Object Manager&lt;br /&gt;Note: external dependencies are broken and replaced by &lt;a href="http://en.wikipedia.org/wiki/Mock_object"&gt;mock objects&lt;/a&gt;:&lt;br /&gt;
&lt;pre class="csharp" name="code"&gt;
[TestFixture]
public class GameObjectManagerTests
{
 // System under test.
 private IGameObjectManager gameObjectManager;

 private ICameraManager cameraManager;
 private IContentManager contentManager;
 private IInputManager inputManager;
 private SpaceShip spaceShip;
 private readonly GameTime gameTime = new GameTime();

 [SetUp]
 public void SetUp()
 {
  cameraManager = MockRepository.GenerateStub&amp;lt;ICameraManager&amp;gt;();
  contentManager = MockRepository.GenerateStub&amp;lt;IContentManager&amp;gt;();
  inputManager = MockRepository.GenerateStub&amp;lt;IInputManager&amp;gt;();
  spaceShip = new SpaceShip();

  gameObjectManager = new GameObjectManager(
   cameraManager,
   contentManager,
   inputManager,
   spaceShip);
 }
}
&lt;/pre&gt;
Test #1: &lt;b&gt;Rotate Left&lt;/b&gt;&lt;br /&gt;
&lt;table width="100%"&gt;
&lt;tr&gt;
&lt;td valign="top"&gt;
&lt;ul&gt;
&lt;li&gt;Simulate input from the controller to return the Rotate Left action&lt;/li&gt;
&lt;li&gt;Update the Game Object Manager which updates the SpaceShip&lt;/li&gt;
&lt;li&gt;Assert the rotation of the SpaceShip updates correctly&lt;/li&gt;
&lt;/ul&gt;
&lt;pre class="csharp" name="code"&gt;
[Test]
public void Left()
{
 // Arrange.
 inputManager.Stub(im =&gt; im.Rotate()).Return(-1);

 // Act.
 gameObjectManager.Update(gameTime);

 // Assert.
 Assert.AreEqual(0.1f, gameObjectManager.SpaceShip.ModelRotation);
}
&lt;/pre&gt;
&lt;/td&gt;
&lt;/tr&gt;
&lt;/table&gt;
Test #2: &lt;b&gt;Rotate Right&lt;/b&gt;&lt;br /&gt;
&lt;table width="100%"&gt;
&lt;tr&gt;
&lt;td valign="top"&gt;
&lt;ul&gt;
&lt;li&gt;Simulate input from the controller to return the Rotate Right action&lt;/li&gt;
&lt;li&gt;Update the Game Object Manager which updates the SpaceShip&lt;/li&gt;
&lt;li&gt;Assert the rotation of the SpaceShip updates correctly&lt;/li&gt;
&lt;/ul&gt;
&lt;pre class="csharp" name="code"&gt;
[Test]
public void Right()
{
 // Arrange.
 inputManager.Stub(im =&gt; im.Rotate()).Return(1);

 // Act.
 gameObjectManager.Update(gameTime);

 // Assert.
 Assert.AreEqual(-0.1f, gameObjectManager.SpaceShip.ModelRotation);
}
&lt;/pre&gt;
&lt;/td&gt;
&lt;/tr&gt;
&lt;/table&gt;
Test #3: &lt;b&gt;Move Forward&lt;/b&gt;&lt;br /&gt;
&lt;table width="100%"&gt;&lt;tr&gt;
&lt;td valign="top"&gt;
&lt;ul&gt;
&lt;li&gt;Simulate input from the controller to return the Move Forward action&lt;/li&gt;
&lt;li&gt;Update the Game Object Manager which updates the SpaceShip&lt;/li&gt;
&lt;li&gt;Assert the position of the SpaceShip updates correctly&lt;/li&gt;
&lt;/ul&gt;
&lt;pre class="csharp" name="code"&gt;
[Test]
public void Move()
{
 // Arrange.
 inputManager.Stub(im =&gt; im.Move()).Return(1);

 // Act.
 gameObjectManager.Update(gameTime);

 // Assert.
 Assert.AreEqual(-1.0f, gameObjectManager.SpaceShip.ModelPosition.Z);
}
&lt;/pre&gt;
&lt;/td&gt;
&lt;/tr&gt;&lt;/table&gt;
Test #4: &lt;b&gt;Warp Center&lt;/b&gt;&lt;br /&gt;
&lt;table width="100%"&gt;&lt;tr&gt;
&lt;td valign="top"&gt;
&lt;ul&gt;
&lt;li&gt;Simulate input from the controller to return the Warp Center action&lt;/li&gt;
&lt;li&gt;Update the Game Object Manager which updates the SpaceShip&lt;/li&gt;
&lt;li&gt;Assert the position of the SpaceShip updates correctly&lt;/li&gt;
&lt;/ul&gt;
&lt;pre class="csharp" name="code"&gt;
[Test]
public void Warp()
{
 // Arrange.
 Vector3 modelPostion = new Vector3(10, 20, 30);
 spaceShip = new SpaceShip(modelPostion);

 gameObjectManager = new GameObjectManager(
  cameraManager,
  contentManager,
  inputManager,
  spaceShip);

 inputManager.Stub(im =&gt; im.Warp()).Return(true);

 // Act.
 gameObjectManager.Update(gameTime);

 // Assert.
 Assert.AreEqual(Vector3.Zero, gameObjectManager.SpaceShip.ModelPosition);
}
&lt;/pre&gt;
&lt;/td&gt;
&lt;/tr&gt;&lt;/table&gt;
Download code sample &lt;b&gt;&lt;a href="http://steveproxna03ut.codeplex.com/SourceControl/list/changesets"&gt;here&lt;/a&gt;&lt;/b&gt;.&lt;br /&gt;&lt;br /&gt;&lt;u&gt;Summary&lt;/u&gt;&lt;br /&gt;The revised &lt;a href="http://msdn.microsoft.com/en-us/library/bb203896(v=XNAGameStudio.31).aspx"&gt;Going Beyond&lt;/a&gt; tutorial demonstrates how to integrate Unit Tests into an existing code &lt;a href="http://steveproxna02ioc.codeplex.com/SourceControl/list/changesets"&gt;base&lt;/a&gt;.&lt;br /&gt;However, simply adding unit tests after the code is written does not guarantee bug free code!&lt;br /&gt;&lt;br /&gt;For example: subtle bugs may be introduced in code that are not caught when tested in isolation simply because the tests may return false positive results.
&lt;br /&gt;&lt;br /&gt;Unit tests state what you expect the code to do.  Therefore, a better approach is to write the tests first: Writing the test &lt;i&gt;before&lt;/i&gt; the code should uncover issues quicker because assertions in the test can fail.&lt;br /&gt;&lt;br /&gt;The practice of writing unit tests &lt;i&gt;before&lt;/i&gt; the objects they test is called: &lt;a href="http://en.wikipedia.org/wiki/Test-driven_development"&gt;Test Driven Development&lt;/a&gt;.&lt;br /&gt;This will be the topic in the next &lt;a href="http://steveproxna.blogspot.com/2011/04/xna-and-test-driven-development.html"&gt;post&lt;/a&gt;.&lt;/span&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/8584570627780730363-1017048091035306639?l=steveproxna.blogspot.com' alt='' /&gt;&lt;/div&gt;
&lt;p&gt;&lt;a href="http://feedads.g.doubleclick.net/~a/TazxM20XTb-nsPlxl69xZ6LIl30/0/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/TazxM20XTb-nsPlxl69xZ6LIl30/0/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;br/&gt;
&lt;a href="http://feedads.g.doubleclick.net/~a/TazxM20XTb-nsPlxl69xZ6LIl30/1/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/TazxM20XTb-nsPlxl69xZ6LIl30/1/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;/p&gt;&lt;img src="http://feeds.feedburner.com/~r/SteveProXNA/~4/qAl5LcrYqWc" height="1" width="1"/&gt;</description><link>http://feedproxy.google.com/~r/SteveProXNA/~3/qAl5LcrYqWc/xna-and-unit-testing.html</link><author>noreply@blogger.com (SteveProXNA)</author><thr:total>1</thr:total><feedburner:origLink>http://steveproxna.blogspot.com/2011/03/xna-and-unit-testing.html</feedburner:origLink></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-8584570627780730363.post-7411921606799455369</guid><pubDate>Tue, 01 Mar 2011 08:06:00 +0000</pubDate><atom:updated>2012-01-01T05:44:54.163-08:00</atom:updated><category domain="http://www.blogger.com/atom/ns#">Agile</category><title>XNA and an IoC Container</title><description>&lt;span style="font-family:verdana;font-size:85%;"&gt;In the previous &lt;a href="http://steveproxna.blogspot.com/2011/02/xna-and-dependency-injection.html"&gt;post&lt;/a&gt;, we discussed the topic of XNA and Dependency Injection.&lt;br /&gt;Now, let's build on this information to discuss an IoC Container with &lt;a href="http://en.wikipedia.org/wiki/XNA_(Microsoft)"&gt;XNA&lt;/a&gt;.
&lt;br /&gt;&lt;br /&gt;Note: this post includes complete code sample on &lt;a href="http://steveproxna02ioc.codeplex.com"&gt;CodePlex&lt;/a&gt;.&lt;br /&gt;
Download code sample &lt;b&gt;&lt;a href="http://steveproxna02ioc.codeplex.com/SourceControl/list/changesets"&gt;here&lt;/a&gt;&lt;/b&gt;.
&lt;br /&gt;&lt;br /&gt;&lt;u&gt;IoC Container&lt;/u&gt;&lt;br /&gt;An &lt;a href="http://www.martinfowler.com/articles/injection.html"&gt;IoC Container&lt;/a&gt; is a framework component that automatically resolves all dependent references for an object: when an object is constructed, the container will instantiate all dependent objects automatically and injects them into the source object accordingly.&lt;br /&gt;&lt;br /&gt;There are many IoC containers available to .NET developers:
&lt;br /&gt;&lt;table width="100%"&gt;&lt;tr&gt;&lt;td valign="top"&gt;&lt;ul&gt;&lt;li&gt;&lt;a href="http://code.google.com/p/autofac"&gt;Autofac&lt;/a&gt;&lt;/li&gt;&lt;li&gt;&lt;a href="http://www.castleproject.org/container/index.html"&gt;Castle Windsor&lt;/a&gt;&lt;/li&gt;&lt;li&gt;&lt;a href="http://ninject.org"&gt;Ninject&lt;/a&gt;&lt;/li&gt;&lt;li&gt;&lt;a href="http://www.springframework.net"&gt;Spring.NET&lt;/a&gt;&lt;/li&gt;&lt;li&gt;&lt;a href="http://structuremap.net/structuremap/index.html"&gt;StructureMap&lt;/a&gt;&lt;/li&gt;&lt;li&gt;&lt;a href="http://unity.codeplex.com"&gt;Unity&lt;/a&gt;&lt;/li&gt;&lt;/ul&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;However, &lt;a href="http://ninject.org"&gt;Ninject&lt;/a&gt; is currently the only IoC container that is compatible with the &lt;a href="http://en.wikipedia.org/wiki/.NET_Compact_Framework"&gt;.NET Compact Framework&lt;/a&gt; and will work on &lt;a href="http://www.microsoft.com/windowsphone/en-us/default.aspx"&gt;Windows Phone 7&lt;/a&gt; and &lt;a href="http://www.xbox.com"&gt;Xbox 360&lt;/a&gt;.&lt;br /&gt;&lt;br /&gt;&lt;u&gt;Example&lt;/u&gt;&lt;br /&gt;As an example, let's revise the &lt;a href="http://msdn.microsoft.com/en-us/library/bb197293(v=XNAGameStudio.31).aspx"&gt;Going Beyond&lt;/a&gt; tutorial to demonstrate XNA and an IoC Container.
&lt;br /&gt;&lt;br /&gt;&lt;u&gt;Sample&lt;/u&gt;&lt;br /&gt;&lt;a href="http://steveproxna01di.codeplex.com/SourceControl/list/changesets"&gt;Download&lt;/a&gt; the code sample from the previous post; the IoC Container will be added to this code.&lt;br /&gt;
All logic to resolve dependent component references can be encapulated into a single object:&lt;br /&gt;&lt;br /&gt;IOC CONTAINER
&lt;pre class="csharp" name="code"&gt;
public static class IoCContainer
{
 private static IKernel kernel;

 public static T Resolve&lt;T&gt;()
 {
  if (null == kernel)
  {
   INinjectModule staticModule = new StaticModule();
   INinjectModule[] modules = new[] { staticModule };

   kernel = new StandardKernel(modules);
  }

  return kernel.Get&lt;T&gt;();
 }

 public static void Release()
 {
  if (null == kernel)
  {
   return;
  }

  kernel.Dispose();
  kernel = null;
 }
}
&lt;/pre&gt;
Next, build a module to configure the bindings and manage the lifetime of all component references:&lt;br /&gt;STATIC MODULE
&lt;pre class="csharp" name="code"&gt;
public class StaticModule : NinjectModule
{
 public override void Load()
 {
  Bind&amp;lt;IGameManager&amp;gt;().To&amp;lt;GameManager&amp;gt;().InSingletonScope();
  Bind&amp;lt;ICameraManager&amp;gt;().To&amp;lt;CameraManager&amp;gt;().InSingletonScope();
  Bind&amp;lt;IContentManager&amp;gt;().To&amp;lt;ContentManager&amp;gt;().InSingletonScope();
  Bind&amp;lt;IGameObjectManager&amp;gt;().To&amp;lt;GameObjectManager&amp;gt;().InSingletonScope();
  Bind&amp;lt;IGraphicsManager&amp;gt;().To&amp;lt;GraphicsManager&amp;gt;().InSingletonScope();
  Bind&amp;lt;IScreenManager&amp;gt;().To&amp;lt;ScreenManager&amp;gt;().InSingletonScope();
 }
}&lt;/pre&gt;
Next, invoke the IoC Container to construct a single instance of the GameManager component:&lt;br /&gt;GAME FACTORY
&lt;pre class="csharp" name="code"&gt;
public static class GameFactory
{
 private static IGameManager gameManager;

 public static IGameManager GetGameManager()
 {
  return gameManager ?? (gameManager = IoCContainer.Resolve&amp;lt;IGameManager&amp;gt;());
 }

 public static void Release()
 {
  IoCContainer.Release();
 }
}
&lt;/pre&gt;
Finally, dispose of the IoC Container when the game exits:&lt;br /&gt;GAME MANAGER
&lt;pre class="csharp" name="code"&gt;
public class GameManager : IGameManager
{
 // Same code as previous post.

 // Exit game.
 public void Exit()
 {
  GameFactory.Release();
 }
}
&lt;/pre&gt;
GAME
&lt;pre class="csharp" name="code"&gt;
public class MyGame : Game
{
 // Same code as previous post.

 protected override void OnExiting(object sender, EventArgs args)
 {
  gameManager.Exit();
  base.OnExiting(sender, args);
 }
}
&lt;/pre&gt;
Execute the updated game code: the output should be identical to the previous &lt;a href="http://steveproxna.blogspot.com/2011/02/xna-and-dependency-injection.html"&gt;post&lt;/a&gt;.
&lt;br /&gt;&lt;br /&gt;
&lt;u&gt;Device Factory&lt;/u&gt;
&lt;br /&gt;
In an older &lt;a href="http://steveproxna.blogspot.com/2009/10/device-factory.html"&gt;post&lt;/a&gt;, we discussed the topic of a Device Factory.  Essentially, the Device Factory is an abstract base class that contains all game code common to every device, but allows device specific game code to be overridden in the concrete implementation class through polymorphism.&lt;br /&gt;&lt;br /&gt;Let's complete the sample by extending the current code base to target all devices currently available in&lt;br /&gt;&lt;a href="http://www.microsoft.com/downloads/en/details.aspx?FamilyID=9ac86eca-206f-4274-97f2-ef6c8b1f478f"&gt;XNA 4.0&lt;/a&gt;: Windows PC, Windows Phone 7 and Xbox 360.&lt;br /&gt;&lt;br /&gt;
First, build the Device Factory abstract base class and all concrete implementation classes:&lt;br /&gt;DEVICE FACTORY
&lt;pre class="csharp" name="code"&gt;
public abstract class ADeviceFactory
{
 // GraphicsManager.
 public Int32 PreferredBackBufferWidth { get; protected set; }
 public Int32 PreferredBackBufferHeight { get; protected set; }
 public Boolean IsFullScreen { get; protected set; }

 // ContentManager.
 public String RootDirectory { get; protected set; }
}

public class PhoneDeviceFactory : ADeviceFactory
{
 public PhoneDeviceFactory()
 {
  PreferredBackBufferWidth = 800;
  PreferredBackBufferHeight = 480;
  IsFullScreen = true;
  RootDirectory = "Content";
 }
}

public class WorkDeviceFactory : ADeviceFactory
{
 public WorkDeviceFactory()
 {
  PreferredBackBufferWidth = 1280;
  PreferredBackBufferHeight = 720;
  IsFullScreen = false;
  RootDirectory = "Content";
 }
}

public class XboxDeviceFactory : ADeviceFactory
{
 public XboxDeviceFactory()
 {
  PreferredBackBufferWidth = 1280;
  PreferredBackBufferHeight = 720;
  IsFullScreen = false;
  RootDirectory = "Content";
 }
}
&lt;/pre&gt;
Next, build a Device Manager to delegate all work to the Device Factory:&lt;br /&gt;DEVICE MANAGER
&lt;pre class="csharp" name="code"&gt;
public class DeviceManager : IDeviceManager
{
 // DeviceManager has dependency on DeviceFactory.
 private readonly ADeviceFactory deviceFactory;

 public DeviceManager(ADeviceFactory deviceFactory)
 {
  this.deviceFactory = deviceFactory;
 }

 public ADeviceFactory DeviceFactory
 {
  get { return deviceFactory; }
 }
}
&lt;/pre&gt;
Note: build an Input Factory and Input Manager; these will be placeholders available for future posts:&lt;br /&gt;INPUT FACTORY
&lt;pre class="csharp" name="code"&gt;
public abstract class AInputFactory
{
}
public class PhoneInputFactory : AInputFactory
{
}
public class WorkInputFactory : AInputFactory
{
}
public class XboxInputFactory : AInputFactory
{
}
&lt;/pre&gt;
INPUT MANAGER
&lt;pre class="csharp" name="code"&gt;
public class InputManager : IInputManager
{
}
&lt;/pre&gt;
Next, build a module to configure the bindings and manage the lifetime of all device specific components:&lt;br /&gt;DYNAMIC MODULE
&lt;pre class="csharp" name="code"&gt;
 public class DynamicModule : NinjectModule
 {
  public override void Load()
  {
#if WINDOWS_PHONE
   Bind&amp;lt;ADeviceFactory&amp;gt;().To&amp;lt;PhoneDeviceFactory&amp;gt;().InSingletonScope();
   Bind&amp;lt;AInputFactory&amp;gt;().To&amp;lt;PhoneInputFactory&amp;gt;().InSingletonScope();
#elif WINDOWS
   Bind&amp;lt;ADeviceFactory&amp;gt;().To&amp;lt;WorkDeviceFactory&amp;gt;().InSingletonScope();
   Bind&amp;lt;AInputFactory&amp;gt;().To&amp;lt;WorkInputFactory&amp;gt;().InSingletonScope();
#elif XBOX
   Bind&amp;lt;ADeviceFactory&amp;gt;().To&amp;lt;XboxDeviceFactory&amp;gt;().InSingletonScope();
   Bind&amp;lt;AInputFactory&amp;gt;().To&amp;lt;XboxInputFactory&amp;gt;().InSingletonScope();
#else
   throw new ArgumentOutOfRangeException("DynamicModule");
#endif
  }
 }
&lt;/pre&gt;
Next, update the IoC Container:&lt;br /&gt;IOC CONTAINER
&lt;pre class="csharp" name="code"&gt;
public static class IoCContainer
{
 private static IKernel kernel;

 public static T Resolve&lt;T&gt;()
 {
  if (null == kernel)
  {
   INinjectModule staticModule = new StaticModule();
   INinjectModule dynamicModule = new DynamicModule();

   INinjectModule[] modules = new[] { staticModule, dynamicModule };
   kernel = new StandardKernel(modules);
  }

  return kernel.Get&lt;T&gt;();
 }

 public static void Release()
 {
  if (null == kernel)
  {
   return;
  }

  kernel.Dispose();
  kernel = null;
 }
}
&lt;/pre&gt;
Finally, inject all device specific components using &lt;a href="http://www.codeproject.com/KB/architecture/DependencyInjection.aspx"&gt;constructor injection&lt;/a&gt; technique:&lt;br /&gt;CONTENT MANAGER
&lt;pre class="csharp" name="code"&gt;
public class ContentManager : IContentManager
{
 // ContentManager has dependency on DeviceManager.
 private readonly IDeviceManager deviceManager;
 private XnaContentManager content;

 public ContentManager(IDeviceManager deviceManager)
 {
  this.deviceManager = deviceManager;
 }

 // Load all content.
 public void LoadContent(XnaContentManager xnaContent)
 {
  if (null != content)
  {
   return;
  }

  content = xnaContent;
  content.RootDirectory = deviceManager.DeviceFactory.RootDirectory;
  SpaceShipModel = content.Load&amp;lt;Model&amp;gt;("Models/p1_wedge");
 }

 // Unload all content.
 public void UnloadContent()
 {
  if (null == content)
  {
   return;
  }

  content.Unload();
 }

 public Model SpaceShipModel { get; private set; }
}
&lt;/pre&gt;
GRAPHICS MANAGER
&lt;pre class="csharp" name="code"&gt;
public class GraphicsManager : IGraphicsManager
{
 // GraphicsManager has dependency on DeviceManager.
 private readonly IDeviceManager deviceManager;
 private XnaGraphicsDeviceManager graphics;

 public GraphicsManager(IDeviceManager deviceManager)
 {
  this.deviceManager = deviceManager;
 }

 // Initialize all graphics properties.
 public void Initialize(XnaGraphicsDeviceManager xnaGraphics)
 {
  if (null != graphics)
  {
   return;
  }

  graphics = xnaGraphics;
  graphics.PreferredBackBufferWidth = deviceManager.DeviceFactory.PreferredBackBufferWidth;
  graphics.PreferredBackBufferHeight = deviceManager.DeviceFactory.PreferredBackBufferHeight;
  graphics.IsFullScreen = deviceManager.DeviceFactory.IsFullScreen;
  graphics.ApplyChanges();

  GraphicsDevice = graphics.GraphicsDevice;
  SpriteBatch = new SpriteBatch(GraphicsDevice);
 }

 public GraphicsDevice GraphicsDevice { get; private set; }
 public Single AspectRatio { get { return GraphicsDevice.Viewport.AspectRatio; } }
 public SpriteBatch SpriteBatch { get; private set; }
}
&lt;/pre&gt;
Download code sample &lt;b&gt;&lt;a href="http://steveproxna02ioc.codeplex.com/SourceControl/list/changesets"&gt;here&lt;/a&gt;&lt;/b&gt;.&lt;br /&gt;&lt;br /&gt;&lt;u&gt;Summary&lt;/u&gt;&lt;br /&gt;The revised &lt;a href="http://msdn.microsoft.com/en-us/library/bb197293(v=XNAGameStudio.31).aspx"&gt;Going Beyond&lt;/a&gt; example demonstrates how to add an IoC Container to an existing code &lt;a href="http://steveproxna01di.codeplex.com/SourceControl/list/changesets"&gt;base&lt;/a&gt;.  Once the bindings for each game component have been configured, the IoC Container will automatically resolve all dependent references for an object.&lt;br /&gt;&lt;br /&gt;Therefore, the code base is now in a testable state: each game component is now able to be tested in isolation: &lt;a href="http://en.wikipedia.org/wiki/Unit_testing"&gt;Unit Testing&lt;/a&gt;.  This will be the topic in the next &lt;a href="http://steveproxna.blogspot.com/2011/03/xna-and-unit-testing.html"&gt;post&lt;/a&gt;.&lt;/span&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/8584570627780730363-7411921606799455369?l=steveproxna.blogspot.com' alt='' /&gt;&lt;/div&gt;
&lt;p&gt;&lt;a href="http://feedads.g.doubleclick.net/~a/sjsDvKz9FftgGkjbk_UPNV_iwyg/0/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/sjsDvKz9FftgGkjbk_UPNV_iwyg/0/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;br/&gt;
&lt;a href="http://feedads.g.doubleclick.net/~a/sjsDvKz9FftgGkjbk_UPNV_iwyg/1/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/sjsDvKz9FftgGkjbk_UPNV_iwyg/1/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;/p&gt;&lt;img src="http://feeds.feedburner.com/~r/SteveProXNA/~4/ygsnrdnPGa0" height="1" width="1"/&gt;</description><link>http://feedproxy.google.com/~r/SteveProXNA/~3/ygsnrdnPGa0/xna-and-ioc-container.html</link><author>noreply@blogger.com (SteveProXNA)</author><thr:total>0</thr:total><feedburner:origLink>http://steveproxna.blogspot.com/2011/03/xna-and-ioc-container.html</feedburner:origLink></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-8584570627780730363.post-262617282702913103</guid><pubDate>Mon, 14 Feb 2011 08:16:00 +0000</pubDate><atom:updated>2012-01-01T05:44:09.836-08:00</atom:updated><category domain="http://www.blogger.com/atom/ns#">Agile</category><title>XNA and Dependency Injection</title><description>&lt;span style="font-family:verdana;font-size:85%;"&gt;In the previous &lt;a href="http://steveproxna.blogspot.com/2011/02/xna-and-agile-software-development.html"&gt;post&lt;/a&gt;, we discussed the topic of XNA and Agile Software Development.&lt;br /&gt;Now, let's build on this information to discuss Dependency Injection with &lt;a href="http://en.wikipedia.org/wiki/XNA_(Microsoft)"&gt;XNA&lt;/a&gt;.&lt;br /&gt;&lt;br /&gt;Note: this post includes complete code sample on &lt;a href="http://steveproxna01di.codeplex.com"&gt;CodePlex&lt;/a&gt;.&lt;br /&gt;Download code sample &lt;b&gt;&lt;a href="http://steveproxna01di.codeplex.com/SourceControl/list/changesets"&gt;here&lt;/a&gt;&lt;/b&gt;.&lt;br /&gt;&lt;br /&gt;&lt;u&gt;Dependency Injection&lt;/u&gt;&lt;br /&gt;&lt;a href="http://en.wikipedia.org/wiki/Dependency_injection"&gt;Dependency Injection&lt;/a&gt; is a simple pattern to loosely couple objects and break their dependencies.&lt;br /&gt;The resulting design principle, &lt;a href=" http://en.wikipedia.org/wiki/Dependency_inversion_principle"&gt;Dependency Inversion&lt;/a&gt;, states: &lt;i&gt;Depend upon abstractions.&lt;br /&gt;Do not depend upon concrete classes.&lt;/i&gt;&lt;br /&gt;&lt;br /&gt;By coupling an object to an interface instead of a specific concrete implementation, you have the ability to use any implementation with minimal change and risk.  This concept is important, especially when testing an object in isolation (unit testing).&lt;br /&gt;&lt;br /&gt;&lt;u&gt;Example&lt;/u&gt;&lt;br /&gt;As an example, let's revise the &lt;a href="http://msdn.microsoft.com/en-us/library/bb197293(v=XNAGameStudio.31).aspx"&gt;Going Beyond&lt;/a&gt; tutorial to demonstrate XNA and Dependency Injection.&lt;br /&gt;&lt;br /&gt;First, isolate the components used throughout the tutorial:
&lt;table width="100%"&gt;&lt;tr&gt;&lt;td valign="top"&gt;&lt;u&gt;Component&lt;/u&gt;&lt;br /&gt;CameraManager&lt;br /&gt;ContentManager&lt;br /&gt;GameObjectManager&lt;br /&gt;GraphicsManager&lt;br /&gt;ScreenManager&lt;/td&gt;&lt;td valign="top"&gt;&lt;u&gt;Responsibility&lt;/u&gt;&lt;br /&gt;manages fixed camera&lt;br /&gt;manages all game content&lt;br /&gt;manages all game objects&lt;br /&gt;manages all graphics&lt;br /&gt;manages all screens&lt;/td&gt;&lt;td valign="top"&gt;&lt;u&gt;Information&lt;/u&gt;&lt;br /&gt;view / projection matrices
&lt;br /&gt;currently only 1x model&lt;br /&gt;currently only 1x spaceship&lt;br /&gt;all graphics properties&lt;br /&gt;currently only 1x screen&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&lt;br /&gt;Next, identify the dependencies between the components:&lt;table width="100%"&gt;&lt;tr&gt;&lt;td valign="top"&gt;&lt;u&gt;Component&lt;/u&gt;&lt;br /&gt;CameraManager&lt;br /&gt;GameObjectManager&lt;br /&gt;GameObjectManager&lt;br /&gt;ScreenManager&lt;br /&gt;ScreenManager&lt;/td&gt;&lt;td valign="top"&gt;&lt;u&gt;Dependency&lt;/u&gt;&lt;br /&gt;depends on GraphicsManager&lt;br /&gt;depends on CameraManager&lt;br /&gt;depends on ContentManager&lt;br /&gt;depends on GameObjectManager&lt;br /&gt;depends on GraphicsManager&lt;/td&gt;&lt;td valign="top"&gt;&lt;u&gt;Information&lt;/u&gt;&lt;br /&gt;aspect ratio on graphics device&lt;br /&gt;game object view / projection&lt;br /&gt;load game object content&lt;br /&gt;update / draw game objects&lt;br /&gt;clear graphics device&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&lt;br /&gt;&lt;u&gt;Sample&lt;/u&gt;&lt;br /&gt;
The following code sample refactors the &lt;a href="http://msdn.microsoft.com/en-us/library/bb197293(v=XNAGameStudio.31).aspx"&gt;Going Beyond&lt;/a&gt; tutorial to render a 3D model on screen.&lt;br /&gt;All logic to load, update and draw the model can be encapsulated into a single game object:&lt;br /&gt;&lt;br /&gt;SPACE SHIP
&lt;pre class="csharp" name="code"&gt;
public class SpaceShip
{
 private Model spaceShipModel;
 private Matrix[] transforms;

 public SpaceShip()
 {
  ModelRotation = 0.0f;
  ModelPosition = Vector3.Zero;
  ModelVelocity = Vector3.Zero;
 }

 // Load model and set view/projection matrices.
 public void LoadContent(Model theSpaceShipModel, Matrix viewMatrix, Matrix projectionMatrix)
 {
  spaceShipModel = theSpaceShipModel;
  transforms = new Matrix[spaceShipModel.Bones.Count];
  spaceShipModel.CopyAbsoluteBoneTransformsTo(transforms);

  foreach (BasicEffect effect in spaceShipModel.Meshes.SelectMany(mesh =&gt; mesh.Effects.Cast&amp;lt;BasicEffect&amp;gt;()))
  {
   effect.EnableDefaultLighting();
   effect.View = viewMatrix;
   effect.Projection = projectionMatrix;
  }
 }

 // Update angle of rotation.
 public void Update(GameTime gameTime)
 {
  Single temps = MathHelper.ToRadians(0.05f);
  Single delta = (Single)gameTime.ElapsedGameTime.TotalMilliseconds;
  ModelRotation -= delta * temps;
 }

 // Draw model.
 public void Draw()
 {
  foreach (ModelMesh mesh in spaceShipModel.Meshes)
  {
   foreach (BasicEffect effect in mesh.Effects)
   {
    effect.World = transforms[mesh.ParentBone.Index]
     * Matrix.CreateRotationY(ModelRotation)
     * Matrix.CreateTranslation(ModelPosition);
   }

   mesh.Draw();
  }
 }

 public Single ModelRotation { get; private set; }
 public Vector3 ModelPosition { get; private set; }
 public Vector3 ModelVelocity { get; private set; }
}
&lt;/pre&gt;
Next, build the components that do not have any dependencies:&lt;br /&gt;CONTENT MANAGER
&lt;pre class="csharp" name="code"&gt;
using XnaContentManager = Microsoft.Xna.Framework.Content.ContentManager;

public class ContentManager : IContentManager
{
 private XnaContentManager content;

 // Load all content.
 public void LoadContent(XnaContentManager xnaContent)
 {
  if (null != content)
  {
   return;
  }

  content = xnaContent;
  content.RootDirectory = "Content";
  SpaceShipModel = content.Load&amp;lt;Model&amp;gt;("Models/p1_wedge");
 }

 // Unload all content.
 public void UnloadContent()
 {
  if (null == content)
  {
   return;
  }

  content.Unload();
 }

 public Model SpaceShipModel { get; private set; }
}
&lt;/pre&gt;
GRAPHICS MANAGER
&lt;pre class="csharp" name="code"&gt;
using XnaGraphicsDeviceManager = Microsoft.Xna.Framework.GraphicsDeviceManager;

public class GraphicsManager : IGraphicsManager
{
 private XnaGraphicsDeviceManager graphics;

 // Initialize all graphics properties.
 public void Initialize(XnaGraphicsDeviceManager xnaGraphics)
 {
  if (null != graphics)
  {
   return;
  }

  graphics = xnaGraphics;
  graphics.PreferredBackBufferWidth = 800;
  graphics.PreferredBackBufferHeight = 480;
  graphics.IsFullScreen = false;
  graphics.ApplyChanges();

  GraphicsDevice = graphics.GraphicsDevice;
  SpriteBatch = new SpriteBatch(GraphicsDevice);
 }

 public GraphicsDevice GraphicsDevice { get; private set; }
 public Single AspectRatio { get { return GraphicsDevice.Viewport.AspectRatio; } }
 public SpriteBatch SpriteBatch { get; private set; }
} 
&lt;/pre&gt;
Next, build the the remaining components that do have dependencies; here each dependent component is injected manually using &lt;a href="http://www.codeproject.com/KB/architecture/DependencyInjection.aspx"&gt;constructor injection&lt;/a&gt; technique:&lt;br /&gt;&lt;br /&gt;CAMERA MANAGER
&lt;pre class="csharp" name="code"&gt;
public class CameraManager : ICameraManager
{
 // CameraManager has dependency on GraphicsManager.
 private readonly IGraphicsManager graphicsManager;

 public CameraManager(IGraphicsManager graphicsManager)
 {
  this.graphicsManager = graphicsManager;
 }

 // Initialize camera view/projection matrices.
 public void Initialize(Vector3 cameraPosition)
 {
  ViewMatrix = Matrix.CreateLookAt(cameraPosition, Vector3.Zero, Vector3.Up);
  ProjectionMatrix = Matrix.CreatePerspectiveFieldOfView(MathHelper.PiOver4, graphicsManager.AspectRatio, 1.0f, 10000.0f);
 }

 public Matrix ViewMatrix { get; private set; }
 public Matrix ProjectionMatrix { get; private set; }
}
&lt;/pre&gt;
GAME OBJECT MANAGER
&lt;pre class="csharp" name="code"&gt;
public class GameObjectManager : IGameObjectManager
{
 // GameObjectManager has dependency on CameraManager and ContentManager.
 private readonly ICameraManager cameraManager;
 private readonly IContentManager contentManager;
 private readonly SpaceShip spaceShip;

 public GameObjectManager(ICameraManager cameraManager, IContentManager contentManager)
 {
  this.cameraManager = cameraManager;
  this.contentManager = contentManager;
  spaceShip = new SpaceShip();
 }

 // Load content for each game object.
 public void LoadContent()
 {
  spaceShip.LoadContent(contentManager.SpaceShipModel, cameraManager.ViewMatrix, cameraManager.ProjectionMatrix);
 }

 // Update each game object.
 public void Update(GameTime gameTime)
 {
  spaceShip.Update(gameTime);
 }

 // Draw each game object.
 public void Draw()
 {
  spaceShip.Draw();
 }
}
&lt;/pre&gt;
SCREEN MANAGER
&lt;pre class="csharp" name="code"&gt;
public class ScreenManager : IScreenManager
{
 // ScreenManager has dependency on GameObjectManager and GraphicsManager.
 private readonly IGameObjectManager gameObjectManager;
 private readonly IGraphicsManager graphicsManager;

 public ScreenManager(IGameObjectManager gameObjectManager, IGraphicsManager graphicsManager)
 {
  this.gameObjectManager = gameObjectManager;
  this.graphicsManager = graphicsManager;
 }

 // Update each game object using GameObjectManager.
 public void Update(GameTime gameTime)
 {
  gameObjectManager.Update(gameTime);
 }

 // Draw each game object using GameObjectManager.
 public void Draw()
 {
  graphicsManager.GraphicsDevice.Clear(Color.Black);
  gameObjectManager.Draw();
 }
}
&lt;/pre&gt;
Finally, build a GameManager component to manage all interaction between the main game class and each game component listed above.  Again, each dependent component is injected manually using &lt;a href="http://www.codeproject.com/KB/architecture/DependencyInjection.aspx"&gt;constructor injection&lt;/a&gt; technique:&lt;br /&gt;&lt;br /&gt;GAME MANAGER
&lt;pre class="csharp" name="code"&gt;
public class GameManager : IGameManager
{
 private readonly ICameraManager cameraManager;
 private readonly IContentManager contentManager;
 private readonly IGameObjectManager gameObjectManager;
 private readonly IGraphicsManager graphicsManager;
 private readonly IScreenManager screenManager;

 public GameManager(
  ICameraManager cameraManager,
  IContentManager contentManager,
  IGameObjectManager gameObjectManager,
  IGraphicsManager graphicsManager,
  IScreenManager screenManager
  )
 {
  this.cameraManager = cameraManager;
  this.contentManager = contentManager;
  this.gameObjectManager = gameObjectManager;
  this.graphicsManager = graphicsManager;
  this.screenManager = screenManager;
 }

 // Initialize graphics and camera.
 public void Initialize(GraphicsDeviceManager graphics)
 {
  graphicsManager.Initialize(graphics);
  cameraManager.Initialize(new Vector3(0.0f, 50.0f, 5000.0f));
 }

 // Load all content.
 public void LoadContent(XnaContentManager content)
 {
  contentManager.LoadContent(content);
  gameObjectManager.LoadContent();
 }

 // Unload all content.
 public void UnloadContent()
 {
  contentManager.UnloadContent();
 }

 // Update each screen.
 public void Update(GameTime gameTime)
 {
  screenManager.Update(gameTime);
 }

 // Draw each screen.
 public void Draw()
 {
  screenManager.Draw();
 }
}
&lt;/pre&gt;
For simplicity, build a GameFactory to construct a single instance of the GameMananger component:&lt;br /&gt;GAME FACTORY
&lt;pre class="csharp" name="code"&gt;
public static class GameFactory
{
 private static IGameManager gameManager;

 public static IGameManager GetGameManager()
 {
  if (null == gameManager)
  {
   IContentManager contentManager = new ContentManager();
   IGraphicsManager graphicsManager = new GraphicsManager();
   ICameraManager cameraManager = new CameraManager(graphicsManager);
   IGameObjectManager gameObjectManager = new GameObjectManager(cameraManager, contentManager);
   IScreenManager screenManager = new ScreenManager(gameObjectManager, graphicsManager);

   gameManager = new GameManager(
    cameraManager,
    contentManager,
    gameObjectManager,
    graphicsManager,
    screenManager
    );
  }

  return gameManager;
 }
}
&lt;/pre&gt;
For completeness, here is the main game class; the GameManager now manages all game actions:&lt;br /&gt;GAME
&lt;pre class="csharp" name="code"&gt;
public class MyGame : Game
{
 private readonly GraphicsDeviceManager graphics;
 private readonly IGameManager gameManager;

 public MyGame()
 {
  graphics = new GraphicsDeviceManager(this);
  gameManager = GameFactory.GetGameManager();
 }

 protected override void Initialize()
 {
  gameManager.Initialize(graphics);
  base.Initialize();
 }

 protected override void LoadContent()
 {
  gameManager.LoadContent(Content);
  base.LoadContent();
 }

 protected override void UnloadContent()
 {
  gameManager.UnloadContent();
  base.UnloadContent();
 }

 protected override void Update(GameTime gameTime)
 {
  if (GamePad.GetState(PlayerIndex.One).Buttons.Back == ButtonState.Pressed ||
   Keyboard.GetState().IsKeyDown(Keys.Escape))
  {
   Exit();
  }
  gameManager.Update(gameTime);
  base.Update(gameTime);
 }

 protected override void Draw(GameTime gameTime)
 {
  gameManager.Draw();
  base.Draw(gameTime);
 }
}
&lt;/pre&gt;
Download code sample &lt;b&gt;&lt;a href="http://steveproxna01di.codeplex.com/SourceControl/list/changesets"&gt;here&lt;/a&gt;&lt;/b&gt;.&lt;br /&gt;&lt;br /&gt;
&lt;u&gt;Summary&lt;/u&gt;&lt;br /&gt;The revised &lt;a href="http://msdn.microsoft.com/en-us/library/bb197293(v=XNAGameStudio.31).aspx"&gt;Going Beyond&lt;/a&gt; example demonstrates how to isolate components using dependency injection:&lt;br /&gt;Game components are able to be tested in isolation as dependencies can be replaced by &lt;a href="http://en.wikipedia.org/wiki/Mock_object"&gt;mock objects&lt;/a&gt;.&lt;br/ &gt;&lt;br/ &gt;The biggest drawback from the code sample above, however, is that all dependent components must be constructed manually in the factory before they can be injected.&lt;br/ &gt;&lt;br/ &gt;Fortunately, there is a framework component available to developers that resolves this issue:&lt;br /&gt;The &lt;a href="http://www.martinfowler.com/articles/injection.html"&gt;IoC Container&lt;/a&gt;.  This will be the topic in the next &lt;a href="http://steveproxna.blogspot.com/2011/03/xna-and-ioc-container.html"&gt;post&lt;/a&gt;.&lt;/span&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/8584570627780730363-262617282702913103?l=steveproxna.blogspot.com' alt='' /&gt;&lt;/div&gt;
&lt;p&gt;&lt;a href="http://feedads.g.doubleclick.net/~a/zPwbkJeJLr7EhWikZLfjd2ab1QE/0/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/zPwbkJeJLr7EhWikZLfjd2ab1QE/0/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;br/&gt;
&lt;a href="http://feedads.g.doubleclick.net/~a/zPwbkJeJLr7EhWikZLfjd2ab1QE/1/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/zPwbkJeJLr7EhWikZLfjd2ab1QE/1/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;/p&gt;&lt;img src="http://feeds.feedburner.com/~r/SteveProXNA/~4/1ItKA1E4-lM" height="1" width="1"/&gt;</description><link>http://feedproxy.google.com/~r/SteveProXNA/~3/1ItKA1E4-lM/xna-and-dependency-injection.html</link><author>noreply@blogger.com (SteveProXNA)</author><thr:total>0</thr:total><feedburner:origLink>http://steveproxna.blogspot.com/2011/02/xna-and-dependency-injection.html</feedburner:origLink></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-8584570627780730363.post-2916009936153892922</guid><pubDate>Tue, 01 Feb 2011 08:06:00 +0000</pubDate><atom:updated>2012-01-01T05:43:23.544-08:00</atom:updated><category domain="http://www.blogger.com/atom/ns#">Agile</category><title>XNA and Agile Software Development</title><description>&lt;span style="font-family:verdana;font-size:85%;"&gt;&lt;a href="http://en.wikipedia.org/wiki/Agile_software_development"&gt;Agile development&lt;/a&gt; is a modern approach to software engineering that provides an iterative incremental framework for managing complex work.  Efficiency is key: by minimizing rework and debugging, teams can more rapidly respond to changing business requirements and improve quality at the same time.&lt;br /&gt;&lt;br /&gt;Game development, by nature, is complex and has many specialized disciplines:&lt;br /&gt;&lt;table width="100%"&gt;&lt;tr&gt;&lt;td valign="top"&gt;
&lt;ul&gt;&lt;li&gt;Core Systems: &lt;i&gt;engine configuration, math library, localization&lt;/i&gt;&lt;/li&gt;&lt;li&gt;Resources (Game Assets): &lt;i&gt;audio, fonts, models, textures&lt;/i&gt;&lt;/li&gt;&lt;li&gt;Human Input Devices (HID): &lt;i&gt;input detection&lt;/i&gt;&lt;/li&gt;
&lt;li&gt;Collision &amp; Physics: &lt;i&gt;rigid bodies&lt;/i&gt;&lt;/li&gt;&lt;li&gt;Online Multiplayer: &lt;i&gt;networking&lt;/i&gt;&lt;/li&gt;&lt;li&gt;Front End: &lt;i&gt;heads-up display, in-game menus, visual effects&lt;/i&gt;&lt;/li&gt;&lt;li&gt;Game Play Foundations: &lt;i&gt;event messaging, finite state machine&lt;/i&gt;&lt;/li&gt;&lt;li&gt;Game Specific Subsystems: &lt;i&gt;rendering, player mechanics, cameras, AI&lt;/i&gt;&lt;/li&gt;&lt;/ul&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;Therefore, each game may have many components working together and subsystems interacting with one another, many of which may depend on other components and subsystems too.&lt;br /&gt;&lt;br /&gt;Consequently, the task of coding and testing game components in isolation can be very challenging due to the tightly coupled nature of these dependencies.&lt;br /&gt;&lt;br /&gt;&lt;u&gt;Example&lt;/u&gt;
&lt;br /&gt;&lt;a href="http://en.wikipedia.org/wiki/Asteroids_(video_game)"&gt;Asteroids&lt;/a&gt;: in this simple game, the player controls a spaceship depending on input from the controller.&lt;br /&gt;In order to test the spaceship's rotate and move methods in isolation, the external dependency on the controller must be broken.&lt;br /&gt;&lt;br /&gt;&lt;u&gt;Dependency Injection and Inversion of Control (IoC)&lt;/u&gt;&lt;br /&gt;When an object instantiates another object that it depends on then this leads to poor design because it promotes tight coupling between the objects.  Tightly coupled code cannot be changed easily without consequences: changes made to one object may cause other objects to break.
&lt;br /&gt;&lt;br /&gt;A better approach is to break dependencies between objects and promote loose coupling:&lt;br /&gt;&lt;a href="http://www.xyzws.com/scjp/SGS11/5/2"&gt;Loose coupling&lt;/a&gt; leads to better design as the software is less likely to break.&lt;br /&gt;&lt;br /&gt;&lt;a href="http://en.wikipedia.org/wiki/Dependency_injection"&gt;Dependency Injection&lt;/a&gt; is a simple pattern to loosely couple objects and break their dependencies.&lt;br /&gt;The resulting design principle, &lt;a href=" http://en.wikipedia.org/wiki/Dependency_inversion_principle"&gt;Dependency Inversion&lt;/a&gt;, states: &lt;i&gt;Depend upon abstractions.&lt;br /&gt;Do not depend upon concrete classes.&lt;/i&gt;&lt;br /&gt;&lt;br /&gt;By coupling an object to an interface instead of a specific concrete implementation, you have the ability to use any implementation with minimal change and risk.  This concept is important, especially when testing an object in isolation (unit testing).&lt;br /&gt;&lt;br /&gt;&lt;a href="http://en.wikipedia.org/wiki/Inversion_of_control"&gt;Inversion of Control&lt;/a&gt; (IoC) is a framework characteristic whereby objects, which depend on other objects, do not need to instantiate those objects; instead they get the objects they need from an external source.&lt;br /&gt;&lt;br /&gt;&lt;u&gt;IoC Container&lt;/u&gt;&lt;br /&gt;An &lt;a href="http://www.martinfowler.com/articles/injection.html"&gt;IoC Container&lt;/a&gt; is a framework component that automatically resolves all dependent references for an object: when an object is constructed, the container will instantiate all dependent objects automatically and injects them into the source object accordingly.&lt;br /&gt;&lt;br /&gt;There are many IoC containers available to .NET developers:
&lt;br /&gt;&lt;table width="100%"&gt;&lt;tr&gt;&lt;td valign="top"&gt;&lt;ul&gt;&lt;li&gt;&lt;a href="http://code.google.com/p/autofac"&gt;Autofac&lt;/a&gt;&lt;/li&gt;&lt;li&gt;&lt;a href="http://www.castleproject.org/container/index.html"&gt;Castle Windsor&lt;/a&gt;&lt;/li&gt;&lt;li&gt;&lt;a href="http://ninject.org"&gt;Ninject&lt;/a&gt;&lt;/li&gt;&lt;li&gt;&lt;a href="http://www.springframework.net"&gt;Spring.NET&lt;/a&gt;&lt;/li&gt;&lt;li&gt;&lt;a href="http://structuremap.net/structuremap/index.html"&gt;StructureMap&lt;/a&gt;&lt;/li&gt;&lt;li&gt;&lt;a href="http://unity.codeplex.com"&gt;Unity&lt;/a&gt;&lt;/li&gt;&lt;/ul&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;However, &lt;a href="http://ninject.org"&gt;Ninject&lt;/a&gt; is currently the only IoC container that is compatible with the &lt;a href="http://en.wikipedia.org/wiki/.NET_Compact_Framework"&gt;.NET Compact Framework&lt;/a&gt; and will work on &lt;a href="http://www.microsoft.com/windowsphone/en-us/default.aspx"&gt;Windows Phone 7&lt;/a&gt; and &lt;a href="http://www.xbox.com"&gt;Xbox 360&lt;/a&gt;.&lt;br /&gt;&lt;br /&gt;&lt;u&gt;Unit Testing&lt;/u&gt;&lt;br /&gt;&lt;a href="http://en.wikipedia.org/wiki/Unit_testing"&gt;Unit testing&lt;/a&gt; is the practice in which individual units of source code are tested in isolation.  Consequently, unit tests do not measure how objects interact with dependent objects; these are integration &lt;a href="http://en.wikipedia.org/wiki/Integration_testing"&gt;tests&lt;/a&gt;.&lt;br /&gt;&lt;br /&gt;In order to successfully unit test an individual game component, external dependencies are broken, and replaced by &lt;a href="http://en.wikipedia.org/wiki/Mock_object"&gt;mock objects&lt;/a&gt;: fake objects that emulate real classes and help test expectations about how that class should function.&lt;br /&gt;&lt;br /&gt;Therefore, clean unit tests should be written &lt;a href="http://java.dzone.com/articles/why-you-should-read-clean-code"&gt;F.I.R.S.T&lt;/a&gt;:&lt;br /&gt;&lt;table width="100%"&gt;&lt;tr&gt;&lt;td valign="top"&gt;Fast&lt;br /&gt;Independent&lt;br /&gt;Repeatable&lt;br /&gt;Self-validating&lt;br /&gt;Timely&lt;br /&gt;&lt;/td&gt;&lt;td valign="top"&gt;Tests should be fast&lt;br /&gt;Tests should not depend on each other&lt;br /&gt;Tests should be repeatable in any environment&lt;br /&gt;Tests should have a Boolean output: either they pass or fail&lt;br /&gt;
Tests should be written in a timely fashion&lt;br /&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&lt;br /&gt;&lt;u&gt;Test Driven Development (TDD)&lt;/u&gt;&lt;br /&gt;&lt;a href="http://en.wikipedia.org/wiki/Test-driven_development"&gt;Test driven development&lt;/a&gt; (TDD) is similar to unit testing except the unit tests are written &lt;i&gt;before&lt;/i&gt; the objects they test.  TDD is gaining as a development best practice because objects are designed with testability in mind: an object and its dependencies must be loosely coupled from the outset.&lt;br /&gt;&lt;br /&gt;TDD practitioners follow these three &lt;a href="http://www2.imm.dtu.dk/pubdb/views/edoc_download.php/5571/pdf/imm5571.pdf"&gt;laws&lt;/a&gt;:&lt;br /&gt;&lt;table width="100%"&gt;&lt;tr&gt;&lt;td valign="top"&gt;First Law:&lt;br /&gt;Second Law:&lt;br /&gt;Third Law:&lt;br /&gt;&lt;/td&gt;&lt;td valign="top"&gt;You may not write production code unless you&amp;#8217;ve first written a failing unit test&lt;br /&gt;You may not write more of a unit test than is sufficient to fail&lt;br /&gt;You may not write more production code than is sufficient to make the failing unit test pass&lt;br /&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&lt;br /&gt;&lt;u&gt;Extreme Programming&lt;/u&gt;&lt;br /&gt;&lt;a href="http://en.wikipedia.org/wiki/Extreme_Programming"&gt;Extreme Programming&lt;/a&gt; is a method of agile software development which advocates frequent &lt;i&gt;releases&lt;/i&gt; with short development cycles.  The focus on delivering business value within each iteration leads to increased quality and lower overall total cost.&lt;br /&gt;&lt;br /&gt;Therefore, it seems only relevant to try and integrate agile methodologies into &lt;a href="http://en.wikipedia.org/wiki/XNA_(Microsoft)"&gt;XNA&lt;/a&gt; game development.  As an exercise, I would like to prototype the following agile techniques accordingly:&lt;br /&gt;
&lt;table width="100%"&gt;&lt;tr&gt;&lt;td valign="top"&gt;&lt;ul&gt;&lt;li&gt;&lt;a href="http://steveproxna.blogspot.com/2011/02/xna-and-dependency-injection.html"&gt;XNA and Dependency Injection&lt;/a&gt;&lt;/li&gt;&lt;li&gt;&lt;a href="http://steveproxna.blogspot.com/2011/03/xna-and-ioc-container.html"&gt;XNA and an IoC Container&lt;/a&gt;&lt;/li&gt;&lt;li&gt;&lt;a href="http://steveproxna.blogspot.com/2011/03/xna-and-unit-testing.html"&gt;XNA and Unit Testing&lt;/a&gt;&lt;/li&gt;&lt;li&gt;&lt;a href="http://steveproxna.blogspot.com/2011/04/xna-and-test-driven-development.html"&gt;XNA and Test Driven Development&lt;/a&gt;&lt;/li&gt;&lt;/ul&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;In conclusion, it will be interesting to see if agile development has the potential to scale using XNA!&lt;/span&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/8584570627780730363-2916009936153892922?l=steveproxna.blogspot.com' alt='' /&gt;&lt;/div&gt;
&lt;p&gt;&lt;a href="http://feedads.g.doubleclick.net/~a/KX2tbnNgWqX15UzuAmUyOSjk7EU/0/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/KX2tbnNgWqX15UzuAmUyOSjk7EU/0/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;br/&gt;
&lt;a href="http://feedads.g.doubleclick.net/~a/KX2tbnNgWqX15UzuAmUyOSjk7EU/1/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/KX2tbnNgWqX15UzuAmUyOSjk7EU/1/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;/p&gt;&lt;img src="http://feeds.feedburner.com/~r/SteveProXNA/~4/P5ceNqDAraY" height="1" width="1"/&gt;</description><link>http://feedproxy.google.com/~r/SteveProXNA/~3/P5ceNqDAraY/xna-and-agile-software-development.html</link><author>noreply@blogger.com (SteveProXNA)</author><thr:total>4</thr:total><feedburner:origLink>http://steveproxna.blogspot.com/2011/02/xna-and-agile-software-development.html</feedburner:origLink></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-8584570627780730363.post-3955233291216747151</guid><pubDate>Sat, 01 Jan 2011 09:13:00 +0000</pubDate><atom:updated>2012-01-01T05:42:48.466-08:00</atom:updated><category domain="http://www.blogger.com/atom/ns#">Agile</category><title>Retrospective II</title><description>&lt;span style="font-family:verdana;font-size:85%;"&gt;Last year, I conducted a simple &lt;a href="http://steveproxna.blogspot.com/2010/01/retrospective.html"&gt;retrospective&lt;/a&gt; for 2009.  Therefore, here is a retrospective for 2010.&lt;br /&gt;&lt;br /&gt;&lt;u&gt;2010 Achievements&lt;/u&gt;&lt;br /&gt;&lt;table width="100%"&gt;&lt;tr&gt;&lt;td valign="top"&gt;&lt;ul&gt;&lt;li&gt;Publish article on &lt;a href="http://steveproxna.blogspot.com/2010/04/xna-and-tax.html"&gt;XNA and TAX&lt;/a&gt;&lt;/li&gt;&lt;li&gt;Receive &lt;a href="http://forums.create.msdn.com/forums/p/58479/358432.aspx"&gt;recommendations&lt;/a&gt; on article&lt;/li&gt;&lt;li&gt;Receive &lt;a href="http://www.irs.gov/individuals/article/0,,id=96287,00.html"&gt;ITIN&lt;/a&gt; from &lt;a href="http://www.irs.gov"&gt;IRS&lt;/a&gt;&lt;/li&gt;&lt;li&gt;Extend knowledge of DirectX using &lt;a href="http://cid-538e432ea49f5bde.skydrive.live.com/self.aspx/Public/Samples%20And%20Tutorials/PIXWithXNA.zip"&gt;PIX with XNA&lt;/a&gt;&lt;/li&gt;&lt;li&gt;Upgrade to &lt;a href="http://msdn.microsoft.com/en-us/library/bb200104.aspx"&gt;XNA 4.0&lt;/a&gt; and revise &lt;a href="http://blogs.msdn.com/b/shawnhar/archive/2010/03/16/breaking-changes-in-xna-game-studio-4-0.aspx"&gt;breaking changes&lt;/a&gt;&lt;/li&gt;&lt;li&gt;Receive &lt;a href="http://marketplace.xbox.com/en-US/games/media/66acd000-77fe-1000-9115-d802585503d8"&gt;Henway&lt;/a&gt; Xbox LIVE Indie Game payments&lt;/li&gt;&lt;li&gt;Receive Publisher Id from &lt;a href="http://www.geotrust.com"&gt;GeoTrust&lt;/a&gt;&lt;/li&gt;&lt;li&gt;Buy &lt;a href="http://www.microsoft.com/windowsphone/en-us/default.aspx"&gt;Windows Phone 7&lt;/a&gt;&lt;/li&gt;&lt;/ul&gt;Note: receiving an &lt;a href="http://www.irs.gov/individuals/article/0,,id=96287,00.html"&gt;ITIN&lt;/a&gt; outside United States is an achievement!&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&lt;br /&gt;&lt;u&gt;2011 Objectives&lt;/u&gt;&lt;br /&gt;
&lt;table width="100%"&gt;&lt;tr&gt;&lt;td valign="top"&gt;&lt;ul&gt;&lt;li&gt;Deliver game project for &lt;a href="http://www.microsoft.com/windowsphone/en-us/default.aspx"&gt;Windows Phone 7&lt;/a&gt; and &lt;a href="http://www.xbox.com"&gt;Xbox 360&lt;/a&gt;&lt;/li&gt;&lt;li&gt;Complete bank and tax information on the &lt;a href="https://users.create.msdn.com/Account/PayeeDetails"&gt;App Hub&lt;/a&gt;&lt;/li&gt;&lt;li&gt;Buy Xbox &lt;a href="http://www.xbox.com/en-us/kinect"&gt;Kinect&lt;/a&gt; if / when APIs available&lt;/li&gt;&lt;li&gt;Integrate into game development:&lt;ul&gt;&lt;li&gt;Test driven development&lt;/li&gt;&lt;li&gt;Dependency injection&lt;/li&gt;&lt;li&gt;An IoC Container&lt;/li&gt;&lt;li&gt;Unit testing&lt;/li&gt;&lt;/ul&gt;&lt;/li&gt;&lt;/ul&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&lt;br /&gt;In conclusion, 2010 was a turbulent year for independent game developers: November saw Indie Games hidden under the Specialty Shops as part of the Xbox dashboard &lt;a href="http://www.xbox.com/en-US/Support/SystemUpdates"&gt;update&lt;/a&gt;.  Consequently, developers &lt;a href="http://www.sgtconker.com/2010/11/savetehxblig"&gt;reported&lt;/a&gt; greatly diminished sales and prompted the campaign to &lt;a href="http://vvgtv.com/2010/11/01/hello-world"&gt;Save XBLIG&lt;/a&gt;.&lt;br /&gt;&lt;br /&gt;Fortunately, Microsoft restored Indie Games to the Game Marketplace by the end-of-the-month.&lt;br /&gt;&lt;br /&gt;In fact, December saw the launch of the &lt;a href="http://www.indiegames-uprising.com"&gt;Indie Games Winter Uprising&lt;/a&gt;, in order to improve the quality of games on the channel.  By the end-of-the-year, the Winter Uprising achieved a &lt;a href="http://vvgtv.com/2010/12/28/indie-games-winter-uprising-sets-spotlight-on-dashboard"&gt;spotlight&lt;/a&gt; on the dashboard to further promote Indie Games on Xbox LIVE Marketplace.&lt;br /&gt;&lt;br /&gt;Therefore, year 2011 has the potential to be another significant year for Indie Games.&lt;br /&gt;One final goal, as always: write more game code, write lots more game code &lt;span style='font-family:Wingdings'&gt;J&lt;/span&gt;&lt;span&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;
&lt;/span&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/8584570627780730363-3955233291216747151?l=steveproxna.blogspot.com' alt='' /&gt;&lt;/div&gt;
&lt;p&gt;&lt;a href="http://feedads.g.doubleclick.net/~a/E1YCrrAfe2r62eCjK8xdpfsuEKA/0/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/E1YCrrAfe2r62eCjK8xdpfsuEKA/0/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;br/&gt;
&lt;a href="http://feedads.g.doubleclick.net/~a/E1YCrrAfe2r62eCjK8xdpfsuEKA/1/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/E1YCrrAfe2r62eCjK8xdpfsuEKA/1/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;/p&gt;&lt;img src="http://feeds.feedburner.com/~r/SteveProXNA/~4/aDPD7UOQeyg" height="1" width="1"/&gt;</description><link>http://feedproxy.google.com/~r/SteveProXNA/~3/aDPD7UOQeyg/retrospective-ii.html</link><author>noreply@blogger.com (SteveProXNA)</author><thr:total>1</thr:total><feedburner:origLink>http://steveproxna.blogspot.com/2011/01/retrospective-ii.html</feedburner:origLink></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-8584570627780730363.post-6824748279617060944</guid><pubDate>Sat, 25 Dec 2010 08:03:00 +0000</pubDate><atom:updated>2012-01-01T05:42:07.286-08:00</atom:updated><category domain="http://www.blogger.com/atom/ns#">App Hub</category><title>Show Developers the Money</title><description>&lt;span style="font-family:verdana;font-size:85%;"&gt;In late November 2010, approximately one month after the launch of the &lt;a href="http://create.msdn.com"&gt;App Hub&lt;/a&gt; website, two major criticisms were &lt;a href="http://www.appleinsider.com/articles/10/11/29/windows_phone_7_developers_fear_platform_flop.html"&gt;reported&lt;/a&gt; by the developer community towards the Windows Phone Marketplace:&lt;table width="100%"&gt;&lt;tr&gt;&lt;td valign="top"&gt;&lt;ol&gt;&lt;li&gt;No App Hub store analytics&lt;/li&gt;&lt;li&gt;No payouts until Feb 2011&lt;/li&gt;&lt;/ol&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&lt;u&gt;No App Hub store analytics&lt;/u&gt;&lt;br /&gt;Initially, the App Hub did not provide developers with store analytics to indicate how many titles they had sold.  One potential explanation for the missing functionality related to sales data in the App Hub was:&lt;br /&gt;&lt;i&gt;An intentional effort to avoid any leaks of hard data that may indicate poor sales of Windows Phones 7 devices.&lt;/i&gt;&lt;br /&gt;&lt;br /&gt;
Fortunately, store &lt;a href="https://windowsphone.create.msdn.com/Secure/Dashboard/ReportDashboard.aspx"&gt;analytics &lt;/a&gt; are now available on the App Hub.&lt;br /&gt;In fact, there are two main types of &lt;a href="http://thenextweb.com/microsoft/2010/12/09/microsoft-promises-to-pay-mobile-developers-early-while-boasting-about-wp7-momentum"&gt;reports&lt;/a&gt;:&lt;table width="100%"&gt;
&lt;tr&gt;&lt;td valign="top"&gt;&lt;ol&gt;&lt;li&gt;Graphical view of daily and cumulative downloads plus raw data break-downs&lt;/li&gt;&lt;li&gt;Payout Reports with aggregated and detailed views of Marketplace payouts&lt;/li&gt;&lt;/ol&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&lt;u&gt;No payouts until Feb 2011&lt;/u&gt;
&lt;br /&gt;The App Hub supports quarterly payouts for all sales of Xbox LIVE Indie Games.  The minimun threshold is $150: if this target is not reached within the quarter then all sales are rolled over into the next quarter.&lt;br /&gt;&lt;br /&gt;The App Hub also supported quarterly payouts for all sales of Windows Phone apps upon launch in October 2010.  The minimum threshold is $200, however.  As Microsoft allows up-to-45 days to payout, this meant there would be &lt;a href="http://thenextweb.com/microsoft/2010/11/30/its-true-no-windows-phone-7-developer-payouts-from-microsoft-until-february"&gt;no payouts until Feb 2011&lt;/a&gt;.&lt;br /&gt;&lt;br /&gt;The announcement: no payouts until Feb 2011, prompted much concern from the developer community, 
&lt;a href="http://kenyarmosh.com/early-woes-for-windows-phone-7-developers"&gt;categorizing&lt;/a&gt;: &lt;i&gt;Windows Phone 7 development as a hobby or a learning experience rather than a source of revenue until the App Hub issues are sorted out&lt;/i&gt;.&lt;br /&gt;Hardly the response Microsoft were targeting after spending $500m on the Windows Phone ad campaign!&lt;br /&gt;&lt;br /&gt;Fortunately, there has been an 
&lt;a href="http://thenextweb.com/microsoft/2010/12/09/microsoft-promises-to-pay-mobile-developers-early-while-boasting-about-wp7-momentum"&gt;update&lt;/a&gt;: the first payout will be in Jan 2011 for all sales of Windows Phone apps in Qtr-IV 2010.  After Jan 2011, developer payouts will be processed on a &lt;b&gt;monthly&lt;/b&gt; basis for all sales of Windows Phone apps that meet the minimum payout threshold limit.&lt;br /&gt;&lt;br /&gt;Going forward, there is an opportunity to align monthly payouts for all sales of Xbox LIVE Indie Games.  Another option would be to consolidate monthly sales figures for all platforms: if total sales accumulated across all platforms meet the minimum payout threshold limit then payment should be made.&lt;br /&gt;&lt;br /&gt;&lt;u&gt;Example&lt;/u&gt;&lt;br /&gt;Developer has published two games: one on Windows Phone and one on Xbox LIVE Indie Games:&lt;table width="100%"&gt;&lt;tr&gt;&lt;td valign="top"&gt;&lt;ul&gt;&lt;li&gt;Monthly sales on WP7  Marketplace = $100&lt;/li&gt;&lt;li&gt;Monthly sales on Xbox Marketplace = $100&lt;/li&gt;&lt;/ul&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;Currently, the developer would not be eligible for an end-of-period payout on either platform.&lt;br /&gt;However, if there was an option to consolidate total sales then payment would be made.&lt;br /&gt;&lt;br /&gt;In conclusion, the App Hub does have potential.  In fact, Microsoft has announced &lt;a href="http://www.develop-online.net/news/36459/Over-15k-devs-register-for-Windows-Phone"&gt;over 15,000 developers&lt;/a&gt; have registered for Windows Phone development since the launch. There are also whispers that &lt;a href="http://en.wikipedia.org/wiki/XNA_(Microsoft)"&gt;XNA&lt;/a&gt; will eventually provide &lt;a href="http://www.gamasutra.com/view/news/31685/Microsoft_XNA_Will_Support_Kinect_Eventually.php"&gt;Kinect API support&lt;/a&gt; in the future as well.&lt;br /&gt;&lt;br /&gt;Therefore, there are encouraging signs that should hopefully increase the number of applications and the quality of games available for sale on the App Hub, which in turn, generate more revenue for developers.&lt;/span&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/8584570627780730363-6824748279617060944?l=steveproxna.blogspot.com' alt='' /&gt;&lt;/div&gt;
&lt;p&gt;&lt;a href="http://feedads.g.doubleclick.net/~a/MxvD9a9-2uuMG9jNJwwts9kHRec/0/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/MxvD9a9-2uuMG9jNJwwts9kHRec/0/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;br/&gt;
&lt;a href="http://feedads.g.doubleclick.net/~a/MxvD9a9-2uuMG9jNJwwts9kHRec/1/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/MxvD9a9-2uuMG9jNJwwts9kHRec/1/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;/p&gt;&lt;img src="http://feeds.feedburner.com/~r/SteveProXNA/~4/uGqBl3pPzXc" height="1" width="1"/&gt;</description><link>http://feedproxy.google.com/~r/SteveProXNA/~3/uGqBl3pPzXc/test-blog-post.html</link><author>noreply@blogger.com (SteveProXNA)</author><thr:total>1</thr:total><feedburner:origLink>http://steveproxna.blogspot.com/2010/12/test-blog-post.html</feedburner:origLink></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-8584570627780730363.post-2452827653548375105</guid><pubDate>Wed, 01 Dec 2010 08:47:00 +0000</pubDate><atom:updated>2012-01-01T05:41:20.538-08:00</atom:updated><category domain="http://www.blogger.com/atom/ns#">App Hub</category><title>XNA Creators Club now the App Hub</title><description>&lt;span style="font-family:verdana;font-size:85%;"&gt;In October 2010, Microsoft re-branded the XNA Creators Club website to the &lt;a href="http://create.msdn.com"&gt;App Hub&lt;/a&gt;.  The new website continues to support Xbox LIVE Indie Games as before, but now includes support for Windows Phone development.&lt;br /&gt;&lt;br /&gt;All existing XNA Creators Club memberships have been migrated to App Hub annual subscriptions: they function as before however, independent game developers can now submit "apps", that is, apps and games to the App Hub for sale or free download in the Windows Phone Marketplace.&lt;br /&gt;&lt;br /&gt;Therefore, the focus from Microsoft is now clearly on the Windows Phone.&lt;br /&gt;&lt;br /&gt;All App Hub subscribers must activate their account and complete the following registration tasks:
&lt;a href="http://3.bp.blogspot.com/_Ra2ABd_qklc/TPuwwd0weLI/AAAAAAAABRI/UxU0pnzcQ_I/s1600/AllRegTasks.JPG"&gt;&lt;img style="float:left; margin:0 10px 10px 0;cursor:pointer; cursor:hand;width: 97%; height: 154px;" src="http://3.bp.blogspot.com/_Ra2ABd_qklc/TPuwwd0weLI/AAAAAAAABRI/UxU0pnzcQ_I/s400/AllRegTasks.JPG" border="0" alt=""id="BLOGGER_PHOTO_ID_5547221712723015858" /&gt;&lt;/a&gt;
&lt;br /&gt;&lt;u&gt;Verify your email address&lt;/u&gt;&lt;br /&gt;
Subscribers new to the App Hub will need to &lt;a href="https://users.create.msdn.com/Register"&gt;register&lt;/a&gt; an account to verify email address.  Existing XNA Creators Club members can simply verify email address from the &lt;a href="https://windowsphone.create.msdn.com/app/list"&gt;My Apps&lt;/a&gt; page.
&lt;br /&gt;&lt;br /&gt;&lt;u&gt;Publisher Identity Verification&lt;/u&gt;&lt;br /&gt;Developers require a process to authenticate their identity.  Identification validation is the process to ensure developers within the Windows Phone Marketplace are authentic.  This protects from someone assuming their identity while also maintaining end-user trust.&lt;br /&gt;&lt;br /&gt;
Important: identity validation &lt;b&gt;must&lt;/b&gt; be complete before developers can unlock Windows Phone devices, deploy apps to the phone, and submit to the App Hub for certification testing.&lt;br /&gt;&lt;br /&gt;Microsoft partners with GeoTrust whom provide identity verification services.  On Microsoft's behalf, GeoTrust will contact the developer during the identity validation process.  Developers outside the U.S. are required to complete a GeoTrust form that includes a copy of government issued photo identification and the developer's signature.  Once identity is confirmed, GeoTrust will issue a unique digital certificate; the App Hub uses the digital certificate to sign all applications published by the developer.&lt;br /&gt;&lt;br /&gt;New subscribers to the App Hub should experience smooth transition here: after verifying email address, GeoTrust will contact the developer and begin the Publisher Identity Verification process.&lt;br /&gt;&lt;br /&gt;However, existing XNA Creators Club members may find the Publisher Identity Verification process confusing and frustrating: after verifying email address, the App Hub displays the following message:&lt;br /&gt;
&lt;a href="http://4.bp.blogspot.com/_Ra2ABd_qklc/TPusMcaVm8I/AAAAAAAABQ4/oqOy_07LNdE/s1600/PIV.jpg"&gt;&lt;img style="float:left; margin:0 10px 10px 0;cursor:pointer; cursor:hand;width: 97%; height: 40px;" src="http://4.bp.blogspot.com/_Ra2ABd_qklc/TPusMcaVm8I/AAAAAAAABQ4/oqOy_07LNdE/s400/PIV.jpg" border="0" alt=""id="BLOGGER_PHOTO_ID_5547216695821966274" /&gt;&lt;/a&gt;
This message is misleading and incorrect: as existing XNA Creators Club memberships are migrated to App Hub subscriptions, no new details are sent to GeoTrust.  Therefore, GeoTrust has no knowledge of existing members, thus no contact is made.  Meanwhile, the developer will wait indefinitely for GeoTrust to contact them, as per the App Hub message!&lt;br /&gt;&lt;br /&gt;Fortunately, there is a &lt;a href="http://forums.create.msdn.com/forums/p/65969/403704.aspx#403704"&gt;workaround&lt;/a&gt; this issue for existing XNA Creators Club members:
&lt;table width="100%"&gt;&lt;tr&gt;&lt;td valign="top"&gt;&lt;tr&gt;&lt;td&gt;&lt;ol&gt;&lt;li&gt;Create dummy app&lt;/li&gt;
&lt;li&gt;&lt;a href="https://windowsphone.create.msdn.com/AppSubmission#/Page1Upload"&gt;Submit&lt;/a&gt; dummy app&lt;/li&gt;&lt;li&gt;Upload capabilities&lt;/li&gt;&lt;li&gt;Follow steps: description, artwork, pricing&lt;/li&gt;&lt;li&gt;Before submitting, &lt;b&gt;uncheck&lt;/b&gt; the Automatically Publish to the Marketplace&lt;br /&gt;This will ensure that the dummy app is not published!&lt;/li&gt;&lt;/ol&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;Submitting a dummy app should initiate contact from GeoTrust.  From there, GeoTrust will request documentation from the developer, as required, in order to complete Publisher Identity Verification.&lt;br /&gt;&lt;br /&gt;&lt;u&gt;Unlock your phone&lt;/u&gt;&lt;br /&gt;Once publisher identity verification is complete, Windows Phone device(s) can be unlocked:
&lt;table width="100%"&gt;&lt;tr&gt;&lt;td valign="top"&gt;&lt;tr&gt;&lt;td&gt;&lt;ol&gt;&lt;li&gt;Download and install the latest &lt;a href="http://www.zune.net/en-US/products/software/download/default.htm"&gt;Zune&lt;/a&gt; software&lt;/li&gt;
&lt;li&gt;Connect Windows Phone to the computer&lt;/li&gt;&lt;li&gt;Launch Zune software and synch phone&lt;/li&gt;&lt;li&gt;Start Menu, Programs, Windows Phone Developer Tools, Registration&lt;/li&gt;&lt;li&gt;Enter Windows Live ID, password and click "Register"&lt;/li&gt;&lt;/ol&gt;
&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;Status: Your phone has successfully been registered.&lt;br /&gt;Apps can now be deployed to Windows Phone.&lt;br /&gt;&lt;br /&gt;&lt;u&gt;Eligibility for Payout&lt;/u&gt;&lt;br /&gt;
While this step is not required to unlock the device, developers &lt;b&gt;must&lt;/b&gt; provide bank and tax information&lt;br /&gt;to ensure payment is made from the sales of apps on Windows Phone Marketplace.&lt;br /&gt;&lt;br /&gt;Navigate to &lt;a href="https://users.create.msdn.com/Account/PayeeDetails"&gt;Payee Details&lt;/a&gt;.  For all subscribers, the App Hub currently displays the following message:&lt;br /&gt;
&lt;a href="http://3.bp.blogspot.com/_Ra2ABd_qklc/TPu3NxWW1DI/AAAAAAAABRY/IQpegLXd_Kc/s1600/W8message.jpg"&gt;&lt;img style="float:left; margin:0 10px 10px 0;cursor:pointer; cursor:hand;width: 97%; height: 339px;" src="http://3.bp.blogspot.com/_Ra2ABd_qklc/TPu3NxWW1DI/AAAAAAAABRY/IQpegLXd_Kc/s400/W8message.jpg" border="0" alt=""id="BLOGGER_PHOTO_ID_5547228813250188338" /&gt;&lt;/a&gt;
New subscribers to the App Hub must submit the relevant Form W-8 tax form to Microsoft.&lt;br /&gt;Pls read this &lt;a href="http://steveproxna.blogspot.com/2010/04/xna-and-tax.html"&gt;post&lt;/a&gt; for more information.&lt;br /&gt;&lt;br /&gt;However, existing XNA Creators Club members may find this message very confusing, especially if they have previously submitted Form W-8 and their Xbox LIVE business information &lt;a href="https://payment.create.msdn.com/pii.aspx?lc=1033"&gt;status&lt;/a&gt; is as follows:&lt;br /&gt;"W8 Form processed. Ready to be paid."&lt;br /&gt;&lt;br /&gt;As of the time of this writing, Microsoft has issued the following &lt;a href="http://forums.create.msdn.com/forums/p/62044/396295.aspx#396295"&gt;statement&lt;/a&gt;:&lt;br /&gt;
&lt;a href="http://2.bp.blogspot.com/_Ra2ABd_qklc/TPznGmktd6I/AAAAAAAABR4/kzYgkBkcENY/s1600/W8Confirm.JPG"&gt;&lt;img style="float:left; margin:0 10px 10px 0;cursor:pointer; cursor:hand;width: 97%; height: 84px;" src="http://2.bp.blogspot.com/_Ra2ABd_qklc/TPznGmktd6I/AAAAAAAABR4/kzYgkBkcENY/s400/W8Confirm.JPG" border="0" alt=""id="BLOGGER_PHOTO_ID_5547562941633361826" /&gt;&lt;/a&gt;&lt;br /&gt;
&lt;i&gt;I have confirmed with internal authorities that the commerce mechanisms are now integrated.  You only need to set up the W8 once for your account, and then it will work for all the technologies supported in the App Hub&lt;/i&gt;.&lt;br /&gt;&lt;br /&gt;Also, the bottom of the &lt;a href="https://users.create.msdn.com/Account/PayeeDetails"&gt;Payee Details&lt;/a&gt; page states:
&lt;a href="http://2.bp.blogspot.com/_Ra2ABd_qklc/TPu_s15VwuI/AAAAAAAABRg/dmdDqWGd_BU/s1600/VAT.jpg"&gt;&lt;img style="float:left; margin:0 10px 10px 0;cursor:pointer; cursor:hand;width: 97%; height: 61px;" src="http://2.bp.blogspot.com/_Ra2ABd_qklc/TPu_s15VwuI/AAAAAAAABRg/dmdDqWGd_BU/s400/VAT.jpg" border="0" alt=""id="BLOGGER_PHOTO_ID_5547238143139627746" /&gt;&lt;/a&gt;&lt;br /&gt;This assumes the VAT identification number is optional.  However, developers are currently unable to save their bank and tax information: when the VAT textbox is left blank, the following error is displayed:&lt;br /&gt;&lt;a href="http://4.bp.blogspot.com/_Ra2ABd_qklc/TPvDyq2UxnI/AAAAAAAABRw/xqSSxxq0nKw/s1600/VATerror.jpg"&gt;&lt;img style="float:left; margin:0 10px 10px 0;cursor:pointer; cursor:hand;width: 97%; height: 61px;" src="http://4.bp.blogspot.com/_Ra2ABd_qklc/TPvDyq2UxnI/AAAAAAAABRw/xqSSxxq0nKw/s400/VATerror.jpg" border="0" alt=""id="BLOGGER_PHOTO_ID_5547242641299916402" /&gt;&lt;/a&gt;&lt;br /&gt;
Fortunately, Microsoft has acknowledged this issue and confirmed a &lt;a href="http://forums.create.msdn.com/forums/p/66752/408134.aspx#408134"&gt;fix&lt;/a&gt; in the next update release.&lt;br /&gt;&lt;br /&gt;In conclusion, the App Hub launch has caused much confusion and frustration for developers:&lt;table width="100%"&gt;&lt;tr&gt;&lt;td valign="top"&gt;&lt;tr&gt;&lt;td&gt;&lt;ul&gt;&lt;li&gt;apps cannot be deployed until Publisher Identity Verification is complete&lt;/li&gt;&lt;li&gt;tax status is inconsistent across Windows Phone and Xbox technologies&lt;/li&gt;&lt;li&gt;bank and tax information cannot currently be saved on the website&lt;/li&gt;&lt;/ul&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;Note: to be correct, some developers have reported the ability to &lt;a href="http://forums.create.msdn.com/forums/p/63577/408026.aspx#408026"&gt;hack&lt;/a&gt; bogus VAT identification number in order to successfully save their bank and tax information, although this does not seem appropriate.&lt;br /&gt;&lt;br /&gt;
On a brighter note, there are &lt;a href="http://www.develop-online.net/news/36466/Encouraging-signs-for-games-on-Windows-Phone-7"&gt;encouraging signs for games&lt;/a&gt; on Windows Phone and &lt;a href="http://www.mobile-ent.biz/news/39632/Paid-games-are-a-hit-on-Windows-Phone-7-Marketplace"&gt;paid games are a hit&lt;/a&gt; on the device: games occupy the Top 10 slots in the Windows Phone Marketplace; good news for independent game developers whom wish to publish on both Windows Phone and Xbox platforms.&lt;br /&gt;&lt;br /&gt;
Hopefully the App Hub experience will also improve once these issues have been resolved.&lt;/span&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/8584570627780730363-2452827653548375105?l=steveproxna.blogspot.com' alt='' /&gt;&lt;/div&gt;
&lt;p&gt;&lt;a href="http://feedads.g.doubleclick.net/~a/VGVjJgAUH5EuQh4StkMPfEIZ38g/0/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/VGVjJgAUH5EuQh4StkMPfEIZ38g/0/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;br/&gt;
&lt;a href="http://feedads.g.doubleclick.net/~a/VGVjJgAUH5EuQh4StkMPfEIZ38g/1/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/VGVjJgAUH5EuQh4StkMPfEIZ38g/1/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;/p&gt;&lt;img src="http://feeds.feedburner.com/~r/SteveProXNA/~4/CXhGHPzk27M" height="1" width="1"/&gt;</description><link>http://feedproxy.google.com/~r/SteveProXNA/~3/CXhGHPzk27M/xna-creators-club-now-app-hub.html</link><author>noreply@blogger.com (SteveProXNA)</author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="http://3.bp.blogspot.com/_Ra2ABd_qklc/TPuwwd0weLI/AAAAAAAABRI/UxU0pnzcQ_I/s72-c/AllRegTasks.JPG" height="72" width="72" /><thr:total>2</thr:total><feedburner:origLink>http://steveproxna.blogspot.com/2010/12/xna-creators-club-now-app-hub.html</feedburner:origLink></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-8584570627780730363.post-6235413296848919015</guid><pubDate>Sat, 01 May 2010 15:06:00 +0000</pubDate><atom:updated>2012-01-01T05:39:39.468-08:00</atom:updated><category domain="http://www.blogger.com/atom/ns#">XNA</category><title>Back in Five Minutes</title><description>&lt;span style="font-family:verdana;font-size:85%;"&gt;&lt;a href="http://en.wikipedia.org/wiki/XNA_(Microsoft)"&gt;XNA&lt;/a&gt; is an exciting technology that allows independent game code to be developed and deployed to Windows, Xbox 360, and Zune.&lt;br /&gt;&lt;br /&gt;In 2009, I developed &lt;a href="http://marketplace.xbox.com/en-US/games/media/66acd000-77fe-1000-9115-d802585503d8"&gt;Henway&lt;/a&gt; using XNA.  The game was approved and published on the Indie Games area of Xbox LIVE Marketplace.&lt;br /&gt;&lt;br /&gt;I also setup this &lt;a href="http://steveproxna.blogspot.com/2009_08_01_archive.html"&gt;blog&lt;/a&gt; to highlight some of the issues encountered during XNA game development, potential solutions to these issues, and to provide a general discussion on XNA.&lt;br /&gt;&lt;br /&gt;Here is a quick summary of some of the previous discussions on the site:
&lt;table width="100%"&gt;&lt;tr&gt;&lt;td&gt;&lt;ul&gt;&lt;li&gt;Design patterns: &lt;a href="http://steveproxna.blogspot.com/2009/10/device-factory.html"&gt;Abstract Factory&lt;/a&gt;, &lt;a href="http://steveproxna.blogspot.com/2009/12/command-design-pattern.html"&gt;Command&lt;/a&gt;, &lt;a href="http://steveproxna.blogspot.com/2009/11/state-design-pattern.html"&gt;State&lt;/a&gt;, &lt;a href="http://steveproxna.blogspot.com/2009/12/template-method-design-pattern.html"&gt;Template Method&lt;/a&gt;&lt;li&gt;Performance &lt;a href="http://steveproxna.blogspot.com/2010/02/remote-performance-monitor.html"&gt;monitoring&lt;/a&gt; and &lt;a href="http://steveproxna.blogspot.com/2010_03_01_archive.html"&gt;testing&lt;/a&gt;&lt;li&gt;&lt;a href="http://steveproxna.blogspot.com/2010_04_01_archive.html"&gt;TAX&lt;/a&gt; forms to submit to get paid&lt;li&gt;&lt;a href="http://steveproxna.blogspot.com/2009/12/first-game-publication.html"&gt;Henway&lt;/a&gt; game publication&lt;/ul&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;
XNA is currently at version 3.1, which includes extensions for the &lt;a href="http://www.zune.net/en-us/products/zunehd/default.htm"&gt;Zune HD&lt;/a&gt; device.  However, version 4.0, scheduled for release later in 2010, will be compatible with &lt;a href="http://www.microsoft.com/visualstudio/en-us"&gt;Visual Studio 2010&lt;/a&gt; and &lt;a href="http://en.wikipedia.org/wiki/.NET_Framework#.NET_Framework_4"&gt; .NET Framework 4.0&lt;/a&gt;.&lt;br /&gt;&lt;br /&gt;The big news from Microsoft however, is that &lt;a href="http://creators.xna.com/en-US/article/XNAGameStudio4.0FAQ"&gt;XNA 4.0&lt;/a&gt; will target the &lt;a href="http://www.microsoft.com/windowsmobile/en-us/cmpn/windowsphone7/default.mspx"&gt;Windows Phone 7&lt;/a&gt; mobile device: provide full 3D graphics support and tight integration with Xbox LIVE Marketplace.&lt;br /&gt;&lt;br /&gt;Therefore, independent game code could now target the same &lt;a href="http://marketplace.xbox.com"&gt;marketplace&lt;/a&gt; on both a &lt;a href="http://www.xbox.com"&gt;gaming console&lt;/a&gt; &lt;i&gt;and&lt;/i&gt; &lt;a href="http://www.windowsphone7.com"&gt;mobile device&lt;/a&gt; within a single deployable code base.  &lt;a href="http://creators.xna.com/en-US/article/XNAGameStudio4.0FAQ"&gt;XNA 4.0&lt;/a&gt; could create some very interesting opportunities, difficult to challenge by competitors in the gaming console and mobile device space.&lt;br /&gt;&lt;br /&gt;In conclusion, I would like to take a break from regular monthly blog posts to get more info on &lt;a href="http://creators.xna.com/en-US/article/XNAGameStudio4.0FAQ"&gt;XNA 4.0&lt;/a&gt; and begin working on the next game project.&lt;br /&gt;&lt;br /&gt;If I'm not back in five minutes, just wait longer &lt;span style='font-family:Wingdings'&gt;J&lt;/span&gt;&lt;span&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/8584570627780730363-6235413296848919015?l=steveproxna.blogspot.com' alt='' /&gt;&lt;/div&gt;
&lt;p&gt;&lt;a href="http://feedads.g.doubleclick.net/~a/aC-zbvSDn8RxM6VfvtLTfOBQaYk/0/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/aC-zbvSDn8RxM6VfvtLTfOBQaYk/0/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;br/&gt;
&lt;a href="http://feedads.g.doubleclick.net/~a/aC-zbvSDn8RxM6VfvtLTfOBQaYk/1/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/aC-zbvSDn8RxM6VfvtLTfOBQaYk/1/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;/p&gt;&lt;img src="http://feeds.feedburner.com/~r/SteveProXNA/~4/aQi3NIKR8CM" height="1" width="1"/&gt;</description><link>http://feedproxy.google.com/~r/SteveProXNA/~3/aQi3NIKR8CM/back-in-five-minutes.html</link><author>noreply@blogger.com (SteveProXNA)</author><thr:total>1</thr:total><feedburner:origLink>http://steveproxna.blogspot.com/2010/05/back-in-five-minutes.html</feedburner:origLink></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-8584570627780730363.post-429317641060434333</guid><pubDate>Thu, 01 Apr 2010 08:09:00 +0000</pubDate><atom:updated>2012-01-01T05:36:52.517-08:00</atom:updated><category domain="http://www.blogger.com/atom/ns#">XNA</category><title>XNA and TAX</title><description>&lt;span style="font-family:verdana;font-size:85%;"&gt;Once your game has been approved and published on Xbox LIVE Marketplace, it will be available for sale to all regions that can purchase Xbox LIVE Indie Games.&lt;br /&gt;&lt;br /&gt;All download history and purchase information can be found in the &lt;a href="https://profile.xna.com/en-US/mybusiness.aspx"&gt;My Business&lt;/a&gt; section of the 
&lt;a href="http://creators.xna.com/en-US/"&gt;XNA Creators Club&lt;/a&gt; web site.  However, in order to get paid, you will need to submit your personal and tax information.&lt;br /&gt;&lt;br /&gt;If you are an independent game developer and a non-U.S. based creator then the task of processing your personal and tax information can be very challenging.  Therefore, this blog post attempts to shed some light on the process, and ensure payment is made from the sales of Xbox LIVE Indie Games.&lt;br /&gt;&lt;br /&gt;Note: I am not a tax advisor; pls do not read the following as defacto or proven advice.&lt;br /&gt;&lt;br /&gt;&lt;u&gt;Process&lt;/u&gt;&lt;br /&gt;In order to get paid, creators must enter their personal and banking information on the &lt;a href="http://creators.xna.com/en-US/"&gt;XNA Creators Club&lt;/a&gt; web site and submit the relevant Form W-8 tax form to Microsoft.&lt;br /&gt;&lt;br /&gt;Note: there are four types of W-8 forms available on the 
&lt;a href="http://www.irs.gov/"&gt;Internal Revenue Service&lt;/a&gt; (IRS) web site;&lt;br /&gt;&lt;a href="http://www.irs.gov/pub/irs-pdf/fw8ben.pdf"&gt;Form W-8BEN&lt;/a&gt; is the most frequently submitted form: I will refer to this as Form W-8 from now on.&lt;br /&gt;&lt;br /&gt;Independent game developers who are non-U.S. based creators, may be eligible for a reduction or exemption from U.S. income tax on their revenue, provided their country has a tax treaty with the U.S.&lt;br /&gt;If this is the case, then you may be able to take advantage, providing you have a relevant &lt;a href="http://www.irs.gov/individuals/article/0,,id=96287,00.html"&gt;Individual Taxpayer Identification Number&lt;/a&gt; (ITIN) and submit a properly completed treaty claim on &lt;a href="http://www.irs.gov/pub/irs-pdf/fw8ben.pdf"&gt;Form W-8&lt;/a&gt;.&lt;br /&gt;&lt;br /&gt;It appears this is the most difficult and confusing part of the tax process for independent game developers who are not based in the U.S.:&lt;table width="100%"&gt;&lt;tr&gt;&lt;td valign="top"&gt;&lt;ol&gt;&lt;li&gt;You must determine if your country has a tax treaty with the U.S., and&lt;li&gt;You must decide if you would like to take advantage of the tax treaty&lt;/ol&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&lt;u&gt;Determine if your country has a tax treaty with the U.S.&lt;/u&gt;&lt;br /&gt;Navigate to the &lt;a href="http://www.irs.gov/businesses/international/article/0,,id=96739,00.html"&gt;United States Income Tax Treaties&lt;/a&gt; page on the IRS web site.  If your country is listed then your country has a tax treaty with the U.S.&lt;br /&gt;&lt;br /&gt;&lt;u&gt;Decide if you would like to take advantage of the tax treaty&lt;/u&gt;
&lt;br /&gt;If your country has a tax treaty with the U.S. then you may like to take advantage in order to claim a reduction in U.S. income tax.  Therefore, you must apply for an &lt;a href="http://www.irs.gov/individuals/article/0,,id=96287,00.html"&gt;ITIN&lt;/a&gt; and submit a properly completed &lt;a href="http://www.irs.gov/pub/irs-pdf/fw7.pdf"&gt;Form W-7&lt;/a&gt; to the IRS.&lt;br /&gt;&lt;br /&gt;Note: an ITIN is not strictly required to get paid, although without it you will be subject to an automatic 30% U.S. tax withholding, even if your country provides a lower rate of U.S. taxation.&lt;br /&gt;&lt;br /&gt;Important: the process of applying for an ITIN alone can take weeks / months and it is easy for the ITIN application to be rejected by the IRS if Form W-7 is not completed perfectly.&lt;br /&gt;&lt;br /&gt;To summarize, in order to get paid, you must complete the following tasks:&lt;table width="100%"&gt;&lt;tr&gt;&lt;td valign="top"&gt;&lt;ol&gt;&lt;li&gt;Enter your personal and banking information&lt;li&gt;Submit the relevant tax form(s)&lt;/ol&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&lt;u&gt;Enter your personal and banking information&lt;/u&gt;&lt;table width="100%"&gt;&lt;tr&gt;&lt;td valign="top"&gt;&lt;ol&gt;&lt;li&gt;Login to the &lt;a href="http://creators.xna.com/en-US/"&gt;XNA Creators Club&lt;/a&gt; web site&lt;li&gt;Navigate to the &lt;a href="https://profile.xna.com/en-US/mybusiness.aspx"&gt;My Business&lt;/a&gt; section
&lt;li&gt;Click the link to &lt;a href="https://payment.xna.com/pii.aspx?lc=1033"&gt;Personal and Tax Information&lt;/a&gt;&lt;li&gt;Enter all relevant personal information&lt;li&gt;Enter all relevant banking information&lt;li&gt;Confirm&lt;/ol&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;When you enter your personal information, you have the option to agree to the 30% U.S. tax withholding:&lt;br /&gt;
&lt;a href="http://2.bp.blogspot.com/_Ra2ABd_qklc/S7TyMHnDyhI/AAAAAAAABGY/ndmtyCLQFjY/s1600/ThirtyPercent.jpg"&gt;&lt;img style="float:left; margin:0 10px 10px 0;cursor:pointer; cursor:hand;width: 97%; height: 86px;" src="http://2.bp.blogspot.com/_Ra2ABd_qklc/S7TyMHnDyhI/AAAAAAAABGY/ndmtyCLQFjY/s400/ThirtyPercent.jpg" border="0" alt=""id="BLOGGER_PHOTO_ID_5455251338667739666" /&gt;&lt;/a&gt;
If your country does not have a tax treaty with the U.S., or you decide not to take advantage of the tax treaty, then leave U.S. Tax Identifier blank and check the box.  If / when you have obtained an ITIN, you can enter this as the U.S. Tax Identifier and leave the box unchecked accordingly.&lt;br /&gt;&lt;br /&gt;After entering your personal and banking details, a confirmation panel similar to the following will appear:&lt;br /&gt;
&lt;a href="http://4.bp.blogspot.com/_Ra2ABd_qklc/S7Tzco5njTI/AAAAAAAABGg/OGdNL_Kn1qQ/s1600/W-8BEN.jpg"&gt;&lt;img style="float:left; margin:0 10px 10px 0;cursor:pointer; cursor:hand;width: 97%; height: 254px;" src="http://4.bp.blogspot.com/_Ra2ABd_qklc/S7Tzco5njTI/AAAAAAAABGg/OGdNL_Kn1qQ/s400/W-8BEN.jpg" border="0" alt=""id="BLOGGER_PHOTO_ID_5455252721993485618" /&gt;&lt;/a&gt;
The panel states you will now need to submit a physical copy of your &lt;a href="http://www.irs.gov/pub/irs-pdf/fw8ben.pdf"&gt;Form W-8&lt;/a&gt; tax form to Microsoft.&lt;br /&gt;The panel may also state which particular Form W-8 tax form you need to send, e.g. Form W-8BEN.&lt;br /&gt;&lt;br /&gt;&lt;u&gt;Submit the relevant tax form(s)&lt;/u&gt;&lt;br /&gt;When you submit the relevant tax form(s), you have 3x options available:&lt;table width="100%"&gt;&lt;tr&gt;&lt;td valign="top"&gt;&lt;ol&gt;&lt;li&gt;Option&lt;ul&gt;&lt;li&gt;Submit Form W-8 without ITIN&lt;/li&gt;&lt;/ul&gt;&lt;/li&gt;&lt;li&gt;Option&lt;ul&gt;&lt;li&gt;Submit Form W-7 to obtain ITIN&lt;/li&gt; &lt;li&gt;Submit Form W-8 with ITIN&lt;/li&gt;&lt;/ul&gt;&lt;/li&gt;&lt;li&gt;Option&lt;ul&gt;&lt;li&gt;Submit Form W-8 without ITIN&lt;/li&gt;&lt;li&gt;Submit Form W-7 to obtain ITIN&lt;/li&gt;&lt;li&gt;Submit Form W-8 with ITIN&lt;/li&gt;&lt;/ul&gt;&lt;/li&gt;&lt;/ol&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&lt;u&gt;Submit Form W-8 without ITIN&lt;/u&gt;&lt;br /&gt;Option 1: you cannot claim a tax treaty with the U.S or you choose not to take advantage of the tax treaty because the effort to obtain an ITIN is too time consuming, too difficult, or you cannot wait.&lt;br /&gt;&lt;br /&gt;Complete Form W-8 as per the &lt;a href="http://www.irs.gov/pub/irs-pdf/iw8ben.pdf"&gt;instructions&lt;/a&gt;.  There is also an informative &lt;a href="http://forums.xna.com/forums/p/35973/237245.aspx#237245"&gt;post&lt;/a&gt; on the XNA Creators Club web site:&lt;table width="100%"&gt;&lt;tr&gt;&lt;td valign="top"&gt;&lt;ol&gt;&lt;li&gt;Simply complete Part I, III and IV
&lt;li&gt;Check 3. Type of beneficial owner as &lt;i&gt;Individual&lt;/i&gt;&lt;li&gt;Leave 6. U.S. taxpayer identification number blank&lt;li&gt;&lt;b&gt;Do not complete Part II&lt;/b&gt; as you are not claiming a tax treaty benefit&lt;/ol&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;Send &lt;a href="http://www.irs.gov/pub/irs-pdf/fw8ben.pdf"&gt;Form W-8&lt;/a&gt; to:&lt;br /&gt; Microsoft&lt;br /&gt; Attn: Finance Department,&lt;br /&gt; 29011 Commerce Center Drive,&lt;br /&gt; Valencia, CA 91355&lt;br /&gt; USA&lt;br /&gt;&lt;br /&gt;&lt;u&gt;Submit Form W-7 to obtain ITIN / Submit Form W-8 with ITIN&lt;/u&gt;&lt;br /&gt;Option 2: your country has a tax treaty with the U.S. and you would like to take advantage in order to claim a reduction in U.S. income tax.&lt;br /&gt;&lt;br /&gt;Download and print the &lt;b&gt;latest&lt;/b&gt; &lt;a href="http://www.irs.gov/pub/irs-pdf/fw7.pdf"&gt;Form W-7&lt;/a&gt;.  Follow the 
&lt;a href="http://www.irs.gov/pub/irs-pdf/iw7.pdf"&gt;instructions&lt;/a&gt; carefully (recommended).&lt;br /&gt;Remember: if Form W-7 is not completed perfectly then your ITIN application will be rejected by the IRS.&lt;br /&gt;&lt;br /&gt;&lt;u&gt;Form W-7&lt;/u&gt;&lt;br /&gt;
As an independent game developer, you will be claiming royalty income from Microsoft.  Therefore, a good example on how to complete Form W-7 can be found on Pg. 27 of &lt;a href="http://www.irs.gov/pub/irs-pdf/p1915.pdf"&gt;IRS Publication 1915&lt;/a&gt;:&lt;br /&gt;
&lt;a href="http://4.bp.blogspot.com/_Ra2ABd_qklc/S7WlAPo0pLI/AAAAAAAABGo/mvXXfkuGh-g/s1600/Royalty.JPG"&gt;&lt;img style="float:left; margin:0 10px 10px 0;cursor:pointer; cursor:hand;width: 97%; height: 122px;" src="http://4.bp.blogspot.com/_Ra2ABd_qklc/S7WlAPo0pLI/AAAAAAAABGo/mvXXfkuGh-g/s400/Royalty.JPG" border="0" alt=""id="BLOGGER_PHOTO_ID_5455447947245561010" /&gt;&lt;/a&gt;
When you check box (a). Nonresident alien required to obtain ITIN to claim tax treaty benefit with a foreign country, also check box (h).  Enter "Exception 1(d) – Royalty Income" on the dotted line next to box (h).  Also, enter treaty country, which is your country of residence, and treaty article number &lt;b&gt;12&lt;/b&gt;.&lt;br /&gt;&lt;br /&gt;Note: to confirm the correct treaty article number:&lt;table width="100%"&gt;&lt;tr&gt;&lt;td valign="top"&gt;&lt;ol&gt;&lt;li&gt;Navigate to &lt;a href="http://www.irs.gov/businesses/international/article/0,,id=96739,00.html"&gt;United States Income Tax Treaties&lt;/a&gt;&lt;li&gt;Click your country link e.g. &lt;a href="http://www.irs.gov/businesses/international/article/0,,id=169529,00.html"&gt;Ireland&lt;/a&gt;&lt;li&gt;Click the &lt;a href="http://www.irs.gov/pub/irs-trty/ireland.pdf"&gt;Income Tax Treaty&lt;/a&gt; link &lt;li&gt;Search for "Royalties" in the Table of Articles; it should be Article &lt;b&gt;12&lt;/b&gt;&lt;/ol&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;
Important: Form W-7 line instructions state "Enter N/A (not applicable) on all lines that do not apply to you.  &lt;b&gt;Do not&lt;/b&gt; leave any lines blank".  Also remember all dates must be month / day / year format.&lt;br /&gt;&lt;br /&gt;Documentation: as Microsoft is the withholding agent, you will need to complete and attach the following &lt;a href="http://creators.xna.com/downloads/?id=233"&gt;letter&lt;/a&gt;.  You will also need to send identification document(s).  If you submit an original valid passport (or a notarized or certified copy of a valid passport), then you do not need to submit any other documents.&lt;br /&gt;&lt;br /&gt;Send &lt;a href="http://www.irs.gov/pub/irs-pdf/fw7.pdf"&gt;Form W-7&lt;/a&gt;, letter from Microsoft, and proof of identity to:&lt;br /&gt; Internal Revenue Service&lt;br /&gt; Austin Service Center&lt;br /&gt; ITIN Operation&lt;br /&gt; P.O.Box 149342&lt;br /&gt; Austin, TX 78714-9342&lt;br /&gt; USA&lt;br /&gt;&lt;br /&gt;
Once you obtain an ITIN, you can now complete &lt;a href="http://www.irs.gov/pub/irs-pdf/fw8ben.pdf"&gt;Form W-8&lt;/a&gt; as per option 1.  However, this time enter your ITIN on line 6. U.S. taxpayer identification number and check box SSN or ITIN accordingly.&lt;br /&gt;&lt;br /&gt;
You must also complete &lt;b&gt;Part II&lt;/b&gt; Claim of Tax Treaty Benefits:  Check box (a). and enter your country on the dotted line.  Also, check box (b) as the U.S. taxpayer identification number is stated on line 6.&lt;br /&gt;&lt;br /&gt;Finally, on line 10. &lt;b&gt;Special rates and conditions&lt;/b&gt;, there is an informative &lt;a href="http://forums.xna.com/forums/t/28456.aspx"&gt;post&lt;/a&gt; on the XNA Creators Club web site (&lt;i&gt;excerpt&lt;/i&gt;):&lt;br /&gt;The beneficial owner is claiming the provisions of Article &lt;b&gt;12&lt;/b&gt; of the treaty identified on line 9a above to claim a &lt;b&gt;0&lt;/b&gt;% rate of withholding on (specify type of income): &lt;b&gt;Royalties&lt;/b&gt;.  Explain the reason the beneficial owner meets the terms of the treaty article: &lt;b&gt;I am a XXXX citizen and resident of XXXX receiving royalties from U.S. source&lt;/b&gt;.&lt;br /&gt;&lt;br /&gt;Send &lt;a href="http://www.irs.gov/pub/irs-pdf/fw8ben.pdf"&gt;Form W-8&lt;/a&gt; to:&lt;br /&gt; Microsoft&lt;br /&gt; Attn: Finance Department,&lt;br /&gt; 29011 Commerce Center Drive,&lt;br /&gt; Valencia, CA 91355&lt;br /&gt; USA&lt;br /&gt;&lt;br /&gt;&lt;u&gt;Submit Form W-8 without ITIN / Submit Form W-7 to obtain ITIN / Submit Form W-8 with ITIN&lt;/u&gt;&lt;br /&gt;Option 3: although you can claim a tax treaty benefit, you would like to get paid immediately:  Submit &lt;a href="http://www.irs.gov/pub/irs-pdf/fw8ben.pdf"&gt;Form W-8&lt;/a&gt; without ITIN as per option 1. and ensure payment is made from the sales of Xbox LIVE Indie Games.&lt;br /&gt;&lt;br /&gt;Next, submit &lt;a href="http://www.irs.gov/pub/irs-pdf/fw7.pdf"&gt;Form W-7&lt;/a&gt; to obtain ITIN as per option 2.  While you ITIN application is being processed, or if your ITIN application is rejected and you need to start over, you will still continue to get paid regardless.  When your ITIN is approved, submit &lt;a href="http://www.irs.gov/pub/irs-pdf/fw8ben.pdf"&gt;Form W-8&lt;/a&gt; with ITIN as per option 2.&lt;br /&gt;&lt;br /&gt;&lt;u&gt;Option 4&lt;/u&gt;&lt;br /&gt;Finally, if you are new to XNA game development, there may be one other option worth considering:  submit &lt;a href="http://www.irs.gov/pub/irs-pdf/fw7.pdf"&gt;Form W-7&lt;/a&gt; immediately.  By the time your game is published you would (hopefully) have obtained the ITIN.&lt;br /&gt;&lt;br /&gt;Therefore, you could enter your personal and banking information on the &lt;a href="http://creators.xna.com/en-US/"&gt;XNA Creators Club&lt;/a&gt; web site: Enter the ITIN as the U.S. Tax Identifier, leave the 30% U.S. tax withholding box unchecked, and submit &lt;a href="http://www.irs.gov/pub/irs-pdf/fw8ben.pdf"&gt;Form W-8&lt;/a&gt; with ITIN from the outset.&lt;/span&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/8584570627780730363-429317641060434333?l=steveproxna.blogspot.com' alt='' /&gt;&lt;/div&gt;
&lt;p&gt;&lt;a href="http://feedads.g.doubleclick.net/~a/zptmkhkYTjZwp5AUJYBRQE1QfoE/0/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/zptmkhkYTjZwp5AUJYBRQE1QfoE/0/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;br/&gt;
&lt;a href="http://feedads.g.doubleclick.net/~a/zptmkhkYTjZwp5AUJYBRQE1QfoE/1/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/zptmkhkYTjZwp5AUJYBRQE1QfoE/1/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;/p&gt;&lt;img src="http://feeds.feedburner.com/~r/SteveProXNA/~4/3lZucJctGnQ" height="1" width="1"/&gt;</description><link>http://feedproxy.google.com/~r/SteveProXNA/~3/3lZucJctGnQ/xna-and-tax.html</link><author>noreply@blogger.com (SteveProXNA)</author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="http://2.bp.blogspot.com/_Ra2ABd_qklc/S7TyMHnDyhI/AAAAAAAABGY/ndmtyCLQFjY/s72-c/ThirtyPercent.jpg" height="72" width="72" /><thr:total>5</thr:total><feedburner:origLink>http://steveproxna.blogspot.com/2010/04/xna-and-tax.html</feedburner:origLink></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-8584570627780730363.post-1315229252040477856</guid><pubDate>Mon, 01 Mar 2010 09:49:00 +0000</pubDate><atom:updated>2010-07-17T07:16:57.015-07:00</atom:updated><category domain="http://www.blogger.com/atom/ns#">Performance</category><title>Remote Performance Monitor II</title><description>&lt;span style="font-family:verdana;font-size:85%;"&gt;In the previous &lt;a href="http://steveproxna.blogspot.com/2010/02/remote-performance-monitor.html"&gt;post&lt;/a&gt;, we began a discussion on the XNA Framework &lt;a href="http://msdn.microsoft.com/en-us/library/bb975830.aspx"&gt;Remote Performance Monitor&lt;/a&gt;.  To recap, the Remote Performance Monitor exposes 2x common game code scenarios that unnecessarily generate garbage on the XNA platform:&lt;ol&gt;&lt;li&gt;Unnecessary string object creation&lt;li&gt;Unnecessary boxed value types&lt;/ol&gt;In the previous post, we discussed the first scenario: Unnecessary string object creation.  Now, let's complete this discussion with the second scenario: Unnecessary boxed value types.&lt;br /&gt;&lt;br /&gt;&lt;u&gt;Unnecessary boxed value types&lt;/u&gt;&lt;br /&gt;In a typical game, there are often enemies to kill, obstacles to avoid, gems to collect etc.  Usually game code stores, for example, a list of enemy sprites to kill, in one collection variable:
&lt;pre class="csharp" name="code"&gt;
IList&amp;lt;Sprite&amp;gt; Enemies { get; set; }
&lt;/pre&gt;
During game play, game code may need to iterate through the list of enemy sprites every single frame to invoke the Update() and/or Draw() methods accordingly.  In .NET, iterating through an IList&amp;lt;T&amp;gt; can typically be done either using the &lt;i&gt;for&lt;/i&gt; statement or the &lt;i&gt;foreach&lt;/i&gt;.&lt;br /&gt;&lt;br /&gt;&lt;a href="http://www.microsoft.com/downloads/details.aspx?displaylang=en&amp;FamilyID=B0332FAA-A3CA-4051-AFB2-9BA8206D61AF"&gt;Code Optimization Demos&lt;/a&gt; measure the performance of the &lt;i&gt;for&lt;/i&gt; statement compared to the &lt;i&gt;foreach&lt;/i&gt;: the &lt;i&gt;for&lt;/i&gt; statement is generally more performant although the &lt;i&gt;foreach&lt;/i&gt; statement provides better readability in code.  However, if used incorrectly, the &lt;i&gt;foreach&lt;/i&gt; statement can unnecessarily generate garbage, impact performance and potentially drop frames.&lt;br /&gt;&lt;br /&gt;Let's check out an example using the &lt;i&gt;foreach&lt;/i&gt; statement in more detail.&lt;br /&gt;Consider the following Sprite class:
&lt;pre class="csharp" name="code"&gt;
public class Sprite()
{
 public Sprite()  {}  // ctor.
 public void Update(GameTime gameTime) {}
 public void Draw(GameTime gameTime) {}
}
&lt;/pre&gt;
As above, game code may store, for example, a list of enemy sprites to kill, in one collection variable and construct the collection accordingly:
&lt;pre class="csharp" name="code"&gt;
IList&amp;lt;Sprite&amp;gt; Enemies { get; set; }
Enemies = new List&amp;lt;Sprite&amp;gt;();
&lt;/pre&gt;
During game play, game code may iterate through the list of enemy sprites and update each sprite accordingly:
&lt;pre class="csharp" name="code"&gt;
public void Update(GameTime gameTime)
{
 foreach (Sprite Enemy in Enemies)
 {
  Enemy.Update();
 }
}
&lt;/pre&gt;
The previous game code snippet may seem harmless enough, however, the Remote Performance Monitor reveals a single managed object allocated on the heap and a single value type is boxed every single frame.  When game code executes this Update() method at 60fps then 60x value types are boxed every second:&lt;br /&gt;&lt;a href="http://1.bp.blogspot.com/_Ra2ABd_qklc/S5Fyen-nINI/AAAAAAAABF4/HFIGpeiNzeU/s1600-h/IListForEach.jpg"&gt;&lt;img style="float:left; margin:0 10px 10px 0;cursor:pointer; cursor:hand;width: 97%; height: 394px;" src="http://1.bp.blogspot.com/_Ra2ABd_qklc/S5Fyen-nINI/AAAAAAAABF4/HFIGpeiNzeU/s400/IListForEach.jpg" border="0" alt=""id="BLOGGER_PHOTO_ID_5445259294920876242" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;What happened?  Why is this simple game code snippet generating so much garbage?&lt;br /&gt;&lt;br /&gt;The problem begins with our collection variable declaration: 
the collection is declared as an IList&amp;lt;T&amp;gt; but game code actually constructs a new List&amp;lt;T&amp;gt;.
&lt;pre class="csharp" name="code"&gt;
IList&amp;lt;Sprite&amp;gt; Enemies { get; set; }
Enemies = new List&amp;lt;Sprite&amp;gt;();
&lt;/pre&gt;
The problem then manifests itself with the &lt;i&gt;foreach&lt;/i&gt; statement: the &lt;i&gt;foreach&lt;/i&gt; statement requires an enumerator to iterate through each enemy sprite in the list.
&lt;pre class="csharp" name="code"&gt;
foreach (Sprite Enemy in Enemies)
{
 Enemy.Update();
}
&lt;/pre&gt;
In .NET, both List&amp;lt;T&amp;gt; and IList&amp;lt;T&amp;gt; implement the IEnumerable&amp;lt;T&amp;gt; interface.  The IEnumerable&amp;lt;T&amp;gt; interface has one method: GetEnumerator(), which returns the enumerator required to iterate through each object in the list.&lt;br /&gt;&lt;br /&gt;However, the implementation of the GetEnumerator() method differs between List&amp;lt;T&amp;gt; and IList&amp;lt;T&amp;gt;: List&amp;lt;T&amp;gt; GetEnumerator() method returns Enumerator&amp;lt;T&amp;gt;, which is a struct: a value type stored on the stack.  Whereas IList&amp;lt;T&amp;gt; GetEnumerator() method returns IEnumerator&amp;lt;T&amp;gt;, which is an interface, a reference type stored on the heap.&lt;br /&gt;&lt;br /&gt;Therefore the previous game code snippet initially returns an Enumerator&amp;lt;T&amp;gt;, as a value type for the List&amp;lt;T&amp;gt;, but then boxes the enumerator value type to a reference type because the collection is actually declared as an IList&amp;lt;T&amp;gt;!&lt;br /&gt;&lt;br /&gt;Therefore, there are 2x potential solutions to resolve this issue with Unnecessary boxed value types:&lt;ol&gt;&lt;li&gt;Update the collection variable declaration to List&amp;lt;T&amp;gt;&lt;li&gt;Replace &lt;i&gt;foreach&lt;/i&gt; with the &lt;i&gt;for&lt;/i&gt; statement altogether&lt;/ol&gt;&lt;br /&gt;The first solution simply updates the collection variable declaration thus no boxing will be necessary:
&lt;pre class="csharp" name="code"&gt;
List&amp;lt;Sprite&amp;gt; Enemies { get; set; }
Enemies = new List&amp;lt;Sprite&amp;gt;();

foreach (Sprite Enemy in Enemies)
{
 Enemy.Update();
}
&lt;/pre&gt;
The second solution simply replaces the &lt;i&gt;foreach&lt;/i&gt; with the &lt;i&gt;for&lt;/i&gt; statement thus no enumerator will be required:
&lt;pre class="csharp" name="code"&gt;
IList&amp;lt;Sprite&amp;gt; Enemies { get; set; }
Enemies = new List&amp;lt;Sprite&amp;gt;();

for (Int32 index = 0; index &lt; Enemies.Length; index++)
{
 Enemies[index].Update();
}
&lt;/pre&gt;
Either way, the results in the Remote Performance Monitor are the same:&lt;br /&gt;&lt;a href="http://2.bp.blogspot.com/_Ra2ABd_qklc/S2nTf92LQ1I/AAAAAAAABCA/wbAIGYhzkxM/s1600-h/Strings02.jpg"&gt;&lt;img style="float:left; margin:0 10px 10px 0;cursor:pointer; cursor:hand;width: 97%; height: 371px;" src="http://2.bp.blogspot.com/_Ra2ABd_qklc/S2nTf92LQ1I/AAAAAAAABCA/wbAIGYhzkxM/s400/Strings02.jpg" border="0" alt=""id="BLOGGER_PHOTO_ID_5434106971530412882" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;To summarize, when using an object in which Enumerator&amp;lt;T&amp;gt; is a value type, like List&amp;lt;T&amp;gt;, game code can employ either the &lt;i&gt;foreach&lt;/i&gt; or &lt;i&gt;for&lt;/i&gt; statement and not generate garbage.  When using an object in which IEnumerator&amp;lt;T&amp;gt; is a reference type, like IList&amp;lt;T&amp;gt;, the &lt;i&gt;foreach&lt;/i&gt; statement may generate garbage whereas the &lt;i&gt;for&lt;/i&gt; statement will not.&lt;br /&gt;&lt;br /&gt;In conclusion, the XNA Framework Remote Performance Monitor a simple tool to detect if game code is generating garbage on the XNA platform.  Typically, there are 3x static statistics that require the most attention during performance testing:&lt;ul&gt;&lt;li&gt;Managed String Objects Allocated&lt;li&gt;Managed Objects Allocated&lt;li&gt;Boxed Value Types&lt;/ul&gt;However, there is also one final statistic that is important to monitor: "Exceptions Thrown".  In a perfect game, the "Delta" column in the Remote Performance Monitor will be zero at all times.&lt;/span&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/8584570627780730363-1315229252040477856?l=steveproxna.blogspot.com' alt='' /&gt;&lt;/div&gt;
&lt;p&gt;&lt;a href="http://feedads.g.doubleclick.net/~a/XSLoC35NQK2bg_p1ugF9iuXS_bM/0/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/XSLoC35NQK2bg_p1ugF9iuXS_bM/0/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;br/&gt;
&lt;a href="http://feedads.g.doubleclick.net/~a/XSLoC35NQK2bg_p1ugF9iuXS_bM/1/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/XSLoC35NQK2bg_p1ugF9iuXS_bM/1/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;/p&gt;&lt;img src="http://feeds.feedburner.com/~r/SteveProXNA/~4/iZIy5giV-GU" height="1" width="1"/&gt;</description><link>http://feedproxy.google.com/~r/SteveProXNA/~3/iZIy5giV-GU/remote-performance-monitor-ii.html</link><author>noreply@blogger.com (SteveProXNA)</author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="http://1.bp.blogspot.com/_Ra2ABd_qklc/S5Fyen-nINI/AAAAAAAABF4/HFIGpeiNzeU/s72-c/IListForEach.jpg" height="72" width="72" /><thr:total>0</thr:total><feedburner:origLink>http://steveproxna.blogspot.com/2010/03/remote-performance-monitor-ii.html</feedburner:origLink></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-8584570627780730363.post-3631505467161266410</guid><pubDate>Mon, 01 Feb 2010 08:55:00 +0000</pubDate><atom:updated>2010-07-17T07:16:18.073-07:00</atom:updated><category domain="http://www.blogger.com/atom/ns#">Performance</category><title>Remote Performance Monitor</title><description>&lt;span style="font-family:verdana;font-size:85%;"&gt;Performance is critical in game development.  In XNA, game performance will degrade if you allow garbage to be generated during game play.  On Xbox 360, generating too much garbage will force full garbage collection.  If garbage collection takes longer than 1/60th of a second then the game will drop frames, and the more frequently full garbage collection occurs, the more frequently the game will drop frames.&lt;br /&gt;&lt;br /&gt;The XNA Framework &lt;a href="http://msdn.microsoft.com/en-us/library/bb975830.aspx"&gt;Remote Performance Monitor&lt;/a&gt; is a simple tool that can detect if game code is generating too much garbage.  Here is a common work flow to game development and performance testing using the Remote Performance Monitor:&lt;ul&gt;&lt;li&gt;Write game code on Windows&lt;li&gt;Test game play on Windows&lt;li&gt;Deploy game code to Xbox 360&lt;li&gt;Launch Remote Performance Monitor&lt;li&gt;Start game from Remote Performance Monitor&lt;li&gt;Monitor performance results&lt;li&gt;Resolve performance issues as necessary&lt;li&gt;Repeat process&lt;/ul&gt;&lt;br /&gt;&lt;a href="http://msdn.microsoft.com/en-us/library/bb198208.aspx"&gt;Here&lt;/a&gt; is a quick tutorial on how to use the XNA Framework Remote Performance Monitor if you have never used the tool before.&lt;br /&gt;&lt;br /&gt;There is a large source of information available on the Internet, in the form of blog posts, audio casts, articles and white papers that gives detailed analysis on &lt;i&gt;all&lt;/i&gt; the statistics generated from the Remote Performance Monitor; from Pinned Objects to Platform Invoke Calls.&lt;br /&gt;&lt;br /&gt;However, in my experience, there are typically 3x statistics that require the most attention during performance testing:&lt;ul&gt;&lt;li&gt;Managed String Objects Allocated&lt;li&gt;Managed Objects Allocated&lt;li&gt;Boxed Value Types&lt;/ul&gt;&lt;br /&gt;
Ideally, the goal is to have the "Delta" column in the Remote Performance Monitor for these 3x statistics consistently set to zero during game play:&lt;br /&gt;
&lt;a href="http://2.bp.blogspot.com/_Ra2ABd_qklc/S2nTf92LQ1I/AAAAAAAABCA/wbAIGYhzkxM/s1600-h/Strings02.jpg"&gt;&lt;img style="float:left; margin:0 10px 10px 0;cursor:pointer; cursor:hand;width: 97%; height: 371px;" src="http://2.bp.blogspot.com/_Ra2ABd_qklc/S2nTf92LQ1I/AAAAAAAABCA/wbAIGYhzkxM/s400/Strings02.jpg" border="0" alt=""id="BLOGGER_PHOTO_ID_5434106971530412882" /&gt;&lt;/a&gt;This ensures game code does not unnecessarily generate garbage, force full collections and drop frames.&lt;br /&gt;&lt;br /&gt;Unfortunately, during game development on the XNA platform, there appears to be 2x common game code scenarios that cause the "Delta" column in the Remote Performance Monitor to be consistently set to values greater than zero during game play:&lt;ol&gt;&lt;li&gt;Unnecessary string object creation&lt;li&gt;Unnecessary boxed value types&lt;/ol&gt;&lt;br /&gt;Each scenario reveals game code that consistently generates too much garbage, impacts performance and has the potential to drop frames.&lt;br /&gt;&lt;br /&gt;Let's check out each scenario in greater detail:&lt;br /&gt;&lt;br /&gt;&lt;u&gt;Unnecessary String Object Creation&lt;/u&gt;&lt;br /&gt;In a typical game, there is often a lot of numeric data that must be displayed on screen to the player, for example: score, hi score, level, lives, bonus etc.  Consequently, there are numerous game code snippets similar to the following:
&lt;pre class="csharp" name="code"&gt;
public void Draw()
{
 spriteBatch.DrawString(spriteFont, score.ToString(), position, color);
}
&lt;/pre&gt;
Each time game code executes score.ToString(), the .NET Framework will allocate a single managed string object on the heap.  When game code executes score.ToString() unconditionally at 60fps then 60x additional managed string objects will be allocated accordingly every second:&lt;br /&gt;
&lt;a href="http://1.bp.blogspot.com/_Ra2ABd_qklc/S2nTPg9PZMI/AAAAAAAABB4/Yxblih_HI3A/s1600-h/Strings01.jpg"&gt;&lt;img style="float:left; margin:0 10px 10px 0;cursor:pointer; cursor:hand;width: 97%; height: 390px;" src="http://1.bp.blogspot.com/_Ra2ABd_qklc/S2nTPg9PZMI/AAAAAAAABB4/Yxblih_HI3A/s400/Strings01.jpg" border="0" alt=""id="BLOGGER_PHOTO_ID_5434106688897508546" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;However, there is no reason for game code to execute score.ToString() unconditionally every single frame.&lt;br /&gt;&lt;br /&gt;A better approach would be to create 2x variables: one variable to store the integer score value and another variable to store the equivalent string representation of the score:
&lt;pre class="csharp" name="code"&gt;
private Int32 scoreValue;
private String scoreText;
&lt;/pre&gt;
Now game code would only be required to execute score.ToString() when the score actually changed:
&lt;pre class="csharp" name="code"&gt;
public void Update()
{
 if (playerKilledSomething)
 {
  scoreValue += 100;
  scoreText = scoreValue.ToString();
 }
}
public void Draw()
{
 spriteBatch.DrawString(spriteFont, scoreText, position, color);
}
&lt;/pre&gt;
During a standard frame, in which the score value will not change, the "Delta" column in the Remote Performance Monitor for Managed String Objects Allocated will now be set to zero as no garbage generation occurs:&lt;br /&gt;
&lt;a href="http://2.bp.blogspot.com/_Ra2ABd_qklc/S2nTf92LQ1I/AAAAAAAABCA/wbAIGYhzkxM/s1600-h/Strings02.jpg"&gt;&lt;img style="float:left; margin:0 10px 10px 0;cursor:pointer; cursor:hand;width: 97%; height: 371px;" src="http://2.bp.blogspot.com/_Ra2ABd_qklc/S2nTf92LQ1I/AAAAAAAABCA/wbAIGYhzkxM/s400/Strings02.jpg" border="0" alt=""id="BLOGGER_PHOTO_ID_5434106971530412882" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;This simple approach to avoid unnecessary string creation may seem obvious, but it is surprising how many times the following game code can be found in Production:
&lt;pre class="csharp" name="code"&gt;
public void Draw()
{
 spriteBatch.DrawString(spriteFont1, score.ToString(), position1, color1);
 spriteBatch.DrawString(spriteFont2, hiScore.ToString(), position2, color2);
 spriteBatch.DrawString(spriteFont3, level.ToString(), position3, color3);
 spriteBatch.DrawString(spriteFont4, lives.ToString(), position4, color4);
 spriteBatch.DrawString(spriteFont5, bonus.ToString(), position5, color5);
 // continue draw method...
}
&lt;/pre&gt;
In the next &lt;a href="http://steveproxna.blogspot.com/2010/03/remote-performance-monitor-ii.html"&gt;post&lt;/a&gt;, we will continue this discussion on the Remote Performance Monitor with unnecessary boxed value types.&lt;/span&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/8584570627780730363-3631505467161266410?l=steveproxna.blogspot.com' alt='' /&gt;&lt;/div&gt;
&lt;p&gt;&lt;a href="http://feedads.g.doubleclick.net/~a/R2rbVlRG7csVtza_KuQ-rF855-E/0/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/R2rbVlRG7csVtza_KuQ-rF855-E/0/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;br/&gt;
&lt;a href="http://feedads.g.doubleclick.net/~a/R2rbVlRG7csVtza_KuQ-rF855-E/1/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/R2rbVlRG7csVtza_KuQ-rF855-E/1/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;/p&gt;&lt;img src="http://feeds.feedburner.com/~r/SteveProXNA/~4/sROmJIPdQzs" height="1" width="1"/&gt;</description><link>http://feedproxy.google.com/~r/SteveProXNA/~3/sROmJIPdQzs/remote-performance-monitor.html</link><author>noreply@blogger.com (SteveProXNA)</author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="http://2.bp.blogspot.com/_Ra2ABd_qklc/S2nTf92LQ1I/AAAAAAAABCA/wbAIGYhzkxM/s72-c/Strings02.jpg" height="72" width="72" /><thr:total>0</thr:total><feedburner:origLink>http://steveproxna.blogspot.com/2010/02/remote-performance-monitor.html</feedburner:origLink></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-8584570627780730363.post-1311129216528538725</guid><pubDate>Fri, 01 Jan 2010 08:53:00 +0000</pubDate><atom:updated>2010-07-17T07:15:38.030-07:00</atom:updated><category domain="http://www.blogger.com/atom/ns#">Agile</category><title>Retrospective</title><description>&lt;span style="font-family:verdana;font-size:85%;"&gt;Happy New Year!  The company that I currently work for operates an agile software development process and employs &lt;a href="http://en.wikipedia.org/wiki/Scrum_(development)"&gt;SCRUM&lt;/a&gt; as an iterative incremental framework for managing complex work.&lt;br /&gt;&lt;br /&gt;At the end of each &lt;a href="http://en.wikipedia.org/wiki/Sprint_(software_development)"&gt;Sprint&lt;/a&gt; cycle our team holds a &lt;a href="http://en.wikipedia.org/wiki/Retrospective#Software_development"&gt;Retrospective&lt;/a&gt; to:&lt;ul&gt;&lt;li&gt;make continuous improvements to the development process&lt;li&gt;reflect on the previous sprint&lt;li&gt;set goals for the next sprint&lt;/ul&gt;Therefore, I thought I would conduct a simple XNA retrospective for 2009 and set goals for 2010.&lt;br /&gt;&lt;br /&gt;&lt;u&gt;2009 Achievements&lt;/u&gt;&lt;br /&gt;&lt;table width="100%"&gt;&lt;tr&gt;&lt;td valign="top"&gt;&lt;ul&gt;&lt;li&gt;Complete &lt;a href="http://www.amazon.com/Game-Programming-Recipes-Problem-Solution-Professionals/dp/159059925X/ref=pd_sim_b_1"&gt;XNA 2.0&lt;/a&gt; book&lt;li&gt;Complete &lt;a href="http://www.amazon.com/Learning-XNA-3-0-Game-Development/dp/0596521952/ref=sr_1_1?ie=UTF8&amp;s=books&amp;qid=1262163479&amp;sr=8-1"&gt;XNA 3.0&lt;/a&gt; book&lt;li&gt;Buy &lt;a href="http://www.amazon.com/Zune-120-Video-Player-Black/dp/B001EQ0HAW"&gt;Zune&lt;/a&gt; 2nd gen. 120 Gb&lt;li&gt;Buy &lt;a href="http://www.amazon.com/Zune-Video-MP3-Player-Platinum/dp/B002JPITY8/ref=sr_1_1?ie=UTF8&amp;s=electronics&amp;qid=1262163561&amp;sr=8-1"&gt;Zune HD&lt;/a&gt; 32Gb Platinum&lt;li&gt;Upgrade &lt;a href="http://www.microsoft.com/downloads/details.aspx?FamilyID=48f7ba37-8ba7-4d16-8873-0b7f83ef77f9&amp;displaylang=en"&gt;XNA Game Studio&lt;/a&gt; 3.1 Zune Extensions&lt;li&gt;Give XNA presentation&lt;li&gt;Setup XNA &lt;a href="http://steveproxna.blogspot.com/"&gt;blog&lt;/a&gt; with monthly posts&lt;li&gt;Publish &lt;a href="http://marketplace.xbox.com/en-US/games/media/66acd000-77fe-1000-9115-d802585503d8"&gt;Henway&lt;/a&gt; XBox LIVE Indie Game&lt;/ul&gt;Note: purchasing and configuring Zune device outside United States is an achievement!&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&lt;br /&gt;&lt;u&gt;2010 Objectives&lt;/u&gt;&lt;br /&gt;&lt;table width="100%"&gt;&lt;tr&gt;&lt;td valign="top"&gt;XNA general development&lt;/td&gt;&lt;td valign="top"&gt;XNA 3.1 development&lt;/td&gt;&lt;td valign="top"&gt;ZUNE development&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td valign="top"&gt;&lt;ul&gt;&lt;li&gt;3D graphics&lt;li&gt;Networking&lt;li&gt;Unit tests&lt;li&gt;Mocking&lt;li&gt;Physics&lt;/ul&gt;&lt;/td&gt;&lt;td valign="top"&gt;&lt;ul&gt;&lt;li&gt;Avatar personalization&lt;li&gt;Xbox LIVE Party&lt;li&gt;Video support&lt;/ul&gt;&lt;/td&gt;&lt;td valign="top"&gt;&lt;ul&gt;&lt;li&gt;Accelerometer&lt;li&gt;Touch panel&lt;li&gt;3D graphics&lt;/ul&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;One final goal is to become more active in the &lt;a href="http://creators.xna.com/en-US/"&gt;XNA Creators Club&lt;/a&gt;: contribute more in the forums and participate more in the playtest and review process.&lt;/span&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/8584570627780730363-1311129216528538725?l=steveproxna.blogspot.com' alt='' /&gt;&lt;/div&gt;
&lt;p&gt;&lt;a href="http://feedads.g.doubleclick.net/~a/msoXIPj0zPTKs5BVQbN5f4GpqEo/0/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/msoXIPj0zPTKs5BVQbN5f4GpqEo/0/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;br/&gt;
&lt;a href="http://feedads.g.doubleclick.net/~a/msoXIPj0zPTKs5BVQbN5f4GpqEo/1/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/msoXIPj0zPTKs5BVQbN5f4GpqEo/1/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;/p&gt;&lt;img src="http://feeds.feedburner.com/~r/SteveProXNA/~4/6udFIUQ-WFM" height="1" width="1"/&gt;</description><link>http://feedproxy.google.com/~r/SteveProXNA/~3/6udFIUQ-WFM/retrospective.html</link><author>noreply@blogger.com (SteveProXNA)</author><thr:total>0</thr:total><feedburner:origLink>http://steveproxna.blogspot.com/2010/01/retrospective.html</feedburner:origLink></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-8584570627780730363.post-3445910747090091094</guid><pubDate>Fri, 25 Dec 2009 17:14:00 +0000</pubDate><atom:updated>2010-07-17T07:15:00.332-07:00</atom:updated><category domain="http://www.blogger.com/atom/ns#">Game</category><title>First Game Publication</title><description>&lt;span style="font-family:verdana;font-size:85%;"&gt;Season's Greetings!  This year, I received a nice gift to complete 2009: the game I recently completed, &lt;a href="http://marketplace.xbox.com/en-US/games/media/66acd000-77fe-1000-9115-d802585503d8"&gt;Henway&lt;/a&gt;, was approved and published on the Indie Games area of Xbox LIVE Marketplace.&lt;br /&gt;&lt;br /&gt;&lt;a href="http://marketplace.xbox.com/en-US/games/media/66acd000-77fe-1000-9115-d802585503d8"&gt;&lt;img style="float:left; margin:0 10px 10px 0;cursor:pointer; cursor:hand;width: 146px; height: 200px;" src="http://1.bp.blogspot.com/_Ra2ABd_qklc/SzUVINGZIoI/AAAAAAAABA4/vOiy4uf_sy4/s200/Henway.jpg" border="0" alt=""id="BLOGGER_PHOTO_ID_5419260957309870722" /&gt;&lt;/a&gt;Henway: &lt;i&gt;The goal is to cross the road without being killed; hence this game is based on real life&lt;/i&gt;.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;During playtest and review, the feedback received on the &lt;a href="http://creators.xna.com"&gt;XNA Creators Club&lt;/a&gt; was really positive and there were plenty of great ideas posted by fellow creators on the site.&lt;br /&gt;&lt;br /&gt;Note: creators must have a &lt;a href="http://creators.xna.com/en-US/membership"&gt;Premium Membership&lt;/a&gt; before they can playtest and review Indie Games.&lt;br /&gt;&lt;br /&gt;Here is a quick summary of features and updates that could potentially be added in a future release:&lt;ul&gt;&lt;li&gt;add more vehicles: trucks, buses, cyclists, motorcycles, tractors, emergency&lt;li&gt;add variety of squelching noises when the chicken gets run down&lt;li&gt;pause game when batteries removed from controller&lt;li&gt;use Xbox button images for quit and error popups
&lt;li&gt;add exhaust particles for some of the vehicles&lt;li&gt;disable sign in guide when saving&lt;li&gt;disable the continue option&lt;/ul&gt;&lt;/span&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/8584570627780730363-3445910747090091094?l=steveproxna.blogspot.com' alt='' /&gt;&lt;/div&gt;
&lt;p&gt;&lt;a href="http://feedads.g.doubleclick.net/~a/9a52pVZCHxxjDr34w326VLmnST4/0/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/9a52pVZCHxxjDr34w326VLmnST4/0/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;br/&gt;
&lt;a href="http://feedads.g.doubleclick.net/~a/9a52pVZCHxxjDr34w326VLmnST4/1/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/9a52pVZCHxxjDr34w326VLmnST4/1/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;/p&gt;&lt;img src="http://feeds.feedburner.com/~r/SteveProXNA/~4/_AqgocNcOcg" height="1" width="1"/&gt;</description><link>http://feedproxy.google.com/~r/SteveProXNA/~3/_AqgocNcOcg/first-game-publication.html</link><author>noreply@blogger.com (SteveProXNA)</author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="http://1.bp.blogspot.com/_Ra2ABd_qklc/SzUVINGZIoI/AAAAAAAABA4/vOiy4uf_sy4/s72-c/Henway.jpg" height="72" width="72" /><thr:total>0</thr:total><feedburner:origLink>http://steveproxna.blogspot.com/2009/12/first-game-publication.html</feedburner:origLink></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-8584570627780730363.post-5211510617399620919</guid><pubDate>Tue, 15 Dec 2009 08:21:00 +0000</pubDate><atom:updated>2010-07-17T07:14:27.666-07:00</atom:updated><category domain="http://www.blogger.com/atom/ns#">Design</category><title>Template Method Design Pattern</title><description>&lt;span style="font-family:verdana;font-size:85%;"&gt;In XNA, the Update() and Draw() methods are invoked, by default, 60 frames per second.  During each frame, a general algorithm for both the Update() and Draw() methods could be applied in game code as follows:&lt;br /&gt;&lt;br /&gt;&lt;table width="100%"&gt;&lt;tr&gt;&lt;td&gt;Update Algorithm&lt;/td&gt;&lt;td&gt;Draw Algorithm&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td&gt;&lt;ul&gt;&lt;li&gt;update input&lt;li&gt;update objects&lt;li&gt;update HUD (&lt;i&gt;heads up display&lt;/i&gt;)&lt;/ul&gt;&lt;/td&gt;&lt;td&gt;&lt;ul&gt;&lt;li&gt;draw background&lt;li&gt;draw objects&lt;li&gt;draw HUD (&lt;i&gt;heads up display&lt;/i&gt;)&lt;/ul&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&lt;br /&gt;Here we have defined a template for both the Update() and Draw() methods.  A template is a method that defines an algorithm as a set of steps.  One or more of these steps can be implemented by the main game code, or deferred to a subclass where appropriate.  This ensures that the structure of the algorithm stays the same, while subclasses can provide some part of the implementation as required.&lt;br /&gt;&lt;br /&gt;By definition, the &lt;a href="http://www.dofactory.com/Patterns/PatternTemplate.aspx"&gt;Template Method&lt;/a&gt; design pattern defines the skeleton of an algorithm in an operation, deferring some steps to subclasses.   Template Method lets subclasses redefine certain steps of an algorithm without changing the algorithm's structure.&lt;br /&gt;&lt;br /&gt;Let’s complete the discussion with a simple code sample.&lt;br /&gt;&lt;br /&gt;First, create the skeleton of an algorithm for both the Update() and Draw() methods in the main game code:
&lt;pre class="csharp" name="code"&gt;
// Template method for Update.
public void Update(Microsoft.Xna.Framework.GameTime gameTime)
{
 if (IsActive)
 {
  return;
 }

 UpdateInput(gameTime); 
 UpdateObjects(gameTime);
 UpdateHUD(gameTime);
}

// Template method for Draw.
public void Draw(Microsoft.Xna.Framework.GameTime gameTime)
{
 if (IsActive)
 {
  return;
 }

 DrawBackground(); 
 DrawObjects();
 DrawHUD();
}
&lt;/pre&gt;
Next, create the steps to be implemented by the template methods in the main game code:
&lt;pre class="csharp" name="code"&gt;
public virtual void UpdateInput(GameTime gameTime) {}
public virtual void UpdateObjects(GameTime gameTime) {}
public virtual void UpdateHUD(GameTime gameTime) {}

public virtual void DrawBackground() {}
public virtual void DrawObjects() {}
public virtual void DrawHUD() {}
&lt;/pre&gt;
As this is a simple example, none of the steps will be deferred to subclasses; each step would execute the same game code each frame.&lt;br /&gt;&lt;br /&gt;However, the Template Method can be used in conjunction with the &lt;a href="http://steveproxna.blogspot.com/2009/11/state-design-pattern.html"&gt;State&lt;/a&gt; design pattern to redefine certain steps of the algorithm without changing the algorithm’s structure.&lt;br /&gt;&lt;br /&gt;First, define an interface to be implemented by all game state objects.  This interface contains all actions that each game state object will implement.  In our example, the 2x actions Update() and Draw(), are now defined as template methods; this ensures that the structure of the Update() and Draw() algorithms stays the same while subclasses can provide some part of the implementation as required:
&lt;pre class="csharp" name="code"&gt;
public class AbstractGameState
{   
 protected readonly Game game;   
  
 protected AbstractGameState(Game game)   
 {   
  this.game = game;   
 }   
 public void Update(GameTime gameTime)
 {
  if (IsActive)
  {
   return;
  }

 UpdateInput(gameTime); 
 UpdateObjects(gameTime);
 UpdateHUD(gameTime);
}

public void Draw(Microsoft.Xna.Framework.GameTime gameTime)
{
 if (IsActive)
 {
  return;
 }

 DrawBackground(); 
 DrawObjects();
 DrawHUD();
}
&lt;/pre&gt;
Next, construct one concrete implementation class for each state in the game.  Each step in both the Update() and Draw() template methods can now be deferred to the concrete implementation class as required.&lt;br /&gt;&lt;br /&gt;For example, imagine the Splash Screen game state concrete implementation class is responsible for detecting the Start button press and displaying the splash screen only:
&lt;pre class="csharp" name="code"&gt;
public class SplashScreenState : AbstractGameState
{
 public override void UpdateInput(GameTime gameTime)
 {
  // Detect player press Start button.
 }

 public override void DrawHUD (GameTime gameTime)
 {
  // Draw splash screen
 }
}
&lt;/pre&gt;
Note: the remaining steps in both the Update() and Draw() template methods are invoked automatically by the algorithms contained in the base game state class.&lt;br /&gt;&lt;br /&gt; To summarize, the Template Method design pattern offers algorithm encapsulation so that subclasses can hook themselves right into a computation anytime they want.
&lt;/span&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/8584570627780730363-5211510617399620919?l=steveproxna.blogspot.com' alt='' /&gt;&lt;/div&gt;
&lt;p&gt;&lt;a href="http://feedads.g.doubleclick.net/~a/grB6cKNMeySZSk_aApIjWUlF7Vg/0/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/grB6cKNMeySZSk_aApIjWUlF7Vg/0/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;br/&gt;
&lt;a href="http://feedads.g.doubleclick.net/~a/grB6cKNMeySZSk_aApIjWUlF7Vg/1/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/grB6cKNMeySZSk_aApIjWUlF7Vg/1/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;/p&gt;&lt;img src="http://feeds.feedburner.com/~r/SteveProXNA/~4/wpbIG1KWgGs" height="1" width="1"/&gt;</description><link>http://feedproxy.google.com/~r/SteveProXNA/~3/wpbIG1KWgGs/template-method-design-pattern.html</link><author>noreply@blogger.com (SteveProXNA)</author><thr:total>0</thr:total><feedburner:origLink>http://steveproxna.blogspot.com/2009/12/template-method-design-pattern.html</feedburner:origLink></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-8584570627780730363.post-762115125544441830</guid><pubDate>Tue, 01 Dec 2009 08:58:00 +0000</pubDate><atom:updated>2010-07-17T07:13:51.696-07:00</atom:updated><category domain="http://www.blogger.com/atom/ns#">Design</category><title>Command Design Pattern</title><description>&lt;span style="font-family:verdana;font-size:85%;"&gt;The &lt;a href="http://www.dofactory.com/Patterns/PatternCommand.aspx"&gt;Command&lt;/a&gt; design pattern encapsulates a command request as an object.  In game code, an example of a command request could be a simple move command: e.g. move sprite left, right, up, down.&lt;br /&gt;&lt;br /&gt;The Command design pattern is used to express a command request, including the method call and all of its required parameters, into a command object.  The command object may then be executed immediately, queued for later use or reused to support undoable actions.&lt;br /&gt;&lt;br /&gt;Note: the command object does not contain the functionality that is to be executed; only the information required to perform an action.  The functionality is contained within a &lt;i&gt;receiver&lt;/i&gt; object.  This removes the direct link between the command object and the functionality to promote loose coupling.  Finally, neither the command object nor the receiver is responsible for determining the execution of the command request; this is controlled using an &lt;i&gt;invoker&lt;/i&gt;.&lt;br /&gt;&lt;br /&gt;In our move sprite example above, the move command object encapsulates the method invocation to update the position of the sprite.  The receiver object is the sprite itself.  The invoker is input detection from the player’s controller to determine the execution of the move command request.&lt;br /&gt;&lt;br /&gt;Initially, the thought of using the Command design pattern to move a sprite seems overkill.  In game code, this can easily be accomplished using the following excerpt:
&lt;pre class="csharp" name="code"&gt;
protected override void Update(Microsoft.Xna.Framework.GameTime gameTime)
{
 Single velocityX = GamePad.GetState(PlayerIndex.One).ThumbSticks.Left.X;
 Single velocityY = GamePad.GetState(PlayerIndex.One).ThumbSticks.Left.Y;
 if (velocityX == 0 &amp;&amp; velocityY == 0)  
 {  
  return;  
 }  

 sprite.Velocity = new Vector2(velocityX, velocityY);
 sprite.Update();
}
&lt;/pre&gt;
However, by implementing the Command design pattern to move a sprite we are now able to record each move command, add to a list of move command objects, and persist to playback at a later time.  This can be useful, for example, to implement a demo mode in a game.  In fact, this is exactly how the game &lt;a href="http://www.youtube.com/watch?v=1rjvB6k7rsc"&gt;Henway&lt;/a&gt; employs a demo mode in the title screen.  Let’s check it out:&lt;br /&gt;&lt;br /&gt;First, define an interface to be implemented by each command object.  Typically, this interface contains a single Execute() method but can be extended to support Undo() operations:
&lt;pre class="csharp" name="code"&gt;
public interface ICommand
{
 void Execute();
}
&lt;/pre&gt;
Next, construct a concrete implementation class for each command object in the game.  In our example there is simply one command object: MoveCommand.
&lt;pre class="csharp" name="code"&gt;
public struct MoveCommand : ICommand
{
 private readonly Sprite sprite;
 private readonly Vector2 velocity;

 public MoveCommand(Sprite sprite, Vector2 velocity): this()
 {
  this.sprite = sprite;
  this.velocity = velocity;
 }

 public void Execute()
 {
  sprite.Velocity = velocity;
  sprite.Update();
 }
}
&lt;/pre&gt;
Next, construct a list of command objects.  This list will record each command object as it’s created in game code and will be used to playback at a later time.
&lt;pre class="csharp" name="code"&gt;
public IList&amp;lt;ICommand&amp;gt; CommandsSave { get; set; }
&lt;/pre&gt;
Note: you will also need to construct a list of integers that record the number of frames that elapse between each command object being recorded; this is required for playback mode.
&lt;pre class="csharp" name="code"&gt;
public IList&amp;lt;Int32&amp;gt; CommandsDelta { get; set; }
&lt;/pre&gt;
Next, update the main game class Update() method: replace the &lt;i&gt;simple&lt;/i&gt; sprite update above with game code that now:&lt;ul&gt;&lt;li&gt;constructs a new command object;&lt;li&gt; sets all required parameters;&lt;li&gt;executes the command;&lt;li&gt;records the command for later use;&lt;/ul&gt;
&lt;pre class="csharp" name="code"&gt;
protected override void Update(Microsoft.Xna.Framework.GameTime gameTime)
{
 updateFrame++;
   
 Single velocityX = GamePad.GetState(PlayerIndex.One).ThumbSticks.Left.X;
 Single velocityY = GamePad.GetState(PlayerIndex.One).ThumbSticks.Left.Y;
 if (velocityX == 0 &amp;&amp; velocityY == 0)
 {
  return;
 }

 Vector2 velocity = new Vector2(velocityX, velocityY);
 ICommand command = new MoveCommand(sprite, velocity);
 command.Execute();

 CommandsSave.Add(command);
 CommandsDelta.Add(updateFrame);

 updateFrame = 0;
}
&lt;/pre&gt;
Finally, after all command objects have been recorded through the revised Update() method, the list of frame deltas and the list of command objects can be formatted and saved:
&lt;pre class="csharp" name="code"&gt;
private void SaveCommands()
{
 for (Int32 index = 0; index &lt; CommandsSave.Count; index++)
 {
  Int32 frame = CommandsDelta[index];

  MoveCommand command = CommandsSave[index];
  Single velocityX = ((MoveCommand)command).Velocity.X;
  Single velocityY = ((MoveCommand)command).Velocity.Y;

  String format = String.Format("{0},{1},{2}",
   frame,
   velocityX,
   velocityY,
   );

  // Persist command object data.
 }
}
&lt;/pre&gt;
Now the list of frame deltas and the list of command objects can be loaded at a later time, for example, during the title screen:
&lt;pre class="csharp" name="code"&gt;
public ICommand[] Commands;
public Int32[] Frames;

private void LoadCommands()
{
 IList&amp;lt;String&amp;gt; lines = GetCommandData();

 Int32 maxCommand = lines.Count;
 Commands = new ICommand[maxCommand];
 Frames = new Int32[maxCommand];

 for (Int32 index = 0; index &lt; maxCommand; index++)
 {
  String line = lines[index];
  String[] values = line.Split(new[] { ',' });

  Frames [index] = Convert.ToInt32(values[0]);

  Single velocityX = Convert.ToSingle(values[1]);
  Single velocityY = Convert.ToSingle(values[2]);
  Vector2 velocity = new Vector2(velocityX, velocityY);

  Commands[index] = new MoveCommand(sprite, velocity);
 } 
}
&lt;/pre&gt;
And the list of frame deltas and the list of command objects can be played back as a demo mode:
&lt;pre class="csharp" name="code"&gt;
private Int32 frame = 0;
private Int32 index = 0;
private Int32 maxCommand = Commands.GetLength(0);

protected override void Update(Microsoft.Xna.Framework.GameTime gameTime)
{
 frame++;
 if (frame &gt;= Frames[index])
 {
  frame = 0;
  Commands[index].Execute();

  index++;
  if (index &gt;= maxCommand)
  {
   // All commands executed – stop playback.
  }
 }  
}
&lt;/pre&gt;
To summarize, the Command design pattern can be very useful in game development: by encapsulating method invocation, game code can crystallize pieces of computation so that the object invoking the computation doesn’t need to worry about how to do things; it just uses the crystallized method to get its work done.
&lt;/span&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/8584570627780730363-762115125544441830?l=steveproxna.blogspot.com' alt='' /&gt;&lt;/div&gt;
&lt;p&gt;&lt;a href="http://feedads.g.doubleclick.net/~a/3Yd2r7Qw1gY7rb1BCoYK2SuX20U/0/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/3Yd2r7Qw1gY7rb1BCoYK2SuX20U/0/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;br/&gt;
&lt;a href="http://feedads.g.doubleclick.net/~a/3Yd2r7Qw1gY7rb1BCoYK2SuX20U/1/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/3Yd2r7Qw1gY7rb1BCoYK2SuX20U/1/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;/p&gt;&lt;img src="http://feeds.feedburner.com/~r/SteveProXNA/~4/Zp0EMpdznJM" height="1" width="1"/&gt;</description><link>http://feedproxy.google.com/~r/SteveProXNA/~3/Zp0EMpdznJM/command-design-pattern.html</link><author>noreply@blogger.com (SteveProXNA)</author><thr:total>0</thr:total><feedburner:origLink>http://steveproxna.blogspot.com/2009/12/command-design-pattern.html</feedburner:origLink></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-8584570627780730363.post-9168263145414539557</guid><pubDate>Sun, 01 Nov 2009 08:56:00 +0000</pubDate><atom:updated>2010-07-17T07:12:10.186-07:00</atom:updated><category domain="http://www.blogger.com/atom/ns#">Design</category><title>State Design Pattern</title><description>&lt;span style="font-family:verdana;font-size:85%;"&gt;During its lifecycle, each game will transition through many states, for example: splash screen, title, introduction, menus, instructions, options, game play, level complete, death sequence, game over, hi scores etc&lt;br /&gt;&lt;br /&gt;Consequently, there should be an easy mechanism to transition from one game state to another in game code.  A typical approach is to construct a custom enum type in game code and set one entry for each game state:
&lt;pre class="csharp" name="code"&gt;
public enum GameState
{
 SplashScreen,
 Title,
 Introduction,
 Menus,
 Instructions,
 Options,
 GamePlay,
 LevelComplete,
 DeathSequence,
 GameOver,
 HiScores
}
&lt;/pre&gt;
Therefore the game can execute state specific code depending on the current state of the custom enum type at each particular frame.&lt;br /&gt;&lt;br /&gt;A simple example of this approach can be demonstrated in Microsoft's Mini Game &lt;a href="http://creators.xna.com/en-US/minigame/catapult"&gt;Catapult&lt;/a&gt;.  This game contains 6x states which are stored in a custom enum type, &lt;i&gt;CatapultState&lt;/i&gt;, in game code:
&lt;pre class="csharp" name="code"&gt;
public enum CatapultState 
{ 
    Rolling, 
    Firing, 
    Crash, 
    ProjectileFlying, 
    ProjectileHit,
    Reset
}
&lt;/pre&gt;
Unfortunately, the logic to execute state specific code in the Update() and Draw() methods is wrapped in a long if-elseif-else code block:
&lt;pre class="csharp" name="code"&gt;
private CatapultState currentState;

if (currentState == CatapultState.Rolling)
{
}
else if (currentState == CatapultState.Firing)
{
}
else if (currentState == CatapultState.Crash)
{
}
else if (currentState == CatapultState.ProjectileFlying)
{
}
else if (currentState == CatapultState.ProjectileHit)
{
}
else if (currentState == CatapultState.Reset)
{
}
&lt;/pre&gt;
Game code that contains multiple if-elseif-else statements throughout the code base like this becomes cumbersome and error prone.  Also, this approach does not scale: if 7x, 8x, 9x etc states were added to the game then this approach would become unwieldly and difficult to manage.&lt;br /&gt;&lt;br /&gt;A cleaner approach would be to implement the &lt;a href="http://www.dofactory.com/Patterns/PatternState.aspx"&gt;State&lt;/a&gt; design pattern.  The State design pattern allows an object, in this case our game, to alter its behavior when its internal state changes.  The object will appear to change its class.&lt;br /&gt;&lt;br /&gt;In the &lt;a href="http://creators.xna.com/en-US/minigame/catapult"&gt;Catapult&lt;/a&gt; example, we would like to localize the behavior of each state into its own class.&lt;br /&gt;&lt;br /&gt;First, define an interface to be implemented by all game state objects.  This interface contains all actions that each game state object will implement.  In our example there are 2x actions, Update() and Draw():
&lt;pre class="csharp" name="code"&gt;
public abstract class AbstractGameState
{
 protected readonly Game game;

 protected AbstractGameState(Game game)
 {
  this.game = game;
 }
 public virtual void Update(Microsoft.Xna.Framework.GameTime gameTime)
 {
  // Update code common to every state.
 }
 public virtual void Draw(Microsoft.Xna.Framework.GameTime gameTime)
 {
  // Draw code common to every state.
 }
}
&lt;/pre&gt;   
Next, construct one concrete implementation class for each state in the game.  In our example there are 6x game state objects, thus one for each state:
&lt;pre class="csharp" name="code"&gt;
public class RollingState : AbstractGameState
{
 // Rolling state specific code.
 public RollingState(Game game) : base(game) {}
 public override void Update(Microsoft.Xna.Framework.GameTime gameTime) {}
 public override void Draw(Microsoft.Xna.Framework.GameTime gameTime) {}
}
public class FiringState : AbstractGameState
{
 // Firing state specific code.
 public FiringState(Game game) : base(game) {}
 public override void Update(Microsoft.Xna.Framework.GameTime gameTime) {}
 public override void Draw(Microsoft.Xna.Framework.GameTime gameTime) {}
}
public class CrashState : AbstractGameState
{
 // Crash state specific code.
 public CrashState(Game game) : base(game) {}
 public override void Update(Microsoft.Xna.Framework.GameTime gameTime) {}
 public override void Draw(Microsoft.Xna.Framework.GameTime gameTime) {}
}
public class ProjectileFlyingState : AbstractGameState
{
 // ProjectileFlying state specific code.
 public ProjectileFlyingState(Game game) : base(game) {}
 public override void Update(Microsoft.Xna.Framework.GameTime gameTime) {}
 public override void Draw(Microsoft.Xna.Framework.GameTime gameTime) {}
}
public class ProjectileHitState : AbstractGameState
{
 // ProjectileHit state specific code.
 public ProjectileHitState(Game game) : base(game) {}
 public override void Update(Microsoft.Xna.Framework.GameTime gameTime) {}
 public override void Draw(Microsoft.Xna.Framework.GameTime gameTime) {}
}
public class ResetState : AbstractGameState
{
 // Reset state specific code.
 public ResetState(Game game) : base(game) {}
 public override void Update(Microsoft.Xna.Framework.GameTime gameTime) {}
 public override void Draw(Microsoft.Xna.Framework.GameTime gameTime) {}
}
&lt;/pre&gt;
Note: state specific code is now localized to each game state object instead of being embedded in a long if-elseif-else code block.&lt;br /&gt;&lt;br /&gt;Next, we construct a custom enum type as before:
&lt;pre class="csharp" name="code"&gt;
public enum CatapultState 
{ 
    Rolling, 
    Firing, 
    Crash, 
    ProjectileFlying, 
    ProjectileHit,
    Reset
}
&lt;/pre&gt;
But now we store a reference to the current game state in a private variable of this custom enum type in the main game class:
&lt;pre class="csharp" name="code"&gt;
private CatapultState currentState;
&lt;/pre&gt;
Finallly, we create an array of AbstractGameState objects, instantiate one concrete implementation class for each state in the game and add to the array:
&lt;pre class="csharp" name="code"&gt;
private AbstractGameState[] States;

protected override void Initialize()
{
 // Use reflection to determine how many states there are as
 // .NET Compact Framework does not support Enum.GetValues().
 Type type = typeof(CatapultState);
 FieldInfo[] info = type.GetFields(BindingFlags.Static | BindingFlags.Public);
 Int32 numberStates = info.Length;

 // Instantiate each game state.
 States = new AbstractGameState[numberStates];
 States[(Int32)CatapultState.Rolling] = new RollingState(this);
 States[(Int32)CatapultState.Firing] = new FiringState(this);
 States[(Int32)CatapultState.Crash] = new CrashState(this);
 States[(Int32)CatapultState.ProjectileFlying] = new ProjectileFlyingState(this);
 States[(Int32)CatapultState.ProjectileHit] = new ProjectileHitState(this);
 States[(Int32)CatapultState.Reset] = new ResetState(this);

 // Initialize current game state.
 currentState = CatapultState.Rolling;
 base.Initialize();
}
&lt;/pre&gt;
The &lt;i&gt;States&lt;/i&gt; array will now be referenced in the main game class Update() and Draw() methods to delegate the corresponding action to the correct game state concrete implementation class:
&lt;pre class="csharp" name="code"&gt;
protected override void Update(GameTime gameTime)
{
 States[(Int32)currentState].Update(gameTime);
 base.Update(gameTime);
}
protected override void Draw(GameTime gameTime)
{
 States[(Int32)currentState].Draw(gameTime);
 base.Draw(gameTime);
}
&lt;/pre&gt;
This solution is scalable: as more states are added to the game, each new game state can be added to the existing custom enum type, then simply add a new game state concrete implementation class to encapsulate all game code specific to that state.&lt;br /&gt;&lt;br /&gt;One final note: the State design pattern can also be used in conjunction with the &lt;a href="http://steveproxna.blogspot.com/2009/10/device-factory.html"&gt;Device Factory&lt;/a&gt;.  The main game class invokes the Update() and Draw() methods on the Device Factory as before:
&lt;pre class="csharp" name="code"&gt;
// Game.cs
protected override void Update(Microsoft.Xna.Framework.GameTime gameTime)
{
 DeviceFactory.Update(gameTime);
 base.Update(gameTime);
}
protected override void Draw(Microsoft.Xna.Framework.GameTime gameTime)
{
 DeviceFactory.Draw(gameTime);
 base.Draw(gameTime);
}
&lt;/pre&gt;
However, each device factory method would now execute state specific code depending on the state of the game at that particular frame but now for the appropriate device:
&lt;pre class="csharp" name="code"&gt;
// AbstractDeviceFactory.cs
public abstract class AbstractDeviceFactory
{
 protected readonly Game game;

 protected AbstractDeviceFactory(Game game)
 {
  this.game = game;
 }
 public virtual void Update(Microsoft.Xna.Framework.GameTime gameTime)
 {
  game.States[(Int32)game.CurrentState].Update(gameTime);
 }
 public virtual void Draw(Microsoft.Xna.Framework.GameTime gameTime)
 {
  game.States[(Int32)game.CurrentState].Draw(gameTime);
 }
}
&lt;/pre&gt;
&lt;/span&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/8584570627780730363-9168263145414539557?l=steveproxna.blogspot.com' alt='' /&gt;&lt;/div&gt;
&lt;p&gt;&lt;a href="http://feedads.g.doubleclick.net/~a/-axhNqesh_pMpvWPdZoCWXf2eRk/0/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/-axhNqesh_pMpvWPdZoCWXf2eRk/0/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;br/&gt;
&lt;a href="http://feedads.g.doubleclick.net/~a/-axhNqesh_pMpvWPdZoCWXf2eRk/1/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/-axhNqesh_pMpvWPdZoCWXf2eRk/1/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;/p&gt;&lt;img src="http://feeds.feedburner.com/~r/SteveProXNA/~4/XR90u_TLdyk" height="1" width="1"/&gt;</description><link>http://feedproxy.google.com/~r/SteveProXNA/~3/XR90u_TLdyk/state-design-pattern.html</link><author>noreply@blogger.com (SteveProXNA)</author><thr:total>0</thr:total><feedburner:origLink>http://steveproxna.blogspot.com/2009/11/state-design-pattern.html</feedburner:origLink></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-8584570627780730363.post-3346500000444322886</guid><pubDate>Thu, 01 Oct 2009 09:02:00 +0000</pubDate><atom:updated>2010-07-17T07:11:44.064-07:00</atom:updated><category domain="http://www.blogger.com/atom/ns#">Design</category><title>Device Factory</title><description>&lt;span style="font-family:verdana;font-size:85%;"&gt;XNA 3.0 allows game development to target 3x independent devices: Windows, Xbox 360 and Zune. Consequently, Microsoft released the &lt;a href="http://msdn.microsoft.com/en-us/library/dd254918.aspx"&gt;Platformer&lt;/a&gt; Starter Kit to demonstrate how a single game code base can be deployed and executed on these 3x devices independently.&lt;br /&gt;&lt;br /&gt;The ability to target a single game code base to multiple devices creates some interesting challenges: there are elements of a game that are dependent on each target device, for example: screen resolution, input detection, frame rate, content, storage, trial mode, volume, etc.&lt;br /&gt;&lt;br /&gt;The &lt;a href="http://msdn.microsoft.com/en-us/library/dd254918.aspx"&gt;Platformer&lt;/a&gt; Starter Kit deploys the same game code on Windows and Xbox 360. However, all Zune specific game code is wrapped within the following #if-#else-#endif conditional statement:
&lt;pre class="csharp" name="code"&gt;
#if ZUNE
 // Execute Zune device dependent code.
#else
 // Execute Windows / Xbox 360 code.
#endif
&lt;/pre&gt;
Game code that contains multiple #if-#else#endif conditional statements throughout the code base like this becomes cumbersome and error prone. Also, this approach does not scale: if 4x, 5x, 6x, etc devices were added to target the XNA platform, then this approach would become unwieldy and difficult to manage.&lt;br /&gt;&lt;br /&gt;A cleaner solution would be to implement a Device Factory. Essentially, the Device Factory is an abstract base class that contains all game code common to every device, but allows device specific game code to be overridden in the concrete implementation class through polymorphism.
&lt;pre class="csharp" name="code"&gt;
public abstract class AbstractDeviceFactory
{
 protected readonly Game game;

 protected AbstractDeviceFactory(Game game)
 {
  this.game = game;
 }
 public virtual void Initialize()
 {
  // Initialize code common to every device.
 }
 public virtual void LoadContent()
 {
  // LoadContent code common to every device.
 }
 public virtual void Update(Microsoft.Xna.Framework.GameTime gameTime)
 {
  // Update code common to every device.
 }
 public virtual void Draw(Microsoft.Xna.Framework.GameTime gameTime)
 {
  // Draw code common to every device.
 }

 // Properties common to every device.
}
&lt;/pre&gt;
In our example, there will be 3x device factory concrete implementation classes: Windows, Xbox 360 and Zune.
Each concrete implementation class will contain all game code to target that specific device. 
&lt;pre class="csharp" name="code"&gt;
public class WorkDeviceFactory : AbstractDeviceFactory
{
 // Windows specific game code implementation.
 public WorkDeviceFactory(Game game) : base(game)
 {
 }

 // Override property and method implementations for Windows.
}
public class XboxDeviceFactory : AbstractDeviceFactory
{
 // Xbox 360 specific game code implementation.
 public XboxDeviceFactory(Game game) : base(game)
 {
 }

 // Override property and method implementations for Xbox 360.
}
public class ZuneDeviceFactory : AbstractDeviceFactory
{
 // Zune specific game code implementation.
 public ZuneDeviceFactory(Game game) : base(game)
 {
 }

 // Override property and method implementations for Zune.
}
&lt;/pre&gt;
The main game constructor is now responsible for creating the device factory concrete implementation for the device the game is deployed to, and this instance will be used throughout the game.
&lt;pre class="csharp" name="code"&gt;
public class MyGame : Microsoft.Xna.Framework.Game
{
 public AbstractDeviceFactory DeviceFactory { get; set; }

 public MyGame()
 {
  DeviceFactory = CreateDeviceFactory();
 }

 private AbstractDeviceFactory CreateDeviceFactory()
 {
  AbstractDeviceFactory deviceFactory;
#if WINDOWS
  deviceFactory = new WorkDeviceFactory(this);
#elif XBOX
  deviceFactory = new XboxDeviceFactory(this);
#elif ZUNE
  deviceFactory = new ZuneDeviceFactory(this);
#else
  throw new NotSupportedException("Device not found");
#endif
  return deviceFactory;
 }
}
&lt;/pre&gt;
Note: there must be at least one #if-#else-#endif conditional statement to determine at runtime what device the game is being executed on.&lt;br /&gt;&lt;br /&gt;The standard XNA methods in the main game class will be now very lean as each method will delegate the corresponding action to the device factory.
&lt;pre class="csharp" name="code"&gt;
protected override void Initialize()
{
 DeviceFactory.Initialize();
 base.Initialize();
}
protected override void LoadContent()
{
 DeviceFactory.LoadContent();
 base.LoadContent();
}
protected override void Update(Microsoft.Xna.Framework.GameTime gameTime)
{
 DeviceFactory.Update(gameTime);
 base.Update(gameTime);
}
protected override void Draw(Microsoft.Xna.Framework.GameTime gameTime)
{
 DeviceFactory.Draw(gameTime);
 base.Draw(gameTime);
}
&lt;/pre&gt;
Each device factory concrete implementation will either execute device dependent game code, or simply invoke the base class where the game code is the same for all devices.&lt;br /&gt;&lt;br /&gt;Finally, this solution is scalable: if another device is added to target the XNA platform then simply add a new device factory concrete implementation class that contains all game code specific to that device, and extend the CreateDeviceFactory() method in the main game class to target this new device.
&lt;/span&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/8584570627780730363-3346500000444322886?l=steveproxna.blogspot.com' alt='' /&gt;&lt;/div&gt;
&lt;p&gt;&lt;a href="http://feedads.g.doubleclick.net/~a/8FWdS-oCtq1oxXdxaDsaIGzg2lw/0/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/8FWdS-oCtq1oxXdxaDsaIGzg2lw/0/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;br/&gt;
&lt;a href="http://feedads.g.doubleclick.net/~a/8FWdS-oCtq1oxXdxaDsaIGzg2lw/1/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/8FWdS-oCtq1oxXdxaDsaIGzg2lw/1/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;/p&gt;&lt;img src="http://feeds.feedburner.com/~r/SteveProXNA/~4/cPfvxwERpD0" height="1" width="1"/&gt;</description><link>http://feedproxy.google.com/~r/SteveProXNA/~3/cPfvxwERpD0/device-factory.html</link><author>noreply@blogger.com (SteveProXNA)</author><thr:total>0</thr:total><feedburner:origLink>http://steveproxna.blogspot.com/2009/10/device-factory.html</feedburner:origLink></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-8584570627780730363.post-8293024356200622196</guid><pubDate>Tue, 01 Sep 2009 17:35:00 +0000</pubDate><atom:updated>2010-07-17T07:11:12.283-07:00</atom:updated><category domain="http://www.blogger.com/atom/ns#">Game</category><title>First Game Completion</title><description>&lt;span style="font-family:verdana;"&gt;&lt;span style="font-size:85%;"&gt;Recently, I completed a basic 2D game to gain more experience in end-to-end game development on the XNA platform.The game, &lt;a href="http://catalog.xna.com/en-US/GameDetails.aspx?catalogEntryId=2c11b9b8-5cb8-426e-b462-ecaa0827a151&amp;type=2"&gt;Henway&lt;/a&gt;, is basically a Frogger clone. The goal is to cross the road without being killed; hence this game is based on real life.&lt;br/&gt;&lt;br/&gt;&lt;a href="http://catalog.xna.com/en-US/GameDetails.aspx?catalogEntryId=2c11b9b8-5cb8-426e-b462-ecaa0827a151&amp;type=2"&gt;Henway&lt;/a&gt; is built using content that I purchased in 2003. The game play is simple; which was important in order to concentrate on the end-to-end game 
development experience in XNA.

&lt;a href="http://1.bp.blogspot.com/_Ra2ABd_qklc/Sw6mxDXoTYI/AAAAAAAABAo/ANi-jlKCp7Q/s1600/HenwayScreen02.jpg"&gt;&lt;img style="float:left; margin:0 10px 10px 0;cursor:pointer; cursor:hand;width: 320px; height: 180px;" src="http://1.bp.blogspot.com/_Ra2ABd_qklc/Sw6mxDXoTYI/AAAAAAAABAo/ANi-jlKCp7Q/s320/HenwayScreen02.jpg" border="0" alt=""id="BLOGGER_PHOTO_ID_5408443564166761858" /&gt;&lt;/a&gt;
&lt;br/&gt;&lt;br/&gt;&lt;br/&gt;&lt;br/&gt;&lt;br/&gt;&lt;br/&gt;&lt;br/&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;The game took about four months to write outside work hours. A further month was spent upgrading game features to comply with XNA's &lt;/span&gt;&lt;a href="http://creators.xna.com/en-us/education/bestpractices"&gt;&lt;span style="font-size:85%;"&gt;best practices&lt;/span&gt;&lt;/a&gt;&lt;span style="font-size:85%;"&gt; and &lt;/span&gt;&lt;/span&gt;&lt;a href="http://creators.xna.com/en-US/faq#anchor_1_14"&gt;&lt;span style="font-family:verdana;font-size:85%;"&gt;publishing requirements&lt;/span&gt;&lt;/a&gt;&lt;span style="font-family:verdana;font-size:85%;"&gt;.&lt;/span&gt;
&lt;span style="font-family:verdana;font-size:85%;"&gt;&lt;/span&gt;
&lt;span style="font-size:85%;"&gt;&lt;span style="font-family:verdana;"&gt;&lt;br/&gt;&lt;br/&gt;The game is available on Windows, Xbox 360 and Zune.
&lt;br/&gt;
Click &lt;a href="http://catalog.xna.com/en-US/GameDetails.aspx?catalogEntryId=2c11b9b8-5cb8-426e-b462-ecaa0827a151&amp;type=2"&gt;here&lt;/a&gt; for more information on this title.
&lt;/span&gt;
&lt;span style="font-family:verdana;"&gt;&lt;br/&gt;&lt;br/&gt;This blog will document some of the design and performance challenges &lt;/span&gt;&lt;/span&gt;&lt;span style="font-family:verdana;font-size:85%;"&gt;encountered during development on the XNA platform, and game development in general.
This information will be available in subsequent posts.&lt;/span&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/8584570627780730363-8293024356200622196?l=steveproxna.blogspot.com' alt='' /&gt;&lt;/div&gt;
&lt;p&gt;&lt;a href="http://feedads.g.doubleclick.net/~a/WnprrVeH2OwBdr-UCv0TeEXJnBk/0/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/WnprrVeH2OwBdr-UCv0TeEXJnBk/0/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;br/&gt;
&lt;a href="http://feedads.g.doubleclick.net/~a/WnprrVeH2OwBdr-UCv0TeEXJnBk/1/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/WnprrVeH2OwBdr-UCv0TeEXJnBk/1/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;/p&gt;&lt;img src="http://feeds.feedburner.com/~r/SteveProXNA/~4/nmtu2mP3GKo" height="1" width="1"/&gt;</description><link>http://feedproxy.google.com/~r/SteveProXNA/~3/nmtu2mP3GKo/first-game-completion.html</link><author>noreply@blogger.com (SteveProXNA)</author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="http://1.bp.blogspot.com/_Ra2ABd_qklc/Sw6mxDXoTYI/AAAAAAAABAo/ANi-jlKCp7Q/s72-c/HenwayScreen02.jpg" height="72" width="72" /><thr:total>2</thr:total><feedburner:origLink>http://steveproxna.blogspot.com/2009/09/first-game-completion.html</feedburner:origLink></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-8584570627780730363.post-8744512676213304126</guid><pubDate>Sat, 01 Aug 2009 14:55:00 +0000</pubDate><atom:updated>2010-07-17T07:10:28.163-07:00</atom:updated><category domain="http://www.blogger.com/atom/ns#">XNA</category><title>SteveProXNA Introduction</title><description>&lt;span style="font-family:verdana;font-size:85%;"&gt;Hi, I’m Steve @ StevePro Studios. SteveProXNA is my XNA creator name and Xbox gamer tag.&lt;br /&gt;&lt;br /&gt;I've been following XNA since 2007. Recently, I completed a basic 2D game to gain more experience in end-to-end game development on the XNA platform.&lt;br /&gt;&lt;br /&gt;This blog attempts to highlight some of the issues found during XNA game development, potential solutions to these issues, and provide a general discussion on XNA.&lt;/span&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/8584570627780730363-8744512676213304126?l=steveproxna.blogspot.com' alt='' /&gt;&lt;/div&gt;
&lt;p&gt;&lt;a href="http://feedads.g.doubleclick.net/~a/MHf3ub0Sx89FkxF_-xb4VqMtozU/0/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/MHf3ub0Sx89FkxF_-xb4VqMtozU/0/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;br/&gt;
&lt;a href="http://feedads.g.doubleclick.net/~a/MHf3ub0Sx89FkxF_-xb4VqMtozU/1/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/MHf3ub0Sx89FkxF_-xb4VqMtozU/1/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;/p&gt;&lt;img src="http://feeds.feedburner.com/~r/SteveProXNA/~4/bdI_aotsezg" height="1" width="1"/&gt;</description><link>http://feedproxy.google.com/~r/SteveProXNA/~3/bdI_aotsezg/welcome-steveproxna.html</link><author>noreply@blogger.com (SteveProXNA)</author><thr:total>0</thr:total><feedburner:origLink>http://steveproxna.blogspot.com/2009/08/welcome-steveproxna.html</feedburner:origLink></item></channel></rss>

