<?xml version="1.0" encoding="utf-8"?><?xml-stylesheet title="XSL formatting" type="text/xsl" href="http://www.handcrafted-games.com/index.php?feed/rss2/xslt" ?><rss version="2.0"
  xmlns:dc="http://purl.org/dc/elements/1.1/"
  xmlns:wfw="http://wellformedweb.org/CommentAPI/"
  xmlns:content="http://purl.org/rss/1.0/modules/content/"
  xmlns:atom="http://www.w3.org/2005/Atom">
<channel>
  <title>Handcrafted Games</title>
  <link>http://www.handcrafted-games.com/index.php?</link>
  <atom:link href="http://www.handcrafted-games.com/index.php?feed/rss2" rel="self" type="application/rss+xml"/>
  <description>Game development &amp;amp; daily life</description>
  <language>en</language>
  <pubDate>Mon, 14 May 2012 18:27:56 +0100</pubDate>
  <copyright></copyright>
  <docs>http://blogs.law.harvard.edu/tech/rss</docs>
  <generator>Dotclear</generator>
  
    
  <item>
    <title>(French) Si vous attérrissez ici</title>
    <link>http://www.handcrafted-games.com/index.php?post/2011/12/13/%28French%29-Si-vous-att%C3%A9rrissez-ici</link>
    <guid isPermaLink="false">urn:md5:81faa7e8810aef4eb9b07ad72a8f005f</guid>
    <pubDate>Tue, 13 Dec 2011 16:44:00 +0000</pubDate>
    <dc:creator>Mister Helmut</dc:creator>
            
    <description>    &lt;p&gt;Si vous provenez du site du Global Game Jam et que vous venez d'attérir sur ce site, c'est que vous êtes curieux ou que vous avez mal tapé l'adresse du site.&lt;/p&gt;


&lt;p&gt;Si vous avez mal tapé l'adresse du site, &lt;a href=&quot;http://ggj.handcrafted-games.com/&quot; title=&quot;Global Game Jam&quot;&gt;cliquez ici pour y accéder&lt;/a&gt;.&lt;/p&gt;


&lt;p&gt;Si vous êtes ici par curiosité, ce présent site est le blog anglophone d'un des organisateurs de l'événement. Ce blog traite du développement de jeux vidéo et plus particulièrement de la technologie XNA. Malheureusement, ce blog n'est plus poursuivi.&lt;/p&gt;</description>
    
    
    
          <comments>http://www.handcrafted-games.com/index.php?post/2011/12/13/%28French%29-Si-vous-att%C3%A9rrissez-ici#comment-form</comments>
      <wfw:comment>http://www.handcrafted-games.com/index.php?post/2011/12/13/%28French%29-Si-vous-att%C3%A9rrissez-ici#comment-form</wfw:comment>
      <wfw:commentRss>http://www.handcrafted-games.com/index.php?feed/atom/comments/15</wfw:commentRss>
      </item>
    
  <item>
    <title>A well deserved status update of this blog</title>
    <link>http://www.handcrafted-games.com/index.php?post/2011/10/07/A-well-deserved-status-update-of-this-blog</link>
    <guid isPermaLink="false">urn:md5:b7fee508c695bc19f3d2c0283ba7da73</guid>
    <pubDate>Fri, 07 Oct 2011 14:15:00 +0100</pubDate>
    <dc:creator>Mister Helmut</dc:creator>
        <category>Blogposts</category>
            
    <description>    &lt;p&gt;Let's cut it short, this blog is discontinued ;-).&lt;/p&gt;


&lt;p&gt;The fact is that I hardly find free times in my professional/personal life to get seriously involved in a project. Well, I fortunately still have free times, but not enough to do what I would like to do, and do it seriously. Writing lengthy and well documented tutorials is incredibly time consuming and I don't find any interest in writing small ones. I would like to write some very didactic stuff, so more people could get in the XNA/WP7 communty, and also because I really like to teach things and share knowledge, encourage vocations and so on. But I am glad that my tutorials are still quite visible and enjoyed, notably the one on Sgt. Conker's website.&lt;/p&gt;


&lt;p&gt;Other reasons could be that blogs are dead now (long live micro-blogging?) and I fear that knowledges sharing will suffer of this. I am also a lot less visible than before. I took a little break from the community and it had the consequence for me to be mostly anonymous by now. I lost my reputation points on the AppHub (not to mention than my nickname has changed with my appliance to the WP7 dev program) and I haven't been in touch with the people I usually speak to for so months now. I am also twitting a lot less dev related stuff, as I switched to &lt;q&gt;researcher&lt;/q&gt; mode over &lt;q&gt;developer&lt;/q&gt;.&lt;/p&gt;


&lt;p&gt;So, what now? My other website, &lt;a href=&quot;http://www.daily-xna.com/&quot; hreflang=&quot;en&quot; title=&quot;Daily XNA&quot;&gt;Daily XNA&lt;/a&gt;, is still alive and kicking. Well, not sure if &lt;q&gt;kicking&lt;/q&gt; is the appropriate word here, the XNA community is living many mutations right now, there's less great people, no more blogs' update from the best MVPs and the current state of the indie landscape are making Steam and mobile platforms the ways to go. I really wonder what will be the future of indie distribution.&lt;/p&gt;


&lt;p&gt;I am also still teaching Game Design and Development to master degree students this year, with some Kinect goodness to promote Natural User Interfaces. I'm really happy with this, as it quenches my thirst of knowledge sharing.&lt;/p&gt;


&lt;p&gt;I still have some long term dev projects, but I have lost my appetite to commercially publishing them, making them to progress really really slowly. It's really a hobby more than everything, but it allowed me to get in touch with some nice people. Especially an alcoholic one from UK ^^.
Still trying to create a French XNA/WP7 User Group, but the whole French community seems to be composed of 5 people... Not to mention students that can't participate to such groups because of geographical restrictions.&lt;/p&gt;


&lt;p&gt;Oh and, I'm quite surprised that I am proposed jobs through this blog. Surprisingly, I received offers for game related positions but also for teaching activities. And I'm also glad that the ones who interviewed me are still in touch with me despite the fact I am not looking for a job right now.&lt;/p&gt;


&lt;p&gt;One last word, I'm trying to organize a Global Game Jam site in the east of France this year. Still working out details but nothing is confirmed yet. I hope to clarify things up by the end of the month.&lt;/p&gt;


&lt;p&gt;Thanks for visiting this blog! And don't forget that you can still get in touch with me via &lt;a href=&quot;https://twitter.com/#!/mrhelmut&quot; hreflang=&quot;en&quot; title=&quot;Twitter&quot;&gt;twitter&lt;/a&gt; or &lt;a href=&quot;http://www.linkedin.com/pub/thomas-altenburger/40/889/8a6&quot; hreflang=&quot;en&quot; title=&quot;linkedin&quot;&gt;linkedin&lt;/a&gt;.&lt;/p&gt;</description>
    
    
    
          <comments>http://www.handcrafted-games.com/index.php?post/2011/10/07/A-well-deserved-status-update-of-this-blog#comment-form</comments>
      <wfw:comment>http://www.handcrafted-games.com/index.php?post/2011/10/07/A-well-deserved-status-update-of-this-blog#comment-form</wfw:comment>
      <wfw:commentRss>http://www.handcrafted-games.com/index.php?feed/atom/comments/14</wfw:commentRss>
      </item>
    
  <item>
    <title>I am still around</title>
    <link>http://www.handcrafted-games.com/index.php?post/2010/10/18/I-am-still-around</link>
    <guid isPermaLink="false">urn:md5:05cfc89cc9db6ed92551e5909d0134f5</guid>
    <pubDate>Mon, 18 Oct 2010 13:47:00 +0100</pubDate>
    <dc:creator>Mister Helmut</dc:creator>
        <category>Blogposts</category>
            
    <description>    &lt;p&gt;Most blogs are not updated mainly due to one reason: personal life/work. I have been quite busy the last few months but I am still around, &quot;contributing&quot; to the XNA community, reading of lot and &lt;a href=&quot;https://twitter.com/mrhelmut&quot; hreflang=&quot;en&quot;&gt;twitting a little bit&lt;/a&gt;.&lt;/p&gt;


&lt;p&gt;First of, I have submitted an updated version of &lt;a href=&quot;http://www.handcrafted-games.com/index.php?post/2010/06/10/Programming-your-first-XNA-game-for-PC%2C-Xbox-360-Windows-Phone-7%3A-Pong&quot;&gt;my Pong tutorial&lt;/a&gt; to the &lt;a href=&quot;http://www.sgtconker.com/2010/10/results-for-the-absolutely-fine-xna-tutorial-contest/&quot; hreflang=&quot;en&quot;&gt;Sgt Conker tutorial contest&lt;/a&gt; and was really surprised to make the third place. I hope that this tutorial will help beginners despite the very good education content on the &lt;a href=&quot;http://create.msdn.com/en-US/&quot; hreflang=&quot;en&quot;&gt;App Hub website&lt;/a&gt; (the new name of the creators' club online). The tutorial I submitted has a lot of typo, so I hope to be able to post a new version on the Sgt Conker website.&lt;/p&gt;


&lt;p&gt;What now? I am still planning to write a few articles on this blog. The first to come out will be an introduction to the &lt;a href=&quot;http://farseerphysics.codeplex.com/&quot; hreflang=&quot;en&quot;&gt;Farseer physics engine&lt;/a&gt; in its 3.1 version. As one may know (or not), I am teaching video game development to master degree students and my course is based on my tutorials. This year, the course has been extended so I will have more time to do more interesting stuff than just a Pong, Space invaders and so on. My plan is to go into 2D physics games as it is a good mean to quickly and simply do funny things (IMO).&lt;/p&gt;


&lt;p&gt;Concerning the prices I have received from the Sgt Conker contest, the four months Premium subscription will be dedicated to peer reviewing creators' projects as I have no concrete projects to submit myself (or more precisely, four month is too short for my ongoing projects). As of the ToonBoom license, I'm planning to do something with it, but can not really speak about it until further confirmation.&lt;/p&gt;


&lt;p&gt;That's all for all the plans and for today.&lt;/p&gt;</description>
    
    
    
          <comments>http://www.handcrafted-games.com/index.php?post/2010/10/18/I-am-still-around#comment-form</comments>
      <wfw:comment>http://www.handcrafted-games.com/index.php?post/2010/10/18/I-am-still-around#comment-form</wfw:comment>
      <wfw:commentRss>http://www.handcrafted-games.com/index.php?feed/atom/comments/13</wfw:commentRss>
      </item>
    
  <item>
    <title>Can game disks really rot?!</title>
    <link>http://www.handcrafted-games.com/index.php?post/2010/08/01/Can-game-disks-really-rot%21</link>
    <guid isPermaLink="false">urn:md5:5b28c8ba691011676598c7c979387ebd</guid>
    <pubDate>Sun, 01 Aug 2010 14:23:00 +0100</pubDate>
    <dc:creator>Mister Helmut</dc:creator>
        <category>Blogposts</category>
        <category>daily life</category><category>xbox 360</category>    
    <description>    &lt;p&gt;Yesterday, I wanted to test the new Alan Wake DLC, 'The Signal', but to my surprise, my console told me that the game disk is unreadable... By unreadable, I mean that the dashboard doesn't even load the preview image nor the name of the disk, but still recognize it as a game. But when I want to launch the game, an error pops up with the 'unreadable disk' message. Sometimes, it even recognizes the disk as a DVD and plays the 'put this disk into a 360 console in order to play' (similar message when you try to put a 360 game in a PC).&lt;/p&gt;


&lt;p&gt;So I tried everything the &lt;a href=&quot;http://support.microsoft.com/kb/909819&quot; hreflang=&quot;en&quot;&gt;xbox support website&lt;/a&gt; is suggesting. Clearing the cache, testing without the hard drive plugged, etc.&lt;/p&gt;


&lt;p&gt;So I tried other games. Some are working, some aren't... Thankfully, I have a second 360 (a day-one console I replaced by a Super Elite last year) and used it to test my games. Guess what? Same problem... Some of my games are definitely unreadable. Don't tell me that the disks may be damaged, since they are all new and unscratched (I double-checked this, since I'm kinda a maniac in regards of my collectibles).&lt;/p&gt;


&lt;p&gt;Here's the list of the affected games: Alan Wake, Mass Effect 2 (disk 1 &amp;amp; 2), Resonance of Fate (End of Eternity), Darksiders and Skate 3 (I didn't even played to this one).&lt;/p&gt;


&lt;p&gt;The point is that this list represents exactly all the games I bought in 2010. The only one which is not in the list is Red Dead Redemption. All of my other games are working (and will hopefully continue to work).&lt;/p&gt;



&lt;p&gt;Well, so, what now? Are both of my consoles having the exact same problem? Are my games really rotten? Is there any reason why only the games I bought in 2010 are affected?&lt;/p&gt;


&lt;p&gt;I'm actually completely puzzled and quite nervous about this.&lt;/p&gt;</description>
    
    
    
          <comments>http://www.handcrafted-games.com/index.php?post/2010/08/01/Can-game-disks-really-rot%21#comment-form</comments>
      <wfw:comment>http://www.handcrafted-games.com/index.php?post/2010/08/01/Can-game-disks-really-rot%21#comment-form</wfw:comment>
      <wfw:commentRss>http://www.handcrafted-games.com/index.php?feed/atom/comments/12</wfw:commentRss>
      </item>
    
  <item>
    <title>XNA 4.0 beta is now available!</title>
    <link>http://www.handcrafted-games.com/index.php?post/2010/07/12/XNA-4.0-beta-is-now-available%21</link>
    <guid isPermaLink="false">urn:md5:ba99f9bb7c90da86338aa0acabe5d9e7</guid>
    <pubDate>Mon, 12 Jul 2010 19:38:00 +0100</pubDate>
    <dc:creator>Mister Helmut</dc:creator>
        <category>Blogposts</category>
        <category>windows phone 7</category><category>xbox live indie games</category><category>xna</category>    
    <description>    &lt;p&gt;After two Community Technological Preview versions, XNA Game Studio 4.0 has finally reached the beta stage.&lt;/p&gt;


&lt;p&gt;Let's cut it short, you can download it here: &lt;a href=&quot;http://download.microsoft.com/download/4/E/A/4EA52332-C6B1-476E-9938-C4F805146AF5/vm_web.exe&quot; hreflang=&quot;en&quot;&gt;http://download.microsoft.com/download/4/E/A/4EA52332-C6B1-476E-9938-C4F805146AF5/vm_web.exe&lt;/a&gt;.&lt;/p&gt;


&lt;p&gt;I'd like to remind you that XNA is now part of the Windows Phone 7 SDK as an all-in-one installation package (which will also install Visual Studio 2010 Express).&lt;/p&gt;


&lt;p&gt;This beta version is still limited: Xbox 360 is not yet allowed and XNA 4.0 will only work with the english RTM of Visual Studio 2010 (included in the all-in-one package in its Express version). But the API is now fully complete with WP7 screen orientation support and HiDef target on Windows (among other new features).&lt;/p&gt;


&lt;p&gt;For more information about this release, please visit &lt;a href=&quot;http://creators.xna.com/en-US/news/xnags40beta&quot; hreflang=&quot;en&quot;&gt;the creators' website&lt;/a&gt; and/or read &lt;a href=&quot;http://go.microsoft.com/fwlink/?LinkId=194469&quot; hreflang=&quot;en&quot;&gt;the release notes&lt;/a&gt;.&lt;/p&gt;


&lt;p&gt;For even further reading, &lt;a href=&quot;http://blogs.msdn.com/b/shawnhar/&quot; hreflang=&quot;en&quot;&gt;Shawn Hargreaves's blog&lt;/a&gt; has a tremendous amount of blogpost detailing API changes in XNA 4.0.&lt;/p&gt;</description>
    
    
    
          <comments>http://www.handcrafted-games.com/index.php?post/2010/07/12/XNA-4.0-beta-is-now-available%21#comment-form</comments>
      <wfw:comment>http://www.handcrafted-games.com/index.php?post/2010/07/12/XNA-4.0-beta-is-now-available%21#comment-form</wfw:comment>
      <wfw:commentRss>http://www.handcrafted-games.com/index.php?feed/atom/comments/11</wfw:commentRss>
      </item>
    
  <item>
    <title>Crowd funding and Indie games?</title>
    <link>http://www.handcrafted-games.com/index.php?post/2010/06/14/Crowd-funding-and-Indie-games</link>
    <guid isPermaLink="false">urn:md5:f2479dd3edb5c6a265a3c9fd21d6ae9b</guid>
    <pubDate>Mon, 14 Jun 2010 19:29:00 +0100</pubDate>
    <dc:creator>Mister Helmut</dc:creator>
        <category>Blogposts</category>
        <category>indie games</category>    
    <description>    &lt;p&gt;Do you know what “&lt;a href=&quot;http://en.wikipedia.org/wiki/Crowd_funding&quot;&gt;crowd funding&lt;/a&gt;” is? It is a way to produce entertainments. Basically, you allow people to participate to the base funding of a project and they will get a part of the benefits (depending on how much they funded, and if there’s any benefits) and/or have special opportunities to participate to the production. Crowd funding originally started with indie film makers unable to raise enough funds and asked people on the internet to donate while promising a return on investment (ROI). They successfully raised $50,000 and shot their film. The model is now adapted to many types of art, mainly music. Websites like &lt;a href=&quot;http://www.mymajorcompany.com/&quot; hreflang=&quot;fr&quot;&gt;mymajorcompany&lt;/a&gt; allow artists to present their works and people freely pick their favorite and donate. Then, if the artist is successfully produced and release an EP, they will receive a part of the benefits. Crowd funding recently reached the adult industry with a twist: in addition to the ROI and depending on the amount you gave, you are able to meet the actors or to shot your own scene… (I said shooting, not acting).&lt;/p&gt;


&lt;p&gt;Crowd funding is not about giving all the production decisions to the people funding you. It is a catchy way to get money directly from your public. People will not have control over what you’re doing, you’re only giving them the feeling they’re producing your project. The typical model involves incremental “goodies” depending on the amount of money given. For example, if people give $1 to $10, they’ll get a ROI when the project is released; if they give $11 to $50, ROI + a free copy of the product; if they give $100+, they’ll meet the team, shake hands etc. up to giving people the opportunity to influence something (like choosing the name of a song, usually something not critical to your project). The advantages of crowd funding are that you barely have to invest yourself and you’re directly get in touch with your clients (which would buy your product anyway if they’re already ok to donate). Crowd funding may not end well: the project could be discontinued, or not sell well. That's why participating in such projects is usually called a “bet”.&lt;/p&gt;


&lt;p&gt;So now, what about Indie games adopting crowd funding? You’ll maybe tell me that most indie developers allow people to donate, pre-order etc. But are they attracting people with something else? Most are not. We can mention &lt;a href=&quot;http://www.unknownworlds.com/&quot; hreflang=&quot;en&quot;&gt;Unknown Worlds&lt;/a&gt;, allowing pre-order on Natural Selection 2 while giving the SDK and special alpha demos to the people who pre-ordered.  &lt;a href=&quot;http://www.puppygames.net/&quot; hreflang=&quot;en&quot;&gt;Puppygames&lt;/a&gt; are also usually offering beta testing to pre-orders. But none are adopting the “internet producers” model by giving back a ROI.&lt;/p&gt;


&lt;p&gt;The big question is: will the benefits large enough to remunerate the producers AND to enable the indie studios to keep going?&lt;/p&gt;


&lt;p&gt;I really wonder if this production model could fit to the Indie game industry. I think that people are now used to play some indie games and may be aware of how such games are produced. So, there should be enough people interested in producing indie games. It would be a little like a “pay what you want” model, except that people are getting involved at the earliest production stage of a project.&lt;/p&gt;</description>
    
    
    
          <comments>http://www.handcrafted-games.com/index.php?post/2010/06/14/Crowd-funding-and-Indie-games#comment-form</comments>
      <wfw:comment>http://www.handcrafted-games.com/index.php?post/2010/06/14/Crowd-funding-and-Indie-games#comment-form</wfw:comment>
      <wfw:commentRss>http://www.handcrafted-games.com/index.php?feed/atom/comments/10</wfw:commentRss>
      </item>
    
  <item>
    <title>Programming your first XNA game for PC, Xbox 360 &amp; Windows Phone 7: Pong</title>
    <link>http://www.handcrafted-games.com/index.php?post/2010/06/10/Programming-your-first-XNA-game-for-PC%2C-Xbox-360-Windows-Phone-7%3A-Pong</link>
    <guid isPermaLink="false">urn:md5:8465fd3b52d8561c989691491d623b9c</guid>
    <pubDate>Thu, 10 Jun 2010 09:33:00 +0100</pubDate>
    <dc:creator>Mister Helmut</dc:creator>
        <category>Articles &amp; Tutorials</category>
        <category>indie games</category><category>tutorial</category><category>windows phone 7</category><category>xbox live indie games</category><category>xna</category>    
    <description>&lt;p&gt;I’d like to introduce the XNA framework to you with this very simple and straightforward tutorial. We will see what XNA is and how its basic features works to continue with the programming of your first game, a simple &lt;a href=&quot;http://en.wikipedia.org/wiki/Pong&quot; hreflang=&quot;en&quot;&gt;Pong&lt;/a&gt; clone for Windows. At last, we’ll try to convert it to the Xbox 360 and Windows Phone 7. This tutorial assumes that the readers have a basic C#/.Net understanding. I hope that it will help you to understand the basics of the framework and that it will motivate you to go further in. The article should be suitable to complete beginners in game programming.&lt;/p&gt;


&lt;p&gt;&lt;strong&gt;About this tutorial:&lt;/strong&gt; when I was running my previous French blog, I wrote &lt;a href=&quot;http://helmut.dev-blog.fr/post/2008/04/22/Votre-premier-jeu-avec-XNA%3A-Pong&quot; hreflang=&quot;en&quot;&gt;this tutorial&lt;/a&gt;. It was first released by the time of XNA 2.0 and is still a nice French references to begin with XNA. I then had the opportunity to teach video game programming to master degree students and choose to use this tutorial as the introduction of the course. I rewrote it a bit for the need of my course and with the coming of XNA 4.0 and the support of the Windows Phone 7 platform I felt like it would be nice to rework it even more to fit actual standards.&lt;/p&gt;


&lt;p&gt;English not being my native language, please forgive and/or report any English oddities.&lt;/p&gt;


&lt;p&gt;&lt;em&gt;This tutorial targets XNA 4.0 “April Refresh” CTP. It will be updated when the final version will be released. It uses some new features of XNA 4.0 so it will not run out-of-the-box on previous XNA version (mainly due to the usage of &lt;a href=&quot;http://msdn.microsoft.com/en-us/library/microsoft.xna.framework.graphics.viewport.bounds%28XNAGameStudio.40%29.aspx&quot; hreflang=&quot;en&quot;&gt;Viewport.Bounds&lt;/a&gt; and changed &lt;a href=&quot;http://msdn.microsoft.com/en-us/library/microsoft.xna.framework.graphics.spritebatch.draw%28v=XNAGameStudio.40%29.aspx&quot; hreflang=&quot;en&quot;&gt;SpriteBatch.Draw&lt;/a&gt; arguments order).&lt;/em&gt;&lt;/p&gt;


&lt;p&gt;&lt;strong&gt;Last modified:&lt;/strong&gt; June the 10th, 2010 (initial post).&lt;br /&gt;
&lt;strong&gt;Required assets:&lt;/strong&gt; &lt;a href=&quot;http://www.handcrafted-games.com/PongCloneContent.zip&quot; hreflang=&quot;en&quot;&gt;download link&lt;/a&gt;.&lt;br /&gt;
&lt;strong&gt;Offline version:&lt;/strong&gt; &lt;a href=&quot;http://www.handcrafted-games.com/XNATutorial1.pdf&quot; hreflang=&quot;en&quot;&gt;PDF&lt;/a&gt;.&lt;br /&gt;&lt;/p&gt;    &lt;h2&gt;The XNA framework&lt;/h2&gt;


&lt;p&gt;XNA is a free development framework by Microsoft, enabling cross-platform game development thanks to simple and comprehensive programming tools. The supported platforms are Windows PC’s, the Xbox 360, Zune media players and Windows Phone 7. The framework integrates itself into Visual Studio 2010 (as of XNA 4.0), including the free Express edition, and features the following components:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;A powerful .NET API to handle graphics, sounds, videos, inputs, networking and storage;&lt;/li&gt;
&lt;li&gt;An audio development tool, XACT, to build complex cross-platform sound banks;&lt;/li&gt;
&lt;li&gt;A debugger capable of remote debugging Xbox 360 and Zune games;&lt;/li&gt;
&lt;li&gt;A Windows Phone 7 emulator so that you don’t need to own such a device to debug WP7 games.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;XNA has been designed for hobbyist and independent developers and builds upon a strong community. If you have any problems during your XNA journey, don’t hesitate to ask for help at the official XNA community, &lt;a href=&quot;http://creators.xna.com/&quot; hreflang=&quot;en&quot;&gt;the creators club&lt;/a&gt;. If correctly and gently exposed, your problem will most likely be resolved with the help of XNA experts or XNA team itself.&lt;/p&gt;


&lt;p&gt;Last but not least, the creators club allows you to release and sell your creations on the Xbox 360 or Windows Phone 7 marketplaces.&lt;/p&gt;


&lt;h2&gt;First steps to the XNA framework&lt;/h2&gt;


&lt;p&gt;In order to begin with the framework, let’s review the requirements and setup our environment. You’ll need a computer with the following specifications (see XNA 4 specs):&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Windows Vista or Seven (or their “server” equivalent);&lt;/li&gt;
&lt;li&gt;A &lt;a href=&quot;http://www.microsoft.com/windows/directx/&quot; hreflang=&quot;en&quot;&gt;DirectX 9.1c&lt;/a&gt; capable graphic card (or better) with up to date drivers and DirectX runtime; A DirectX 10 capable graphic card if you’d like to debug Windows Phone 7 XNA projects;&lt;/li&gt;
&lt;li&gt;Visual Studio 2010 (or the free-to-use &lt;a href=&quot;http://www.microsoft.com/express/&quot; hreflang=&quot;en&quot;&gt;Express edition&lt;/a&gt;);&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;http://creators.xna.com/en-US/downloads&quot; hreflang=&quot;en&quot;&gt;XNA 4.0&lt;/a&gt;.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;If you’re a student, you may be able to get a copy of Windows Vista/Seven and/or a professional release of Visual Studio through the MSDN AA of your school (if it has subscribed to it). So go ask the IT manager of your school for further detail. If you’re school don’t have access to the MSDN AA, you can still pretend to student advantages thanks to the &lt;a href=&quot;https://www.dreamspark.com/&quot; hreflang=&quot;en&quot;&gt;Microsoft’s Dreamspark program&lt;/a&gt; (sign up and follow the instructions).&lt;/p&gt;


&lt;p&gt;If you’re not a student or simply don’t want to bother with a professional edition of Visual Studio, the Express edition is fairly enough for XNA purpose. Another version wouldn’t bring you more features unless you have other programming need than XNA.&lt;/p&gt;


&lt;p&gt;When you’re fully equipped, install Visual Studio 2010 and XNA 4.0 after. You’re now ready to go.&lt;/p&gt;


&lt;p&gt;&lt;strong&gt;Note about the CTP:&lt;/strong&gt; installing Visual Studio before XNA 4.0 is no longer required since XNA 4.0 comes in an all-in-one installation package.&lt;/p&gt;


&lt;h2&gt;Creating your first project&lt;/h2&gt;


&lt;p&gt;Start up Visual Studio and create a new project by clicking the “File/New Project…” menu. Here you’ll have a list of the available project templates. Give the name and directory you want to your project and under the Visual C# item, pick “Windows Game (4.0)”.&lt;/p&gt;


&lt;p&gt;The project you’ve just created is now composed of the following elements:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;The “Properties” directory, holding application manifest (not-so-important stuff);&lt;/li&gt;
&lt;li&gt;The “References” meta-directory, listing all the .Net assemblies your project need;&lt;/li&gt;
&lt;li&gt;The “Content References”, listing the linked Content Pipeline (we’ll see what it is soon);&lt;/li&gt;
&lt;li&gt;The “App.config” file, holding basic .Net setup, no need to edit it (for a XNA game);&lt;/li&gt;
&lt;li&gt;The “Game.ico” file, is the icon of the executable file of your game;&lt;/li&gt;
&lt;li&gt;The “Game1.cs” file, is the main source code file of a XNA project (I’ll detail this later);&lt;/li&gt;
&lt;li&gt;The “GameThumbnail.png” file, is the icon of your game that will be displayed on the Xbox 360 and Windows Phone 7 marketplaces;&lt;/li&gt;
&lt;li&gt;The “Program.cs” file, is the entry point of your program (initializing your Game1 class).&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Alongside your project, you’ll find another project having the same name with a “Content” suffix. This represents the Content Pipeline of your project, a very important XNA component.&lt;/p&gt;


&lt;h4&gt;The Content Pipeline&lt;/h4&gt;


&lt;p&gt;The &lt;a href=&quot;http://msdn.microsoft.com/en-us/library/bb203887%28v=XNAGameStudio.40%29.aspx&quot; hreflang=&quot;en&quot;&gt;Content Pipeline&lt;/a&gt; has an almost explicit name. Its purpose is to manage your game assets (graphics, sounds, 3D models…) from the importation up to the execution with barely any hassle. Its main features are:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Importing the most common asset file formats and transparently load them into comprehensible C# objects;&lt;/li&gt;
&lt;li&gt;Ease of use (one line asset loading);&lt;/li&gt;
&lt;li&gt;Automatically links dependent assets (3D models, textures, shaders…);&lt;/li&gt;
&lt;li&gt;Ensures that your assets are cross-platform, loaded and displayed the same way;&lt;/li&gt;
&lt;li&gt;Offers on-the-fly assets compression;&lt;/li&gt;
&lt;li&gt;Bake up your assets and bundle it with you game.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;The use of the &lt;a href=&quot;http://msdn.microsoft.com/en-us/library/bb203887%28v=XNAGameStudio.40%29.aspx&quot; hreflang=&quot;en&quot;&gt;Content Pipeline&lt;/a&gt; is mandatory for non-Windows deployment. You can still load your assets the “hard way” from files on PC if you’d like to.&lt;/p&gt;


&lt;p&gt;You can create as many Content projects as you want but it is more convenient to stick with one per game project. Remember the “Content References” in your game project? This is where you link your project to your Content project. By default, your project is linked to the already created Content project.&lt;/p&gt;


&lt;p&gt;Now for the supported file formats, here’s the list:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;2D graphics&lt;/strong&gt;: .bmp, .png, .jpg;&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;3D models&lt;/strong&gt;: .x, .fbx;&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Shaders&lt;/strong&gt;: .fx;&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Audio&lt;/strong&gt;: .mp3, .wav, .wma;&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Video&lt;/strong&gt;: .wmv;&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Font&lt;/strong&gt;: TrueType;&lt;/li&gt;
&lt;li&gt;Any XML, text or binary files.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;You may find many other format importers on the web or code one yourself if you need to (&lt;a href=&quot;http://msdn.microsoft.com/en-us/library/bb447754.aspx&quot; hreflang=&quot;en&quot;&gt;http://msdn.microsoft.com/en-us/library/bb447754.aspx&lt;/a&gt;).&lt;/p&gt;


&lt;h4&gt;Adding assets to your project&lt;/h4&gt;


&lt;p&gt;To add assets to your project, right click on your Content project, and “Add/Add an existing item” and pick your assets. You can also organize your assets into folders or add assets just by drag’n’droping files to your Content project.&lt;/p&gt;


&lt;h4&gt;The Game class&lt;/h4&gt;


&lt;p&gt;Now open up the Game1.cs file. You should notice that the Game1 class is inherited from a class named &lt;a href=&quot;http://msdn.microsoft.com/en-us/library/microsoft.xna.framework.game%28v=XNAGameStudio.40%29.aspx&quot; hreflang=&quot;en&quot;&gt;Game&lt;/a&gt;. The &lt;a href=&quot;http://msdn.microsoft.com/en-us/library/microsoft.xna.framework.game%28v=XNAGameStudio.40%29.aspx&quot; hreflang=&quot;en&quot;&gt;Game&lt;/a&gt; class is provided by XNA and manages the game loop (more generally the game workflow). It is composed of the following methods:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href=&quot;http://msdn.microsoft.com/en-us/library/microsoft.xna.framework.game.initialize%28v=XNAGameStudio.40%29.aspx&quot; hreflang=&quot;en&quot;&gt;Initialize&lt;/a&gt;: called after the construction of the class, it ensures that all the class fields are constructed and ready to be initialized. The purpose of this method is (as you may have guessed) to initialize class members (in the same way of the Winforms’ Initialize method);&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;http://msdn.microsoft.com/en-us/library/microsoft.xna.framework.game.loadcontent%28v=XNAGameStudio.40%29.aspx&quot; hreflang=&quot;en&quot;&gt;LoadContent&lt;/a&gt;: called after Initialize, this method is meant to be used to load your game assets;&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;http://msdn.microsoft.com/en-us/library/microsoft.xna.framework.game.unloadcontent%28v=XNAGameStudio.40%29.aspx&quot; hreflang=&quot;en&quot;&gt;UnloadContent&lt;/a&gt;: called before during the disposal of the &lt;a href=&quot;http://msdn.microsoft.com/en-us/library/microsoft.xna.framework.game%28v=XNAGameStudio.40%29.aspx&quot; hreflang=&quot;en&quot;&gt;Game&lt;/a&gt; class and ensure that your game assets are disposed correctly when you exit it (it doesn’t mean that you don’t have to take care of your memory allocation);&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;http://msdn.microsoft.com/en-us/library/microsoft.xna.framework.game.update%28v=XNAGameStudio.40%29.aspx&quot; hreflang=&quot;en&quot;&gt;Update&lt;/a&gt;: called every time before the &lt;a href=&quot;http://msdn.microsoft.com/en-us/library/microsoft.xna.framework.game.draw%28v=XNAGameStudio.40%29.aspx&quot; hreflang=&quot;en&quot;&gt;Draw&lt;/a&gt; method and should be used to update your game engine. This will be the place of collision handling, inputs handling, game world updating etc. Its &lt;a href=&quot;http://msdn.microsoft.com/en-us/library/microsoft.xna.framework.gametime%28v=XNAGameStudio.40%29.aspx&quot; hreflang=&quot;en&quot;&gt;GameTime&lt;/a&gt; argument propose services to know the amount of time elapsed since the last Update call. This is very useful to synchronize your game engine;&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;http://msdn.microsoft.com/en-us/library/microsoft.xna.framework.game.draw%28v=XNAGameStudio.40%29.aspx&quot; hreflang=&quot;en&quot;&gt;Draw&lt;/a&gt;: called in an infinite loop, it is meant to draw your game. Even if it is possible, for the sake of clean code, you should avoid writing any logic update here.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;The &lt;a href=&quot;http://msdn.microsoft.com/en-us/library/microsoft.xna.framework.game.update%28v=XNAGameStudio.40%29.aspx&quot; hreflang=&quot;en&quot;&gt;Update&lt;/a&gt; and &lt;a href=&quot;http://msdn.microsoft.com/en-us/library/microsoft.xna.framework.game.draw%28v=XNAGameStudio.40%29.aspx&quot; hreflang=&quot;en&quot;&gt;Draw&lt;/a&gt; methods represent the Game Loop and are called in an infinite loop so that your game is constantly refreshed and running. XNA default settings set the loop frequency to 60 loops per second, meaning that your game should run at 60 frames per second (as long as your &lt;a href=&quot;http://msdn.microsoft.com/en-us/library/microsoft.xna.framework.game.update%28v=XNAGameStudio.40%29.aspx&quot; hreflang=&quot;en&quot;&gt;Update&lt;/a&gt;/&lt;a href=&quot;http://msdn.microsoft.com/en-us/library/microsoft.xna.framework.game.draw%28v=XNAGameStudio.40%29.aspx&quot; hreflang=&quot;en&quot;&gt;Draw&lt;/a&gt; don’t take too much time). You can adjust the settings to void this limit so that your game runs as fast as your &lt;a href=&quot;http://msdn.microsoft.com/en-us/library/microsoft.xna.framework.game.update%28v=XNAGameStudio.40%29.aspx&quot; hreflang=&quot;en&quot;&gt;Update&lt;/a&gt;/&lt;a href=&quot;http://msdn.microsoft.com/en-us/library/microsoft.xna.framework.game.draw%28v=XNAGameStudio.40%29.aspx&quot; hreflang=&quot;en&quot;&gt;Draw&lt;/a&gt; allow it to, but we’re not going to cover this in this tutorial.&lt;/p&gt;


&lt;p&gt;You’re free to not use the &lt;a href=&quot;http://msdn.microsoft.com/en-us/library/microsoft.xna.framework.game%28v=XNAGameStudio.40%29.aspx&quot; hreflang=&quot;en&quot;&gt;Game&lt;/a&gt; class but it provides useful services behind the Game Loop and if you’re coding yourself such a class, you’ll most likely end up with a pretty similar one. So why bothering re-writing the wheel? Plus the fact the &lt;a href=&quot;http://msdn.microsoft.com/en-us/library/microsoft.xna.framework.game%28v=XNAGameStudio.40%29.aspx&quot; hreflang=&quot;en&quot;&gt;Game&lt;/a&gt; class ensures the workflow of your game.&lt;/p&gt;


&lt;p&gt;The &lt;a href=&quot;http://msdn.microsoft.com/en-us/library/microsoft.xna.framework.game%28v=XNAGameStudio.40%29.aspx&quot; hreflang=&quot;en&quot;&gt;Game1&lt;/a&gt; class comes with two fields initialized:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href=&quot;http://msdn.microsoft.com/en-us/library/microsoft.xna.framework.graphicsdevicemanager%28v=XNAGameStudio.40%29.aspx&quot; hreflang=&quot;en&quot;&gt;GraphicsDeviceManager&lt;/a&gt; graphics: manages what is called the “graphical context”. More accurately, it allows you to setup the graphics card states (i.e. screen resolution, vertical synchronization, anti-aliasing, etc.) and to get information about the hardware capabilities;&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;http://msdn.microsoft.com/en-us/library/microsoft.xna.framework.graphics.spritebatch%28v=XNAGameStudio.40%29.aspx&quot; hreflang=&quot;en&quot;&gt;SpriteBatch&lt;/a&gt; spriteBatch: provides services for 2D drawings. This will be the most important object covered by this tutorial.&lt;/li&gt;
&lt;/ul&gt;

&lt;h4&gt;Initializing and drawing 2D graphics&lt;/h4&gt;


&lt;p&gt;We will now take a look at how one can import 2D graphics and display it. You will need some game assets in order to continue. I’ve prepared a bundle with everything you need to follow this tutorial: &lt;a href=&quot;http://www.handcrafted-games.com/PongCloneContent.zip&quot; hreflang=&quot;en&quot;&gt;grab it there&lt;/a&gt;.&lt;/p&gt;


&lt;p&gt;Now take a look at the file named texture1.bmp. It is a simple image with 2D graphics. Notice that there are many single graphic entities inside the picture. An individual graphical entity is called a sprite and if an image contains many sprites, we’re in front of a sprite sheet.&lt;/p&gt;


&lt;p&gt;Other terms do exist to describe sprites and sprite sheets. Like tiles and tile sets. If you have already toyed with some “RPG maker”, you should be familiar with their meanings. Like a sprite sheet, a tile set is an image containing several tiles, a tile being an independent rectangle of your image. To the difference with sprites, tiles inside a tile set are usually the same size, forming a regular grid. You may have noticed that tiles can be disposed side by side to form complex graphics, like a puzzle, using several times the same tile. This technique is commonly used in 2D games (RPG, side-scroller…) and was historically used because of the lack of memory of the 8/16bit systems.&lt;/p&gt;


&lt;p&gt;Let’s import the texture: right click on your Content project, create a new folder named “Textures”, and add the existing texture1.bmp to this folder. It should now appear in your project. Right click on the texture1.bmp item and select “properties”, this will obviously show the asset properties. You’ll see a bunch of stuff, the one that is important for now is the “Asset Name” which should be set to “texture1”. This is the internal name of your asset, not its filename. XNA set a default name corresponding to the filename without its file extension, but you can freely change it. Keep in mind it has nothing to do with the filename.&lt;/p&gt;


&lt;p&gt;Now, inside your &lt;a href=&quot;http://msdn.microsoft.com/en-us/library/microsoft.xna.framework.game%28v=XNAGameStudio.40%29.aspx&quot; hreflang=&quot;en&quot;&gt;Game1&lt;/a&gt; class, as a class member, add a new member to host our texture. To this purpose, the &lt;a href=&quot;http://msdn.microsoft.com/en-us/library/microsoft.xna.framework.graphics.texture2d%28v=XNAGameStudio.40%29.aspx&quot; hreflang=&quot;en&quot;&gt;Texture2D&lt;/a&gt; is intended manage your 2D texture (as you could have found out by yourself).&lt;/p&gt;

&lt;pre class=&quot;csharp&quot;&gt;&lt;ol&gt;&lt;li style=&quot;font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;&quot;&gt;&lt;div style=&quot;font-family: 'Courier New', Courier, monospace; font-weight: normal;&quot;&gt;Texture2D myTexture;&lt;/div&gt;&lt;/li&gt;&lt;/ol&gt;&lt;/pre&gt;


&lt;p&gt;We now need to code the actual loading of the asset, so go inside the &lt;a href=&quot;http://msdn.microsoft.com/en-us/library/microsoft.xna.framework.game.loadcontent%28v=XNAGameStudio.40%29.aspx&quot; hreflang=&quot;en&quot;&gt;LoadContent&lt;/a&gt; method and add the following line of code:&lt;/p&gt;

&lt;pre class=&quot;csharp&quot;&gt;&lt;ol&gt;&lt;li style=&quot;font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;&quot;&gt;&lt;div style=&quot;font-family: 'Courier New', Courier, monospace; font-weight: normal;&quot;&gt;myTexture &lt;span style=&quot;color: #008000;&quot;&gt;=&lt;/span&gt; Content.&lt;span style=&quot;color: #0000FF;&quot;&gt;Load&lt;/span&gt;&lt;span style=&quot;color: #008000;&quot;&gt;&amp;lt;&lt;/span&gt;Texture2D&lt;span style=&quot;color: #008000;&quot;&gt;&amp;gt;&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #808080;&quot;&gt;@&quot;Textures/texture1&amp;quot;&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#41;&lt;/span&gt;;&lt;/div&gt;&lt;/li&gt;&lt;/ol&gt;&lt;/pre&gt;


&lt;p&gt;The &lt;a href=&quot;http://msdn.microsoft.com/en-us/library/microsoft.xna.framework.content.contentmanager%28v=XNAGameStudio.40%29.aspx&quot; hreflang=&quot;en&quot;&gt;Content&lt;/a&gt; object is a default &lt;a href=&quot;http://msdn.microsoft.com/en-us/library/microsoft.xna.framework.game%28v=XNAGameStudio.40%29.aspx&quot; hreflang=&quot;en&quot;&gt;Game&lt;/a&gt; class member representing your Content project. Everything linked to your Content project should be accessed through the Content member. Its Load function is generic and will allow you to easily load any supported type of asset by specifying the wanted type to the &lt;a href=&quot;http://msdn.microsoft.com/en-us/library/bb197848%28v=XNAGameStudio.40%29.aspx&quot; hreflang=&quot;en&quot;&gt;Load&amp;lt;Type&amp;gt;&lt;/a&gt; template. To load an asset, just specify the desired type and the asset name (not its file name). If you try to load an unsupported type for the given asset, you’ll encounter an exception at runtime. The “@” before the asset name is a C# operator specifying that the special characters of the following string don’t need to be escaped. It is way more convenient to use it when dealing with asset locations since it will avoid you from doubling all the dashes (making your code more readable). Notice that you access assets as if they were files in the hierarchy of your Content project, but with assets names as their filename (this may be a bit puzzling at first glance).&lt;/p&gt;


&lt;p&gt;Take a look at the content of the &lt;a href=&quot;http://msdn.microsoft.com/en-us/library/microsoft.xna.framework.game.draw%28v=XNAGameStudio.40%29.aspx&quot; hreflang=&quot;en&quot;&gt;Draw&lt;/a&gt; method:&lt;/p&gt;

&lt;pre class=&quot;csharp&quot;&gt;&lt;ol&gt;&lt;li style=&quot;font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;&quot;&gt;&lt;div style=&quot;font-family: 'Courier New', Courier, monospace; font-weight: normal;&quot;&gt;&lt;span style=&quot;color: #0600FF;&quot;&gt;protected&lt;/span&gt; &lt;span style=&quot;color: #0600FF;&quot;&gt;override&lt;/span&gt; &lt;span style=&quot;color: #0600FF;&quot;&gt;void&lt;/span&gt; Draw&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#40;&lt;/span&gt;GameTime gameTime&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style=&quot;font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;&quot;&gt;&lt;div style=&quot;font-family: 'Courier New', Courier, monospace; font-weight: normal;&quot;&gt;        &lt;span style=&quot;color: #000000;&quot;&gt;&amp;#123;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style=&quot;font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;&quot;&gt;&lt;div style=&quot;font-family: 'Courier New', Courier, monospace; font-weight: normal;&quot;&gt;            GraphicsDevice.&lt;span style=&quot;color: #0000FF;&quot;&gt;Clear&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#40;&lt;/span&gt;Color.&lt;span style=&quot;color: #0000FF;&quot;&gt;CornflowerBlue&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#41;&lt;/span&gt;;&lt;/div&gt;&lt;/li&gt;&lt;li style=&quot;font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;&quot;&gt;&lt;div style=&quot;font-family: 'Courier New', Courier, monospace; font-weight: normal;&quot;&gt;&amp;nbsp;&lt;/div&gt;&lt;/li&gt;&lt;li style=&quot;font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;&quot;&gt;&lt;div style=&quot;font-family: 'Courier New', Courier, monospace; font-weight: normal;&quot;&gt;            &lt;span style=&quot;color: #008080; font-style: italic;&quot;&gt;// TODO: Add your drawing code here&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style=&quot;font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;&quot;&gt;&lt;div style=&quot;font-family: 'Courier New', Courier, monospace; font-weight: normal;&quot;&gt;&amp;nbsp;&lt;/div&gt;&lt;/li&gt;&lt;li style=&quot;font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;&quot;&gt;&lt;div style=&quot;font-family: 'Courier New', Courier, monospace; font-weight: normal;&quot;&gt;            &lt;span style=&quot;color: #0600FF;&quot;&gt;base&lt;/span&gt;.&lt;span style=&quot;color: #0000FF;&quot;&gt;Draw&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#40;&lt;/span&gt;gameTime&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#41;&lt;/span&gt;;&lt;/div&gt;&lt;/li&gt;&lt;li style=&quot;font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;&quot;&gt;&lt;div style=&quot;font-family: 'Courier New', Courier, monospace; font-weight: normal;&quot;&gt;        &lt;span style=&quot;color: #000000;&quot;&gt;&amp;#125;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;/ol&gt;&lt;/pre&gt;


&lt;p&gt;The first line cleans the entire buffer so that the whole screen is reset to a blue color (the infamous &lt;a href=&quot;http://msdn.microsoft.com/en-us/library/microsoft.xna.framework.color.cornflowerblue%28v=XNAGameStudio.40%29.aspx&quot; hreflang=&quot;en&quot;&gt;CornflowerBlue&lt;/a&gt;). The last line calls the &lt;a href=&quot;http://msdn.microsoft.com/en-us/library/microsoft.xna.framework.game%28v=XNAGameStudio.40%29.aspx&quot; hreflang=&quot;en&quot;&gt;Game&lt;/a&gt; base &lt;a href=&quot;http://msdn.microsoft.com/en-us/library/microsoft.xna.framework.game.draw%28v=XNAGameStudio.40%29.aspx&quot; hreflang=&quot;en&quot;&gt;Draw&lt;/a&gt; method and should always be the last instruction of your &lt;a href=&quot;http://msdn.microsoft.com/en-us/library/microsoft.xna.framework.game.draw%28v=XNAGameStudio.40%29.aspx&quot; hreflang=&quot;en&quot;&gt;Draw&lt;/a&gt; method. I will not cover this feature as we will not use inheritance and game components.&lt;/p&gt;


&lt;h4&gt;The SpriteBatch.Draw(…) method&lt;/h4&gt;


&lt;p&gt;To draw 2D graphics, the only thing you will need is the &lt;a href=&quot;http://msdn.microsoft.com/en-us/library/microsoft.xna.framework.graphics.spritebatch.draw%28v=XNAGameStudio.40%29.aspx&quot; hreflang=&quot;en&quot;&gt;SpriteBatch.Draw(…)&lt;/a&gt; method. But beforehand, take a look at how the screen is addressed by XNA:&lt;/p&gt;


&lt;p&gt;&lt;img src=&quot;http://www.handcrafted-games.com/public/Tuto1/axes.png&quot; alt=&quot;axes.png&quot; style=&quot;display:block; margin:0 auto;&quot; title=&quot;axes.png, Jun 2010&quot; /&gt;&lt;/p&gt;


&lt;p&gt;As you can see, the screen origin is in the upper left corner and goes positively to the opposite screen corner. This is a bit strange if you’re used to &lt;a href=&quot;http://en.wikipedia.org/wiki/Cartesian_coordinate_system&quot; hreflang=&quot;en&quot;&gt;the Cartesian system&lt;/a&gt;. The unit is the pixel, meaning that (with default XNA screen resolution of 800x600) the X axis goes up to 800 and the Y one to 600. Textures are addressed the same way.&lt;/p&gt;


&lt;p&gt;Here’s one the &lt;a href=&quot;http://msdn.microsoft.com/en-us/library/microsoft.xna.framework.graphics.spritebatch.draw%28v=XNAGameStudio.40%29.aspx&quot; hreflang=&quot;en&quot;&gt;SpriteBatch.Draw(…)&lt;/a&gt; overload header:&lt;/p&gt;


&lt;p&gt;&lt;a href=&quot;http://msdn.microsoft.com/en-us/library/microsoft.xna.framework.graphics.spritebatch.draw%28v=XNAGameStudio.40%29.aspx&quot; hreflang=&quot;en&quot;&gt;SpriteBatch.Draw&lt;/a&gt;(
&lt;a href=&quot;http://msdn.microsoft.com/en-us/library/microsoft.xna.framework.graphics.texture2d%28v=XNAGameStudio.40%29.aspx&quot; hreflang=&quot;en&quot;&gt;Texture2D&lt;/a&gt;, // the texture to use for drawing
&lt;a href=&quot;http://msdn.microsoft.com/en-us/library/microsoft.xna.framework.rectangle%28v=XNAGameStudio.40%29.aspx&quot; hreflang=&quot;en&quot;&gt;Rectangle&lt;/a&gt;, // the rectangle where you want to draw on the screen (in screen coordinate)
&lt;a href=&quot;http://msdn.microsoft.com/en-us/library/microsoft.xna.framework.rectangle%28v=XNAGameStudio.40%29.aspx&quot; hreflang=&quot;en&quot;&gt;Rectangle&lt;/a&gt;, // the part of the texture you want to draw (in texture coordinate)
&lt;a href=&quot;http://msdn.microsoft.com/en-us/library/microsoft.xna.framework.color%28v=XNAGameStudio.40%29.aspx&quot; hreflang=&quot;en&quot;&gt;Color&lt;/a&gt;); // the color hue of the drawing, Color.White will give a default hue&lt;/p&gt;


&lt;p&gt;Now, considering our texture1, here’s an example call and the expected result:&lt;/p&gt;

&lt;pre class=&quot;csharp&quot;&gt;&lt;ol&gt;&lt;li style=&quot;font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;&quot;&gt;&lt;div style=&quot;font-family: 'Courier New', Courier, monospace; font-weight: normal;&quot;&gt;spriteBatch.&lt;span style=&quot;color: #0000FF;&quot;&gt;Begin&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#41;&lt;/span&gt;;&lt;/div&gt;&lt;/li&gt;&lt;li style=&quot;font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;&quot;&gt;&lt;div style=&quot;font-family: 'Courier New', Courier, monospace; font-weight: normal;&quot;&gt;            spriteBatch.&lt;span style=&quot;color: #0000FF;&quot;&gt;Draw&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style=&quot;font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;&quot;&gt;&lt;div style=&quot;font-family: 'Courier New', Courier, monospace; font-weight: normal;&quot;&gt;                myTexture,&lt;/div&gt;&lt;/li&gt;&lt;li style=&quot;font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;&quot;&gt;&lt;div style=&quot;font-family: 'Courier New', Courier, monospace; font-weight: normal;&quot;&gt;                &lt;span style=&quot;color: #008000;&quot;&gt;new&lt;/span&gt; Rectangle&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #FF0000;&quot;&gt;10&lt;/span&gt;, &lt;span style=&quot;color: #FF0000;&quot;&gt;20&lt;/span&gt;, &lt;span style=&quot;color: #FF0000;&quot;&gt;50&lt;/span&gt;, &lt;span style=&quot;color: #FF0000;&quot;&gt;100&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#41;&lt;/span&gt;,&lt;/div&gt;&lt;/li&gt;&lt;li style=&quot;font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;&quot;&gt;&lt;div style=&quot;font-family: 'Courier New', Courier, monospace; font-weight: normal;&quot;&gt;                &lt;span style=&quot;color: #008000;&quot;&gt;new&lt;/span&gt; Rectangle&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #FF0000;&quot;&gt;0&lt;/span&gt;, &lt;span style=&quot;color: #FF0000;&quot;&gt;0&lt;/span&gt;, &lt;span style=&quot;color: #FF0000;&quot;&gt;50&lt;/span&gt;, &lt;span style=&quot;color: #FF0000;&quot;&gt;100&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#41;&lt;/span&gt;,&lt;/div&gt;&lt;/li&gt;&lt;li style=&quot;font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;&quot;&gt;&lt;div style=&quot;font-family: 'Courier New', Courier, monospace; font-weight: normal;&quot;&gt;                Color.&lt;span style=&quot;color: #0000FF;&quot;&gt;White&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#41;&lt;/span&gt;;&lt;/div&gt;&lt;/li&gt;&lt;li style=&quot;font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;&quot;&gt;&lt;div style=&quot;font-family: 'Courier New', Courier, monospace; font-weight: normal;&quot;&gt;            spriteBatch.&lt;span style=&quot;color: #0000FF;&quot;&gt;End&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#41;&lt;/span&gt;;&lt;/div&gt;&lt;/li&gt;&lt;/ol&gt;&lt;/pre&gt;


&lt;p&gt;The main difficulty in understanding 2D drawing is to understand the difference between source and destination rectangles. Have a look at the following illustration.&lt;/p&gt;


&lt;p&gt;&lt;img src=&quot;http://www.handcrafted-games.com/public/Tuto1/sprite.png&quot; alt=&quot;sprite.png&quot; style=&quot;display:block; margin:0 auto;&quot; title=&quot;sprite.png, Jun 2010&quot; /&gt;&lt;/p&gt;


&lt;p&gt;On the left, we have the texture containing the objects we’d like to draw, but we only want to draw a portion of that texture. The source rectangle defines this portion and must use the texture coordinates. Then, you define where on the screen you want that portion to be drawn by defining the destination rectangle (in screen coordinates). Note that the destination rectangle doesn’t have to be as wide/high as the source rectangle. Different sizes will result in stretched drawing.&lt;/p&gt;


&lt;h4&gt;SpriteBatch.Begin(…) / End()&lt;/h4&gt;


&lt;p&gt;You may notice that the &lt;a href=&quot;http://msdn.microsoft.com/en-us/library/microsoft.xna.framework.graphics.spritebatch.draw%28v=XNAGameStudio.40%29.aspx&quot; hreflang=&quot;en&quot;&gt;SpriteBatch.Draw&lt;/a&gt; call is surrounded by two other methods, namely &lt;a href=&quot;http://msdn.microsoft.com/en-us/library/microsoft.xna.framework.graphics.spritebatch.begin%28v=XNAGameStudio.40%29.aspx&quot; hreflang=&quot;en&quot;&gt;Begin&lt;/a&gt; and &lt;a href=&quot;http://msdn.microsoft.com/en-us/library/microsoft.xna.framework.graphics.spritebatch.end%28v=XNAGameStudio.40%29.aspx&quot; hreflang=&quot;en&quot;&gt;End&lt;/a&gt;. &lt;a href=&quot;http://msdn.microsoft.com/en-us/library/microsoft.xna.framework.graphics.spritebatch.begin%28v=XNAGameStudio.40%29.aspx&quot; hreflang=&quot;en&quot;&gt;Begin&lt;/a&gt;&lt;a href=&quot;http://msdn.microsoft.com/en-us/library/microsoft.xna.framework.graphics.spritebatch.begin%28v=XNAGameStudio.40%29.aspx&quot; hreflang=&quot;en&quot;&gt;Begin&lt;/a&gt; could mean “ok mister GPU, here’s what you’re going to draw and how you’re going to draw it”. It tells the GPU to draw what’s coming and the properties to apply, like the usage of &lt;a href=&quot;http://msdn.microsoft.com/en-us/library/microsoft.xna.framework.graphics.blendstate.alphablend%28v=XNAGameStudio.40%29.aspx&quot; hreflang=&quot;en&quot;&gt;AlphaBlend&lt;/a&gt;, the order in which the sprites are going to be drawn etc.&lt;/p&gt;


&lt;p&gt;The &lt;a href=&quot;http://msdn.microsoft.com/en-us/library/microsoft.xna.framework.graphics.spritebatch.end%28v=XNAGameStudio.40%29.aspx&quot; hreflang=&quot;en&quot;&gt;End&lt;/a&gt; method tells to the GPU that the &lt;a href=&quot;http://msdn.microsoft.com/en-us/library/microsoft.xna.framework.graphics.spritebatch.draw%28v=XNAGameStudio.40%29.aspx&quot; hreflang=&quot;en&quot;&gt;Draw&lt;/a&gt; calls are complete and that he can now draw everything with the properties it have been configured.&lt;/p&gt;


&lt;p&gt;You have to know that the CPU will tell the GPU what to draw only when you call the &lt;a href=&quot;http://msdn.microsoft.com/en-us/library/microsoft.xna.framework.graphics.spritebatch.end%28v=XNAGameStudio.40%29.aspx&quot; hreflang=&quot;en&quot;&gt;End&lt;/a&gt; method. The result of this method is the transfer of the drawing primitives to the GPU and transferring data between the CPU and the GPU is very expensive. So try to put as many Draw calls as possible between the &lt;a href=&quot;http://msdn.microsoft.com/en-us/library/microsoft.xna.framework.graphics.spritebatch.begin%28v=XNAGameStudio.40%29.aspx&quot; hreflang=&quot;en&quot;&gt;Begin&lt;/a&gt; and &lt;a href=&quot;http://msdn.microsoft.com/en-us/library/microsoft.xna.framework.graphics.spritebatch.end%28v=XNAGameStudio.40%29.aspx&quot; hreflang=&quot;en&quot;&gt;End&lt;/a&gt; statements, this will greatly improve your game performance by reducing transfers to the GPU. Using several &lt;a href=&quot;http://msdn.microsoft.com/en-us/library/microsoft.xna.framework.graphics.spritebatch.begin%28v=XNAGameStudio.40%29.aspx&quot; hreflang=&quot;en&quot;&gt;Begin&lt;/a&gt;/&lt;a href=&quot;http://msdn.microsoft.com/en-us/library/microsoft.xna.framework.graphics.spritebatch.end%28v=XNAGameStudio.40%29.aspx&quot; hreflang=&quot;en&quot;&gt;End&lt;/a&gt; is mainly intended to use different drawing parameters or to ensure that some elements are drawn before/after other elements.&lt;/p&gt;


&lt;h2&gt;Coding a Pong clone in 5 minutes&lt;/h2&gt;


&lt;p&gt;You should now master the basics of XNA. Despite the title of this section, we’re not going to write a Pong clone in 5 minutes, but if you were confident in XNA, you should be able to do it.&lt;/p&gt;


&lt;h4&gt;Defining the basics&lt;/h4&gt;


&lt;p&gt;Ok, what do we need to make a Pong game?&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Two playable bars (2 x &lt;a href=&quot;http://msdn.microsoft.com/en-us/library/microsoft.xna.framework.rectangle%28v=XNAGameStudio.40%29.aspx&quot; hreflang=&quot;en&quot;&gt;Rectangle&lt;/a&gt;);&lt;/li&gt;
&lt;li&gt;A ball (1 x Circle);&lt;/li&gt;
&lt;li&gt;A tennis field;&lt;/li&gt;
&lt;li&gt;A score display;&lt;/li&gt;
&lt;li&gt;Motivated supporters.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Inside the assets package you should have already downloaded (if not so, &lt;a href=&quot;http://www.handcrafted-games.com/PongCloneContent.zip&quot; hreflang=&quot;en&quot;&gt;grab it here&lt;/a&gt;), you should find the following files:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;Objects.png&lt;/strong&gt;: an image file containing the graphics for the two bars and the ball;&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Grass.png&lt;/strong&gt;: an image file, a grass texture;&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Bounce.wav&lt;/strong&gt;: a sound file for ball bounces;&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Supporters.wav&lt;/strong&gt;: a sound file for goals.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Add all of them to your Content project.&lt;/p&gt;


&lt;p&gt;Let’s now define all those entities in our project, as &lt;a href=&quot;http://msdn.microsoft.com/en-us/library/microsoft.xna.framework.game%28v=XNAGameStudio.40%29.aspx&quot; hreflang=&quot;en&quot;&gt;Game1&lt;/a&gt; class members.&lt;/p&gt;

&lt;pre class=&quot;csharp&quot;&gt;&lt;ol&gt;&lt;li style=&quot;font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;&quot;&gt;&lt;div style=&quot;font-family: 'Courier New', Courier, monospace; font-weight: normal;&quot;&gt;&lt;span style=&quot;color: #008080; font-style: italic;&quot;&gt;// our pong entities&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style=&quot;font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;&quot;&gt;&lt;div style=&quot;font-family: 'Courier New', Courier, monospace; font-weight: normal;&quot;&gt;        Rectangle blueBar;&lt;/div&gt;&lt;/li&gt;&lt;li style=&quot;font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;&quot;&gt;&lt;div style=&quot;font-family: 'Courier New', Courier, monospace; font-weight: normal;&quot;&gt;        Rectangle redBar;&lt;/div&gt;&lt;/li&gt;&lt;li style=&quot;font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;&quot;&gt;&lt;div style=&quot;font-family: 'Courier New', Courier, monospace; font-weight: normal;&quot;&gt;        Rectangle ball; &lt;span style=&quot;color: #008080; font-style: italic;&quot;&gt;// since there’s no “circle” class in XNA, we’ll simulate it with a bounding rectangle box&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style=&quot;font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;&quot;&gt;&lt;div style=&quot;font-family: 'Courier New', Courier, monospace; font-weight: normal;&quot;&gt;&amp;nbsp;&lt;/div&gt;&lt;/li&gt;&lt;li style=&quot;font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;&quot;&gt;&lt;div style=&quot;font-family: 'Courier New', Courier, monospace; font-weight: normal;&quot;&gt;        &lt;span style=&quot;color: #008080; font-style: italic;&quot;&gt;// our pong clone textures&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style=&quot;font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;&quot;&gt;&lt;div style=&quot;font-family: 'Courier New', Courier, monospace; font-weight: normal;&quot;&gt;        Texture2D grass;&lt;/div&gt;&lt;/li&gt;&lt;li style=&quot;font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;&quot;&gt;&lt;div style=&quot;font-family: 'Courier New', Courier, monospace; font-weight: normal;&quot;&gt;        Texture2D spriteSheet;&lt;/div&gt;&lt;/li&gt;&lt;li style=&quot;font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;&quot;&gt;&lt;div style=&quot;font-family: 'Courier New', Courier, monospace; font-weight: normal;&quot;&gt;&amp;nbsp;&lt;/div&gt;&lt;/li&gt;&lt;li style=&quot;font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;&quot;&gt;&lt;div style=&quot;font-family: 'Courier New', Courier, monospace; font-weight: normal;&quot;&gt;        &lt;span style=&quot;color: #008080; font-style: italic;&quot;&gt;// our sound effects&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style=&quot;font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;&quot;&gt;&lt;div style=&quot;font-family: 'Courier New', Courier, monospace; font-weight: normal;&quot;&gt;        SoundEffect ballBounce;&lt;/div&gt;&lt;/li&gt;&lt;li style=&quot;font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;&quot;&gt;&lt;div style=&quot;font-family: 'Courier New', Courier, monospace; font-weight: normal;&quot;&gt;        SoundEffect playerScored;&lt;/div&gt;&lt;/li&gt;&lt;/ol&gt;&lt;/pre&gt;


&lt;p&gt;We now need to initialize our three Rectangle structures and we’ll do it in the (suspense…) &lt;a href=&quot;http://msdn.microsoft.com/en-us/library/microsoft.xna.framework.game.initialize%28v=XNAGameStudio.40%29.aspx&quot; hreflang=&quot;en&quot;&gt;Initilize&lt;/a&gt; method:&lt;/p&gt;

&lt;pre class=&quot;csharp&quot;&gt;&lt;ol&gt;&lt;li style=&quot;font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;&quot;&gt;&lt;div style=&quot;font-family: 'Courier New', Courier, monospace; font-weight: normal;&quot;&gt;&lt;span style=&quot;color: #0600FF;&quot;&gt;protected&lt;/span&gt; &lt;span style=&quot;color: #0600FF;&quot;&gt;override&lt;/span&gt; &lt;span style=&quot;color: #0600FF;&quot;&gt;void&lt;/span&gt; Initialize&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style=&quot;font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;&quot;&gt;&lt;div style=&quot;font-family: 'Courier New', Courier, monospace; font-weight: normal;&quot;&gt;        &lt;span style=&quot;color: #000000;&quot;&gt;&amp;#123;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style=&quot;font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;&quot;&gt;&lt;div style=&quot;font-family: 'Courier New', Courier, monospace; font-weight: normal;&quot;&gt;            &lt;span style=&quot;color: #008080; font-style: italic;&quot;&gt;// initializing our entities&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style=&quot;font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;&quot;&gt;&lt;div style=&quot;font-family: 'Courier New', Courier, monospace; font-weight: normal;&quot;&gt;            blueBar &lt;span style=&quot;color: #008000;&quot;&gt;=&lt;/span&gt; &lt;span style=&quot;color: #008000;&quot;&gt;new&lt;/span&gt; Rectangle&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style=&quot;font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;&quot;&gt;&lt;div style=&quot;font-family: 'Courier New', Courier, monospace; font-weight: normal;&quot;&gt;                &lt;span style=&quot;color: #FF0000;&quot;&gt;32&lt;/span&gt;, &lt;span style=&quot;color: #008080; font-style: italic;&quot;&gt;// x coordinate of the upper left corner of our rectangle&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style=&quot;font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;&quot;&gt;&lt;div style=&quot;font-family: 'Courier New', Courier, monospace; font-weight: normal;&quot;&gt;                GraphicsDevice.&lt;span style=&quot;color: #0000FF;&quot;&gt;Viewport&lt;/span&gt;.&lt;span style=&quot;color: #0000FF;&quot;&gt;Bounds&lt;/span&gt;.&lt;span style=&quot;color: #0000FF;&quot;&gt;Height&lt;/span&gt; &lt;span style=&quot;color: #008000;&quot;&gt;/&lt;/span&gt; &lt;span style=&quot;color: #FF0000;&quot;&gt;2&lt;/span&gt; &lt;span style=&quot;color: #008000;&quot;&gt;-&lt;/span&gt; &lt;span style=&quot;color: #FF0000;&quot;&gt;64&lt;/span&gt;, &lt;span style=&quot;color: #008080; font-style: italic;&quot;&gt;// y coordinate of the upper left corner&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style=&quot;font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;&quot;&gt;&lt;div style=&quot;font-family: 'Courier New', Courier, monospace; font-weight: normal;&quot;&gt;                &lt;span style=&quot;color: #FF0000;&quot;&gt;32&lt;/span&gt;, &lt;span style=&quot;color: #008080; font-style: italic;&quot;&gt;// its width&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style=&quot;font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;&quot;&gt;&lt;div style=&quot;font-family: 'Courier New', Courier, monospace; font-weight: normal;&quot;&gt;                &lt;span style=&quot;color: #FF0000;&quot;&gt;128&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#41;&lt;/span&gt;; &lt;span style=&quot;color: #008080; font-style: italic;&quot;&gt;// and its height&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style=&quot;font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;&quot;&gt;&lt;div style=&quot;font-family: 'Courier New', Courier, monospace; font-weight: normal;&quot;&gt;            redBar &lt;span style=&quot;color: #008000;&quot;&gt;=&lt;/span&gt; &lt;span style=&quot;color: #008000;&quot;&gt;new&lt;/span&gt; Rectangle&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style=&quot;font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;&quot;&gt;&lt;div style=&quot;font-family: 'Courier New', Courier, monospace; font-weight: normal;&quot;&gt;                GraphicsDevice.&lt;span style=&quot;color: #0000FF;&quot;&gt;Viewport&lt;/span&gt;.&lt;span style=&quot;color: #0000FF;&quot;&gt;Bounds&lt;/span&gt;.&lt;span style=&quot;color: #0000FF;&quot;&gt;Width&lt;/span&gt; &lt;span style=&quot;color: #008000;&quot;&gt;-&lt;/span&gt; &lt;span style=&quot;color: #FF0000;&quot;&gt;64&lt;/span&gt;, &lt;span style=&quot;color: #008080; font-style: italic;&quot;&gt;// x coordinate of the upper left corner of our rectangle&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style=&quot;font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;&quot;&gt;&lt;div style=&quot;font-family: 'Courier New', Courier, monospace; font-weight: normal;&quot;&gt;                GraphicsDevice.&lt;span style=&quot;color: #0000FF;&quot;&gt;Viewport&lt;/span&gt;.&lt;span style=&quot;color: #0000FF;&quot;&gt;Bounds&lt;/span&gt;.&lt;span style=&quot;color: #0000FF;&quot;&gt;Height&lt;/span&gt; &lt;span style=&quot;color: #008000;&quot;&gt;/&lt;/span&gt; &lt;span style=&quot;color: #FF0000;&quot;&gt;2&lt;/span&gt; &lt;span style=&quot;color: #008000;&quot;&gt;-&lt;/span&gt; &lt;span style=&quot;color: #FF0000;&quot;&gt;64&lt;/span&gt;, &lt;span style=&quot;color: #008080; font-style: italic;&quot;&gt;// y coordinate of the upper left corner&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style=&quot;font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;&quot;&gt;&lt;div style=&quot;font-family: 'Courier New', Courier, monospace; font-weight: normal;&quot;&gt;                &lt;span style=&quot;color: #FF0000;&quot;&gt;32&lt;/span&gt;, &lt;span style=&quot;color: #008080; font-style: italic;&quot;&gt;// its width&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style=&quot;font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;&quot;&gt;&lt;div style=&quot;font-family: 'Courier New', Courier, monospace; font-weight: normal;&quot;&gt;                &lt;span style=&quot;color: #FF0000;&quot;&gt;128&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#41;&lt;/span&gt;; &lt;span style=&quot;color: #008080; font-style: italic;&quot;&gt;// and its height&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style=&quot;font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;&quot;&gt;&lt;div style=&quot;font-family: 'Courier New', Courier, monospace; font-weight: normal;&quot;&gt;            ball &lt;span style=&quot;color: #008000;&quot;&gt;=&lt;/span&gt; &lt;span style=&quot;color: #008000;&quot;&gt;new&lt;/span&gt; Rectangle&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style=&quot;font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;&quot;&gt;&lt;div style=&quot;font-family: 'Courier New', Courier, monospace; font-weight: normal;&quot;&gt;                GraphicsDevice.&lt;span style=&quot;color: #0000FF;&quot;&gt;Viewport&lt;/span&gt;.&lt;span style=&quot;color: #0000FF;&quot;&gt;Bounds&lt;/span&gt;.&lt;span style=&quot;color: #0000FF;&quot;&gt;Width&lt;/span&gt; &lt;span style=&quot;color: #008000;&quot;&gt;/&lt;/span&gt; &lt;span style=&quot;color: #FF0000;&quot;&gt;2&lt;/span&gt; &lt;span style=&quot;color: #008000;&quot;&gt;-&lt;/span&gt; &lt;span style=&quot;color: #FF0000;&quot;&gt;16&lt;/span&gt;, &lt;span style=&quot;color: #008080; font-style: italic;&quot;&gt;// x coordinate of the upper left corner of our rectangle&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style=&quot;font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;&quot;&gt;&lt;div style=&quot;font-family: 'Courier New', Courier, monospace; font-weight: normal;&quot;&gt;                GraphicsDevice.&lt;span style=&quot;color: #0000FF;&quot;&gt;Viewport&lt;/span&gt;.&lt;span style=&quot;color: #0000FF;&quot;&gt;Bounds&lt;/span&gt;.&lt;span style=&quot;color: #0000FF;&quot;&gt;Height&lt;/span&gt; &lt;span style=&quot;color: #008000;&quot;&gt;/&lt;/span&gt; &lt;span style=&quot;color: #FF0000;&quot;&gt;2&lt;/span&gt; &lt;span style=&quot;color: #008000;&quot;&gt;-&lt;/span&gt; &lt;span style=&quot;color: #FF0000;&quot;&gt;16&lt;/span&gt;, &lt;span style=&quot;color: #008080; font-style: italic;&quot;&gt;// y coordinate of the upper left corner&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style=&quot;font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;&quot;&gt;&lt;div style=&quot;font-family: 'Courier New', Courier, monospace; font-weight: normal;&quot;&gt;                &lt;span style=&quot;color: #FF0000;&quot;&gt;32&lt;/span&gt;, &lt;span style=&quot;color: #008080; font-style: italic;&quot;&gt;// its width&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style=&quot;font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;&quot;&gt;&lt;div style=&quot;font-family: 'Courier New', Courier, monospace; font-weight: normal;&quot;&gt;                &lt;span style=&quot;color: #FF0000;&quot;&gt;32&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#41;&lt;/span&gt;; &lt;span style=&quot;color: #008080; font-style: italic;&quot;&gt;// and its height&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style=&quot;font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;&quot;&gt;&lt;div style=&quot;font-family: 'Courier New', Courier, monospace; font-weight: normal;&quot;&gt;&amp;nbsp;&lt;/div&gt;&lt;/li&gt;&lt;li style=&quot;font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;&quot;&gt;&lt;div style=&quot;font-family: 'Courier New', Courier, monospace; font-weight: normal;&quot;&gt;            &lt;span style=&quot;color: #0600FF;&quot;&gt;base&lt;/span&gt;.&lt;span style=&quot;color: #0000FF;&quot;&gt;Initialize&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#41;&lt;/span&gt;;&lt;/div&gt;&lt;/li&gt;&lt;li style=&quot;font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;&quot;&gt;&lt;div style=&quot;font-family: 'Courier New', Courier, monospace; font-weight: normal;&quot;&gt;        &lt;span style=&quot;color: #000000;&quot;&gt;&amp;#125;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;/ol&gt;&lt;/pre&gt;


&lt;p&gt;&lt;strong&gt;Explanation:&lt;/strong&gt;&lt;/p&gt;


&lt;p&gt;We want our bars to be 32x128 pixels and be placed left and right to the screen and perfectly centered. Defining a &lt;a href=&quot;http://msdn.microsoft.com/en-us/library/microsoft.xna.framework.rectangle%28v=XNAGameStudio.40%29.aspx&quot; hreflang=&quot;en&quot;&gt;Rectangle&lt;/a&gt; consist of four parameter: the x coordinate of the upper left corner (in screen coordinate), the y coordinate of the upper left corner, the width of the rectangle (32) and its height (128).&lt;/p&gt;


&lt;p&gt;Noticed this kind of math?&lt;/p&gt;

&lt;pre class=&quot;csharp&quot;&gt;&lt;ol&gt;&lt;li style=&quot;font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;&quot;&gt;&lt;div style=&quot;font-family: 'Courier New', Courier, monospace; font-weight: normal;&quot;&gt;GraphicsDevice.&lt;span style=&quot;color: #0000FF;&quot;&gt;Viewport&lt;/span&gt;.&lt;span style=&quot;color: #0000FF;&quot;&gt;Bounds&lt;/span&gt;.&lt;span style=&quot;color: #0000FF;&quot;&gt;Height&lt;/span&gt; &lt;span style=&quot;color: #008000;&quot;&gt;/&lt;/span&gt; &lt;span style=&quot;color: #FF0000;&quot;&gt;2&lt;/span&gt; – &lt;span style=&quot;color: #FF0000;&quot;&gt;64&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;/ol&gt;&lt;/pre&gt;


&lt;p&gt;This is how we vertically center our bars. &lt;a href=&quot;http://msdn.microsoft.com/en-us/library/microsoft.xna.framework.graphics.viewport.bounds%28XNAGameStudio.40%29.aspx&quot; hreflang=&quot;en&quot;&gt;GraphicsDevice.Viewport.Bounds&lt;/a&gt; is a &lt;a href=&quot;http://msdn.microsoft.com/en-us/library/microsoft.xna.framework.rectangle%28v=XNAGameStudio.40%29.aspx&quot; hreflang=&quot;en&quot;&gt;Rectangle&lt;/a&gt; provided by XNA that will always represent the actual bounds of the screen. If the resolution of your game is 800x600, the bounds will be &lt;a href=&quot;http://msdn.microsoft.com/en-us/library/microsoft.xna.framework.rectangle.rectangle%28v=XNAGameStudio.40%29.aspx&quot; hreflang=&quot;en&quot;&gt;Rectangle(0, 0, 800, 600)&lt;/a&gt;. So if we want to center something, we just have to consider the half of the screen, minus the half of the rectangle we’d like to be centered (or else only its upper left corner will be centered).&lt;/p&gt;


&lt;p&gt;If you understood all this, you shouldn’t have difficulties understanding our ball definition. We’d like our ball to have a 32 pixels diameter so we bound it with a 32x32 &lt;a href=&quot;http://msdn.microsoft.com/en-us/library/microsoft.xna.framework.rectangle%28v=XNAGameStudio.40%29.aspx&quot; hreflang=&quot;en&quot;&gt;Rectangle&lt;/a&gt; (since no circle class exists in XNA, up to you write one).&lt;/p&gt;


&lt;p&gt;Let’s now load the assets we’ve defined earlier, so go to the &lt;a href=&quot;http://msdn.microsoft.com/en-us/library/microsoft.xna.framework.game.loadcontent%28v=XNAGameStudio.40%29.aspx&quot; hreflang=&quot;en&quot;&gt;LoadContent&lt;/a&gt; method. The following code should be straightforward if you read the introduction of this article:&lt;/p&gt;

&lt;pre class=&quot;csharp&quot;&gt;&lt;ol&gt;&lt;li style=&quot;font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;&quot;&gt;&lt;div style=&quot;font-family: 'Courier New', Courier, monospace; font-weight: normal;&quot;&gt;&lt;span style=&quot;color: #0600FF;&quot;&gt;protected&lt;/span&gt; &lt;span style=&quot;color: #0600FF;&quot;&gt;override&lt;/span&gt; &lt;span style=&quot;color: #0600FF;&quot;&gt;void&lt;/span&gt; LoadContent&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style=&quot;font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;&quot;&gt;&lt;div style=&quot;font-family: 'Courier New', Courier, monospace; font-weight: normal;&quot;&gt;        &lt;span style=&quot;color: #000000;&quot;&gt;&amp;#123;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style=&quot;font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;&quot;&gt;&lt;div style=&quot;font-family: 'Courier New', Courier, monospace; font-weight: normal;&quot;&gt;            &lt;span style=&quot;color: #008080; font-style: italic;&quot;&gt;// Create a new SpriteBatch, which can be used to draw textures.&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style=&quot;font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;&quot;&gt;&lt;div style=&quot;font-family: 'Courier New', Courier, monospace; font-weight: normal;&quot;&gt;            spriteBatch &lt;span style=&quot;color: #008000;&quot;&gt;=&lt;/span&gt; &lt;span style=&quot;color: #008000;&quot;&gt;new&lt;/span&gt; SpriteBatch&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#40;&lt;/span&gt;GraphicsDevice&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#41;&lt;/span&gt;;&lt;/div&gt;&lt;/li&gt;&lt;li style=&quot;font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;&quot;&gt;&lt;div style=&quot;font-family: 'Courier New', Courier, monospace; font-weight: normal;&quot;&gt;&amp;nbsp;&lt;/div&gt;&lt;/li&gt;&lt;li style=&quot;font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;&quot;&gt;&lt;div style=&quot;font-family: 'Courier New', Courier, monospace; font-weight: normal;&quot;&gt;            &lt;span style=&quot;color: #008080; font-style: italic;&quot;&gt;// load our textures from the Content Pipeline&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style=&quot;font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;&quot;&gt;&lt;div style=&quot;font-family: 'Courier New', Courier, monospace; font-weight: normal;&quot;&gt;            grass &lt;span style=&quot;color: #008000;&quot;&gt;=&lt;/span&gt; Content.&lt;span style=&quot;color: #0000FF;&quot;&gt;Load&lt;/span&gt;&lt;span style=&quot;color: #008000;&quot;&gt;&amp;lt;&lt;/span&gt;Texture2D&lt;span style=&quot;color: #008000;&quot;&gt;&amp;gt;&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #808080;&quot;&gt;@&quot;Textures/Grass&amp;quot;&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#41;&lt;/span&gt;;&lt;/div&gt;&lt;/li&gt;&lt;li style=&quot;font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;&quot;&gt;&lt;div style=&quot;font-family: 'Courier New', Courier, monospace; font-weight: normal;&quot;&gt;            spriteSheet &lt;span style=&quot;color: #008000;&quot;&gt;=&lt;/span&gt; Content.&lt;span style=&quot;color: #0000FF;&quot;&gt;Load&lt;/span&gt;&lt;span style=&quot;color: #008000;&quot;&gt;&amp;lt;&lt;/span&gt;Texture2D&lt;span style=&quot;color: #008000;&quot;&gt;&amp;gt;&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #808080;&quot;&gt;@&quot;Textures/Objects&amp;quot;&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#41;&lt;/span&gt;;&lt;/div&gt;&lt;/li&gt;&lt;li style=&quot;font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;&quot;&gt;&lt;div style=&quot;font-family: 'Courier New', Courier, monospace; font-weight: normal;&quot;&gt;&amp;nbsp;&lt;/div&gt;&lt;/li&gt;&lt;li style=&quot;font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;&quot;&gt;&lt;div style=&quot;font-family: 'Courier New', Courier, monospace; font-weight: normal;&quot;&gt;            &lt;span style=&quot;color: #008080; font-style: italic;&quot;&gt;// load our sound effects from the Content Pipeline&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style=&quot;font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;&quot;&gt;&lt;div style=&quot;font-family: 'Courier New', Courier, monospace; font-weight: normal;&quot;&gt;            ballBounce &lt;span style=&quot;color: #008000;&quot;&gt;=&lt;/span&gt; Content.&lt;span style=&quot;color: #0000FF;&quot;&gt;Load&lt;/span&gt;&lt;span style=&quot;color: #008000;&quot;&gt;&amp;lt;&lt;/span&gt;SoundEffect&lt;span style=&quot;color: #008000;&quot;&gt;&amp;gt;&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #808080;&quot;&gt;@&quot;Sounds/Bounce&amp;quot;&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#41;&lt;/span&gt;;&lt;/div&gt;&lt;/li&gt;&lt;li style=&quot;font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;&quot;&gt;&lt;div style=&quot;font-family: 'Courier New', Courier, monospace; font-weight: normal;&quot;&gt;            playerScored &lt;span style=&quot;color: #008000;&quot;&gt;=&lt;/span&gt; Content.&lt;span style=&quot;color: #0000FF;&quot;&gt;Load&lt;/span&gt;&lt;span style=&quot;color: #008000;&quot;&gt;&amp;lt;&lt;/span&gt;SoundEffect&lt;span style=&quot;color: #008000;&quot;&gt;&amp;gt;&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #808080;&quot;&gt;@&quot;Sounds/Supporters&amp;quot;&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#41;&lt;/span&gt;;&lt;/div&gt;&lt;/li&gt;&lt;li style=&quot;font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;&quot;&gt;&lt;div style=&quot;font-family: 'Courier New', Courier, monospace; font-weight: normal;&quot;&gt;        &lt;span style=&quot;color: #000000;&quot;&gt;&amp;#125;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;/ol&gt;&lt;/pre&gt;


&lt;h4&gt;Drawing the scene&lt;/h4&gt;


&lt;p&gt;At last, we will draw the entire scene but beforehand, I’ll introduce to you a simple problem.&lt;/p&gt;


&lt;p&gt;&lt;a href=&quot;http://en.wikipedia.org/wiki/Painter%27s_algorithm&quot; hreflang=&quot;en&quot;&gt;The painter’s problem&lt;/a&gt;: even if you never heard about it, you should be familiar to it. When a painter would like to drawn a landscape on the background and a house in front of it, it has to first complete the background and then paint the house over it. If he did the house first, he would encounter problems detailing the background at the house’s edges. Graphics API pretty much the same way but are more restrictive: everything that is drawn will recover what’s already drawn if it overlaps. So you have to draw graphics according to their distance from the camera.&lt;/p&gt;


&lt;p&gt;Currently, what I said is not completely true since there’s some hardware magic called the Z-buffer which sorts everything out even if you draw everything in a random order. But the Z-buffer has been designed for 3D purposes and when dealing with 2D graphics, we’re no more working with Z coordinate so we have to sort this ourselves.&lt;/p&gt;


&lt;p&gt;XNA offers mechanisms to sort 2D graphics via the &lt;a href=&quot;http://msdn.microsoft.com/en-us/library/microsoft.xna.framework.graphics.spritesortmode%28v=XNAGameStudio.40%29.aspx&quot; hreflang=&quot;en&quot;&gt;SpriteSortMode&lt;/a&gt; argument of the &lt;a href=&quot;http://msdn.microsoft.com/en-us/library/microsoft.xna.framework.graphics.spritebatch.draw%28v=XNAGameStudio.40%29.aspx&quot; hreflang=&quot;en&quot;&gt;SpriteBatch.Draw&lt;/a&gt; method but it is cleaner to draw things in the right order and to tell XNA to draw directly (&lt;a href=&quot;http://msdn.microsoft.com/en-us/library/microsoft.xna.framework.graphics.spritesortmode%28v=XNAGameStudio.40%29.aspx&quot; hreflang=&quot;en&quot;&gt;SpriteSortMode.Immediate&lt;/a&gt;) because: 1) your code will be much more readable 2) it will be faster at execution.&lt;/p&gt;


&lt;p&gt;Let’s draw our background first:&lt;/p&gt;

&lt;pre class=&quot;csharp&quot;&gt;&lt;ol&gt;&lt;li style=&quot;font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;&quot;&gt;&lt;div style=&quot;font-family: 'Courier New', Courier, monospace; font-weight: normal;&quot;&gt;&lt;span style=&quot;color: #0600FF;&quot;&gt;protected&lt;/span&gt; &lt;span style=&quot;color: #0600FF;&quot;&gt;override&lt;/span&gt; &lt;span style=&quot;color: #0600FF;&quot;&gt;void&lt;/span&gt; Draw&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#40;&lt;/span&gt;GameTime gameTime&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style=&quot;font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;&quot;&gt;&lt;div style=&quot;font-family: 'Courier New', Courier, monospace; font-weight: normal;&quot;&gt;        &lt;span style=&quot;color: #000000;&quot;&gt;&amp;#123;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style=&quot;font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;&quot;&gt;&lt;div style=&quot;font-family: 'Courier New', Courier, monospace; font-weight: normal;&quot;&gt;            GraphicsDevice.&lt;span style=&quot;color: #0000FF;&quot;&gt;Clear&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#40;&lt;/span&gt;Color.&lt;span style=&quot;color: #0000FF;&quot;&gt;CornflowerBlue&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#41;&lt;/span&gt;; &lt;span style=&quot;color: #008080; font-style: italic;&quot;&gt;// clear all the screen with a blue color&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style=&quot;font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;&quot;&gt;&lt;div style=&quot;font-family: 'Courier New', Courier, monospace; font-weight: normal;&quot;&gt;&amp;nbsp;&lt;/div&gt;&lt;/li&gt;&lt;li style=&quot;font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;&quot;&gt;&lt;div style=&quot;font-family: 'Courier New', Courier, monospace; font-weight: normal;&quot;&gt;            &lt;span style=&quot;color: #008080; font-style: italic;&quot;&gt;// draw the grass background&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style=&quot;font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;&quot;&gt;&lt;div style=&quot;font-family: 'Courier New', Courier, monospace; font-weight: normal;&quot;&gt;            spriteBatch.&lt;span style=&quot;color: #0000FF;&quot;&gt;Begin&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#41;&lt;/span&gt;;&lt;/div&gt;&lt;/li&gt;&lt;li style=&quot;font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;&quot;&gt;&lt;div style=&quot;font-family: 'Courier New', Courier, monospace; font-weight: normal;&quot;&gt;            spriteBatch.&lt;span style=&quot;color: #0000FF;&quot;&gt;Draw&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style=&quot;font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;&quot;&gt;&lt;div style=&quot;font-family: 'Courier New', Courier, monospace; font-weight: normal;&quot;&gt;                grass, &lt;span style=&quot;color: #008080; font-style: italic;&quot;&gt;// use the grass texture&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style=&quot;font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;&quot;&gt;&lt;div style=&quot;font-family: 'Courier New', Courier, monospace; font-weight: normal;&quot;&gt;                GraphicsDevice.&lt;span style=&quot;color: #0000FF;&quot;&gt;Viewport&lt;/span&gt;.&lt;span style=&quot;color: #0000FF;&quot;&gt;Bounds&lt;/span&gt;, &lt;span style=&quot;color: #008080; font-style: italic;&quot;&gt;// stretch the texture to the whole screen&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style=&quot;font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;&quot;&gt;&lt;div style=&quot;font-family: 'Courier New', Courier, monospace; font-weight: normal;&quot;&gt;                &lt;span style=&quot;color: #008080; font-style: italic;&quot;&gt;// GraphicsDevice.Viewport.Bounds is Rectangle corresponding to the actual viewport (meaning the entire screen no matter the resolution), only available as of XNA 4.0 CTP&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style=&quot;font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;&quot;&gt;&lt;div style=&quot;font-family: 'Courier New', Courier, monospace; font-weight: normal;&quot;&gt;                Color.&lt;span style=&quot;color: #0000FF;&quot;&gt;White&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#41;&lt;/span&gt;;&lt;/div&gt;&lt;/li&gt;&lt;li style=&quot;font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;&quot;&gt;&lt;div style=&quot;font-family: 'Courier New', Courier, monospace; font-weight: normal;&quot;&gt;            spriteBatch.&lt;span style=&quot;color: #0000FF;&quot;&gt;End&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#41;&lt;/span&gt;;&lt;/div&gt;&lt;/li&gt;&lt;/ol&gt;&lt;/pre&gt;


&lt;p&gt;What’s new here? We’re using the &lt;a href=&quot;http://msdn.microsoft.com/en-us/library/microsoft.xna.framework.graphics.viewport.bounds%28XNAGameStudio.40%29.aspx&quot; hreflang=&quot;en&quot;&gt;Viewport.Bounds&lt;/a&gt; as our destination &lt;a href=&quot;http://msdn.microsoft.com/en-us/library/microsoft.xna.framework.rectangle%28v=XNAGameStudio.40%29.aspx&quot; hreflang=&quot;en&quot;&gt;Rectangle&lt;/a&gt;, why? Do you remember that this Rectangle always represent the whole screen resolution? We’re just telling the Draw method to stretch the entire grass texture to the entire screen. And we’re done with our background. At this state, if you try to run the game (by pressing F5 to debug it), it should display our nice grass tennis field.&lt;/p&gt;


&lt;p&gt;&lt;img src=&quot;http://www.handcrafted-games.com/public/Tuto1/grass.png&quot; alt=&quot;grass.png&quot; style=&quot;display:block; margin:0 auto;&quot; title=&quot;grass.png, Jun 2010&quot; /&gt;&lt;/p&gt;


&lt;p&gt;What comes after the background? The bars and the ball should be on the same plane. We can draw all of them at the same time since there’s no risk that they overlap but, wait… all the assets of those entities are in the same single texture. Once again, do you remember the usage of “source rectangle”? (Check the introduction if the answer is no). Before drawing our elements we need to define a source rectangle for each of them to access individual portion of the texture. Look at what’s inside the texture and how it is placed:&lt;/p&gt;


&lt;p&gt;&lt;img src=&quot;http://www.handcrafted-games.com/public/Tuto1/spritesheet.png&quot; alt=&quot;spritesheet.png&quot; style=&quot;display:block; margin:0 auto;&quot; title=&quot;spritesheet.png, Jun 2010&quot; /&gt;&lt;/p&gt;


&lt;p&gt;The following three source rectangles should be easy to understand (define them as &lt;a href=&quot;http://msdn.microsoft.com/en-us/library/microsoft.xna.framework.game%28v=XNAGameStudio.40%29.aspx&quot; hreflang=&quot;en&quot;&gt;Game1&lt;/a&gt; class members):&lt;/p&gt;

&lt;pre class=&quot;csharp&quot;&gt;&lt;ol&gt;&lt;li style=&quot;font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;&quot;&gt;&lt;div style=&quot;font-family: 'Courier New', Courier, monospace; font-weight: normal;&quot;&gt;&lt;span style=&quot;color: #008080; font-style: italic;&quot;&gt;// source rectangles of our graphics&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style=&quot;font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;&quot;&gt;&lt;div style=&quot;font-family: 'Courier New', Courier, monospace; font-weight: normal;&quot;&gt;        Rectangle blueSrcRect &lt;span style=&quot;color: #008000;&quot;&gt;=&lt;/span&gt; &lt;span style=&quot;color: #008000;&quot;&gt;new&lt;/span&gt; Rectangle&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#40;&lt;/span&gt; &lt;span style=&quot;color: #008080; font-style: italic;&quot;&gt;// blue bar src rectangle&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style=&quot;font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;&quot;&gt;&lt;div style=&quot;font-family: 'Courier New', Courier, monospace; font-weight: normal;&quot;&gt;            &lt;span style=&quot;color: #FF0000;&quot;&gt;0&lt;/span&gt;, &lt;span style=&quot;color: #008080; font-style: italic;&quot;&gt;// upper left corner x-coordinate of the blue bar inside the spriteSheet&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style=&quot;font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;&quot;&gt;&lt;div style=&quot;font-family: 'Courier New', Courier, monospace; font-weight: normal;&quot;&gt;            &lt;span style=&quot;color: #FF0000;&quot;&gt;0&lt;/span&gt;, &lt;span style=&quot;color: #008080; font-style: italic;&quot;&gt;// upper left corner y-coordinate&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style=&quot;font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;&quot;&gt;&lt;div style=&quot;font-family: 'Courier New', Courier, monospace; font-weight: normal;&quot;&gt;            &lt;span style=&quot;color: #FF0000;&quot;&gt;32&lt;/span&gt;, &lt;span style=&quot;color: #008080; font-style: italic;&quot;&gt;// width&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style=&quot;font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;&quot;&gt;&lt;div style=&quot;font-family: 'Courier New', Courier, monospace; font-weight: normal;&quot;&gt;            &lt;span style=&quot;color: #FF0000;&quot;&gt;128&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#41;&lt;/span&gt;; &lt;span style=&quot;color: #008080; font-style: italic;&quot;&gt;// height&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style=&quot;font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;&quot;&gt;&lt;div style=&quot;font-family: 'Courier New', Courier, monospace; font-weight: normal;&quot;&gt;        Rectangle redSrcRect &lt;span style=&quot;color: #008000;&quot;&gt;=&lt;/span&gt; &lt;span style=&quot;color: #008000;&quot;&gt;new&lt;/span&gt; Rectangle&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#40;&lt;/span&gt; &lt;span style=&quot;color: #008080; font-style: italic;&quot;&gt;// red bar src rectangle&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style=&quot;font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;&quot;&gt;&lt;div style=&quot;font-family: 'Courier New', Courier, monospace; font-weight: normal;&quot;&gt;            &lt;span style=&quot;color: #FF0000;&quot;&gt;32&lt;/span&gt;, &lt;span style=&quot;color: #008080; font-style: italic;&quot;&gt;// upper left corner x-coordinate of the red bar inside the spriteSheet&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style=&quot;font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;&quot;&gt;&lt;div style=&quot;font-family: 'Courier New', Courier, monospace; font-weight: normal;&quot;&gt;            &lt;span style=&quot;color: #FF0000;&quot;&gt;0&lt;/span&gt;,&lt;/div&gt;&lt;/li&gt;&lt;li style=&quot;font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;&quot;&gt;&lt;div style=&quot;font-family: 'Courier New', Courier, monospace; font-weight: normal;&quot;&gt;            &lt;span style=&quot;color: #FF0000;&quot;&gt;32&lt;/span&gt;,&lt;/div&gt;&lt;/li&gt;&lt;li style=&quot;font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;&quot;&gt;&lt;div style=&quot;font-family: 'Courier New', Courier, monospace; font-weight: normal;&quot;&gt;            &lt;span style=&quot;color: #FF0000;&quot;&gt;128&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#41;&lt;/span&gt;;&lt;/div&gt;&lt;/li&gt;&lt;li style=&quot;font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;&quot;&gt;&lt;div style=&quot;font-family: 'Courier New', Courier, monospace; font-weight: normal;&quot;&gt;        Rectangle ballSrcRect &lt;span style=&quot;color: #008000;&quot;&gt;=&lt;/span&gt; &lt;span style=&quot;color: #008000;&quot;&gt;new&lt;/span&gt; Rectangle&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#40;&lt;/span&gt; &lt;span style=&quot;color: #008080; font-style: italic;&quot;&gt;// ball src rectangle&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style=&quot;font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;&quot;&gt;&lt;div style=&quot;font-family: 'Courier New', Courier, monospace; font-weight: normal;&quot;&gt;            &lt;span style=&quot;color: #FF0000;&quot;&gt;64&lt;/span&gt;, &lt;span style=&quot;color: #008080; font-style: italic;&quot;&gt;// upper left corner x-coordinate of the ball inside the spriteSheet&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style=&quot;font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;&quot;&gt;&lt;div style=&quot;font-family: 'Courier New', Courier, monospace; font-weight: normal;&quot;&gt;            &lt;span style=&quot;color: #FF0000;&quot;&gt;0&lt;/span&gt;,&lt;/div&gt;&lt;/li&gt;&lt;li style=&quot;font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;&quot;&gt;&lt;div style=&quot;font-family: 'Courier New', Courier, monospace; font-weight: normal;&quot;&gt;            &lt;span style=&quot;color: #FF0000;&quot;&gt;32&lt;/span&gt;,&lt;/div&gt;&lt;/li&gt;&lt;li style=&quot;font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;&quot;&gt;&lt;div style=&quot;font-family: 'Courier New', Courier, monospace; font-weight: normal;&quot;&gt;            &lt;span style=&quot;color: #FF0000;&quot;&gt;32&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#41;&lt;/span&gt;;&lt;/div&gt;&lt;/li&gt;&lt;/ol&gt;&lt;/pre&gt;


&lt;p&gt;We now have everything up to draw the remaining elements. Here’s what comes after our backgrounds drawing:&lt;/p&gt;

&lt;pre class=&quot;csharp&quot;&gt;&lt;ol&gt;&lt;li style=&quot;font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;&quot;&gt;&lt;div style=&quot;font-family: 'Courier New', Courier, monospace; font-weight: normal;&quot;&gt;&lt;span style=&quot;color: #008080; font-style: italic;&quot;&gt;// draw the entities (bars and ball)&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style=&quot;font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;&quot;&gt;&lt;div style=&quot;font-family: 'Courier New', Courier, monospace; font-weight: normal;&quot;&gt;            spriteBatch.&lt;span style=&quot;color: #0000FF;&quot;&gt;Begin&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#40;&lt;/span&gt;SpriteSortMode.&lt;span style=&quot;color: #0000FF;&quot;&gt;Immediate&lt;/span&gt;, BlendState.&lt;span style=&quot;color: #0000FF;&quot;&gt;AlphaBlend&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#41;&lt;/span&gt;; &lt;span style=&quot;color: #008080; font-style: italic;&quot;&gt;// setup alpha blend to support transparency&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style=&quot;font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;&quot;&gt;&lt;div style=&quot;font-family: 'Courier New', Courier, monospace; font-weight: normal;&quot;&gt;            &lt;span style=&quot;color: #008080; font-style: italic;&quot;&gt;// draw the red bar&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style=&quot;font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;&quot;&gt;&lt;div style=&quot;font-family: 'Courier New', Courier, monospace; font-weight: normal;&quot;&gt;            spriteBatch.&lt;span style=&quot;color: #0000FF;&quot;&gt;Draw&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style=&quot;font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;&quot;&gt;&lt;div style=&quot;font-family: 'Courier New', Courier, monospace; font-weight: normal;&quot;&gt;                spriteSheet, &lt;span style=&quot;color: #008080; font-style: italic;&quot;&gt;// use the sprites texture&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style=&quot;font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;&quot;&gt;&lt;div style=&quot;font-family: 'Courier New', Courier, monospace; font-weight: normal;&quot;&gt;                redBar, &lt;span style=&quot;color: #008080; font-style: italic;&quot;&gt;// the rectangle where to draw the bar on the screen&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style=&quot;font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;&quot;&gt;&lt;div style=&quot;font-family: 'Courier New', Courier, monospace; font-weight: normal;&quot;&gt;                redSrcRect, &lt;span style=&quot;color: #008080; font-style: italic;&quot;&gt;// the source rectangle of the bar inside the sprite sheet&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style=&quot;font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;&quot;&gt;&lt;div style=&quot;font-family: 'Courier New', Courier, monospace; font-weight: normal;&quot;&gt;                Color.&lt;span style=&quot;color: #0000FF;&quot;&gt;White&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#41;&lt;/span&gt;;&lt;/div&gt;&lt;/li&gt;&lt;li style=&quot;font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;&quot;&gt;&lt;div style=&quot;font-family: 'Courier New', Courier, monospace; font-weight: normal;&quot;&gt;            &lt;span style=&quot;color: #008080; font-style: italic;&quot;&gt;// draw the blue bar&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style=&quot;font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;&quot;&gt;&lt;div style=&quot;font-family: 'Courier New', Courier, monospace; font-weight: normal;&quot;&gt;            spriteBatch.&lt;span style=&quot;color: #0000FF;&quot;&gt;Draw&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style=&quot;font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;&quot;&gt;&lt;div style=&quot;font-family: 'Courier New', Courier, monospace; font-weight: normal;&quot;&gt;                spriteSheet,&lt;/div&gt;&lt;/li&gt;&lt;li style=&quot;font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;&quot;&gt;&lt;div style=&quot;font-family: 'Courier New', Courier, monospace; font-weight: normal;&quot;&gt;                blueBar,&lt;/div&gt;&lt;/li&gt;&lt;li style=&quot;font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;&quot;&gt;&lt;div style=&quot;font-family: 'Courier New', Courier, monospace; font-weight: normal;&quot;&gt;                blueSrcRect,&lt;/div&gt;&lt;/li&gt;&lt;li style=&quot;font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;&quot;&gt;&lt;div style=&quot;font-family: 'Courier New', Courier, monospace; font-weight: normal;&quot;&gt;                Color.&lt;span style=&quot;color: #0000FF;&quot;&gt;White&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#41;&lt;/span&gt;;&lt;/div&gt;&lt;/li&gt;&lt;li style=&quot;font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;&quot;&gt;&lt;div style=&quot;font-family: 'Courier New', Courier, monospace; font-weight: normal;&quot;&gt;            &lt;span style=&quot;color: #008080; font-style: italic;&quot;&gt;// draw the ball&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style=&quot;font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;&quot;&gt;&lt;div style=&quot;font-family: 'Courier New', Courier, monospace; font-weight: normal;&quot;&gt;            spriteBatch.&lt;span style=&quot;color: #0000FF;&quot;&gt;Draw&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style=&quot;font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;&quot;&gt;&lt;div style=&quot;font-family: 'Courier New', Courier, monospace; font-weight: normal;&quot;&gt;                spriteSheet,&lt;/div&gt;&lt;/li&gt;&lt;li style=&quot;font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;&quot;&gt;&lt;div style=&quot;font-family: 'Courier New', Courier, monospace; font-weight: normal;&quot;&gt;                ball,&lt;/div&gt;&lt;/li&gt;&lt;li style=&quot;font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;&quot;&gt;&lt;div style=&quot;font-family: 'Courier New', Courier, monospace; font-weight: normal;&quot;&gt;                ballSrcRect,&lt;/div&gt;&lt;/li&gt;&lt;li style=&quot;font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;&quot;&gt;&lt;div style=&quot;font-family: 'Courier New', Courier, monospace; font-weight: normal;&quot;&gt;                Color.&lt;span style=&quot;color: #0000FF;&quot;&gt;White&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#41;&lt;/span&gt;;&lt;/div&gt;&lt;/li&gt;&lt;li style=&quot;font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;&quot;&gt;&lt;div style=&quot;font-family: 'Courier New', Courier, monospace; font-weight: normal;&quot;&gt;            spriteBatch.&lt;span style=&quot;color: #0000FF;&quot;&gt;End&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#41;&lt;/span&gt;;&lt;/div&gt;&lt;/li&gt;&lt;/ol&gt;&lt;/pre&gt;


&lt;p&gt;Press F5, and see that our game almost look like it is finished. There’s still all the gameplay to implement but our graphics are setup and we’re now free to toy with the gameplay.&lt;/p&gt;


&lt;p&gt;&lt;img src=&quot;http://www.handcrafted-games.com/public/Tuto1/nogameplay.png&quot; alt=&quot;nogameplay.png&quot; style=&quot;display:block; margin:0 auto;&quot; title=&quot;nogameplay.png, Jun 2010&quot; /&gt;&lt;/p&gt;


&lt;h4&gt;Coding the gameplay&lt;/h4&gt;


&lt;h5&gt;Handling the inputs&lt;/h5&gt;


&lt;p&gt;Now that we’re done with the &lt;a href=&quot;http://msdn.microsoft.com/en-us/library/microsoft.xna.framework.game.draw%28v=XNAGameStudio.40%29.aspx&quot; hreflang=&quot;en&quot;&gt;Draw&lt;/a&gt; method, we’ll take a look at the &lt;a href=&quot;http://msdn.microsoft.com/en-us/library/microsoft.xna.framework.game.update%28v=XNAGameStudio.40%29.aspx&quot; hreflang=&quot;en&quot;&gt;Update&lt;/a&gt; method, so go at the corresponding line of code, we’re going to examine its default content:&lt;/p&gt;

&lt;pre class=&quot;csharp&quot;&gt;&lt;ol&gt;&lt;li style=&quot;font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;&quot;&gt;&lt;div style=&quot;font-family: 'Courier New', Courier, monospace; font-weight: normal;&quot;&gt;&lt;span style=&quot;color: #0600FF;&quot;&gt;if&lt;/span&gt; &lt;span style=&quot;color: #000000;&quot;&gt;&amp;#40;&lt;/span&gt;GamePad.&lt;span style=&quot;color: #0000FF;&quot;&gt;GetState&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#40;&lt;/span&gt;PlayerIndex.&lt;span style=&quot;color: #0000FF;&quot;&gt;One&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#41;&lt;/span&gt;.&lt;span style=&quot;color: #0000FF;&quot;&gt;Buttons&lt;/span&gt;.&lt;span style=&quot;color: #0000FF;&quot;&gt;Back&lt;/span&gt; &lt;span style=&quot;color: #008000;&quot;&gt;==&lt;/span&gt; ButtonState.&lt;span style=&quot;color: #0000FF;&quot;&gt;Pressed&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#41;&lt;/span&gt; &lt;span style=&quot;color: #008080; font-style: italic;&quot;&gt;// if the Back gamepad button is pressed&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style=&quot;font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;&quot;&gt;&lt;div style=&quot;font-family: 'Courier New', Courier, monospace; font-weight: normal;&quot;&gt;        &lt;span style=&quot;color: #0600FF;&quot;&gt;this&lt;/span&gt;.&lt;span style=&quot;color: #0000FF;&quot;&gt;Exit&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#41;&lt;/span&gt;; &lt;span style=&quot;color: #008080; font-style: italic;&quot;&gt;// exit our game&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;/ol&gt;&lt;/pre&gt;


&lt;p&gt;The &lt;a href=&quot;http://msdn.microsoft.com/en-us/library/microsoft.xna.framework.input.gamepad%28v=XNAGameStudio.40%29.aspx&quot; hreflang=&quot;en&quot;&gt;GamePad&lt;/a&gt; class allows getting the current state of an Xbox 360 gamepad, being plugged to a PC or to your 360. Its &lt;a href=&quot;http://msdn.microsoft.com/en-us/library/microsoft.xna.framework.input.gamepad.getstate%28v=XNAGameStudio.40%29.aspx&quot; hreflang=&quot;en&quot;&gt;GetState(PlayerIndex)&lt;/a&gt; method returns the &lt;a href=&quot;http://msdn.microsoft.com/en-us/library/microsoft.xna.framework.input.gamepadstate%28v=XNAGameStudio.40%29.aspx&quot; hreflang=&quot;en&quot;&gt;GamePadState&lt;/a&gt; of the player corresponding to the given &lt;a href=&quot;http://msdn.microsoft.com/en-us/library/microsoft.xna.framework.playerindex%28v=XNAGameStudio.40%29.aspx&quot; hreflang=&quot;en&quot;&gt;PlayerIndex&lt;/a&gt;.&lt;/p&gt;


&lt;p&gt;A &lt;a href=&quot;http://msdn.microsoft.com/en-us/library/microsoft.xna.framework.input.gamepadstate%28v=XNAGameStudio.40%29.aspx&quot; hreflang=&quot;en&quot;&gt;GamePadState&lt;/a&gt; object has a Buttons member, listing every up-down buttons and their state (A, B, Y, X, RB, LB, Back, Start, and Buttons on Sticks). If you want to know if a button is pressed, just compare a button to a &lt;a href=&quot;http://msdn.microsoft.com/en-us/library/microsoft.xna.framework.input.buttonstate%28v=XNAGameStudio.40%29.aspx&quot; hreflang=&quot;en&quot;&gt;ButtonState&lt;/a&gt;. Buttons of the directional pad works the same way and their states are stored in the &lt;a href=&quot;http://msdn.microsoft.com/en-us/library/microsoft.xna.framework.input.gamepadstate.dpad(v=XNAGameStudio.40).aspx&quot; hreflang=&quot;en&quot;&gt;DPad&lt;/a&gt; member of a &lt;a href=&quot;http://msdn.microsoft.com/en-us/library/microsoft.xna.framework.input.gamepadstate%28v=XNAGameStudio.40%29.aspx&quot; hreflang=&quot;en&quot;&gt;GamePadState&lt;/a&gt;. The other inputs of a gamepad are different, they’re continuous (Sticks’ X &amp;amp; Y axes and Triggers) so you can’t compare them to a &lt;a href=&quot;http://msdn.microsoft.com/en-us/library/microsoft.xna.framework.input.buttonstate%28v=XNAGameStudio.40%29.aspx&quot; hreflang=&quot;en&quot;&gt;ButtonState&lt;/a&gt; since they are floating point values. When in default position, those controls have 0.0f value. Triggers go up to 1.0f when fully pressed and the axes range from -1.0f up to 1.0f depending the direction of the axes. (X = 1.0f and Y = -1.0f would mean that the stick is in the lower right corner).&lt;/p&gt;


&lt;p&gt;Getting the keyboard state works pretty much the same way. Let’s add a keyboard control to the default code:&lt;/p&gt;

&lt;pre class=&quot;csharp&quot;&gt;&lt;ol&gt;&lt;li style=&quot;font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;&quot;&gt;&lt;div style=&quot;font-family: 'Courier New', Courier, monospace; font-weight: normal;&quot;&gt;&lt;span style=&quot;color: #0600FF;&quot;&gt;if&lt;/span&gt; &lt;span style=&quot;color: #000000;&quot;&gt;&amp;#40;&lt;/span&gt;GamePad.&lt;span style=&quot;color: #0000FF;&quot;&gt;GetState&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#40;&lt;/span&gt;PlayerIndex.&lt;span style=&quot;color: #0000FF;&quot;&gt;One&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#41;&lt;/span&gt;.&lt;span style=&quot;color: #0000FF;&quot;&gt;Buttons&lt;/span&gt;.&lt;span style=&quot;color: #0000FF;&quot;&gt;Back&lt;/span&gt; &lt;span style=&quot;color: #008000;&quot;&gt;==&lt;/span&gt; ButtonState.&lt;span style=&quot;color: #0000FF;&quot;&gt;Pressed&lt;/span&gt; &lt;span style=&quot;color: #008000;&quot;&gt;||&lt;/span&gt; &lt;span style=&quot;color: #008080; font-style: italic;&quot;&gt;// if the Back gamepad button is pressed&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style=&quot;font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;&quot;&gt;&lt;div style=&quot;font-family: 'Courier New', Courier, monospace; font-weight: normal;&quot;&gt;                Keyboard.&lt;span style=&quot;color: #0000FF;&quot;&gt;GetState&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#41;&lt;/span&gt;.&lt;span style=&quot;color: #0000FF;&quot;&gt;IsKeyDown&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#40;&lt;/span&gt;Keys.&lt;span style=&quot;color: #0000FF;&quot;&gt;Escape&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#41;&lt;/span&gt; &lt;span style=&quot;color: #008080; font-style: italic;&quot;&gt;// or if the Escape key is down&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style=&quot;font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;&quot;&gt;&lt;div style=&quot;font-family: 'Courier New', Courier, monospace; font-weight: normal;&quot;&gt;                &lt;span style=&quot;color: #0600FF;&quot;&gt;this&lt;/span&gt;.&lt;span style=&quot;color: #0000FF;&quot;&gt;Exit&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#41;&lt;/span&gt;; &lt;span style=&quot;color: #008080; font-style: italic;&quot;&gt;// exit our game&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;/ol&gt;&lt;/pre&gt;


&lt;p&gt;&lt;a href=&quot;http://msdn.microsoft.com/en-us/library/microsoft.xna.framework.input.keyboard.getstate%28v=XNAGameStudio.40%29.aspx&quot; hreflang=&quot;en&quot;&gt;Keyboard.GetState()&lt;/a&gt; should be simple to understand now. But what is this &lt;a href=&quot;http://msdn.microsoft.com/en-us/library/microsoft.xna.framework.input.keyboardstate.iskeydown(v=XNAGameStudio.40).aspx&quot; hreflang=&quot;en&quot;&gt;IsKeyDown&lt;/a&gt; method? Unlike a &lt;a href=&quot;http://msdn.microsoft.com/en-us/library/microsoft.xna.framework.input.gamepadstate%28v=XNAGameStudio.40%29.aspx&quot; hreflang=&quot;en&quot;&gt;GamePadState&lt;/a&gt;, &lt;a href=&quot;http://msdn.microsoft.com/en-us/library/microsoft.xna.framework.input.keyboardstate%28v=XNAGameStudio.40%29.aspx&quot; hreflang=&quot;en&quot;&gt;KeyboardState&lt;/a&gt; don’t hold directly fields with keys’ states, you have to ask for a state with the &lt;a href=&quot;http://msdn.microsoft.com/en-us/library/microsoft.xna.framework.input.keyboardstate.iskeydown(v=XNAGameStudio.40).aspx&quot; hreflang=&quot;en&quot;&gt;IsKeyDown&lt;/a&gt; / &lt;a href=&quot;http://msdn.microsoft.com/en-us/library/microsoft.xna.framework.input.keyboardstate.iskeyup(v=XNAGameStudio.40).aspx&quot; hreflang=&quot;en&quot;&gt;IsKeyUp&lt;/a&gt; methods. Actually, &lt;a href=&quot;http://msdn.microsoft.com/en-us/library/microsoft.xna.framework.input.gamepadstate%28v=XNAGameStudio.40%29.aspx&quot; hreflang=&quot;en&quot;&gt;GamePadState&lt;/a&gt; has a similar mechanism and propose the &lt;a href=&quot;http://msdn.microsoft.com/en-us/library/microsoft.xna.framework.input.gamepadstate.isbuttondown(v=XNAGameStudio.40).aspx&quot; hreflang=&quot;en&quot;&gt;IsButtonDown&lt;/a&gt; / &lt;a href=&quot;http://msdn.microsoft.com/en-us/library/microsoft.xna.framework.input.gamepadstate.isbuttonup(v=XNAGameStudio.40).aspx&quot; hreflang=&quot;en&quot;&gt;IsButtonUp&lt;/a&gt; methods.&lt;/p&gt;


&lt;h5&gt;Moving the bars&lt;/h5&gt;


&lt;p&gt;Our bars are represented by the redBar and blueBar rectangles, so if we want them to move, when need to modify their Y position (in a Pong game, bars only move along the Y axis). We will use the keyboard as our main input method, up to you to add handle two different gamepads.&lt;/p&gt;

&lt;pre class=&quot;csharp&quot;&gt;&lt;ol&gt;&lt;li style=&quot;font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;&quot;&gt;&lt;div style=&quot;font-family: 'Courier New', Courier, monospace; font-weight: normal;&quot;&gt;&lt;span style=&quot;color: #008080; font-style: italic;&quot;&gt;// handling keyboard inputs&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style=&quot;font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;&quot;&gt;&lt;div style=&quot;font-family: 'Courier New', Courier, monospace; font-weight: normal;&quot;&gt;            &lt;span style=&quot;color: #0600FF;&quot;&gt;if&lt;/span&gt; &lt;span style=&quot;color: #000000;&quot;&gt;&amp;#40;&lt;/span&gt;Keyboard.&lt;span style=&quot;color: #0000FF;&quot;&gt;GetState&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#41;&lt;/span&gt;.&lt;span style=&quot;color: #0000FF;&quot;&gt;IsKeyDown&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#40;&lt;/span&gt;Keys.&lt;span style=&quot;color: #0000FF;&quot;&gt;E&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#41;&lt;/span&gt; &lt;span style=&quot;color: #008080; font-style: italic;&quot;&gt;// E key down ?&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style=&quot;font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;&quot;&gt;&lt;div style=&quot;font-family: 'Courier New', Courier, monospace; font-weight: normal;&quot;&gt;                blueBar.&lt;span style=&quot;color: #0000FF;&quot;&gt;Y&lt;/span&gt; &lt;span style=&quot;color: #008000;&quot;&gt;-=&lt;/span&gt; &lt;span style=&quot;color: #FF0000;&quot;&gt;10&lt;/span&gt;; &lt;span style=&quot;color: #008080; font-style: italic;&quot;&gt;// move the blue bar up&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style=&quot;font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;&quot;&gt;&lt;div style=&quot;font-family: 'Courier New', Courier, monospace; font-weight: normal;&quot;&gt;            &lt;span style=&quot;color: #0600FF;&quot;&gt;else&lt;/span&gt; &lt;span style=&quot;color: #0600FF;&quot;&gt;if&lt;/span&gt; &lt;span style=&quot;color: #000000;&quot;&gt;&amp;#40;&lt;/span&gt;Keyboard.&lt;span style=&quot;color: #0000FF;&quot;&gt;GetState&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#41;&lt;/span&gt;.&lt;span style=&quot;color: #0000FF;&quot;&gt;IsKeyDown&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#40;&lt;/span&gt;Keys.&lt;span style=&quot;color: #0000FF;&quot;&gt;D&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#41;&lt;/span&gt; &lt;span style=&quot;color: #008080; font-style: italic;&quot;&gt;// D key down ?&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style=&quot;font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;&quot;&gt;&lt;div style=&quot;font-family: 'Courier New', Courier, monospace; font-weight: normal;&quot;&gt;                blueBar.&lt;span style=&quot;color: #0000FF;&quot;&gt;Y&lt;/span&gt; &lt;span style=&quot;color: #008000;&quot;&gt;+=&lt;/span&gt; &lt;span style=&quot;color: #FF0000;&quot;&gt;10&lt;/span&gt;; &lt;span style=&quot;color: #008080; font-style: italic;&quot;&gt;// move the blue bar down&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style=&quot;font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;&quot;&gt;&lt;div style=&quot;font-family: 'Courier New', Courier, monospace; font-weight: normal;&quot;&gt;            &lt;span style=&quot;color: #0600FF;&quot;&gt;if&lt;/span&gt; &lt;span style=&quot;color: #000000;&quot;&gt;&amp;#40;&lt;/span&gt;Keyboard.&lt;span style=&quot;color: #0000FF;&quot;&gt;GetState&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#41;&lt;/span&gt;.&lt;span style=&quot;color: #0000FF;&quot;&gt;IsKeyDown&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#40;&lt;/span&gt;Keys.&lt;span style=&quot;color: #0000FF;&quot;&gt;Up&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#41;&lt;/span&gt; &lt;span style=&quot;color: #008080; font-style: italic;&quot;&gt;// Up key down ?&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style=&quot;font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;&quot;&gt;&lt;div style=&quot;font-family: 'Courier New', Courier, monospace; font-weight: normal;&quot;&gt;                redBar.&lt;span style=&quot;color: #0000FF;&quot;&gt;Y&lt;/span&gt; &lt;span style=&quot;color: #008000;&quot;&gt;-=&lt;/span&gt; &lt;span style=&quot;color: #FF0000;&quot;&gt;10&lt;/span&gt;; &lt;span style=&quot;color: #008080; font-style: italic;&quot;&gt;// move the red bar up&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style=&quot;font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;&quot;&gt;&lt;div style=&quot;font-family: 'Courier New', Courier, monospace; font-weight: normal;&quot;&gt;            &lt;span style=&quot;color: #0600FF;&quot;&gt;else&lt;/span&gt; &lt;span style=&quot;color: #0600FF;&quot;&gt;if&lt;/span&gt; &lt;span style=&quot;color: #000000;&quot;&gt;&amp;#40;&lt;/span&gt;Keyboard.&lt;span style=&quot;color: #0000FF;&quot;&gt;GetState&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#41;&lt;/span&gt;.&lt;span style=&quot;color: #0000FF;&quot;&gt;IsKeyDown&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#40;&lt;/span&gt;Keys.&lt;span style=&quot;color: #0000FF;&quot;&gt;Down&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#41;&lt;/span&gt; &lt;span style=&quot;color: #008080; font-style: italic;&quot;&gt;// Down key down ?&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style=&quot;font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;&quot;&gt;&lt;div style=&quot;font-family: 'Courier New', Courier, monospace; font-weight: normal;&quot;&gt;                redBar.&lt;span style=&quot;color: #0000FF;&quot;&gt;Y&lt;/span&gt; &lt;span style=&quot;color: #008000;&quot;&gt;+=&lt;/span&gt; &lt;span style=&quot;color: #FF0000;&quot;&gt;10&lt;/span&gt;; &lt;span style=&quot;color: #008080; font-style: italic;&quot;&gt;// move the red bar down&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;/ol&gt;&lt;/pre&gt;


&lt;p&gt;Quite simply isn’t it? If you launch the game and try to move the bars (with the E/D and Up/Down keys) you’ll notice that the bar can go behind the screen. We don’t want that behavior since they should stop at screen borders.&lt;/p&gt;

&lt;pre class=&quot;csharp&quot;&gt;&lt;ol&gt;&lt;li style=&quot;font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;&quot;&gt;&lt;div style=&quot;font-family: 'Courier New', Courier, monospace; font-weight: normal;&quot;&gt;&lt;span style=&quot;color: #008080; font-style: italic;&quot;&gt;// limit the bars movement to the screen bounds&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style=&quot;font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;&quot;&gt;&lt;div style=&quot;font-family: 'Courier New', Courier, monospace; font-weight: normal;&quot;&gt;            &lt;span style=&quot;color: #0600FF;&quot;&gt;if&lt;/span&gt; &lt;span style=&quot;color: #000000;&quot;&gt;&amp;#40;&lt;/span&gt;redBar.&lt;span style=&quot;color: #0000FF;&quot;&gt;Y&lt;/span&gt; &lt;span style=&quot;color: #008000;&quot;&gt;&amp;lt;&lt;/span&gt; &lt;span style=&quot;color: #FF0000;&quot;&gt;0&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#41;&lt;/span&gt; &lt;span style=&quot;color: #008080; font-style: italic;&quot;&gt;// upper bound&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style=&quot;font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;&quot;&gt;&lt;div style=&quot;font-family: 'Courier New', Courier, monospace; font-weight: normal;&quot;&gt;                redBar.&lt;span style=&quot;color: #0000FF;&quot;&gt;Y&lt;/span&gt; &lt;span style=&quot;color: #008000;&quot;&gt;=&lt;/span&gt; &lt;span style=&quot;color: #FF0000;&quot;&gt;0&lt;/span&gt;; &lt;span style=&quot;color: #008080; font-style: italic;&quot;&gt;// limit&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style=&quot;font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;&quot;&gt;&lt;div style=&quot;font-family: 'Courier New', Courier, monospace; font-weight: normal;&quot;&gt;            &lt;span style=&quot;color: #0600FF;&quot;&gt;if&lt;/span&gt; &lt;span style=&quot;color: #000000;&quot;&gt;&amp;#40;&lt;/span&gt;blueBar.&lt;span style=&quot;color: #0000FF;&quot;&gt;Y&lt;/span&gt; &lt;span style=&quot;color: #008000;&quot;&gt;&amp;lt;&lt;/span&gt; &lt;span style=&quot;color: #FF0000;&quot;&gt;0&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style=&quot;font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;&quot;&gt;&lt;div style=&quot;font-family: 'Courier New', Courier, monospace; font-weight: normal;&quot;&gt;                blueBar.&lt;span style=&quot;color: #0000FF;&quot;&gt;Y&lt;/span&gt; &lt;span style=&quot;color: #008000;&quot;&gt;=&lt;/span&gt; &lt;span style=&quot;color: #FF0000;&quot;&gt;0&lt;/span&gt;;&lt;/div&gt;&lt;/li&gt;&lt;li style=&quot;font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;&quot;&gt;&lt;div style=&quot;font-family: 'Courier New', Courier, monospace; font-weight: normal;&quot;&gt;            &lt;span style=&quot;color: #0600FF;&quot;&gt;if&lt;/span&gt; &lt;span style=&quot;color: #000000;&quot;&gt;&amp;#40;&lt;/span&gt;redBar.&lt;span style=&quot;color: #0000FF;&quot;&gt;Y&lt;/span&gt; &lt;span style=&quot;color: #008000;&quot;&gt;+&lt;/span&gt; redBar.&lt;span style=&quot;color: #0000FF;&quot;&gt;Height&lt;/span&gt; &lt;span style=&quot;color: #008000;&quot;&gt;&amp;gt;&lt;/span&gt; GraphicsDevice.&lt;span style=&quot;color: #0000FF;&quot;&gt;Viewport&lt;/span&gt;.&lt;span style=&quot;color: #0000FF;&quot;&gt;Bounds&lt;/span&gt;.&lt;span style=&quot;color: #0000FF;&quot;&gt;Height&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style=&quot;font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;&quot;&gt;&lt;div style=&quot;font-family: 'Courier New', Courier, monospace; font-weight: normal;&quot;&gt;                redBar.&lt;span style=&quot;color: #0000FF;&quot;&gt;Y&lt;/span&gt; &lt;span style=&quot;color: #008000;&quot;&gt;=&lt;/span&gt; GraphicsDevice.&lt;span style=&quot;color: #0000FF;&quot;&gt;Viewport&lt;/span&gt;.&lt;span style=&quot;color: #0000FF;&quot;&gt;Bounds&lt;/span&gt;.&lt;span style=&quot;color: #0000FF;&quot;&gt;Height&lt;/span&gt; &lt;span style=&quot;color: #008000;&quot;&gt;-&lt;/span&gt; redBar.&lt;span style=&quot;color: #0000FF;&quot;&gt;Height&lt;/span&gt;;&lt;/div&gt;&lt;/li&gt;&lt;li style=&quot;font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;&quot;&gt;&lt;div style=&quot;font-family: 'Courier New', Courier, monospace; font-weight: normal;&quot;&gt;            &lt;span style=&quot;color: #0600FF;&quot;&gt;if&lt;/span&gt; &lt;span style=&quot;color: #000000;&quot;&gt;&amp;#40;&lt;/span&gt;blueBar.&lt;span style=&quot;color: #0000FF;&quot;&gt;Y&lt;/span&gt; &lt;span style=&quot;color: #008000;&quot;&gt;+&lt;/span&gt; blueBar.&lt;span style=&quot;color: #0000FF;&quot;&gt;Height&lt;/span&gt; &lt;span style=&quot;color: #008000;&quot;&gt;&amp;gt;&lt;/span&gt; GraphicsDevice.&lt;span style=&quot;color: #0000FF;&quot;&gt;Viewport&lt;/span&gt;.&lt;span style=&quot;color: #0000FF;&quot;&gt;Bounds&lt;/span&gt;.&lt;span style=&quot;color: #0000FF;&quot;&gt;Height&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style=&quot;font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;&quot;&gt;&lt;div style=&quot;font-family: 'Courier New', Courier, monospace; font-weight: normal;&quot;&gt;                blueBar.&lt;span style=&quot;color: #0000FF;&quot;&gt;Y&lt;/span&gt; &lt;span style=&quot;color: #008000;&quot;&gt;=&lt;/span&gt; GraphicsDevice.&lt;span style=&quot;color: #0000FF;&quot;&gt;Viewport&lt;/span&gt;.&lt;span style=&quot;color: #0000FF;&quot;&gt;Bounds&lt;/span&gt;.&lt;span style=&quot;color: #0000FF;&quot;&gt;Height&lt;/span&gt; &lt;span style=&quot;color: #008000;&quot;&gt;-&lt;/span&gt; blueBar.&lt;span style=&quot;color: #0000FF;&quot;&gt;Height&lt;/span&gt;;&lt;/div&gt;&lt;/li&gt;&lt;/ol&gt;&lt;/pre&gt;


&lt;p&gt;Now the bars don’t move outside the screen. The only trick resides in the handling of the lower bound: don’t forget to consider the bar height (the Y coordinates being the one of the upper left corner).&lt;/p&gt;


&lt;h5&gt;Ball’s motion&lt;/h5&gt;


&lt;p&gt;In order to make the ball moving, we need something to represent its velocity. Using a 2D vector seems to be the way to go. Fortunately, XNA already have everything at your disposal. Here we define a 2D vector (&lt;a href=&quot;http://msdn.microsoft.com/en-us/library/microsoft.xna.framework.vector2(v=XNAGameStudio.40).aspx&quot; hreflang=&quot;en&quot;&gt;Vector2&lt;/a&gt;) for our ball velocity (as a &lt;a href=&quot;http://msdn.microsoft.com/en-us/library/microsoft.xna.framework.game%28v=XNAGameStudio.40%29.aspx&quot; hreflang=&quot;en&quot;&gt;Game1&lt;/a&gt; class member):&lt;/p&gt;

&lt;pre class=&quot;csharp&quot;&gt;&lt;ol&gt;&lt;li style=&quot;font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;&quot;&gt;&lt;div style=&quot;font-family: 'Courier New', Courier, monospace; font-weight: normal;&quot;&gt;&lt;span style=&quot;color: #008080; font-style: italic;&quot;&gt;// ball speed&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style=&quot;font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;&quot;&gt;&lt;div style=&quot;font-family: 'Courier New', Courier, monospace; font-weight: normal;&quot;&gt;        Vector2 ballVelocity &lt;span style=&quot;color: #008000;&quot;&gt;=&lt;/span&gt; Vector2.&lt;span style=&quot;color: #0000FF;&quot;&gt;Zero&lt;/span&gt;;&lt;/div&gt;&lt;/li&gt;&lt;/ol&gt;&lt;/pre&gt;


&lt;p&gt;And back in the &lt;a href=&quot;http://msdn.microsoft.com/en-us/library/microsoft.xna.framework.game.update%28v=XNAGameStudio.40%29.aspx&quot; hreflang=&quot;en&quot;&gt;Update&lt;/a&gt; method, we can now make our ball move by adding its velocity to its current position:&lt;/p&gt;

&lt;pre class=&quot;csharp&quot;&gt;&lt;ol&gt;&lt;li style=&quot;font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;&quot;&gt;&lt;div style=&quot;font-family: 'Courier New', Courier, monospace; font-weight: normal;&quot;&gt;&lt;span style=&quot;color: #008080; font-style: italic;&quot;&gt;// move the ball&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style=&quot;font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;&quot;&gt;&lt;div style=&quot;font-family: 'Courier New', Courier, monospace; font-weight: normal;&quot;&gt;            ball.&lt;span style=&quot;color: #0000FF;&quot;&gt;X&lt;/span&gt; &lt;span style=&quot;color: #008000;&quot;&gt;+=&lt;/span&gt; &lt;span style=&quot;color: #000000;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #FF0000;&quot;&gt;int&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#41;&lt;/span&gt;ballVelocity.&lt;span style=&quot;color: #0000FF;&quot;&gt;X&lt;/span&gt;;&lt;/div&gt;&lt;/li&gt;&lt;li style=&quot;font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;&quot;&gt;&lt;div style=&quot;font-family: 'Courier New', Courier, monospace; font-weight: normal;&quot;&gt;            ball.&lt;span style=&quot;color: #0000FF;&quot;&gt;Y&lt;/span&gt; &lt;span style=&quot;color: #008000;&quot;&gt;+=&lt;/span&gt; &lt;span style=&quot;color: #000000;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #FF0000;&quot;&gt;int&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#41;&lt;/span&gt;ballVelocity.&lt;span style=&quot;color: #0000FF;&quot;&gt;Y&lt;/span&gt;;&lt;/div&gt;&lt;/li&gt;&lt;/ol&gt;&lt;/pre&gt;


&lt;p&gt;But, our ball isn’t really moving yet. Notice that we initialized the velocity to zero speed. We need to set a positive speed somewhere so the gameplay can begin. We will do this by adding a separate method we can re-use to re-initialize the ball every time we need it (when players score):&lt;/p&gt;

&lt;pre class=&quot;csharp&quot;&gt;&lt;ol&gt;&lt;li style=&quot;font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;&quot;&gt;&lt;div style=&quot;font-family: 'Courier New', Courier, monospace; font-weight: normal;&quot;&gt;&lt;span style=&quot;color: #0600FF;&quot;&gt;private&lt;/span&gt; &lt;span style=&quot;color: #0600FF;&quot;&gt;void&lt;/span&gt; InitBall&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style=&quot;font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;&quot;&gt;&lt;div style=&quot;font-family: 'Courier New', Courier, monospace; font-weight: normal;&quot;&gt;        &lt;span style=&quot;color: #000000;&quot;&gt;&amp;#123;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style=&quot;font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;&quot;&gt;&lt;div style=&quot;font-family: 'Courier New', Courier, monospace; font-weight: normal;&quot;&gt;            &lt;span style=&quot;color: #FF0000;&quot;&gt;int&lt;/span&gt; speed &lt;span style=&quot;color: #008000;&quot;&gt;=&lt;/span&gt; &lt;span style=&quot;color: #FF0000;&quot;&gt;5&lt;/span&gt;; &lt;span style=&quot;color: #008080; font-style: italic;&quot;&gt;// default velocity&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style=&quot;font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;&quot;&gt;&lt;div style=&quot;font-family: 'Courier New', Courier, monospace; font-weight: normal;&quot;&gt;            Random rand &lt;span style=&quot;color: #008000;&quot;&gt;=&lt;/span&gt; &lt;span style=&quot;color: #008000;&quot;&gt;new&lt;/span&gt; Random&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#41;&lt;/span&gt;;&lt;/div&gt;&lt;/li&gt;&lt;li style=&quot;font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;&quot;&gt;&lt;div style=&quot;font-family: 'Courier New', Courier, monospace; font-weight: normal;&quot;&gt;&amp;nbsp;&lt;/div&gt;&lt;/li&gt;&lt;li style=&quot;font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;&quot;&gt;&lt;div style=&quot;font-family: 'Courier New', Courier, monospace; font-weight: normal;&quot;&gt;            &lt;span style=&quot;color: #008080; font-style: italic;&quot;&gt;// randomize the ball orientation&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style=&quot;font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;&quot;&gt;&lt;div style=&quot;font-family: 'Courier New', Courier, monospace; font-weight: normal;&quot;&gt;            &lt;span style=&quot;color: #0600FF;&quot;&gt;switch&lt;/span&gt; &lt;span style=&quot;color: #000000;&quot;&gt;&amp;#40;&lt;/span&gt;rand.&lt;span style=&quot;color: #0000FF;&quot;&gt;Next&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #FF0000;&quot;&gt;4&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style=&quot;font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;&quot;&gt;&lt;div style=&quot;font-family: 'Courier New', Courier, monospace; font-weight: normal;&quot;&gt;            &lt;span style=&quot;color: #000000;&quot;&gt;&amp;#123;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style=&quot;font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;&quot;&gt;&lt;div style=&quot;font-family: 'Courier New', Courier, monospace; font-weight: normal;&quot;&gt;                &lt;span style=&quot;color: #0600FF;&quot;&gt;case&lt;/span&gt; &lt;span style=&quot;color: #FF0000;&quot;&gt;0&lt;/span&gt;&lt;span style=&quot;color: #008000;&quot;&gt;:&lt;/span&gt; ballVelocity.&lt;span style=&quot;color: #0000FF;&quot;&gt;X&lt;/span&gt; &lt;span style=&quot;color: #008000;&quot;&gt;=&lt;/span&gt; speed; ballVelocity.&lt;span style=&quot;color: #0000FF;&quot;&gt;Y&lt;/span&gt; &lt;span style=&quot;color: #008000;&quot;&gt;=&lt;/span&gt; speed; &lt;span style=&quot;color: #0600FF;&quot;&gt;break&lt;/span&gt;;&lt;/div&gt;&lt;/li&gt;&lt;li style=&quot;font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;&quot;&gt;&lt;div style=&quot;font-family: 'Courier New', Courier, monospace; font-weight: normal;&quot;&gt;                &lt;span style=&quot;color: #0600FF;&quot;&gt;case&lt;/span&gt; &lt;span style=&quot;color: #FF0000;&quot;&gt;1&lt;/span&gt;&lt;span style=&quot;color: #008000;&quot;&gt;:&lt;/span&gt; ballVelocity.&lt;span style=&quot;color: #0000FF;&quot;&gt;X&lt;/span&gt; &lt;span style=&quot;color: #008000;&quot;&gt;=&lt;/span&gt; &lt;span style=&quot;color: #008000;&quot;&gt;-&lt;/span&gt;speed; ballVelocity.&lt;span style=&quot;color: #0000FF;&quot;&gt;Y&lt;/span&gt; &lt;span style=&quot;color: #008000;&quot;&gt;=&lt;/span&gt; speed; &lt;span style=&quot;color: #0600FF;&quot;&gt;break&lt;/span&gt;;&lt;/div&gt;&lt;/li&gt;&lt;li style=&quot;font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;&quot;&gt;&lt;div style=&quot;font-family: 'Courier New', Courier, monospace; font-weight: normal;&quot;&gt;                &lt;span style=&quot;color: #0600FF;&quot;&gt;case&lt;/span&gt; &lt;span style=&quot;color: #FF0000;&quot;&gt;2&lt;/span&gt;&lt;span style=&quot;color: #008000;&quot;&gt;:&lt;/span&gt; ballVelocity.&lt;span style=&quot;color: #0000FF;&quot;&gt;X&lt;/span&gt; &lt;span style=&quot;color: #008000;&quot;&gt;=&lt;/span&gt; speed; ballVelocity.&lt;span style=&quot;color: #0000FF;&quot;&gt;Y&lt;/span&gt; &lt;span style=&quot;color: #008000;&quot;&gt;=&lt;/span&gt; &lt;span style=&quot;color: #008000;&quot;&gt;-&lt;/span&gt;speed; &lt;span style=&quot;color: #0600FF;&quot;&gt;break&lt;/span&gt;;&lt;/div&gt;&lt;/li&gt;&lt;li style=&quot;font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;&quot;&gt;&lt;div style=&quot;font-family: 'Courier New', Courier, monospace; font-weight: normal;&quot;&gt;                &lt;span style=&quot;color: #0600FF;&quot;&gt;case&lt;/span&gt; &lt;span style=&quot;color: #FF0000;&quot;&gt;3&lt;/span&gt;&lt;span style=&quot;color: #008000;&quot;&gt;:&lt;/span&gt; ballVelocity.&lt;span style=&quot;color: #0000FF;&quot;&gt;X&lt;/span&gt; &lt;span style=&quot;color: #008000;&quot;&gt;=&lt;/span&gt; &lt;span style=&quot;color: #008000;&quot;&gt;-&lt;/span&gt;speed; ballVelocity.&lt;span style=&quot;color: #0000FF;&quot;&gt;Y&lt;/span&gt; &lt;span style=&quot;color: #008000;&quot;&gt;=&lt;/span&gt; &lt;span style=&quot;color: #008000;&quot;&gt;-&lt;/span&gt;speed; &lt;span style=&quot;color: #0600FF;&quot;&gt;break&lt;/span&gt;;&lt;/div&gt;&lt;/li&gt;&lt;li style=&quot;font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;&quot;&gt;&lt;div style=&quot;font-family: 'Courier New', Courier, monospace; font-weight: normal;&quot;&gt;            &lt;span style=&quot;color: #000000;&quot;&gt;&amp;#125;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style=&quot;font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;&quot;&gt;&lt;div style=&quot;font-family: 'Courier New', Courier, monospace; font-weight: normal;&quot;&gt;&amp;nbsp;&lt;/div&gt;&lt;/li&gt;&lt;li style=&quot;font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;&quot;&gt;&lt;div style=&quot;font-family: 'Courier New', Courier, monospace; font-weight: normal;&quot;&gt;            &lt;span style=&quot;color: #008080; font-style: italic;&quot;&gt;// initialize the ball to the center of the screen&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style=&quot;font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;&quot;&gt;&lt;div style=&quot;font-family: 'Courier New', Courier, monospace; font-weight: normal;&quot;&gt;            ball.&lt;span style=&quot;color: #0000FF;&quot;&gt;X&lt;/span&gt; &lt;span style=&quot;color: #008000;&quot;&gt;=&lt;/span&gt; GraphicsDevice.&lt;span style=&quot;color: #0000FF;&quot;&gt;Viewport&lt;/span&gt;.&lt;span style=&quot;color: #0000FF;&quot;&gt;Bounds&lt;/span&gt;.&lt;span style=&quot;color: #0000FF;&quot;&gt;Width&lt;/span&gt; &lt;span style=&quot;color: #008000;&quot;&gt;/&lt;/span&gt; &lt;span style=&quot;color: #FF0000;&quot;&gt;2&lt;/span&gt; &lt;span style=&quot;color: #008000;&quot;&gt;-&lt;/span&gt; ball.&lt;span style=&quot;color: #0000FF;&quot;&gt;Width&lt;/span&gt; &lt;span style=&quot;color: #008000;&quot;&gt;/&lt;/span&gt; &lt;span style=&quot;color: #FF0000;&quot;&gt;2&lt;/span&gt;;&lt;/div&gt;&lt;/li&gt;&lt;li style=&quot;font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;&quot;&gt;&lt;div style=&quot;font-family: 'Courier New', Courier, monospace; font-weight: normal;&quot;&gt;            ball.&lt;span style=&quot;color: #0000FF;&quot;&gt;Y&lt;/span&gt; &lt;span style=&quot;color: #008000;&quot;&gt;=&lt;/span&gt; GraphicsDevice.&lt;span style=&quot;color: #0000FF;&quot;&gt;Viewport&lt;/span&gt;.&lt;span style=&quot;color: #0000FF;&quot;&gt;Bounds&lt;/span&gt;.&lt;span style=&quot;color: #0000FF;&quot;&gt;Height&lt;/span&gt; &lt;span style=&quot;color: #008000;&quot;&gt;/&lt;/span&gt; &lt;span style=&quot;color: #FF0000;&quot;&gt;2&lt;/span&gt; &lt;span style=&quot;color: #008000;&quot;&gt;-&lt;/span&gt; ball.&lt;span style=&quot;color: #0000FF;&quot;&gt;Height&lt;/span&gt; &lt;span style=&quot;color: #008000;&quot;&gt;/&lt;/span&gt; &lt;span style=&quot;color: #FF0000;&quot;&gt;2&lt;/span&gt;;&lt;/div&gt;&lt;/li&gt;&lt;li style=&quot;font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;&quot;&gt;&lt;div style=&quot;font-family: 'Courier New', Courier, monospace; font-weight: normal;&quot;&gt;        &lt;span style=&quot;color: #000000;&quot;&gt;&amp;#125;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;/ol&gt;&lt;/pre&gt;


&lt;p&gt;We have a default velocity defined and a random number generator to add some unpredictability to the ball direction. In a switch statement, we make the ball go randomly in one of the four diagonal. Then, we set the ball’s position to the center of the screen, and the gameplay shall begin.&lt;/p&gt;


&lt;p&gt;We can now call our newly created method to initialize the game. Back in the &lt;a href=&quot;http://msdn.microsoft.com/en-us/library/microsoft.xna.framework.game.update%28v=XNAGameStudio.40%29.aspx&quot; hreflang=&quot;en&quot;&gt;Update&lt;/a&gt; method:&lt;/p&gt;

&lt;pre class=&quot;csharp&quot;&gt;&lt;ol&gt;&lt;li style=&quot;font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;&quot;&gt;&lt;div style=&quot;font-family: 'Courier New', Courier, monospace; font-weight: normal;&quot;&gt;&lt;span style=&quot;color: #008080; font-style: italic;&quot;&gt;// handling ball initialization&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style=&quot;font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;&quot;&gt;&lt;div style=&quot;font-family: 'Courier New', Courier, monospace; font-weight: normal;&quot;&gt;            &lt;span style=&quot;color: #0600FF;&quot;&gt;if&lt;/span&gt; &lt;span style=&quot;color: #000000;&quot;&gt;&amp;#40;&lt;/span&gt;Keyboard.&lt;span style=&quot;color: #0000FF;&quot;&gt;GetState&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#41;&lt;/span&gt;.&lt;span style=&quot;color: #0000FF;&quot;&gt;IsKeyDown&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#40;&lt;/span&gt;Keys.&lt;span style=&quot;color: #0000FF;&quot;&gt;Space&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style=&quot;font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;&quot;&gt;&lt;div style=&quot;font-family: 'Courier New', Courier, monospace; font-weight: normal;&quot;&gt;                InitBall&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#41;&lt;/span&gt;;&lt;/div&gt;&lt;/li&gt;&lt;/ol&gt;&lt;/pre&gt;


&lt;p&gt;This code means that every time we press the space bar, the ball is reset. Meaning that even during the gameplay, one can re-init the ball. That’s not a correct behavior but we don’t care since we’re aiming a playable game, not a polished one ;-). Keep in mind that this is for educational purpose.&lt;/p&gt;


&lt;h5&gt;Worlds collide&lt;/h5&gt;


&lt;p&gt;If you tried to run the project, you’ll see that the ball is not bouncing on screen bounds. In the &lt;a href=&quot;http://msdn.microsoft.com/en-us/library/microsoft.xna.framework.game.update%28v=XNAGameStudio.40%29.aspx&quot; hreflang=&quot;en&quot;&gt;Update&lt;/a&gt; method, we add the required code:&lt;/p&gt;

&lt;pre class=&quot;csharp&quot;&gt;&lt;ol&gt;&lt;li style=&quot;font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;&quot;&gt;&lt;div style=&quot;font-family: 'Courier New', Courier, monospace; font-weight: normal;&quot;&gt;&lt;span style=&quot;color: #008080; font-style: italic;&quot;&gt;// collision handling&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style=&quot;font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;&quot;&gt;&lt;div style=&quot;font-family: 'Courier New', Courier, monospace; font-weight: normal;&quot;&gt;            &lt;span style=&quot;color: #0600FF;&quot;&gt;if&lt;/span&gt; &lt;span style=&quot;color: #000000;&quot;&gt;&amp;#40;&lt;/span&gt;ball.&lt;span style=&quot;color: #0000FF;&quot;&gt;Y&lt;/span&gt; &lt;span style=&quot;color: #008000;&quot;&gt;&amp;lt;&lt;/span&gt; &lt;span style=&quot;color: #FF0000;&quot;&gt;0&lt;/span&gt; &lt;span style=&quot;color: #008000;&quot;&gt;||&lt;/span&gt; &lt;span style=&quot;color: #008080; font-style: italic;&quot;&gt;// if the ball reach the upper bound of the screen&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style=&quot;font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;&quot;&gt;&lt;div style=&quot;font-family: 'Courier New', Courier, monospace; font-weight: normal;&quot;&gt;                ball.&lt;span style=&quot;color: #0000FF;&quot;&gt;Y&lt;/span&gt; &lt;span style=&quot;color: #008000;&quot;&gt;+&lt;/span&gt; ball.&lt;span style=&quot;color: #0000FF;&quot;&gt;Height&lt;/span&gt; &lt;span style=&quot;color: #008000;&quot;&gt;&amp;gt;&lt;/span&gt; GraphicsDevice.&lt;span style=&quot;color: #0000FF;&quot;&gt;Viewport&lt;/span&gt;.&lt;span style=&quot;color: #0000FF;&quot;&gt;Bounds&lt;/span&gt;.&lt;span style=&quot;color: #0000FF;&quot;&gt;Height&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#41;&lt;/span&gt; &lt;span style=&quot;color: #008080; font-style: italic;&quot;&gt;// or the lower one&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style=&quot;font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;&quot;&gt;&lt;div style=&quot;font-family: 'Courier New', Courier, monospace; font-weight: normal;&quot;&gt;            &lt;span style=&quot;color: #000000;&quot;&gt;&amp;#123;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style=&quot;font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;&quot;&gt;&lt;div style=&quot;font-family: 'Courier New', Courier, monospace; font-weight: normal;&quot;&gt;                ballVelocity.&lt;span style=&quot;color: #0000FF;&quot;&gt;Y&lt;/span&gt; &lt;span style=&quot;color: #008000;&quot;&gt;=&lt;/span&gt; &lt;span style=&quot;color: #008000;&quot;&gt;-&lt;/span&gt;ballVelocity.&lt;span style=&quot;color: #0000FF;&quot;&gt;Y&lt;/span&gt;; &lt;span style=&quot;color: #008080; font-style: italic;&quot;&gt;// make if bounce by inverting the Y velocity&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style=&quot;font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;&quot;&gt;&lt;div style=&quot;font-family: 'Courier New', Courier, monospace; font-weight: normal;&quot;&gt;            &lt;span style=&quot;color: #000000;&quot;&gt;&amp;#125;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;/ol&gt;&lt;/pre&gt;


&lt;p&gt;This is similar to the way we managed the bars’ movement, with the particularity that instead of blocking the movement, we invert the Y velocity so the ball bounce.&lt;/p&gt;


&lt;p&gt;We also need to manage the collision with the bars. It is a little bit different, since we’re going to check for Rectangle to &lt;a href=&quot;http://msdn.microsoft.com/en-us/library/microsoft.xna.framework.rectangle(v=XNAGameStudio.40).aspx&quot; hreflang=&quot;en&quot;&gt;Rectangle&lt;/a&gt; collisions. To this purpose, XNA is making our life a lot easier since the &lt;a href=&quot;http://msdn.microsoft.com/en-us/library/microsoft.xna.framework.rectangle(v=XNAGameStudio.40).aspx&quot; hreflang=&quot;en&quot;&gt;Rectangle&lt;/a&gt; class has a very useful method to test if two &lt;a href=&quot;http://msdn.microsoft.com/en-us/library/microsoft.xna.framework.rectangle(v=XNAGameStudio.40).aspx&quot; hreflang=&quot;en&quot;&gt;Rectangle&lt;/a&gt; are colliding:&lt;/p&gt;

&lt;pre class=&quot;csharp&quot;&gt;&lt;ol&gt;&lt;li style=&quot;font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;&quot;&gt;&lt;div style=&quot;font-family: 'Courier New', Courier, monospace; font-weight: normal;&quot;&gt;&lt;span style=&quot;color: #0600FF;&quot;&gt;if&lt;/span&gt; &lt;span style=&quot;color: #000000;&quot;&gt;&amp;#40;&lt;/span&gt;ball.&lt;span style=&quot;color: #0000FF;&quot;&gt;Intersects&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#40;&lt;/span&gt;redBar&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#41;&lt;/span&gt; &lt;span style=&quot;color: #008000;&quot;&gt;||&lt;/span&gt; &lt;span style=&quot;color: #008080; font-style: italic;&quot;&gt;// if the ball collide with blue bar&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style=&quot;font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;&quot;&gt;&lt;div style=&quot;font-family: 'Courier New', Courier, monospace; font-weight: normal;&quot;&gt;                ball.&lt;span style=&quot;color: #0000FF;&quot;&gt;Intersects&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#40;&lt;/span&gt;blueBar&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#41;&lt;/span&gt; &lt;span style=&quot;color: #008080; font-style: italic;&quot;&gt;// or the red one&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style=&quot;font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;&quot;&gt;&lt;div style=&quot;font-family: 'Courier New', Courier, monospace; font-weight: normal;&quot;&gt;            &lt;span style=&quot;color: #000000;&quot;&gt;&amp;#123;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style=&quot;font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;&quot;&gt;&lt;div style=&quot;font-family: 'Courier New', Courier, monospace; font-weight: normal;&quot;&gt;                ballVelocity.&lt;span style=&quot;color: #0000FF;&quot;&gt;X&lt;/span&gt; &lt;span style=&quot;color: #008000;&quot;&gt;=&lt;/span&gt; &lt;span style=&quot;color: #008000;&quot;&gt;-&lt;/span&gt;ballVelocity.&lt;span style=&quot;color: #0000FF;&quot;&gt;X&lt;/span&gt;; &lt;span style=&quot;color: #008080; font-style: italic;&quot;&gt;// make if bounce by inverting the X velocity&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style=&quot;font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;&quot;&gt;&lt;div style=&quot;font-family: 'Courier New', Courier, monospace; font-weight: normal;&quot;&gt;            &lt;span style=&quot;color: #000000;&quot;&gt;&amp;#125;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;/ol&gt;&lt;/pre&gt;


&lt;p&gt;Very simple: we just check if the ball (which is a Rectangle) is colliding with either one of the bars, and invert the X velocity to make it bounce.&lt;/p&gt;


&lt;p&gt;Here we are! We have a fully playable gameplay. The game only need some polish and it is almost ready for huge commercial success (if we were in the 70’s by the way…).&lt;/p&gt;


&lt;h5&gt;Scoring&lt;/h5&gt;


&lt;p&gt;To add some competition, we will handle a simple score counter and display. We’ll use two more &lt;a href=&quot;http://msdn.microsoft.com/en-us/library/microsoft.xna.framework.game%28v=XNAGameStudio.40%29.aspx&quot; hreflang=&quot;en&quot;&gt;Game1&lt;/a&gt; class members to manage the scores:&lt;/p&gt;

&lt;pre class=&quot;csharp&quot;&gt;&lt;ol&gt;&lt;li style=&quot;font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;&quot;&gt;&lt;div style=&quot;font-family: 'Courier New', Courier, monospace; font-weight: normal;&quot;&gt;&lt;span style=&quot;color: #008080; font-style: italic;&quot;&gt;// scores&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style=&quot;font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;&quot;&gt;&lt;div style=&quot;font-family: 'Courier New', Courier, monospace; font-weight: normal;&quot;&gt;        &lt;span style=&quot;color: #FF0000;&quot;&gt;int&lt;/span&gt; blueScore &lt;span style=&quot;color: #008000;&quot;&gt;=&lt;/span&gt; &lt;span style=&quot;color: #FF0000;&quot;&gt;0&lt;/span&gt;;&lt;/div&gt;&lt;/li&gt;&lt;li style=&quot;font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;&quot;&gt;&lt;div style=&quot;font-family: 'Courier New', Courier, monospace; font-weight: normal;&quot;&gt;        &lt;span style=&quot;color: #FF0000;&quot;&gt;int&lt;/span&gt; redScore &lt;span style=&quot;color: #008000;&quot;&gt;=&lt;/span&gt; &lt;span style=&quot;color: #FF0000;&quot;&gt;0&lt;/span&gt;;&lt;/div&gt;&lt;/li&gt;&lt;/ol&gt;&lt;/pre&gt;


&lt;p&gt;We need to detect if the ball goes behind a bar in order to increment the corresponding score. We’ll do it in the &lt;a href=&quot;http://msdn.microsoft.com/en-us/library/microsoft.xna.framework.game.update%28v=XNAGameStudio.40%29.aspx&quot; hreflang=&quot;en&quot;&gt;Update&lt;/a&gt; method:&lt;/p&gt;

&lt;pre class=&quot;csharp&quot;&gt;&lt;ol&gt;&lt;li style=&quot;font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;&quot;&gt;&lt;div style=&quot;font-family: 'Courier New', Courier, monospace; font-weight: normal;&quot;&gt;&lt;span style=&quot;color: #008080; font-style: italic;&quot;&gt;// score handling&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style=&quot;font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;&quot;&gt;&lt;div style=&quot;font-family: 'Courier New', Courier, monospace; font-weight: normal;&quot;&gt;            &lt;span style=&quot;color: #0600FF;&quot;&gt;if&lt;/span&gt; &lt;span style=&quot;color: #000000;&quot;&gt;&amp;#40;&lt;/span&gt;ball.&lt;span style=&quot;color: #0000FF;&quot;&gt;X&lt;/span&gt; &lt;span style=&quot;color: #008000;&quot;&gt;&amp;lt;&lt;/span&gt; &lt;span style=&quot;color: #FF0000;&quot;&gt;0&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#41;&lt;/span&gt; &lt;span style=&quot;color: #008080; font-style: italic;&quot;&gt;// red scores&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style=&quot;font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;&quot;&gt;&lt;div style=&quot;font-family: 'Courier New', Courier, monospace; font-weight: normal;&quot;&gt;            &lt;span style=&quot;color: #000000;&quot;&gt;&amp;#123;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style=&quot;font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;&quot;&gt;&lt;div style=&quot;font-family: 'Courier New', Courier, monospace; font-weight: normal;&quot;&gt;                redScore&lt;span style=&quot;color: #008000;&quot;&gt;++&lt;/span&gt;;&lt;/div&gt;&lt;/li&gt;&lt;li style=&quot;font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;&quot;&gt;&lt;div style=&quot;font-family: 'Courier New', Courier, monospace; font-weight: normal;&quot;&gt;                InitBall&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#41;&lt;/span&gt;; &lt;span style=&quot;color: #008080; font-style: italic;&quot;&gt;// re-init the ball&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style=&quot;font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;&quot;&gt;&lt;div style=&quot;font-family: 'Courier New', Courier, monospace; font-weight: normal;&quot;&gt;            &lt;span style=&quot;color: #000000;&quot;&gt;&amp;#125;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style=&quot;font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;&quot;&gt;&lt;div style=&quot;font-family: 'Courier New', Courier, monospace; font-weight: normal;&quot;&gt;            &lt;span style=&quot;color: #0600FF;&quot;&gt;else&lt;/span&gt; &lt;span style=&quot;color: #0600FF;&quot;&gt;if&lt;/span&gt; &lt;span style=&quot;color: #000000;&quot;&gt;&amp;#40;&lt;/span&gt;ball.&lt;span style=&quot;color: #0000FF;&quot;&gt;X&lt;/span&gt; &lt;span style=&quot;color: #008000;&quot;&gt;+&lt;/span&gt; ball.&lt;span style=&quot;color: #0000FF;&quot;&gt;Width&lt;/span&gt; &lt;span style=&quot;color: #008000;&quot;&gt;&amp;gt;&lt;/span&gt; GraphicsDevice.&lt;span style=&quot;color: #0000FF;&quot;&gt;Viewport&lt;/span&gt;.&lt;span style=&quot;color: #0000FF;&quot;&gt;Bounds&lt;/span&gt;.&lt;span style=&quot;color: #0000FF;&quot;&gt;Width&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#41;&lt;/span&gt; &lt;span style=&quot;color: #008080; font-style: italic;&quot;&gt;// blue scores&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style=&quot;font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;&quot;&gt;&lt;div style=&quot;font-family: 'Courier New', Courier, monospace; font-weight: normal;&quot;&gt;            &lt;span style=&quot;color: #000000;&quot;&gt;&amp;#123;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style=&quot;font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;&quot;&gt;&lt;div style=&quot;font-family: 'Courier New', Courier, monospace; font-weight: normal;&quot;&gt;                blueScore&lt;span style=&quot;color: #008000;&quot;&gt;++&lt;/span&gt;;&lt;/div&gt;&lt;/li&gt;&lt;li style=&quot;font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;&quot;&gt;&lt;div style=&quot;font-family: 'Courier New', Courier, monospace; font-weight: normal;&quot;&gt;                InitBall&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#41;&lt;/span&gt;; &lt;span style=&quot;color: #008080; font-style: italic;&quot;&gt;// re-init the ball&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style=&quot;font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;&quot;&gt;&lt;div style=&quot;font-family: 'Courier New', Courier, monospace; font-weight: normal;&quot;&gt;            &lt;span style=&quot;color: #000000;&quot;&gt;&amp;#125;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;/ol&gt;&lt;/pre&gt;


&lt;p&gt;Same math as before to check screen bounds. When the ball goes behind the left or right bound, a player just scored and we re-initialize the ball.&lt;/p&gt;


&lt;p&gt;Displaying the score involves to draw some text. Drawing text with graphics API is a bit problematic, text fonts are not ready-to-be-drawn graphics and their structure is not suitable with how graphics cards operate. Prior to use a font, it has to be processed or converted to a suitable asset. Some tools allow you to do so by generating a sprite sheet containing one sprite per character in the font. I let you imagine how boring it is to write a helper class able to seamlessly use this sprite sheet. Graphics API like SDL or OpenGL don’t do this out-of-the-box but some useful libraries exist.&lt;/p&gt;


&lt;p&gt;XNA has the feature to handle fonts easily. Let’s have a look at it. We need to add a special type of asset to our Content project: right on the Content project, add a new file, select the Sprite Font item and name it “ScoreFont.spritefont”. An XML file should be showing up after you added it. This file will hold the properties of the font we want to use: the font name, its size, its type (bold, italic…) and other not-so-important stuff. We want the score to be displayed with big readable font, so change the size to 18 and the type to “Bold” (case sensitive!):&lt;/p&gt;

&lt;pre class=&quot;xml&quot;&gt;&lt;ol&gt;&lt;li style=&quot;font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;&quot;&gt;&lt;div style=&quot;font-family: 'Courier New', Courier, monospace; font-weight: normal;&quot;&gt;&lt;span style=&quot;color: #009900;&quot;&gt;&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;lt;Size&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;18&lt;span style=&quot;color: #009900;&quot;&gt;&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;lt;/Size&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style=&quot;font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;&quot;&gt;&lt;div style=&quot;font-family: 'Courier New', Courier, monospace; font-weight: normal;&quot;&gt;…&lt;/div&gt;&lt;/li&gt;&lt;li style=&quot;font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;&quot;&gt;&lt;div style=&quot;font-family: 'Courier New', Courier, monospace; font-weight: normal;&quot;&gt;&lt;span style=&quot;color: #009900;&quot;&gt;&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;lt;Style&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;Bold&lt;span style=&quot;color: #009900;&quot;&gt;&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;lt;/Style&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;/ol&gt;&lt;/pre&gt;


&lt;p&gt;Like any asset, we have to define the corresponding variable and to load it. As a &lt;a href=&quot;http://msdn.microsoft.com/en-us/library/microsoft.xna.framework.game%28v=XNAGameStudio.40%29.aspx&quot; hreflang=&quot;en&quot;&gt;Game1&lt;/a&gt; member:&lt;/p&gt;

&lt;pre class=&quot;csharp&quot;&gt;&lt;ol&gt;&lt;li style=&quot;font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;&quot;&gt;&lt;div style=&quot;font-family: 'Courier New', Courier, monospace; font-weight: normal;&quot;&gt;SpriteFont font;&lt;/div&gt;&lt;/li&gt;&lt;/ol&gt;&lt;/pre&gt;


&lt;p&gt;And then in the &lt;a href=&quot;http://msdn.microsoft.com/en-us/library/microsoft.xna.framework.game.loadcontent(v=XNAGameStudio.40).aspx&quot; hreflang=&quot;en&quot;&gt;LoadContent&lt;/a&gt; method:&lt;/p&gt;

&lt;pre class=&quot;csharp&quot;&gt;&lt;ol&gt;&lt;li style=&quot;font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;&quot;&gt;&lt;div style=&quot;font-family: 'Courier New', Courier, monospace; font-weight: normal;&quot;&gt;&lt;span style=&quot;color: #008080; font-style: italic;&quot;&gt;// load our score font&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style=&quot;font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;&quot;&gt;&lt;div style=&quot;font-family: 'Courier New', Courier, monospace; font-weight: normal;&quot;&gt;            font &lt;span style=&quot;color: #008000;&quot;&gt;=&lt;/span&gt; Content.&lt;span style=&quot;color: #0000FF;&quot;&gt;Load&lt;/span&gt;&lt;span style=&quot;color: #008000;&quot;&gt;&amp;lt;&lt;/span&gt;SpriteFont&lt;span style=&quot;color: #008000;&quot;&gt;&amp;gt;&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #808080;&quot;&gt;@&quot;ScoreFont&amp;quot;&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#41;&lt;/span&gt;;&lt;/div&gt;&lt;/li&gt;&lt;/ol&gt;&lt;/pre&gt;


&lt;p&gt;All we have to do now is to draw the text, the same way if it was 2D graphics with the &lt;a href=&quot;http://msdn.microsoft.com/en-us/library/microsoft.xna.framework.graphics.spritebatch(v=XNAGameStudio.40).aspx&quot; hreflang=&quot;en&quot;&gt;SpriteBatch&lt;/a&gt; (in the &lt;a href=&quot;http://msdn.microsoft.com/en-us/library/microsoft.xna.framework.game.draw%28v=XNAGameStudio.40%29.aspx&quot; hreflang=&quot;en&quot;&gt;Draw&lt;/a&gt; method, after the grass drawing so it isn’t underneath):&lt;/p&gt;

&lt;pre class=&quot;csharp&quot;&gt;&lt;ol&gt;&lt;li style=&quot;font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;&quot;&gt;&lt;div style=&quot;font-family: 'Courier New', Courier, monospace; font-weight: normal;&quot;&gt;&lt;span style=&quot;color: #008080; font-style: italic;&quot;&gt;// draw the score&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style=&quot;font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;&quot;&gt;&lt;div style=&quot;font-family: 'Courier New', Courier, monospace; font-weight: normal;&quot;&gt;            spriteBatch.&lt;span style=&quot;color: #0000FF;&quot;&gt;Begin&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#40;&lt;/span&gt;SpriteSortMode.&lt;span style=&quot;color: #0000FF;&quot;&gt;Immediate&lt;/span&gt;, BlendState.&lt;span style=&quot;color: #0000FF;&quot;&gt;AlphaBlend&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#41;&lt;/span&gt;;&lt;/div&gt;&lt;/li&gt;&lt;li style=&quot;font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;&quot;&gt;&lt;div style=&quot;font-family: 'Courier New', Courier, monospace; font-weight: normal;&quot;&gt;            spriteBatch.&lt;span style=&quot;color: #0000FF;&quot;&gt;DrawString&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#40;&lt;/span&gt; &lt;span style=&quot;color: #008080; font-style: italic;&quot;&gt;// draw our score string&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style=&quot;font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;&quot;&gt;&lt;div style=&quot;font-family: 'Courier New', Courier, monospace; font-weight: normal;&quot;&gt;                font, &lt;span style=&quot;color: #008080; font-style: italic;&quot;&gt;// our score font&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style=&quot;font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;&quot;&gt;&lt;div style=&quot;font-family: 'Courier New', Courier, monospace; font-weight: normal;&quot;&gt;                blueScore.&lt;span style=&quot;color: #0000FF;&quot;&gt;ToString&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#41;&lt;/span&gt; &lt;span style=&quot;color: #008000;&quot;&gt;+&lt;/span&gt; &lt;span style=&quot;color: #808080;&quot;&gt;&amp;quot; - &amp;quot;&lt;/span&gt; &lt;span style=&quot;color: #008000;&quot;&gt;+&lt;/span&gt; redScore.&lt;span style=&quot;color: #0000FF;&quot;&gt;ToString&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#41;&lt;/span&gt;, &lt;span style=&quot;color: #008080; font-style: italic;&quot;&gt;// building the string&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style=&quot;font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;&quot;&gt;&lt;div style=&quot;font-family: 'Courier New', Courier, monospace; font-weight: normal;&quot;&gt;                &lt;span style=&quot;color: #008000;&quot;&gt;new&lt;/span&gt; Vector2&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#40;&lt;/span&gt; &lt;span style=&quot;color: #008080; font-style: italic;&quot;&gt;// text position&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style=&quot;font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;&quot;&gt;&lt;div style=&quot;font-family: 'Courier New', Courier, monospace; font-weight: normal;&quot;&gt;                    GraphicsDevice.&lt;span style=&quot;color: #0000FF;&quot;&gt;Viewport&lt;/span&gt;.&lt;span style=&quot;color: #0000FF;&quot;&gt;Bounds&lt;/span&gt;.&lt;span style=&quot;color: #0000FF;&quot;&gt;Width&lt;/span&gt; &lt;span style=&quot;color: #008000;&quot;&gt;/&lt;/span&gt; &lt;span style=&quot;color: #FF0000;&quot;&gt;2&lt;/span&gt; &lt;span style=&quot;color: #008000;&quot;&gt;-&lt;/span&gt; &lt;span style=&quot;color: #FF0000;&quot;&gt;25&lt;/span&gt;, &lt;span style=&quot;color: #008080; font-style: italic;&quot;&gt;// half the screen and a little to the left&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style=&quot;font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;&quot;&gt;&lt;div style=&quot;font-family: 'Courier New', Courier, monospace; font-weight: normal;&quot;&gt;                    &lt;span style=&quot;color: #FF0000;&quot;&gt;10&lt;/span&gt;.0f&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#41;&lt;/span&gt;,&lt;/div&gt;&lt;/li&gt;&lt;li style=&quot;font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;&quot;&gt;&lt;div style=&quot;font-family: 'Courier New', Courier, monospace; font-weight: normal;&quot;&gt;                Color.&lt;span style=&quot;color: #0000FF;&quot;&gt;Yellow&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#41;&lt;/span&gt;; &lt;span style=&quot;color: #008080; font-style: italic;&quot;&gt;// yellow text&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style=&quot;font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;&quot;&gt;&lt;div style=&quot;font-family: 'Courier New', Courier, monospace; font-weight: normal;&quot;&gt;            spriteBatch.&lt;span style=&quot;color: #0000FF;&quot;&gt;End&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#41;&lt;/span&gt;;&lt;/div&gt;&lt;/li&gt;&lt;/ol&gt;&lt;/pre&gt;


&lt;p&gt;Note that drawing text needs a dedicated method, &lt;a href=&quot;http://msdn.microsoft.com/en-us/library/microsoft.xna.framework.graphics.spritebatch.drawstring(v=XNAGameStudio.40).aspx&quot; hreflang=&quot;en&quot;&gt;DrawString&lt;/a&gt;. It takes as argument the font, the string to display, a 2D vector for the screen coordinate where we want the text to be displayed (remind that it consider the upper left corner of the text box), and finally, the color of the text.&lt;/p&gt;


&lt;h5&gt;Sound blasting&lt;/h5&gt;


&lt;p&gt;Last but not least, the sound. We already have our two &lt;a href=&quot;http://msdn.microsoft.com/en-us/library/microsoft.xna.framework.audio.soundeffect%28v=XNAGameStudio.40%29.aspxhttp:/msdn.microsoft.com/en-us/library/microsoft.xna.framework.audio.soundeffect%28v=XNAGameStudio.40%29.aspx&quot; hreflang=&quot;en&quot;&gt;SoundEffect&lt;/a&gt; ready (ballBounce &amp;amp; playerScored). Since XNA 3.0, playing a sound is simple as pie: &lt;a href=&quot;http://msdn.microsoft.com/en-us/library/microsoft.xna.framework.audio.soundeffect.play(v=XNAGameStudio.40).aspx&quot; hreflang=&quot;en&quot;&gt;SoundEffect.Play()&lt;/a&gt;. All we have to do, is to call the play method when the ball bounce and when a player scores. Here’s the code update:&lt;/p&gt;

&lt;pre class=&quot;csharp&quot;&gt;&lt;ol&gt;&lt;li style=&quot;font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;&quot;&gt;&lt;div style=&quot;font-family: 'Courier New', Courier, monospace; font-weight: normal;&quot;&gt;&lt;span style=&quot;color: #008080; font-style: italic;&quot;&gt;// collision handling&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style=&quot;font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;&quot;&gt;&lt;div style=&quot;font-family: 'Courier New', Courier, monospace; font-weight: normal;&quot;&gt;            &lt;span style=&quot;color: #0600FF;&quot;&gt;if&lt;/span&gt; &lt;span style=&quot;color: #000000;&quot;&gt;&amp;#40;&lt;/span&gt;ball.&lt;span style=&quot;color: #0000FF;&quot;&gt;Y&lt;/span&gt; &lt;span style=&quot;color: #008000;&quot;&gt;&amp;lt;&lt;/span&gt; &lt;span style=&quot;color: #FF0000;&quot;&gt;0&lt;/span&gt; &lt;span style=&quot;color: #008000;&quot;&gt;||&lt;/span&gt; &lt;span style=&quot;color: #008080; font-style: italic;&quot;&gt;// if the ball reach the upper bound of the screen&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style=&quot;font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;&quot;&gt;&lt;div style=&quot;font-family: 'Courier New', Courier, monospace; font-weight: normal;&quot;&gt;                ball.&lt;span style=&quot;color: #0000FF;&quot;&gt;Y&lt;/span&gt; &lt;span style=&quot;color: #008000;&quot;&gt;+&lt;/span&gt; ball.&lt;span style=&quot;color: #0000FF;&quot;&gt;Height&lt;/span&gt; &lt;span style=&quot;color: #008000;&quot;&gt;&amp;gt;&lt;/span&gt; GraphicsDevice.&lt;span style=&quot;color: #0000FF;&quot;&gt;Viewport&lt;/span&gt;.&lt;span style=&quot;color: #0000FF;&quot;&gt;Bounds&lt;/span&gt;.&lt;span style=&quot;color: #0000FF;&quot;&gt;Height&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#41;&lt;/span&gt; &lt;span style=&quot;color: #008080; font-style: italic;&quot;&gt;// or the lower one&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style=&quot;font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;&quot;&gt;&lt;div style=&quot;font-family: 'Courier New', Courier, monospace; font-weight: normal;&quot;&gt;            &lt;span style=&quot;color: #000000;&quot;&gt;&amp;#123;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style=&quot;font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;&quot;&gt;&lt;div style=&quot;font-family: 'Courier New', Courier, monospace; font-weight: normal;&quot;&gt;                ballVelocity.&lt;span style=&quot;color: #0000FF;&quot;&gt;Y&lt;/span&gt; &lt;span style=&quot;color: #008000;&quot;&gt;=&lt;/span&gt; &lt;span style=&quot;color: #008000;&quot;&gt;-&lt;/span&gt;ballVelocity.&lt;span style=&quot;color: #0000FF;&quot;&gt;Y&lt;/span&gt;; &lt;span style=&quot;color: #008080; font-style: italic;&quot;&gt;// make if bounce by inverting the Y velocity&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style=&quot;font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;&quot;&gt;&lt;div style=&quot;font-family: 'Courier New', Courier, monospace; font-weight: normal;&quot;&gt;                ballBounce.&lt;span style=&quot;color: #0000FF;&quot;&gt;Play&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#41;&lt;/span&gt;; &lt;span style=&quot;color: #008080; font-style: italic;&quot;&gt;// bounce sound&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style=&quot;font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;&quot;&gt;&lt;div style=&quot;font-family: 'Courier New', Courier, monospace; font-weight: normal;&quot;&gt;            &lt;span style=&quot;color: #000000;&quot;&gt;&amp;#125;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style=&quot;font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;&quot;&gt;&lt;div style=&quot;font-family: 'Courier New', Courier, monospace; font-weight: normal;&quot;&gt;&amp;nbsp;&lt;/div&gt;&lt;/li&gt;&lt;li style=&quot;font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;&quot;&gt;&lt;div style=&quot;font-family: 'Courier New', Courier, monospace; font-weight: normal;&quot;&gt;            &lt;span style=&quot;color: #0600FF;&quot;&gt;if&lt;/span&gt; &lt;span style=&quot;color: #000000;&quot;&gt;&amp;#40;&lt;/span&gt;ball.&lt;span style=&quot;color: #0000FF;&quot;&gt;Intersects&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#40;&lt;/span&gt;redBar&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#41;&lt;/span&gt; &lt;span style=&quot;color: #008000;&quot;&gt;||&lt;/span&gt; &lt;span style=&quot;color: #008080; font-style: italic;&quot;&gt;// if the ball collide with blue bar&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style=&quot;font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;&quot;&gt;&lt;div style=&quot;font-family: 'Courier New', Courier, monospace; font-weight: normal;&quot;&gt;                ball.&lt;span style=&quot;color: #0000FF;&quot;&gt;Intersects&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#40;&lt;/span&gt;blueBar&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#41;&lt;/span&gt; &lt;span style=&quot;color: #008080; font-style: italic;&quot;&gt;// or the red one&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style=&quot;font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;&quot;&gt;&lt;div style=&quot;font-family: 'Courier New', Courier, monospace; font-weight: normal;&quot;&gt;            &lt;span style=&quot;color: #000000;&quot;&gt;&amp;#123;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style=&quot;font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;&quot;&gt;&lt;div style=&quot;font-family: 'Courier New', Courier, monospace; font-weight: normal;&quot;&gt;                ballVelocity.&lt;span style=&quot;color: #0000FF;&quot;&gt;X&lt;/span&gt; &lt;span style=&quot;color: #008000;&quot;&gt;=&lt;/span&gt; &lt;span style=&quot;color: #008000;&quot;&gt;-&lt;/span&gt;ballVelocity.&lt;span style=&quot;color: #0000FF;&quot;&gt;X&lt;/span&gt;; &lt;span style=&quot;color: #008080; font-style: italic;&quot;&gt;// make if bounce by inverting the X velocity&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style=&quot;font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;&quot;&gt;&lt;div style=&quot;font-family: 'Courier New', Courier, monospace; font-weight: normal;&quot;&gt;                ballBounce.&lt;span style=&quot;color: #0000FF;&quot;&gt;Play&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#41;&lt;/span&gt;; &lt;span style=&quot;color: #008080; font-style: italic;&quot;&gt;// bounce sound&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style=&quot;font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;&quot;&gt;&lt;div style=&quot;font-family: 'Courier New', Courier, monospace; font-weight: normal;&quot;&gt;            &lt;span style=&quot;color: #000000;&quot;&gt;&amp;#125;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style=&quot;font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;&quot;&gt;&lt;div style=&quot;font-family: 'Courier New', Courier, monospace; font-weight: normal;&quot;&gt;&amp;nbsp;&lt;/div&gt;&lt;/li&gt;&lt;li style=&quot;font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;&quot;&gt;&lt;div style=&quot;font-family: 'Courier New', Courier, monospace; font-weight: normal;&quot;&gt;            &lt;span style=&quot;color: #008080; font-style: italic;&quot;&gt;// score handling&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style=&quot;font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;&quot;&gt;&lt;div style=&quot;font-family: 'Courier New', Courier, monospace; font-weight: normal;&quot;&gt;            &lt;span style=&quot;color: #0600FF;&quot;&gt;if&lt;/span&gt; &lt;span style=&quot;color: #000000;&quot;&gt;&amp;#40;&lt;/span&gt;ball.&lt;span style=&quot;color: #0000FF;&quot;&gt;X&lt;/span&gt; &lt;span style=&quot;color: #008000;&quot;&gt;&amp;lt;&lt;/span&gt; &lt;span style=&quot;color: #FF0000;&quot;&gt;0&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#41;&lt;/span&gt; &lt;span style=&quot;color: #008080; font-style: italic;&quot;&gt;// red scores&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style=&quot;font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;&quot;&gt;&lt;div style=&quot;font-family: 'Courier New', Courier, monospace; font-weight: normal;&quot;&gt;            &lt;span style=&quot;color: #000000;&quot;&gt;&amp;#123;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style=&quot;font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;&quot;&gt;&lt;div style=&quot;font-family: 'Courier New', Courier, monospace; font-weight: normal;&quot;&gt;                redScore&lt;span style=&quot;color: #008000;&quot;&gt;++&lt;/span&gt;;&lt;/div&gt;&lt;/li&gt;&lt;li style=&quot;font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;&quot;&gt;&lt;div style=&quot;font-family: 'Courier New', Courier, monospace; font-weight: normal;&quot;&gt;                playerScored.&lt;span style=&quot;color: #0000FF;&quot;&gt;Play&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#41;&lt;/span&gt;; &lt;span style=&quot;color: #008080; font-style: italic;&quot;&gt;// hurray !&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style=&quot;font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;&quot;&gt;&lt;div style=&quot;font-family: 'Courier New', Courier, monospace; font-weight: normal;&quot;&gt;                InitBall&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#41;&lt;/span&gt;; &lt;span style=&quot;color: #008080; font-style: italic;&quot;&gt;// re-init the ball&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style=&quot;font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;&quot;&gt;&lt;div style=&quot;font-family: 'Courier New', Courier, monospace; font-weight: normal;&quot;&gt;            &lt;span style=&quot;color: #000000;&quot;&gt;&amp;#125;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style=&quot;font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;&quot;&gt;&lt;div style=&quot;font-family: 'Courier New', Courier, monospace; font-weight: normal;&quot;&gt;            &lt;span style=&quot;color: #0600FF;&quot;&gt;else&lt;/span&gt; &lt;span style=&quot;color: #0600FF;&quot;&gt;if&lt;/span&gt; &lt;span style=&quot;color: #000000;&quot;&gt;&amp;#40;&lt;/span&gt;ball.&lt;span style=&quot;color: #0000FF;&quot;&gt;X&lt;/span&gt; &lt;span style=&quot;color: #008000;&quot;&gt;+&lt;/span&gt; ball.&lt;span style=&quot;color: #0000FF;&quot;&gt;Width&lt;/span&gt; &lt;span style=&quot;color: #008000;&quot;&gt;&amp;gt;&lt;/span&gt; GraphicsDevice.&lt;span style=&quot;color: #0000FF;&quot;&gt;Viewport&lt;/span&gt;.&lt;span style=&quot;color: #0000FF;&quot;&gt;Bounds&lt;/span&gt;.&lt;span style=&quot;color: #0000FF;&quot;&gt;Width&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#41;&lt;/span&gt; &lt;span style=&quot;color: #008080; font-style: italic;&quot;&gt;// blue scores&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style=&quot;font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;&quot;&gt;&lt;div style=&quot;font-family: 'Courier New', Courier, monospace; font-weight: normal;&quot;&gt;            &lt;span style=&quot;color: #000000;&quot;&gt;&amp;#123;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style=&quot;font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;&quot;&gt;&lt;div style=&quot;font-family: 'Courier New', Courier, monospace; font-weight: normal;&quot;&gt;                blueScore&lt;span style=&quot;color: #008000;&quot;&gt;++&lt;/span&gt;;&lt;/div&gt;&lt;/li&gt;&lt;li style=&quot;font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;&quot;&gt;&lt;div style=&quot;font-family: 'Courier New', Courier, monospace; font-weight: normal;&quot;&gt;                playerScored.&lt;span style=&quot;color: #0000FF;&quot;&gt;Play&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#41;&lt;/span&gt;; &lt;span style=&quot;color: #008080; font-style: italic;&quot;&gt;// hurray !&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style=&quot;font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;&quot;&gt;&lt;div style=&quot;font-family: 'Courier New', Courier, monospace; font-weight: normal;&quot;&gt;                InitBall&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#41;&lt;/span&gt;; &lt;span style=&quot;color: #008080; font-style: italic;&quot;&gt;// re-init the ball&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style=&quot;font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;&quot;&gt;&lt;div style=&quot;font-family: 'Courier New', Courier, monospace; font-weight: normal;&quot;&gt;            &lt;span style=&quot;color: #000000;&quot;&gt;&amp;#125;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;/ol&gt;&lt;/pre&gt;


&lt;h4&gt;Intermediary conclusion&lt;/h4&gt;


&lt;p&gt;&lt;img src=&quot;http://www.handcrafted-games.com/public/Tuto1/full.png&quot; alt=&quot;full.png&quot; style=&quot;display:block; margin:0 auto;&quot; title=&quot;full.png, Jun 2010&quot; /&gt;&lt;/p&gt;


&lt;p&gt;Our Windows game is now complete! At least what I wanted to expose. Our prototype is far from being perfect, but one of the goals of this article is to give you opportunity to express yourself in the polishing of the game. You may copy/pasted everything but now, it’s up to you to enhance it. Here’s a list of thing you may consider doing:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Enhance collision handling: our model is very rough and far from a true physical model, plus the fact that the bar-to-ball collision is poorly managed (if the ball collide with another border than the front one, you can expect strange behaviors);&lt;/li&gt;
&lt;li&gt;Enhance the beginning of the game: in a classic Pong, the ball should go randomly in any direction while our game only throw the ball with 45° angles (more randomness is needed!); when a player score, the ball should be thrown at the him next (and not randomly);&lt;/li&gt;
&lt;li&gt;Add a menu;&lt;/li&gt;
&lt;li&gt;Handle the end of the game: our prototype doesn’t stop the score;&lt;/li&gt;
&lt;li&gt;Add an artificial intelligence: pretty easy, just apply a movement to the enemy’s bar if the ball is up or down the middle of the bar;&lt;/li&gt;
&lt;li&gt;…&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;Porting our Pong clone to the Xbox 360 and testing it&lt;/h2&gt;


&lt;p&gt;To run a game on the Xbox 360, we need to setup a new project, a 360 one. When it comes to port an existing project, XNA allow you to copy your current project and to create a port with one click. Right click on your Windows project, and select “Create a Copy of Project for Xbox 360”. Tadam, you’ve successfully ported your game. Note that this “copy” isn’t really a copy: all the source files are the one from the original project, they’re just shared between all the ports. This means that if you modify the Windows project, the changes will be applied to the Xbox 360 version as well. You’ll see that you know have two Game1.cs files (one in the Windows project, and one in the 360 one) but actually, there’s only one file, shared. The fact that it appears in all the projects is a little bit misleading.&lt;/p&gt;


&lt;h4&gt;Running the game on your 360&lt;/h4&gt;


&lt;p&gt;&lt;em&gt;Please note that the XNA 4.0 CTP “April Refresh” doesn’t allow yet deploying games on an Xbox 360. The following process is valid as of XNA 3.1 and should remain the same with the final XNA 4.0 version. I’ll update the article once it is released.&lt;/em&gt;&lt;/p&gt;


&lt;p&gt;Prior to be able to run code on your Xbox 360, you need your Xbox to be on the same LAN as your computer (I suppose you know how to setup a network) and a Creators Club license. This license is mandatory to publish games on the Xbox and Windows Phone marketplaces and to debug code on the gaming console. This is because Microsoft host and promote your games on the marketplaces and it is a good way to regulate the community by letting in only serious people (plus the fact that Microsoft want to stay in control of what’s being executed on the 360, for obvious security reasons). The license has a yearly cost of $99 and can be acquired from the Xbox Live marketplace or from xbox.com.&lt;/p&gt;


&lt;p&gt;There’s a possibility to get a free trial license enabling you to debug code on your console, but not to sell games (as well as not having access to premium content and forums on the creators club). You may find a trial license via a MSDN AA account, if you’re a student/teacher and if your school has subscribed to the program. If you don’t know if your school can get you a MSDN AA account, go ask the person in charge of your school’s computers. Another way to a trial license is to (still) be student and subscribe to the Microsoft’s Dreamspark program.&lt;/p&gt;


&lt;p&gt;Once you have successfully registered your license, you can start downloading the XNA launcher to your 360. You’ll find on the games marketplace along with the Indie Games. It should be named “XNA Game Studio Connect”. This program will only run if you’re connected to the Xbox Live and if the connected GamerTag has a valid creators club license. Run it and go back to Visual Studio.&lt;/p&gt;


&lt;p&gt;You now have to link your PC to your Xbox 360. This is to ensure that only trusted computer can deploy trusted code to a trusted console. In Visual Studio, click on the “Add a New Device”.&lt;/p&gt;


&lt;p&gt;&lt;img src=&quot;http://www.handcrafted-games.com/public/Tuto1/add_device.png&quot; alt=&quot;add_device.png&quot; style=&quot;display:block; margin:0 auto;&quot; title=&quot;add_device.png, Jun 2010&quot; /&gt;&lt;/p&gt;


&lt;p&gt;Choose to add an Xbox 360 console. Visual Studio should now ask you to enter a keycode, this code should be displayed on your 360 if you’ve successfully started the XNA launcher. Enter the code and validate. If everything went ok, you’re now ready to go and you won’t need to do this step anymore. If not, check out your network setup.&lt;/p&gt;


&lt;p&gt;When you’re ready, select the Xbox 360 as the target of your application.&lt;/p&gt;


&lt;p&gt;&lt;img src=&quot;http://www.handcrafted-games.com/public/Tuto1/change_target.png&quot; alt=&quot;change_target.png&quot; style=&quot;display:block; margin:0 auto;&quot; title=&quot;change_target.png, Jun 2010&quot; /&gt;&lt;/p&gt;


&lt;p&gt;And run the Xbox 360 project. You now have your game running on your TV! You can also debug the game like if it was running on the computer by putting some break points etc. Remote debugging works pretty darn well.&lt;/p&gt;


&lt;p&gt;We now have a problem: we didn’t handle the gamepad so the game isn’t playable. The only thing you can do, is to press the “back” button to exit the game. The update is simple to achieve:&lt;/p&gt;

&lt;pre class=&quot;csharp&quot;&gt;&lt;ol&gt;&lt;li style=&quot;font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;&quot;&gt;&lt;div style=&quot;font-family: 'Courier New', Courier, monospace; font-weight: normal;&quot;&gt;&lt;span style=&quot;color: #008080; font-style: italic;&quot;&gt;// handling keyboard and gamepad inputs&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style=&quot;font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;&quot;&gt;&lt;div style=&quot;font-family: 'Courier New', Courier, monospace; font-weight: normal;&quot;&gt;            &lt;span style=&quot;color: #0600FF;&quot;&gt;if&lt;/span&gt; &lt;span style=&quot;color: #000000;&quot;&gt;&amp;#40;&lt;/span&gt;Keyboard.&lt;span style=&quot;color: #0000FF;&quot;&gt;GetState&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#41;&lt;/span&gt;.&lt;span style=&quot;color: #0000FF;&quot;&gt;IsKeyDown&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#40;&lt;/span&gt;Keys.&lt;span style=&quot;color: #0000FF;&quot;&gt;E&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#41;&lt;/span&gt; &lt;span style=&quot;color: #008080; font-style: italic;&quot;&gt;// E key down ?&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style=&quot;font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;&quot;&gt;&lt;div style=&quot;font-family: 'Courier New', Courier, monospace; font-weight: normal;&quot;&gt;                &lt;span style=&quot;color: #008000;&quot;&gt;||&lt;/span&gt; GamePad.&lt;span style=&quot;color: #0000FF;&quot;&gt;GetState&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#40;&lt;/span&gt;PlayerIndex.&lt;span style=&quot;color: #0000FF;&quot;&gt;One&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#41;&lt;/span&gt;.&lt;span style=&quot;color: #0000FF;&quot;&gt;DPad&lt;/span&gt;.&lt;span style=&quot;color: #0000FF;&quot;&gt;Up&lt;/span&gt; &lt;span style=&quot;color: #008000;&quot;&gt;==&lt;/span&gt; ButtonState.&lt;span style=&quot;color: #0000FF;&quot;&gt;Pressed&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style=&quot;font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;&quot;&gt;&lt;div style=&quot;font-family: 'Courier New', Courier, monospace; font-weight: normal;&quot;&gt;                blueBar.&lt;span style=&quot;color: #0000FF;&quot;&gt;Y&lt;/span&gt; &lt;span style=&quot;color: #008000;&quot;&gt;-=&lt;/span&gt; &lt;span style=&quot;color: #FF0000;&quot;&gt;10&lt;/span&gt;; &lt;span style=&quot;color: #008080; font-style: italic;&quot;&gt;// move the blue bar up&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style=&quot;font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;&quot;&gt;&lt;div style=&quot;font-family: 'Courier New', Courier, monospace; font-weight: normal;&quot;&gt;            &lt;span style=&quot;color: #0600FF;&quot;&gt;else&lt;/span&gt; &lt;span style=&quot;color: #0600FF;&quot;&gt;if&lt;/span&gt; &lt;span style=&quot;color: #000000;&quot;&gt;&amp;#40;&lt;/span&gt;Keyboard.&lt;span style=&quot;color: #0000FF;&quot;&gt;GetState&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#41;&lt;/span&gt;.&lt;span style=&quot;color: #0000FF;&quot;&gt;IsKeyDown&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#40;&lt;/span&gt;Keys.&lt;span style=&quot;color: #0000FF;&quot;&gt;D&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#41;&lt;/span&gt; &lt;span style=&quot;color: #008080; font-style: italic;&quot;&gt;// D key down ?&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style=&quot;font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;&quot;&gt;&lt;div style=&quot;font-family: 'Courier New', Courier, monospace; font-weight: normal;&quot;&gt;                &lt;span style=&quot;color: #008000;&quot;&gt;||&lt;/span&gt; GamePad.&lt;span style=&quot;color: #0000FF;&quot;&gt;GetState&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#40;&lt;/span&gt;PlayerIndex.&lt;span style=&quot;color: #0000FF;&quot;&gt;One&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#41;&lt;/span&gt;.&lt;span style=&quot;color: #0000FF;&quot;&gt;DPad&lt;/span&gt;.&lt;span style=&quot;color: #0000FF;&quot;&gt;Down&lt;/span&gt; &lt;span style=&quot;color: #008000;&quot;&gt;==&lt;/span&gt; ButtonState.&lt;span style=&quot;color: #0000FF;&quot;&gt;Pressed&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style=&quot;font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;&quot;&gt;&lt;div style=&quot;font-family: 'Courier New', Courier, monospace; font-weight: normal;&quot;&gt;                blueBar.&lt;span style=&quot;color: #0000FF;&quot;&gt;Y&lt;/span&gt; &lt;span style=&quot;color: #008000;&quot;&gt;+=&lt;/span&gt; &lt;span style=&quot;color: #FF0000;&quot;&gt;10&lt;/span&gt;; &lt;span style=&quot;color: #008080; font-style: italic;&quot;&gt;// move the blue bar down&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style=&quot;font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;&quot;&gt;&lt;div style=&quot;font-family: 'Courier New', Courier, monospace; font-weight: normal;&quot;&gt;            &lt;span style=&quot;color: #0600FF;&quot;&gt;if&lt;/span&gt; &lt;span style=&quot;color: #000000;&quot;&gt;&amp;#40;&lt;/span&gt;Keyboard.&lt;span style=&quot;color: #0000FF;&quot;&gt;GetState&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#41;&lt;/span&gt;.&lt;span style=&quot;color: #0000FF;&quot;&gt;IsKeyDown&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#40;&lt;/span&gt;Keys.&lt;span style=&quot;color: #0000FF;&quot;&gt;Up&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#41;&lt;/span&gt; &lt;span style=&quot;color: #008080; font-style: italic;&quot;&gt;// Up key down ?&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style=&quot;font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;&quot;&gt;&lt;div style=&quot;font-family: 'Courier New', Courier, monospace; font-weight: normal;&quot;&gt;                &lt;span style=&quot;color: #008000;&quot;&gt;||&lt;/span&gt; GamePad.&lt;span style=&quot;color: #0000FF;&quot;&gt;GetState&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#40;&lt;/span&gt;PlayerIndex.&lt;span style=&quot;color: #0000FF;&quot;&gt;Two&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#41;&lt;/span&gt;.&lt;span style=&quot;color: #0000FF;&quot;&gt;DPad&lt;/span&gt;.&lt;span style=&quot;color: #0000FF;&quot;&gt;Up&lt;/span&gt; &lt;span style=&quot;color: #008000;&quot;&gt;==&lt;/span&gt; ButtonState.&lt;span style=&quot;color: #0000FF;&quot;&gt;Pressed&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style=&quot;font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;&quot;&gt;&lt;div style=&quot;font-family: 'Courier New', Courier, monospace; font-weight: normal;&quot;&gt;                redBar.&lt;span style=&quot;color: #0000FF;&quot;&gt;Y&lt;/span&gt; &lt;span style=&quot;color: #008000;&quot;&gt;-=&lt;/span&gt; &lt;span style=&quot;color: #FF0000;&quot;&gt;10&lt;/span&gt;; &lt;span style=&quot;color: #008080; font-style: italic;&quot;&gt;// move the red bar up&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style=&quot;font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;&quot;&gt;&lt;div style=&quot;font-family: 'Courier New', Courier, monospace; font-weight: normal;&quot;&gt;            &lt;span style=&quot;color: #0600FF;&quot;&gt;else&lt;/span&gt; &lt;span style=&quot;color: #0600FF;&quot;&gt;if&lt;/span&gt; &lt;span style=&quot;color: #000000;&quot;&gt;&amp;#40;&lt;/span&gt;Keyboard.&lt;span style=&quot;color: #0000FF;&quot;&gt;GetState&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#41;&lt;/span&gt;.&lt;span style=&quot;color: #0000FF;&quot;&gt;IsKeyDown&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#40;&lt;/span&gt;Keys.&lt;span style=&quot;color: #0000FF;&quot;&gt;Down&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#41;&lt;/span&gt; &lt;span style=&quot;color: #008080; font-style: italic;&quot;&gt;// Down key down ?&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style=&quot;font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;&quot;&gt;&lt;div style=&quot;font-family: 'Courier New', Courier, monospace; font-weight: normal;&quot;&gt;                &lt;span style=&quot;color: #008000;&quot;&gt;||&lt;/span&gt; GamePad.&lt;span style=&quot;color: #0000FF;&quot;&gt;GetState&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#40;&lt;/span&gt;PlayerIndex.&lt;span style=&quot;color: #0000FF;&quot;&gt;Two&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#41;&lt;/span&gt;.&lt;span style=&quot;color: #0000FF;&quot;&gt;DPad&lt;/span&gt;.&lt;span style=&quot;color: #0000FF;&quot;&gt;Down&lt;/span&gt; &lt;span style=&quot;color: #008000;&quot;&gt;==&lt;/span&gt; ButtonState.&lt;span style=&quot;color: #0000FF;&quot;&gt;Pressed&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style=&quot;font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;&quot;&gt;&lt;div style=&quot;font-family: 'Courier New', Courier, monospace; font-weight: normal;&quot;&gt;                redBar.&lt;span style=&quot;color: #0000FF;&quot;&gt;Y&lt;/span&gt; &lt;span style=&quot;color: #008000;&quot;&gt;+=&lt;/span&gt; &lt;span style=&quot;color: #FF0000;&quot;&gt;10&lt;/span&gt;; &lt;span style=&quot;color: #008080; font-style: italic;&quot;&gt;// move the red bar down&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;/ol&gt;&lt;/pre&gt;

&lt;pre class=&quot;csharp&quot;&gt;&lt;ol&gt;&lt;li style=&quot;font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;&quot;&gt;&lt;div style=&quot;font-family: 'Courier New', Courier, monospace; font-weight: normal;&quot;&gt;&lt;span style=&quot;color: #008080; font-style: italic;&quot;&gt;// handling ball initialization&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style=&quot;font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;&quot;&gt;&lt;div style=&quot;font-family: 'Courier New', Courier, monospace; font-weight: normal;&quot;&gt;            &lt;span style=&quot;color: #0600FF;&quot;&gt;if&lt;/span&gt; &lt;span style=&quot;color: #000000;&quot;&gt;&amp;#40;&lt;/span&gt;Keyboard.&lt;span style=&quot;color: #0000FF;&quot;&gt;GetState&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#41;&lt;/span&gt;.&lt;span style=&quot;color: #0000FF;&quot;&gt;IsKeyDown&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#40;&lt;/span&gt;Keys.&lt;span style=&quot;color: #0000FF;&quot;&gt;Space&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style=&quot;font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;&quot;&gt;&lt;div style=&quot;font-family: 'Courier New', Courier, monospace; font-weight: normal;&quot;&gt;                &lt;span style=&quot;color: #008000;&quot;&gt;||&lt;/span&gt; GamePad.&lt;span style=&quot;color: #0000FF;&quot;&gt;GetState&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#40;&lt;/span&gt;PlayerIndex.&lt;span style=&quot;color: #0000FF;&quot;&gt;One&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#41;&lt;/span&gt;.&lt;span style=&quot;color: #0000FF;&quot;&gt;Buttons&lt;/span&gt;.&lt;span style=&quot;color: #0000FF;&quot;&gt;Start&lt;/span&gt; &lt;span style=&quot;color: #008000;&quot;&gt;==&lt;/span&gt; ButtonState.&lt;span style=&quot;color: #0000FF;&quot;&gt;Pressed&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style=&quot;font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;&quot;&gt;&lt;div style=&quot;font-family: 'Courier New', Courier, monospace; font-weight: normal;&quot;&gt;                InitBall&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#41;&lt;/span&gt;;&lt;/div&gt;&lt;/li&gt;&lt;/ol&gt;&lt;/pre&gt;


&lt;p&gt;Here it is, we can now play with two gamepad and our Xbox 360 port is complete!&lt;/p&gt;


&lt;h2&gt;Serious business: porting our game to Windows Phone 7&lt;/h2&gt;


&lt;p&gt;&lt;em&gt;Before we proceed, another note about the CTP. Copying an existing project to a Windows Phone one has a bug: manifest files are missing. If you want to correct this, read &lt;a href=&quot;http://download.microsoft.com/download/D/9/2/D926FB38-BB43-4D87-AE5A-1A3391279FAC/ReleaseNotes.htm&quot; hreflang=&quot;en&quot;&gt;the release notes&lt;/a&gt;. The second and last problem this article may encounter, is that the CTP emulator doesn’t feature automatic screen orientation. This means that our pong game can only run in portrait mode which looks strange for a pong clone. These problems will be fixed in the final XNA 4 version.&lt;/em&gt;&lt;/p&gt;


&lt;p&gt;As we did for the Xbox 360 port, create copy for Windows Phone of your project. If you try to run the game in the emulator, you’ll most likely end up with a cornflower blue screen. This means our game has incompatible graphics properties. To fix this, we need to switch to Windows Phone 7 specific parameters, namely a screen resolution of 480x800 and a refresh rate of 30 frames per second. But we don’t want to apply these changes to our other ports. Fortunately, there’s a way to write code that we only be considered by a specific port thanks to preprocessor statements. The changes will be applied in the &lt;a href=&quot;http://msdn.microsoft.com/en-us/library/microsoft.xna.framework.game%28v=XNAGameStudio.40%29.aspx&quot; hreflang=&quot;en&quot;&gt;Game1&lt;/a&gt; constructor:&lt;/p&gt;

&lt;pre class=&quot;csharp&quot;&gt;&lt;ol&gt;&lt;li style=&quot;font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;&quot;&gt;&lt;div style=&quot;font-family: 'Courier New', Courier, monospace; font-weight: normal;&quot;&gt;&lt;span style=&quot;color: #0600FF;&quot;&gt;public&lt;/span&gt; Game1&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style=&quot;font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;&quot;&gt;&lt;div style=&quot;font-family: 'Courier New', Courier, monospace; font-weight: normal;&quot;&gt;        &lt;span style=&quot;color: #000000;&quot;&gt;&amp;#123;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style=&quot;font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;&quot;&gt;&lt;div style=&quot;font-family: 'Courier New', Courier, monospace; font-weight: normal;&quot;&gt;            graphics &lt;span style=&quot;color: #008000;&quot;&gt;=&lt;/span&gt; &lt;span style=&quot;color: #008000;&quot;&gt;new&lt;/span&gt; GraphicsDeviceManager&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #0600FF;&quot;&gt;this&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#41;&lt;/span&gt;;&lt;/div&gt;&lt;/li&gt;&lt;li style=&quot;font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;&quot;&gt;&lt;div style=&quot;font-family: 'Courier New', Courier, monospace; font-weight: normal;&quot;&gt;            Content.&lt;span style=&quot;color: #0000FF;&quot;&gt;RootDirectory&lt;/span&gt; &lt;span style=&quot;color: #008000;&quot;&gt;=&lt;/span&gt; &lt;span style=&quot;color: #808080;&quot;&gt;&amp;quot;Content&amp;quot;&lt;/span&gt;;&lt;/div&gt;&lt;/li&gt;&lt;li style=&quot;font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;&quot;&gt;&lt;div style=&quot;font-family: 'Courier New', Courier, monospace; font-weight: normal;&quot;&gt;&amp;nbsp;&lt;/div&gt;&lt;/li&gt;&lt;li style=&quot;font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;&quot;&gt;&lt;div style=&quot;font-family: 'Courier New', Courier, monospace; font-weight: normal;&quot;&gt;&lt;span style=&quot;color: #008080;&quot;&gt;#if WINDOWS_PHONE&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style=&quot;font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;&quot;&gt;&lt;div style=&quot;font-family: 'Courier New', Courier, monospace; font-weight: normal;&quot;&gt;            &lt;span style=&quot;color: #008080; font-style: italic;&quot;&gt;// Frame rate is 30 fps by default for Windows Phone.&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style=&quot;font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;&quot;&gt;&lt;div style=&quot;font-family: 'Courier New', Courier, monospace; font-weight: normal;&quot;&gt;            TargetElapsedTime &lt;span style=&quot;color: #008000;&quot;&gt;=&lt;/span&gt; TimeSpan.&lt;span style=&quot;color: #0000FF;&quot;&gt;FromTicks&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #FF0000;&quot;&gt;333333&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#41;&lt;/span&gt;;&lt;/div&gt;&lt;/li&gt;&lt;li style=&quot;font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;&quot;&gt;&lt;div style=&quot;font-family: 'Courier New', Courier, monospace; font-weight: normal;&quot;&gt;&amp;nbsp;&lt;/div&gt;&lt;/li&gt;&lt;li style=&quot;font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;&quot;&gt;&lt;div style=&quot;font-family: 'Courier New', Courier, monospace; font-weight: normal;&quot;&gt;            &lt;span style=&quot;color: #008080; font-style: italic;&quot;&gt;// Pre-autoscale settings.&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style=&quot;font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;&quot;&gt;&lt;div style=&quot;font-family: 'Courier New', Courier, monospace; font-weight: normal;&quot;&gt;            graphics.&lt;span style=&quot;color: #0000FF;&quot;&gt;PreferredBackBufferWidth&lt;/span&gt; &lt;span style=&quot;color: #008000;&quot;&gt;=&lt;/span&gt; &lt;span style=&quot;color: #FF0000;&quot;&gt;480&lt;/span&gt;;&lt;/div&gt;&lt;/li&gt;&lt;li style=&quot;font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;&quot;&gt;&lt;div style=&quot;font-family: 'Courier New', Courier, monospace; font-weight: normal;&quot;&gt;            graphics.&lt;span style=&quot;color: #0000FF;&quot;&gt;PreferredBackBufferHeight&lt;/span&gt; &lt;span style=&quot;color: #008000;&quot;&gt;=&lt;/span&gt; &lt;span style=&quot;color: #FF0000;&quot;&gt;800&lt;/span&gt;;&lt;/div&gt;&lt;/li&gt;&lt;li style=&quot;font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;&quot;&gt;&lt;div style=&quot;font-family: 'Courier New', Courier, monospace; font-weight: normal;&quot;&gt;            graphics.&lt;span style=&quot;color: #0000FF;&quot;&gt;IsFullScreen&lt;/span&gt; &lt;span style=&quot;color: #008000;&quot;&gt;=&lt;/span&gt; &lt;span style=&quot;color: #0600FF;&quot;&gt;true&lt;/span&gt;;&lt;/div&gt;&lt;/li&gt;&lt;li style=&quot;font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;&quot;&gt;&lt;div style=&quot;font-family: 'Courier New', Courier, monospace; font-weight: normal;&quot;&gt;&lt;span style=&quot;color: #008080;&quot;&gt;#endif&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style=&quot;font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;&quot;&gt;&lt;div style=&quot;font-family: 'Courier New', Courier, monospace; font-weight: normal;&quot;&gt;        &lt;span style=&quot;color: #000000;&quot;&gt;&amp;#125;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;/ol&gt;&lt;/pre&gt;


&lt;p&gt;Note that we also set the game to run in full screen mode. On Windows Phone 7, it means that the battery status will not show up over the game. If it wasn’t in full screen, the battery status would hide our score display.&lt;/p&gt;


&lt;p&gt;Try to run the game and look at our super portrait pong.&lt;/p&gt;


&lt;p&gt;You may notice that the inputs don’t work. Some Windows Phone 7 devices come with a physical keyboard, but since some are not, XNA designer choose to not support keyboards as an input method so that games are experienced the same way on all Windows Phone 7 devices. The only method we have at our disposal if the multi-touch screen.&lt;/p&gt;


&lt;p&gt;First, we need to design some sort of interaction scheme: to move the blue bar, we’ll consider the upper left and lower left corner of the screen as our up and down buttons; the opposite corners will be used to move the red bar; to initialize the game, we’ll consider a tap on the middle of the screen. The following code comes right after the inputs handling in the &lt;a href=&quot;http://msdn.microsoft.com/en-us/library/microsoft.xna.framework.game.update%28v=XNAGameStudio.40%29.aspx&quot; hreflang=&quot;en&quot;&gt;Update&lt;/a&gt; method:&lt;/p&gt;

&lt;pre class=&quot;csharp&quot;&gt;&lt;ol&gt;&lt;li style=&quot;font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;&quot;&gt;&lt;div style=&quot;font-family: 'Courier New', Courier, monospace; font-weight: normal;&quot;&gt;&lt;span style=&quot;color: #008080;&quot;&gt;#if WINDOWS_PHONE&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style=&quot;font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;&quot;&gt;&lt;div style=&quot;font-family: 'Courier New', Courier, monospace; font-weight: normal;&quot;&gt;            &lt;span style=&quot;color: #008080; font-style: italic;&quot;&gt;// for each detected touch&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style=&quot;font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;&quot;&gt;&lt;div style=&quot;font-family: 'Courier New', Courier, monospace; font-weight: normal;&quot;&gt;            TouchCollection touchCollection &lt;span style=&quot;color: #008000;&quot;&gt;=&lt;/span&gt; TouchPanel.&lt;span style=&quot;color: #0000FF;&quot;&gt;GetState&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#41;&lt;/span&gt;;&lt;/div&gt;&lt;/li&gt;&lt;li style=&quot;font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;&quot;&gt;&lt;div style=&quot;font-family: 'Courier New', Courier, monospace; font-weight: normal;&quot;&gt;            &lt;span style=&quot;color: #0600FF;&quot;&gt;foreach&lt;/span&gt; &lt;span style=&quot;color: #000000;&quot;&gt;&amp;#40;&lt;/span&gt;TouchLocation touchLocation &lt;span style=&quot;color: #0600FF;&quot;&gt;in&lt;/span&gt; touchCollection&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style=&quot;font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;&quot;&gt;&lt;div style=&quot;font-family: 'Courier New', Courier, monospace; font-weight: normal;&quot;&gt;            &lt;span style=&quot;color: #000000;&quot;&gt;&amp;#123;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style=&quot;font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;&quot;&gt;&lt;div style=&quot;font-family: 'Courier New', Courier, monospace; font-weight: normal;&quot;&gt;                &lt;span style=&quot;color: #008080; font-style: italic;&quot;&gt;// upper left corner touche detection&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style=&quot;font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;&quot;&gt;&lt;div style=&quot;font-family: 'Courier New', Courier, monospace; font-weight: normal;&quot;&gt;                &lt;span style=&quot;color: #0600FF;&quot;&gt;if&lt;/span&gt; &lt;span style=&quot;color: #000000;&quot;&gt;&amp;#40;&lt;/span&gt;touchLocation.&lt;span style=&quot;color: #0000FF;&quot;&gt;Position&lt;/span&gt;.&lt;span style=&quot;color: #0000FF;&quot;&gt;X&lt;/span&gt; &lt;span style=&quot;color: #008000;&quot;&gt;&amp;lt;&lt;/span&gt; &lt;span style=&quot;color: #FF0000;&quot;&gt;50&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style=&quot;font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;&quot;&gt;&lt;div style=&quot;font-family: 'Courier New', Courier, monospace; font-weight: normal;&quot;&gt;                    &lt;span style=&quot;color: #008000;&quot;&gt;&amp;amp;&amp;amp;&lt;/span&gt; touchLocation.&lt;span style=&quot;color: #0000FF;&quot;&gt;Position&lt;/span&gt;.&lt;span style=&quot;color: #0000FF;&quot;&gt;Y&lt;/span&gt; &lt;span style=&quot;color: #008000;&quot;&gt;&amp;lt;&lt;/span&gt; &lt;span style=&quot;color: #FF0000;&quot;&gt;50&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style=&quot;font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;&quot;&gt;&lt;div style=&quot;font-family: 'Courier New', Courier, monospace; font-weight: normal;&quot;&gt;                    blueBar.&lt;span style=&quot;color: #0000FF;&quot;&gt;Y&lt;/span&gt; &lt;span style=&quot;color: #008000;&quot;&gt;-=&lt;/span&gt; &lt;span style=&quot;color: #FF0000;&quot;&gt;10&lt;/span&gt;; &lt;span style=&quot;color: #008080; font-style: italic;&quot;&gt;// move the blue bar up&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style=&quot;font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;&quot;&gt;&lt;div style=&quot;font-family: 'Courier New', Courier, monospace; font-weight: normal;&quot;&gt;                &lt;span style=&quot;color: #008080; font-style: italic;&quot;&gt;// lower left corner&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style=&quot;font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;&quot;&gt;&lt;div style=&quot;font-family: 'Courier New', Courier, monospace; font-weight: normal;&quot;&gt;                &lt;span style=&quot;color: #0600FF;&quot;&gt;else&lt;/span&gt; &lt;span style=&quot;color: #0600FF;&quot;&gt;if&lt;/span&gt; &lt;span style=&quot;color: #000000;&quot;&gt;&amp;#40;&lt;/span&gt;touchLocation.&lt;span style=&quot;color: #0000FF;&quot;&gt;Position&lt;/span&gt;.&lt;span style=&quot;color: #0000FF;&quot;&gt;X&lt;/span&gt; &lt;span style=&quot;color: #008000;&quot;&gt;&amp;lt;&lt;/span&gt; &lt;span style=&quot;color: #FF0000;&quot;&gt;50&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style=&quot;font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;&quot;&gt;&lt;div style=&quot;font-family: 'Courier New', Courier, monospace; font-weight: normal;&quot;&gt;                    &lt;span style=&quot;color: #008000;&quot;&gt;&amp;amp;&amp;amp;&lt;/span&gt; touchLocation.&lt;span style=&quot;color: #0000FF;&quot;&gt;Position&lt;/span&gt;.&lt;span style=&quot;color: #0000FF;&quot;&gt;Y&lt;/span&gt; &lt;span style=&quot;color: #008000;&quot;&gt;&amp;gt;&lt;/span&gt; &lt;span style=&quot;color: #FF0000;&quot;&gt;750&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style=&quot;font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;&quot;&gt;&lt;div style=&quot;font-family: 'Courier New', Courier, monospace; font-weight: normal;&quot;&gt;                    blueBar.&lt;span style=&quot;color: #0000FF;&quot;&gt;Y&lt;/span&gt; &lt;span style=&quot;color: #008000;&quot;&gt;+=&lt;/span&gt; &lt;span style=&quot;color: #FF0000;&quot;&gt;10&lt;/span&gt;; &lt;span style=&quot;color: #008080; font-style: italic;&quot;&gt;// move the blue bar down&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style=&quot;font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;&quot;&gt;&lt;div style=&quot;font-family: 'Courier New', Courier, monospace; font-weight: normal;&quot;&gt;&amp;nbsp;&lt;/div&gt;&lt;/li&gt;&lt;li style=&quot;font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;&quot;&gt;&lt;div style=&quot;font-family: 'Courier New', Courier, monospace; font-weight: normal;&quot;&gt;                &lt;span style=&quot;color: #008080; font-style: italic;&quot;&gt;// upper right corner touche detection&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style=&quot;font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;&quot;&gt;&lt;div style=&quot;font-family: 'Courier New', Courier, monospace; font-weight: normal;&quot;&gt;                &lt;span style=&quot;color: #0600FF;&quot;&gt;if&lt;/span&gt; &lt;span style=&quot;color: #000000;&quot;&gt;&amp;#40;&lt;/span&gt;touchLocation.&lt;span style=&quot;color: #0000FF;&quot;&gt;Position&lt;/span&gt;.&lt;span style=&quot;color: #0000FF;&quot;&gt;X&lt;/span&gt; &lt;span style=&quot;color: #008000;&quot;&gt;&amp;gt;&lt;/span&gt; &lt;span style=&quot;color: #FF0000;&quot;&gt;430&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style=&quot;font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;&quot;&gt;&lt;div style=&quot;font-family: 'Courier New', Courier, monospace; font-weight: normal;&quot;&gt;                    &lt;span style=&quot;color: #008000;&quot;&gt;&amp;amp;&amp;amp;&lt;/span&gt; touchLocation.&lt;span style=&quot;color: #0000FF;&quot;&gt;Position&lt;/span&gt;.&lt;span style=&quot;color: #0000FF;&quot;&gt;Y&lt;/span&gt; &lt;span style=&quot;color: #008000;&quot;&gt;&amp;lt;&lt;/span&gt; &lt;span style=&quot;color: #FF0000;&quot;&gt;50&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style=&quot;font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;&quot;&gt;&lt;div style=&quot;font-family: 'Courier New', Courier, monospace; font-weight: normal;&quot;&gt;                    redBar.&lt;span style=&quot;color: #0000FF;&quot;&gt;Y&lt;/span&gt; &lt;span style=&quot;color: #008000;&quot;&gt;-=&lt;/span&gt; &lt;span style=&quot;color: #FF0000;&quot;&gt;10&lt;/span&gt;; &lt;span style=&quot;color: #008080; font-style: italic;&quot;&gt;// move the red bar up&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style=&quot;font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;&quot;&gt;&lt;div style=&quot;font-family: 'Courier New', Courier, monospace; font-weight: normal;&quot;&gt;                &lt;span style=&quot;color: #008080; font-style: italic;&quot;&gt;// lower right corner&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style=&quot;font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;&quot;&gt;&lt;div style=&quot;font-family: 'Courier New', Courier, monospace; font-weight: normal;&quot;&gt;                &lt;span style=&quot;color: #0600FF;&quot;&gt;else&lt;/span&gt; &lt;span style=&quot;color: #0600FF;&quot;&gt;if&lt;/span&gt; &lt;span style=&quot;color: #000000;&quot;&gt;&amp;#40;&lt;/span&gt;touchLocation.&lt;span style=&quot;color: #0000FF;&quot;&gt;Position&lt;/span&gt;.&lt;span style=&quot;color: #0000FF;&quot;&gt;X&lt;/span&gt; &lt;span style=&quot;color: #008000;&quot;&gt;&amp;gt;&lt;/span&gt; &lt;span style=&quot;color: #FF0000;&quot;&gt;430&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style=&quot;font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;&quot;&gt;&lt;div style=&quot;font-family: 'Courier New', Courier, monospace; font-weight: normal;&quot;&gt;                    &lt;span style=&quot;color: #008000;&quot;&gt;&amp;amp;&amp;amp;&lt;/span&gt; touchLocation.&lt;span style=&quot;color: #0000FF;&quot;&gt;Position&lt;/span&gt;.&lt;span style=&quot;color: #0000FF;&quot;&gt;Y&lt;/span&gt; &lt;span style=&quot;color: #008000;&quot;&gt;&amp;gt;&lt;/span&gt; &lt;span style=&quot;color: #FF0000;&quot;&gt;750&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style=&quot;font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;&quot;&gt;&lt;div style=&quot;font-family: 'Courier New', Courier, monospace; font-weight: normal;&quot;&gt;                    redBar.&lt;span style=&quot;color: #0000FF;&quot;&gt;Y&lt;/span&gt; &lt;span style=&quot;color: #008000;&quot;&gt;+=&lt;/span&gt; &lt;span style=&quot;color: #FF0000;&quot;&gt;10&lt;/span&gt;; &lt;span style=&quot;color: #008080; font-style: italic;&quot;&gt;// move the red bar down&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style=&quot;font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;&quot;&gt;&lt;div style=&quot;font-family: 'Courier New', Courier, monospace; font-weight: normal;&quot;&gt;&amp;nbsp;&lt;/div&gt;&lt;/li&gt;&lt;li style=&quot;font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;&quot;&gt;&lt;div style=&quot;font-family: 'Courier New', Courier, monospace; font-weight: normal;&quot;&gt;                &lt;span style=&quot;color: #008080; font-style: italic;&quot;&gt;// ball touch&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style=&quot;font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;&quot;&gt;&lt;div style=&quot;font-family: 'Courier New', Courier, monospace; font-weight: normal;&quot;&gt;                &lt;span style=&quot;color: #0600FF;&quot;&gt;if&lt;/span&gt; &lt;span style=&quot;color: #000000;&quot;&gt;&amp;#40;&lt;/span&gt;touchLocation.&lt;span style=&quot;color: #0000FF;&quot;&gt;Position&lt;/span&gt;.&lt;span style=&quot;color: #0000FF;&quot;&gt;X&lt;/span&gt; &lt;span style=&quot;color: #008000;&quot;&gt;&amp;lt;&lt;/span&gt; &lt;span style=&quot;color: #FF0000;&quot;&gt;260&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style=&quot;font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;&quot;&gt;&lt;div style=&quot;font-family: 'Courier New', Courier, monospace; font-weight: normal;&quot;&gt;                    &lt;span style=&quot;color: #008000;&quot;&gt;&amp;amp;&amp;amp;&lt;/span&gt; touchLocation.&lt;span style=&quot;color: #0000FF;&quot;&gt;Position&lt;/span&gt;.&lt;span style=&quot;color: #0000FF;&quot;&gt;X&lt;/span&gt; &lt;span style=&quot;color: #008000;&quot;&gt;&amp;gt;&lt;/span&gt; &lt;span style=&quot;color: #FF0000;&quot;&gt;220&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style=&quot;font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;&quot;&gt;&lt;div style=&quot;font-family: 'Courier New', Courier, monospace; font-weight: normal;&quot;&gt;                    &lt;span style=&quot;color: #008000;&quot;&gt;&amp;amp;&amp;amp;&lt;/span&gt; touchLocation.&lt;span style=&quot;color: #0000FF;&quot;&gt;Position&lt;/span&gt;.&lt;span style=&quot;color: #0000FF;&quot;&gt;Y&lt;/span&gt; &lt;span style=&quot;color: #008000;&quot;&gt;&amp;lt;&lt;/span&gt; &lt;span style=&quot;color: #FF0000;&quot;&gt;420&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style=&quot;font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;&quot;&gt;&lt;div style=&quot;font-family: 'Courier New', Courier, monospace; font-weight: normal;&quot;&gt;                    &lt;span style=&quot;color: #008000;&quot;&gt;&amp;amp;&amp;amp;&lt;/span&gt; touchLocation.&lt;span style=&quot;color: #0000FF;&quot;&gt;Position&lt;/span&gt;.&lt;span style=&quot;color: #0000FF;&quot;&gt;Y&lt;/span&gt; &lt;span style=&quot;color: #008000;&quot;&gt;&amp;gt;&lt;/span&gt; &lt;span style=&quot;color: #FF0000;&quot;&gt;380&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style=&quot;font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;&quot;&gt;&lt;div style=&quot;font-family: 'Courier New', Courier, monospace; font-weight: normal;&quot;&gt;                    InitBall&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#41;&lt;/span&gt;;&lt;/div&gt;&lt;/li&gt;&lt;li style=&quot;font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;&quot;&gt;&lt;div style=&quot;font-family: 'Courier New', Courier, monospace; font-weight: normal;&quot;&gt;            &lt;span style=&quot;color: #000000;&quot;&gt;&amp;#125;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style=&quot;font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;&quot;&gt;&lt;div style=&quot;font-family: 'Courier New', Courier, monospace; font-weight: normal;&quot;&gt;&lt;span style=&quot;color: #008080;&quot;&gt;#endif&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;/ol&gt;&lt;/pre&gt;


&lt;p&gt;This is a quite rough technique. If you’d like to better use the touch screen, try to use the &lt;a href=&quot;http://msdn.microsoft.com/en-us/library/microsoft.xna.framework.input.touch.touchlocation.trygetpreviouslocation(v=XNAGameStudio.40).aspx&quot; hreflang=&quot;en&quot;&gt;TryGetPreviousPosition&lt;/a&gt; method of a &lt;a href=&quot;http://msdn.microsoft.com/en-us/library/microsoft.xna.framework.input.touch.touchlocation%28v=XNAGameStudio.40%29.aspx&quot; hreflang=&quot;en&quot;&gt;TouchLocation&lt;/a&gt; to follow a finger along the left or right corner of the screen and make the bar follow the gesture.&lt;/p&gt;


&lt;p&gt;By the way, our Pong clone is now fully playable on Windows Phone 7! And that’s it.&lt;/p&gt;


&lt;h2&gt;Conclusion&lt;/h2&gt;


&lt;p&gt;Your Pong clone is now (almost) finished and working on three different platforms. There are still many aspects to fine tune, but this up to you now. You should have the background to do basic 2D games.&lt;/p&gt;


&lt;p&gt;Hopefully, you noticed that I’m referring to the MSDN online documentation as much as possible. This was a secret message telling you that reading the documentation can save you much time and avoid you some useless search on the internet. If you still have problems, search on the creators club forum, or expose your problem on the forum.&lt;/p&gt;


&lt;p&gt;I hope that you enjoyed following this tutorial and don’t hesitate to give me some feedback about it.&lt;/p&gt;</description>
    
    
    
          <comments>http://www.handcrafted-games.com/index.php?post/2010/06/10/Programming-your-first-XNA-game-for-PC%2C-Xbox-360-Windows-Phone-7%3A-Pong#comment-form</comments>
      <wfw:comment>http://www.handcrafted-games.com/index.php?post/2010/06/10/Programming-your-first-XNA-game-for-PC%2C-Xbox-360-Windows-Phone-7%3A-Pong#comment-form</wfw:comment>
      <wfw:commentRss>http://www.handcrafted-games.com/index.php?feed/atom/comments/9</wfw:commentRss>
      </item>
    
  <item>
    <title>Will my children be zombies ?</title>
    <link>http://www.handcrafted-games.com/index.php?post/2010/05/27/Will-my-children-be-zombies</link>
    <guid isPermaLink="false">urn:md5:a475def6f48e3ff30879135e64b5ec16</guid>
    <pubDate>Thu, 27 May 2010 10:17:00 +0100</pubDate>
    <dc:creator>Mister Helmut</dc:creator>
        <category>Blogposts</category>
        <category>daily life</category>    
    <description>    &lt;p&gt;Like most computer freaks, I started playing and programming quite soon, at the age of 7 I presume. My taller sister received an Amstrad CPC, a quite ironical fact since she was spending her time gossiping and using it as an hype decoration to her desk. After having rolled myself on the floor crying a few times, I successfully got parental rights over the Amstrad. Till the age of 16, I was considered by my family as a strange introverted kid. I don’t remember myself to have been such a scary kid, I had just interests different than playing G.I. Joe and watching TV all the day long, I even was a talkative kid to my parents but the fact that I had different hobbies compared to “standard” kids made me strange.&lt;/p&gt;


&lt;p&gt;Where things start puzzling me: recently, I was in my local multimedia store looking for the latest Jeff Lindsay (Dexter anyone?) when I stumbled upon something strange and very moody by the video games shelves. Two games were playable, namely Dante’s Inferno and New Super Mario Bros Wii. Three kids were roaming around, maybe 6 to 8 years old. I’d like to remind the audience that Dante’s is a 18+ rated game, fully playable just next to a Mario game. This sounded to me like a “spot the differences” game. Well,  the two oldest of them were playing Dante’s Inferno, while the third, a freaky-6-years-old-pale-kid, was staring at Dante slashing anything to ham sacks, mouth and eyes full open, like if he saw a one mile tall free Lego pyramid. I just stopped myself and scratched my head. Not that this was not common, but this particular kid freaked me out. I had to pass behind him, so I excused myself so he would let me pass. He didn’t moved. He didn’t even noticed me. So I poked him on the shoulder. He didn’t moved… I’ve lifted him and dropped him a little bit off so I could pass. He didn’t even noticed I lifted him… I think that if I wasn’t carefully lifting him, I could have obstructed his vision and he may have patched a leather cross upon his chest and started attacking me.&lt;/p&gt;


&lt;p&gt;It may looks like an isolated case, but a few days later, I had a very bad “déjà-vu” in the very same settings. Kids, same store, God of War 3 VS Sega All Star Racing, a scary-blond-kid and two other kids extravagantly happy to put to the light centaurs’ stomach. If this happens quite often, does it mean it is a common fact by today standards? I hope not. Was I such a kid? Obviously not. Most importantly, will my children be zombie gamers? Gotta prepare myself for the outbreak… I don’t feel like it is a normal situation and I’m a little bit afraid about it: I grew up with games and by actual culture evolution, I expect my kids to do so to. I don’t know what could make a kid so scary: being exposed to games with parent looking over them or not being exposed at all. For instance, the kid of a friend grew up playing Quake 3 with his father on LAN, fraging at the age of 6 and he’s a totally normal teenager now. I wonder if those strange kids grew up with games and which one.&lt;/p&gt;


&lt;p&gt;Anyway, I don’t agree with the fact that big stores are demoing 18+ games next to a Mario game.&lt;/p&gt;</description>
    
    
    
          <comments>http://www.handcrafted-games.com/index.php?post/2010/05/27/Will-my-children-be-zombies#comment-form</comments>
      <wfw:comment>http://www.handcrafted-games.com/index.php?post/2010/05/27/Will-my-children-be-zombies#comment-form</wfw:comment>
      <wfw:commentRss>http://www.handcrafted-games.com/index.php?feed/atom/comments/8</wfw:commentRss>
      </item>
    
  <item>
    <title>Writing a simple javascript RSS parser</title>
    <link>http://www.handcrafted-games.com/index.php?post/2010/05/05/Writing-a-simple-javascript-RSS-parser</link>
    <guid isPermaLink="false">urn:md5:59a38d8f0636b64fe11002b808327cac</guid>
    <pubDate>Wed, 05 May 2010 12:36:00 +0100</pubDate>
    <dc:creator>Mister Helmut</dc:creator>
        <category>Articles &amp; Tutorials</category>
        <category>daily xna</category><category>javascript</category><category>jquery</category><category>rss</category>    
    <description>&lt;p&gt;When I started to think about coding a personal news portal (&lt;a href=&quot;http://www.daily-xna.com/&quot; hreflang=&quot;en&quot;&gt;daily-xna.com&lt;/a&gt;), I had one main requirement: it had to be lightweight in order to run smoothly on my not-so-powerfull webserver. A common solution would have been to use &lt;a href=&quot;http://magpierss.sourceforge.net/&quot; hreflang=&quot;en&quot;&gt;Magpie RSS&lt;/a&gt;, a simple and well featured PHP RSS parser but it wouldn't meet my requirement as I'd like my portal to display more than 10 RSS feeds. More importantly, I needed fast page loading, which is not possible with magpie (parsing 10 rss takes way too much time). I prefered to use an asynchronous loading so that the main page loads quickly and doesn't use many server resources. I went with client side scripting, namely javascript, so that the actual parsing occurs in the client browser. But coding a RSS parser implies to download remote XML files. This isn't possible via javascript since it doesn't allow the usage of distant files. There's still ways to achieve it.&lt;/p&gt;


&lt;p&gt;This blogpost describes how I coded my asynchronous RSS parser thanks to a file proxy and caching system.&lt;/p&gt;    &lt;p&gt;First of, as I said, javascript doesn't allow file downloading from another domain name than the one the script is running on. Why? For obvious security reasons (it is fairly easy to replace a javascript code since everything runs inside the client browser, one could download malicious files). There is still ways to feed javascript with distant file, mainly by tricking it via a proxy.&lt;/p&gt;


&lt;h3&gt;Coding a file proxy&lt;/h3&gt;


&lt;p&gt;I used PHP to code a file proxy with caching features to reduce remote file access. To this purpose, I used the CURL PHP extension (which need to be activated, not all webhosters support it, so check your phpinfo() beforehand). CURL allows to build HTTP request in order to download distant files. I added a caching system to limit XML file downloading (my news feeds are rarely updated more than once per hour). Here's the code:&lt;/p&gt;

&lt;pre class=&quot;php&quot;&gt;&lt;ol&gt;&lt;li style=&quot;font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;&quot;&gt;&lt;div style=&quot;font-family: 'Courier New', Courier, monospace; font-weight: normal;&quot;&gt;&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;&amp;lt;?php&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style=&quot;font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;&quot;&gt;&lt;div style=&quot;font-family: 'Courier New', Courier, monospace; font-weight: normal;&quot;&gt;&lt;span style=&quot;color: #808080; font-style: italic;&quot;&gt;// filename: proxycache.php&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style=&quot;font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;&quot;&gt;&lt;div style=&quot;font-family: 'Courier New', Courier, monospace; font-weight: normal;&quot;&gt;&amp;nbsp;&lt;/div&gt;&lt;/li&gt;&lt;li style=&quot;font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;&quot;&gt;&lt;div style=&quot;font-family: 'Courier New', Courier, monospace; font-weight: normal;&quot;&gt;&lt;span style=&quot;color: #808080; font-style: italic;&quot;&gt;// parameters&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style=&quot;font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;&quot;&gt;&lt;div style=&quot;font-family: 'Courier New', Courier, monospace; font-weight: normal;&quot;&gt;&lt;span style=&quot;color: #ff0000&quot;&gt;$timeout&lt;/span&gt; &lt;span style=&quot;color: #66cc66;&quot;&gt;=&lt;/span&gt; &lt;span style=&quot;color: #cc66cc;&quot;&gt;3600&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;;&lt;/span&gt; &lt;span style=&quot;color: #808080; font-style: italic;&quot;&gt;// time before a cached file gets refreshed (in sec)&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style=&quot;font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;&quot;&gt;&lt;div style=&quot;font-family: 'Courier New', Courier, monospace; font-weight: normal;&quot;&gt;&lt;span style=&quot;color: #ff0000&quot;&gt;$folder&lt;/span&gt; &lt;span style=&quot;color: #66cc66;&quot;&gt;=&lt;/span&gt; &lt;span style=&quot;color: #ff0000;&quot;&gt;'./cache/'&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;;&lt;/span&gt; &lt;span style=&quot;color: #808080; font-style: italic;&quot;&gt;// directory where cache files belong (the directory must already exist)&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style=&quot;font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;&quot;&gt;&lt;div style=&quot;font-family: 'Courier New', Courier, monospace; font-weight: normal;&quot;&gt;&amp;nbsp;&lt;/div&gt;&lt;/li&gt;&lt;li style=&quot;font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;&quot;&gt;&lt;div style=&quot;font-family: 'Courier New', Courier, monospace; font-weight: normal;&quot;&gt;&lt;span style=&quot;color: #ff0000&quot;&gt;$url&lt;/span&gt; &lt;span style=&quot;color: #66cc66;&quot;&gt;=&lt;/span&gt; &lt;span style=&quot;color: #ff0000&quot;&gt;$_GET&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#91;&lt;/span&gt;&lt;span style=&quot;color: #ff0000;&quot;&gt;'url'&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#93;&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;;&lt;/span&gt; &lt;span style=&quot;color: #808080; font-style: italic;&quot;&gt;// the URL of the file to download is given to the script via the &amp;quot;url&amp;quot; GET variable and encoded (i.e. proxycache.php?url=http%3A%2F%2Fexample.com%2Frss.xml)&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style=&quot;font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;&quot;&gt;&lt;div style=&quot;font-family: 'Courier New', Courier, monospace; font-weight: normal;&quot;&gt;&lt;span style=&quot;color: #ff0000&quot;&gt;$hash&lt;/span&gt; &lt;span style=&quot;color: #66cc66;&quot;&gt;=&lt;/span&gt; &lt;span style=&quot;color: #000066;&quot;&gt;md5&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #ff0000&quot;&gt;$url&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;;&lt;/span&gt; &lt;span style=&quot;color: #808080; font-style: italic;&quot;&gt;// we create a hash so that our feed is uniquely identified&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style=&quot;font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;&quot;&gt;&lt;div style=&quot;font-family: 'Courier New', Courier, monospace; font-weight: normal;&quot;&gt;&lt;span style=&quot;color: #ff0000&quot;&gt;$file&lt;/span&gt; &lt;span style=&quot;color: #66cc66;&quot;&gt;=&lt;/span&gt; &lt;span style=&quot;color: #ff0000&quot;&gt;$folder&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color: #ff0000&quot;&gt;$hash&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;;&lt;/span&gt; &lt;span style=&quot;color: #808080; font-style: italic;&quot;&gt;// we define a unique filename for the cache system so that feeds have a unique cache file&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style=&quot;font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;&quot;&gt;&lt;div style=&quot;font-family: 'Courier New', Courier, monospace; font-weight: normal;&quot;&gt;&amp;nbsp;&lt;/div&gt;&lt;/li&gt;&lt;li style=&quot;font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;&quot;&gt;&lt;div style=&quot;font-family: 'Courier New', Courier, monospace; font-weight: normal;&quot;&gt;&lt;span style=&quot;color: #ff0000&quot;&gt;$xml&lt;/span&gt; &lt;span style=&quot;color: #66cc66;&quot;&gt;=&lt;/span&gt; &lt;span style=&quot;color: #ff0000;&quot;&gt;''&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;;&lt;/span&gt; &lt;span style=&quot;color: #808080; font-style: italic;&quot;&gt;// the futur RSS&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style=&quot;font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;&quot;&gt;&lt;div style=&quot;font-family: 'Courier New', Courier, monospace; font-weight: normal;&quot;&gt;&amp;nbsp;&lt;/div&gt;&lt;/li&gt;&lt;li style=&quot;font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;&quot;&gt;&lt;div style=&quot;font-family: 'Courier New', Courier, monospace; font-weight: normal;&quot;&gt;&lt;span style=&quot;color: #808080; font-style: italic;&quot;&gt;// first of, we check the date of the last modification of the cached file&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style=&quot;font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;&quot;&gt;&lt;div style=&quot;font-family: 'Courier New', Courier, monospace; font-weight: normal;&quot;&gt;&lt;span style=&quot;color: #b1b100;&quot;&gt;if&lt;/span&gt; &lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #000066;&quot;&gt;file_exists&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #ff0000&quot;&gt;$file&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt; &lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;amp;&amp;amp;&lt;/span&gt; &lt;span style=&quot;color: #000066;&quot;&gt;time&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt; &lt;span style=&quot;color: #66cc66;&quot;&gt;-&lt;/span&gt; &lt;span style=&quot;color: #000066;&quot;&gt;filemtime&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #ff0000&quot;&gt;$file&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt; &lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;lt;&lt;/span&gt; &lt;span style=&quot;color: #ff0000&quot;&gt;$timeout&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt; &lt;span style=&quot;color: #808080; font-style: italic;&quot;&gt;// if the elapsed time is smaller than the defined cache lifespan&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style=&quot;font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;&quot;&gt;&lt;div style=&quot;font-family: 'Courier New', Courier, monospace; font-weight: normal;&quot;&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#123;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style=&quot;font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;&quot;&gt;&lt;div style=&quot;font-family: 'Courier New', Courier, monospace; font-weight: normal;&quot;&gt;	&lt;span style=&quot;color: #808080; font-style: italic;&quot;&gt;// we read the cached file and put it into $xml&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style=&quot;font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;&quot;&gt;&lt;div style=&quot;font-family: 'Courier New', Courier, monospace; font-weight: normal;&quot;&gt;	&lt;span style=&quot;color: #b1b100;&quot;&gt;if&lt;/span&gt; &lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #ff0000&quot;&gt;$handle&lt;/span&gt; &lt;span style=&quot;color: #66cc66;&quot;&gt;=&lt;/span&gt; &lt;span style=&quot;color: #000066;&quot;&gt;fopen&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #ff0000&quot;&gt;$file&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;,&lt;/span&gt; &lt;span style=&quot;color: #ff0000;&quot;&gt;'r'&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style=&quot;font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;&quot;&gt;&lt;div style=&quot;font-family: 'Courier New', Courier, monospace; font-weight: normal;&quot;&gt;	&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#123;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style=&quot;font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;&quot;&gt;&lt;div style=&quot;font-family: 'Courier New', Courier, monospace; font-weight: normal;&quot;&gt;		&lt;span style=&quot;color: #808080; font-style: italic;&quot;&gt;//ok&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style=&quot;font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;&quot;&gt;&lt;div style=&quot;font-family: 'Courier New', Courier, monospace; font-weight: normal;&quot;&gt;		&lt;span style=&quot;color: #ff0000&quot;&gt;$xml&lt;/span&gt; &lt;span style=&quot;color: #66cc66;&quot;&gt;=&lt;/span&gt; &lt;span style=&quot;color: #000066;&quot;&gt;fread&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #ff0000&quot;&gt;$handle&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;,&lt;/span&gt; &lt;span style=&quot;color: #000066;&quot;&gt;filesize&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #ff0000&quot;&gt;$file&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style=&quot;font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;&quot;&gt;&lt;div style=&quot;font-family: 'Courier New', Courier, monospace; font-weight: normal;&quot;&gt;		&lt;span style=&quot;color: #000066;&quot;&gt;fclose&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #ff0000&quot;&gt;$handle&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style=&quot;font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;&quot;&gt;&lt;div style=&quot;font-family: 'Courier New', Courier, monospace; font-weight: normal;&quot;&gt;	&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#125;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style=&quot;font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;&quot;&gt;&lt;div style=&quot;font-family: 'Courier New', Courier, monospace; font-weight: normal;&quot;&gt;	&lt;span style=&quot;color: #b1b100;&quot;&gt;else&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style=&quot;font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;&quot;&gt;&lt;div style=&quot;font-family: 'Courier New', Courier, monospace; font-weight: normal;&quot;&gt;	&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#123;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style=&quot;font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;&quot;&gt;&lt;div style=&quot;font-family: 'Courier New', Courier, monospace; font-weight: normal;&quot;&gt;		&lt;span style=&quot;color: #808080; font-style: italic;&quot;&gt;// cannot open cache for reading&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style=&quot;font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;&quot;&gt;&lt;div style=&quot;font-family: 'Courier New', Courier, monospace; font-weight: normal;&quot;&gt;		&lt;span style=&quot;color: #000066;&quot;&gt;exit&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #ff0000;&quot;&gt;'cannot open cache for reading'&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style=&quot;font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;&quot;&gt;&lt;div style=&quot;font-family: 'Courier New', Courier, monospace; font-weight: normal;&quot;&gt;	&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#125;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style=&quot;font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;&quot;&gt;&lt;div style=&quot;font-family: 'Courier New', Courier, monospace; font-weight: normal;&quot;&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#125;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style=&quot;font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;&quot;&gt;&lt;div style=&quot;font-family: 'Courier New', Courier, monospace; font-weight: normal;&quot;&gt;&lt;span style=&quot;color: #b1b100;&quot;&gt;else&lt;/span&gt; &lt;span style=&quot;color: #808080; font-style: italic;&quot;&gt;// if the cache is timed out&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style=&quot;font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;&quot;&gt;&lt;div style=&quot;font-family: 'Courier New', Courier, monospace; font-weight: normal;&quot;&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#123;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style=&quot;font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;&quot;&gt;&lt;div style=&quot;font-family: 'Courier New', Courier, monospace; font-weight: normal;&quot;&gt;	&lt;span style=&quot;color: #808080; font-style: italic;&quot;&gt;// we open a distant connexion to download the file&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style=&quot;font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;&quot;&gt;&lt;div style=&quot;font-family: 'Courier New', Courier, monospace; font-weight: normal;&quot;&gt;	&lt;span style=&quot;color: #ff0000&quot;&gt;$session&lt;/span&gt; &lt;span style=&quot;color: #66cc66;&quot;&gt;=&lt;/span&gt; curl_init&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #ff0000&quot;&gt;$url&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style=&quot;font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;&quot;&gt;&lt;div style=&quot;font-family: 'Courier New', Courier, monospace; font-weight: normal;&quot;&gt;	curl_setopt&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #ff0000&quot;&gt;$session&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;,&lt;/span&gt; CURLOPT_HEADER&lt;span style=&quot;color: #66cc66;&quot;&gt;,&lt;/span&gt; &lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;false&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style=&quot;font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;&quot;&gt;&lt;div style=&quot;font-family: 'Courier New', Courier, monospace; font-weight: normal;&quot;&gt;	curl_setopt&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #ff0000&quot;&gt;$session&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;,&lt;/span&gt; CURLOPT_RETURNTRANSFER&lt;span style=&quot;color: #66cc66;&quot;&gt;,&lt;/span&gt; &lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;true&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style=&quot;font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;&quot;&gt;&lt;div style=&quot;font-family: 'Courier New', Courier, monospace; font-weight: normal;&quot;&gt;	&lt;span style=&quot;color: #ff0000&quot;&gt;$xml&lt;/span&gt; &lt;span style=&quot;color: #66cc66;&quot;&gt;=&lt;/span&gt; curl_exec&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #ff0000&quot;&gt;$session&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style=&quot;font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;&quot;&gt;&lt;div style=&quot;font-family: 'Courier New', Courier, monospace; font-weight: normal;&quot;&gt;	curl_close&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #ff0000&quot;&gt;$session&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style=&quot;font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;&quot;&gt;&lt;div style=&quot;font-family: 'Courier New', Courier, monospace; font-weight: normal;&quot;&gt;&amp;nbsp;&lt;/div&gt;&lt;/li&gt;&lt;li style=&quot;font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;&quot;&gt;&lt;div style=&quot;font-family: 'Courier New', Courier, monospace; font-weight: normal;&quot;&gt;	&lt;span style=&quot;color: #808080; font-style: italic;&quot;&gt;// once we have successfuly downloaded the RSS file, we update the cache&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style=&quot;font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;&quot;&gt;&lt;div style=&quot;font-family: 'Courier New', Courier, monospace; font-weight: normal;&quot;&gt;	&lt;span style=&quot;color: #b1b100;&quot;&gt;if&lt;/span&gt; &lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #ff0000&quot;&gt;$handle&lt;/span&gt; &lt;span style=&quot;color: #66cc66;&quot;&gt;=&lt;/span&gt; &lt;span style=&quot;color: #000066;&quot;&gt;fopen&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #ff0000&quot;&gt;$file&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;,&lt;/span&gt; &lt;span style=&quot;color: #ff0000;&quot;&gt;'w'&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style=&quot;font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;&quot;&gt;&lt;div style=&quot;font-family: 'Courier New', Courier, monospace; font-weight: normal;&quot;&gt;	&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#123;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style=&quot;font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;&quot;&gt;&lt;div style=&quot;font-family: 'Courier New', Courier, monospace; font-weight: normal;&quot;&gt;		&lt;span style=&quot;color: #808080; font-style: italic;&quot;&gt;//ok&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style=&quot;font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;&quot;&gt;&lt;div style=&quot;font-family: 'Courier New', Courier, monospace; font-weight: normal;&quot;&gt;		&lt;span style=&quot;color: #000066;&quot;&gt;fwrite&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #ff0000&quot;&gt;$handle&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;,&lt;/span&gt; &lt;span style=&quot;color: #ff0000&quot;&gt;$xml&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style=&quot;font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;&quot;&gt;&lt;div style=&quot;font-family: 'Courier New', Courier, monospace; font-weight: normal;&quot;&gt;		&lt;span style=&quot;color: #000066;&quot;&gt;fclose&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #ff0000&quot;&gt;$handle&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style=&quot;font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;&quot;&gt;&lt;div style=&quot;font-family: 'Courier New', Courier, monospace; font-weight: normal;&quot;&gt;	&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#125;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style=&quot;font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;&quot;&gt;&lt;div style=&quot;font-family: 'Courier New', Courier, monospace; font-weight: normal;&quot;&gt;	&lt;span style=&quot;color: #b1b100;&quot;&gt;else&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style=&quot;font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;&quot;&gt;&lt;div style=&quot;font-family: 'Courier New', Courier, monospace; font-weight: normal;&quot;&gt;	&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#123;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style=&quot;font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;&quot;&gt;&lt;div style=&quot;font-family: 'Courier New', Courier, monospace; font-weight: normal;&quot;&gt;		&lt;span style=&quot;color: #808080; font-style: italic;&quot;&gt;// cannot open cache for updating&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style=&quot;font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;&quot;&gt;&lt;div style=&quot;font-family: 'Courier New', Courier, monospace; font-weight: normal;&quot;&gt;		&lt;span style=&quot;color: #000066;&quot;&gt;exit&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #ff0000;&quot;&gt;'cannot open cache for updating'&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style=&quot;font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;&quot;&gt;&lt;div style=&quot;font-family: 'Courier New', Courier, monospace; font-weight: normal;&quot;&gt;	&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#125;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style=&quot;font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;&quot;&gt;&lt;div style=&quot;font-family: 'Courier New', Courier, monospace; font-weight: normal;&quot;&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#125;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style=&quot;font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;&quot;&gt;&lt;div style=&quot;font-family: 'Courier New', Courier, monospace; font-weight: normal;&quot;&gt;&amp;nbsp;&lt;/div&gt;&lt;/li&gt;&lt;li style=&quot;font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;&quot;&gt;&lt;div style=&quot;font-family: 'Courier New', Courier, monospace; font-weight: normal;&quot;&gt;&lt;span style=&quot;color: #808080; font-style: italic;&quot;&gt;// we'r done, let's display the XML file&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style=&quot;font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;&quot;&gt;&lt;div style=&quot;font-family: 'Courier New', Courier, monospace; font-weight: normal;&quot;&gt;&lt;span style=&quot;color: #000066;&quot;&gt;header&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #ff0000;&quot;&gt;'Content-Type: text/xml'&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style=&quot;font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;&quot;&gt;&lt;div style=&quot;font-family: 'Courier New', Courier, monospace; font-weight: normal;&quot;&gt;&lt;span style=&quot;color: #000066;&quot;&gt;echo&lt;/span&gt; &lt;span style=&quot;color: #ff0000&quot;&gt;$xml&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style=&quot;font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;&quot;&gt;&lt;div style=&quot;font-family: 'Courier New', Courier, monospace; font-weight: normal;&quot;&gt;&amp;nbsp;&lt;/div&gt;&lt;/li&gt;&lt;li style=&quot;font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;&quot;&gt;&lt;div style=&quot;font-family: 'Courier New', Courier, monospace; font-weight: normal;&quot;&gt;&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;?&amp;gt;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;/ol&gt;&lt;/pre&gt;


&lt;h3&gt;RSS parsing with jQuery&lt;/h3&gt;


&lt;p&gt;Now that we have a file proxy, we can start using client side scripting. I needed something to parse XML files easily. I went with the &lt;a href=&quot;http://jquery.com/&quot; hreflang=&quot;en&quot;&gt;jQuery&lt;/a&gt; library which also enabled me to parse the feeds asynchronously so that the HTML page doesn't have to wait the processing of all the feed before being displayed.&lt;/p&gt;

&lt;pre class=&quot;html&quot;&gt;&lt;ol&gt;&lt;li style=&quot;font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;&quot;&gt;&lt;div style=&quot;font-family: 'Courier New', Courier, monospace; font-weight: normal;&quot;&gt;&lt;span style=&quot;color: #009900;&quot;&gt;&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;&amp;lt;head&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: #009900;&quot;&gt;&lt;span style=&quot;color: #808080; font-style: italic;&quot;&gt;&amp;lt;!-- put the javascript code in the head --&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style=&quot;font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;&quot;&gt;&lt;div style=&quot;font-family: 'Courier New', Courier, monospace; font-weight: normal;&quot;&gt;&amp;nbsp;&lt;/div&gt;&lt;/li&gt;&lt;li style=&quot;font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;&quot;&gt;&lt;div style=&quot;font-family: 'Courier New', Courier, monospace; font-weight: normal;&quot;&gt;	&lt;span style=&quot;color: #009900;&quot;&gt;&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;&amp;lt;script&lt;/span&gt; &lt;span style=&quot;color: #000066;&quot;&gt;type&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color: #ff0000;&quot;&gt;&amp;quot;text/javascript&amp;quot;&lt;/span&gt; &lt;span style=&quot;color: #000066;&quot;&gt;src&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color: #ff0000;&quot;&gt;&amp;quot;jquery-1.4.2.min.js&amp;quot;&lt;/span&gt;&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: #009900;&quot;&gt;&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;&amp;lt;/script&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style=&quot;font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;&quot;&gt;&lt;div style=&quot;font-family: 'Courier New', Courier, monospace; font-weight: normal;&quot;&gt;	&lt;span style=&quot;color: #009900;&quot;&gt;&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;&amp;lt;script&lt;/span&gt; &lt;span style=&quot;color: #000066;&quot;&gt;type&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color: #ff0000;&quot;&gt;&amp;quot;text/javascript&amp;quot;&lt;/span&gt;&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style=&quot;font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;&quot;&gt;&lt;div style=&quot;font-family: 'Courier New', Courier, monospace; font-weight: normal;&quot;&gt;		//&lt;span style=&quot;color: #009900;&quot;&gt;&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;&amp;lt;&lt;/span&gt;!&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#91;&lt;/span&gt;CDATA&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#91;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style=&quot;font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;&quot;&gt;&lt;div style=&quot;font-family: 'Courier New', Courier, monospace; font-weight: normal;&quot;&gt;		&lt;span style=&quot;color: #66cc66;&quot;&gt;//&lt;/span&gt; our main parsing function&lt;/div&gt;&lt;/li&gt;&lt;li style=&quot;font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;&quot;&gt;&lt;div style=&quot;font-family: 'Courier New', Courier, monospace; font-weight: normal;&quot;&gt;		&lt;span style=&quot;color: #66cc66;&quot;&gt;//&lt;/span&gt; ContentDiv: the &lt;span style=&quot;color: #000066;&quot;&gt;id&lt;/span&gt; of the div where the feed should be displayed&lt;/div&gt;&lt;/li&gt;&lt;li style=&quot;font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;&quot;&gt;&lt;div style=&quot;font-family: 'Courier New', Courier, monospace; font-weight: normal;&quot;&gt;		&lt;span style=&quot;color: #66cc66;&quot;&gt;//&lt;/span&gt; FeedURL: the encoded URL of the news feed&lt;/div&gt;&lt;/li&gt;&lt;li style=&quot;font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;&quot;&gt;&lt;div style=&quot;font-family: 'Courier New', Courier, monospace; font-weight: normal;&quot;&gt;		function get_rss_feed&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt;ContentDiv, FeedURL&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt; &lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#123;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style=&quot;font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;&quot;&gt;&lt;div style=&quot;font-family: 'Courier New', Courier, monospace; font-weight: normal;&quot;&gt;			&lt;span style=&quot;color: #66cc66;&quot;&gt;//&lt;/span&gt; settings&lt;/div&gt;&lt;/li&gt;&lt;li style=&quot;font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;&quot;&gt;&lt;div style=&quot;font-family: 'Courier New', Courier, monospace; font-weight: normal;&quot;&gt;			var limit &lt;span style=&quot;color: #66cc66;&quot;&gt;=&lt;/span&gt; &lt;span style=&quot;color: #cc66cc;&quot;&gt;10&lt;/span&gt;; &lt;span style=&quot;color: #66cc66;&quot;&gt;//&lt;/span&gt; number of element to display &lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt;some feeds are already truncated, so do not be suprised if some of them are shorter than your limit&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style=&quot;font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;&quot;&gt;&lt;div style=&quot;font-family: 'Courier New', Courier, monospace; font-weight: normal;&quot;&gt;&amp;nbsp;&lt;/div&gt;&lt;/li&gt;&lt;li style=&quot;font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;&quot;&gt;&lt;div style=&quot;font-family: 'Courier New', Courier, monospace; font-weight: normal;&quot;&gt;			var regSpace &lt;span style=&quot;color: #66cc66;&quot;&gt;=&lt;/span&gt; new RegExp&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #ff0000;&quot;&gt;&amp;quot;[ ]&amp;quot;&lt;/span&gt;, &lt;span style=&quot;color: #ff0000;&quot;&gt;&amp;quot;g&amp;quot;&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt;; &lt;span style=&quot;color: #66cc66;&quot;&gt;//&lt;/span&gt; a regexp to split spaces &lt;span style=&quot;color: #000066;&quot;&gt;for&lt;/span&gt; RSS date parsing&lt;/div&gt;&lt;/li&gt;&lt;li style=&quot;font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;&quot;&gt;&lt;div style=&quot;font-family: 'Courier New', Courier, monospace; font-weight: normal;&quot;&gt;			var regA10 &lt;span style=&quot;color: #66cc66;&quot;&gt;=&lt;/span&gt; new RegExp&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #ff0000;&quot;&gt;&amp;quot;[T-]&amp;quot;&lt;/span&gt;, &lt;span style=&quot;color: #ff0000;&quot;&gt;&amp;quot;g&amp;quot;&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt;; &lt;span style=&quot;color: #66cc66;&quot;&gt;//&lt;/span&gt; a regexp to split &lt;span style=&quot;color: #ff0000;&quot;&gt;&amp;quot;T&amp;quot;&lt;/span&gt; and &lt;span style=&quot;color: #ff0000;&quot;&gt;&amp;quot;-&amp;quot;&lt;/span&gt; &lt;span style=&quot;color: #000066;&quot;&gt;for&lt;/span&gt; Atom date parsing&lt;/div&gt;&lt;/li&gt;&lt;li style=&quot;font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;&quot;&gt;&lt;div style=&quot;font-family: 'Courier New', Courier, monospace; font-weight: normal;&quot;&gt;			var tabMonth &lt;span style=&quot;color: #66cc66;&quot;&gt;=&lt;/span&gt; new Array&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #ff0000;&quot;&gt;&amp;quot;Jan&amp;quot;&lt;/span&gt;, &lt;span style=&quot;color: #ff0000;&quot;&gt;&amp;quot;Feb&amp;quot;&lt;/span&gt;, &lt;span style=&quot;color: #ff0000;&quot;&gt;&amp;quot;Mar&amp;quot;&lt;/span&gt;, &lt;span style=&quot;color: #ff0000;&quot;&gt;&amp;quot;Apr&amp;quot;&lt;/span&gt;, &lt;span style=&quot;color: #ff0000;&quot;&gt;&amp;quot;May&amp;quot;&lt;/span&gt;, &lt;span style=&quot;color: #ff0000;&quot;&gt;&amp;quot;Jun&amp;quot;&lt;/span&gt;, &lt;span style=&quot;color: #ff0000;&quot;&gt;&amp;quot;Jul&amp;quot;&lt;/span&gt;, &lt;span style=&quot;color: #ff0000;&quot;&gt;&amp;quot;Aug&amp;quot;&lt;/span&gt;, &lt;span style=&quot;color: #ff0000;&quot;&gt;&amp;quot;Sep&amp;quot;&lt;/span&gt;, &lt;span style=&quot;color: #ff0000;&quot;&gt;&amp;quot;Oct&amp;quot;&lt;/span&gt;, &lt;span style=&quot;color: #ff0000;&quot;&gt;&amp;quot;Nov&amp;quot;&lt;/span&gt;, &lt;span style=&quot;color: #ff0000;&quot;&gt;&amp;quot;Dec&amp;quot;&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt;;&lt;/div&gt;&lt;/li&gt;&lt;li style=&quot;font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;&quot;&gt;&lt;div style=&quot;font-family: 'Courier New', Courier, monospace; font-weight: normal;&quot;&gt;&amp;nbsp;&lt;/div&gt;&lt;/li&gt;&lt;li style=&quot;font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;&quot;&gt;&lt;div style=&quot;font-family: 'Courier New', Courier, monospace; font-weight: normal;&quot;&gt;			&lt;span style=&quot;color: #66cc66;&quot;&gt;//&lt;/span&gt; get the current date&lt;/div&gt;&lt;/li&gt;&lt;li style=&quot;font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;&quot;&gt;&lt;div style=&quot;font-family: 'Courier New', Courier, monospace; font-weight: normal;&quot;&gt;			var date &lt;span style=&quot;color: #66cc66;&quot;&gt;=&lt;/span&gt; new Date&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt;;&lt;/div&gt;&lt;/li&gt;&lt;li style=&quot;font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;&quot;&gt;&lt;div style=&quot;font-family: 'Courier New', Courier, monospace; font-weight: normal;&quot;&gt;			var month &lt;span style=&quot;color: #66cc66;&quot;&gt;=&lt;/span&gt; tabMonth&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#91;&lt;/span&gt;date.getMonth&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#93;&lt;/span&gt;;&lt;/div&gt;&lt;/li&gt;&lt;li style=&quot;font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;&quot;&gt;&lt;div style=&quot;font-family: 'Courier New', Courier, monospace; font-weight: normal;&quot;&gt;			var day &lt;span style=&quot;color: #66cc66;&quot;&gt;=&lt;/span&gt; date.getDate&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt;;&lt;/div&gt;&lt;/li&gt;&lt;li style=&quot;font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;&quot;&gt;&lt;div style=&quot;font-family: 'Courier New', Courier, monospace; font-weight: normal;&quot;&gt;&amp;nbsp;&lt;/div&gt;&lt;/li&gt;&lt;li style=&quot;font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;&quot;&gt;&lt;div style=&quot;font-family: 'Courier New', Courier, monospace; font-weight: normal;&quot;&gt;			&lt;span style=&quot;color: #66cc66;&quot;&gt;//&lt;/span&gt; use the JQuery get function to grab the URL via our proxy, put the results into an argument &lt;span style=&quot;color: #000066;&quot;&gt;for&lt;/span&gt; parsing when the feed retrieval is complete&lt;/div&gt;&lt;/li&gt;&lt;li style=&quot;font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;&quot;&gt;&lt;div style=&quot;font-family: 'Courier New', Courier, monospace; font-weight: normal;&quot;&gt;			$.get&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #ff0000;&quot;&gt;'proxycache.php?url='&lt;/span&gt; + FeedURL, function&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt;d&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt; &lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#123;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style=&quot;font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;&quot;&gt;&lt;div style=&quot;font-family: 'Courier New', Courier, monospace; font-weight: normal;&quot;&gt;&amp;nbsp;&lt;/div&gt;&lt;/li&gt;&lt;li style=&quot;font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;&quot;&gt;&lt;div style=&quot;font-family: 'Courier New', Courier, monospace; font-weight: normal;&quot;&gt;				&lt;span style=&quot;color: #66cc66;&quot;&gt;//&lt;/span&gt; grab the post &lt;span style=&quot;color: #000066;&quot;&gt;title&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style=&quot;font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;&quot;&gt;&lt;div style=&quot;font-family: 'Courier New', Courier, monospace; font-weight: normal;&quot;&gt;				var feedTitle &lt;span style=&quot;color: #66cc66;&quot;&gt;=&lt;/span&gt; $&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt;d&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt;.find&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #ff0000;&quot;&gt;'title:first'&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt;.&lt;span style=&quot;color: #000066;&quot;&gt;text&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt;;&lt;/div&gt;&lt;/li&gt;&lt;li style=&quot;font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;&quot;&gt;&lt;div style=&quot;font-family: 'Courier New', Courier, monospace; font-weight: normal;&quot;&gt;				&lt;span style=&quot;color: #66cc66;&quot;&gt;//&lt;/span&gt; grab the post URL&lt;/div&gt;&lt;/li&gt;&lt;li style=&quot;font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;&quot;&gt;&lt;div style=&quot;font-family: 'Courier New', Courier, monospace; font-weight: normal;&quot;&gt;				var feedLink &lt;span style=&quot;color: #66cc66;&quot;&gt;=&lt;/span&gt; $&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt;d&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt;.find&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #ff0000;&quot;&gt;'link:first'&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt;.&lt;span style=&quot;color: #000066;&quot;&gt;text&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt;;&lt;/div&gt;&lt;/li&gt;&lt;li style=&quot;font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;&quot;&gt;&lt;div style=&quot;font-family: 'Courier New', Courier, monospace; font-weight: normal;&quot;&gt;				&lt;span style=&quot;color: #66cc66;&quot;&gt;//&lt;/span&gt; create our output HTML &lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt;you may edit it to fit your own design&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style=&quot;font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;&quot;&gt;&lt;div style=&quot;font-family: 'Courier New', Courier, monospace; font-weight: normal;&quot;&gt;				var html &lt;span style=&quot;color: #66cc66;&quot;&gt;=&lt;/span&gt; &lt;span style=&quot;color: #ff0000;&quot;&gt;&amp;quot;&amp;lt;a href=&amp;quot;&lt;/span&gt; + feedLink + &lt;span style=&quot;color: #ff0000;&quot;&gt;&amp;quot;&amp;gt;&lt;/span&gt;&lt;span style=&quot;color: #009900;&quot;&gt;&amp;lt;span class=\&amp;quot;&lt;/span&gt;&lt;span style=&quot;color: #000066;&quot;&gt;title&lt;/span&gt;\&lt;span style=&quot;color: #ff0000;&quot;&gt;&amp;quot;&amp;gt;&lt;/span&gt;&amp;quot; + feedTitle + &amp;quot;&lt;span style=&quot;color: #009900;&quot;&gt;&amp;lt;/span&amp;gt;&lt;/span&gt;&lt;span style=&quot;color: #009900;&quot;&gt;&amp;lt;/a&amp;gt;&lt;/span&gt;&amp;quot;;&lt;/div&gt;&lt;/li&gt;&lt;li style=&quot;font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;&quot;&gt;&lt;div style=&quot;font-family: 'Courier New', Courier, monospace; font-weight: normal;&quot;&gt;				// limiting iteration (used to limit the number of item displayed)&lt;/div&gt;&lt;/li&gt;&lt;li style=&quot;font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;&quot;&gt;&lt;div style=&quot;font-family: 'Courier New', Courier, monospace; font-weight: normal;&quot;&gt;				var loop = 1;&lt;/div&gt;&lt;/li&gt;&lt;li style=&quot;font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;&quot;&gt;&lt;div style=&quot;font-family: 'Courier New', Courier, monospace; font-weight: normal;&quot;&gt;&amp;nbsp;&lt;/div&gt;&lt;/li&gt;&lt;li style=&quot;font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;&quot;&gt;&lt;div style=&quot;font-family: 'Courier New', Courier, monospace; font-weight: normal;&quot;&gt;				// find each &lt;span style=&quot;color: #009900;&quot;&gt;&amp;lt;item&amp;gt;&lt;/span&gt; in the file and parse it&lt;/div&gt;&lt;/li&gt;&lt;li style=&quot;font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;&quot;&gt;&lt;div style=&quot;font-family: 'Courier New', Courier, monospace; font-weight: normal;&quot;&gt;				var items = $(d).find('item'); // rss&lt;/div&gt;&lt;/li&gt;&lt;li style=&quot;font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;&quot;&gt;&lt;div style=&quot;font-family: 'Courier New', Courier, monospace; font-weight: normal;&quot;&gt;				if (items.length == 0) // if an &lt;span style=&quot;color: #009900;&quot;&gt;&amp;lt;item&amp;gt;&lt;/span&gt; isn't found, we may be facing an Atom file instead of a RSS one&lt;/div&gt;&lt;/li&gt;&lt;li style=&quot;font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;&quot;&gt;&lt;div style=&quot;font-family: 'Courier New', Courier, monospace; font-weight: normal;&quot;&gt;					items = $(d).find('entry'); // so we look for an &lt;span style=&quot;color: #009900;&quot;&gt;&amp;lt;entry&amp;gt;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style=&quot;font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;&quot;&gt;&lt;div style=&quot;font-family: 'Courier New', Courier, monospace; font-weight: normal;&quot;&gt;&amp;nbsp;&lt;/div&gt;&lt;/li&gt;&lt;li style=&quot;font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;&quot;&gt;&lt;div style=&quot;font-family: 'Courier New', Courier, monospace; font-weight: normal;&quot;&gt;				$(items).each(function() { // items iteration&lt;/div&gt;&lt;/li&gt;&lt;li style=&quot;font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;&quot;&gt;&lt;div style=&quot;font-family: 'Courier New', Courier, monospace; font-weight: normal;&quot;&gt;					if (loop == limit) // if we reach our number of item to display, we end the iteration&lt;/div&gt;&lt;/li&gt;&lt;li style=&quot;font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;&quot;&gt;&lt;div style=&quot;font-family: 'Courier New', Courier, monospace; font-weight: normal;&quot;&gt;						return false;&lt;/div&gt;&lt;/li&gt;&lt;li style=&quot;font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;&quot;&gt;&lt;div style=&quot;font-family: 'Courier New', Courier, monospace; font-weight: normal;&quot;&gt;&amp;nbsp;&lt;/div&gt;&lt;/li&gt;&lt;li style=&quot;font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;&quot;&gt;&lt;div style=&quot;font-family: 'Courier New', Courier, monospace; font-weight: normal;&quot;&gt;					// grab the current item&lt;/div&gt;&lt;/li&gt;&lt;li style=&quot;font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;&quot;&gt;&lt;div style=&quot;font-family: 'Courier New', Courier, monospace; font-weight: normal;&quot;&gt;					var $item = $(this);&lt;/div&gt;&lt;/li&gt;&lt;li style=&quot;font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;&quot;&gt;&lt;div style=&quot;font-family: 'Courier New', Courier, monospace; font-weight: normal;&quot;&gt;					// grab the post title&lt;/div&gt;&lt;/li&gt;&lt;li style=&quot;font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;&quot;&gt;&lt;div style=&quot;font-family: 'Courier New', Courier, monospace; font-weight: normal;&quot;&gt;					var title = $item.find('title').text();&lt;/div&gt;&lt;/li&gt;&lt;li style=&quot;font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;&quot;&gt;&lt;div style=&quot;font-family: 'Courier New', Courier, monospace; font-weight: normal;&quot;&gt;					// grab the post's URL&lt;/div&gt;&lt;/li&gt;&lt;li style=&quot;font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;&quot;&gt;&lt;div style=&quot;font-family: 'Courier New', Courier, monospace; font-weight: normal;&quot;&gt;					var link = $item.find('link').text();&lt;/div&gt;&lt;/li&gt;&lt;li style=&quot;font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;&quot;&gt;&lt;div style=&quot;font-family: 'Courier New', Courier, monospace; font-weight: normal;&quot;&gt;					// do not forget the pubdate&lt;/div&gt;&lt;/li&gt;&lt;li style=&quot;font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;&quot;&gt;&lt;div style=&quot;font-family: 'Courier New', Courier, monospace; font-weight: normal;&quot;&gt;					var pubDate = $item.find('pubDate');&lt;/div&gt;&lt;/li&gt;&lt;li style=&quot;font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;&quot;&gt;&lt;div style=&quot;font-family: 'Courier New', Courier, monospace; font-weight: normal;&quot;&gt;					var fullDate = '';&lt;/div&gt;&lt;/li&gt;&lt;li style=&quot;font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;&quot;&gt;&lt;div style=&quot;font-family: 'Courier New', Courier, monospace; font-weight: normal;&quot;&gt;&amp;nbsp;&lt;/div&gt;&lt;/li&gt;&lt;li style=&quot;font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;&quot;&gt;&lt;div style=&quot;font-family: 'Courier New', Courier, monospace; font-weight: normal;&quot;&gt;					if (pubDate.length == 0) { // no pubdate? looks like we hitted an Atom entry&lt;/div&gt;&lt;/li&gt;&lt;li style=&quot;font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;&quot;&gt;&lt;div style=&quot;font-family: 'Courier New', Courier, monospace; font-weight: normal;&quot;&gt;						pubDate = $item.find('a10\\:updated');&lt;/div&gt;&lt;/li&gt;&lt;li style=&quot;font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;&quot;&gt;&lt;div style=&quot;font-family: 'Courier New', Courier, monospace; font-weight: normal;&quot;&gt;						if (pubDate.length == 0) // there's different Atom syntax, if no &lt;span style=&quot;color: #009900;&quot;&gt;&amp;lt;a10:updated&amp;gt;&lt;/span&gt; is found, we look for &lt;span style=&quot;color: #009900;&quot;&gt;&amp;lt;updated&amp;gt;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style=&quot;font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;&quot;&gt;&lt;div style=&quot;font-family: 'Courier New', Courier, monospace; font-weight: normal;&quot;&gt;							pubDate = $item.find('updated');&lt;/div&gt;&lt;/li&gt;&lt;li style=&quot;font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;&quot;&gt;&lt;div style=&quot;font-family: 'Courier New', Courier, monospace; font-weight: normal;&quot;&gt;						// parsing the date, grabbing the day and the month&lt;/div&gt;&lt;/li&gt;&lt;li style=&quot;font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;&quot;&gt;&lt;div style=&quot;font-family: 'Courier New', Courier, monospace; font-weight: normal;&quot;&gt;						pubDate = pubDate.text().split(regA10);&lt;/div&gt;&lt;/li&gt;&lt;li style=&quot;font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;&quot;&gt;&lt;div style=&quot;font-family: 'Courier New', Courier, monospace; font-weight: normal;&quot;&gt;						pubDate[1] = tabMonth[pubDate[1] - 1];&lt;/div&gt;&lt;/li&gt;&lt;li style=&quot;font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;&quot;&gt;&lt;div style=&quot;font-family: 'Courier New', Courier, monospace; font-weight: normal;&quot;&gt;						fullDate = pubDate[1] + ' ' + pubDate[2];&lt;/div&gt;&lt;/li&gt;&lt;li style=&quot;font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;&quot;&gt;&lt;div style=&quot;font-family: 'Courier New', Courier, monospace; font-weight: normal;&quot;&gt;					}&lt;/div&gt;&lt;/li&gt;&lt;li style=&quot;font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;&quot;&gt;&lt;div style=&quot;font-family: 'Courier New', Courier, monospace; font-weight: normal;&quot;&gt;					else { // RSS date format&lt;/div&gt;&lt;/li&gt;&lt;li style=&quot;font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;&quot;&gt;&lt;div style=&quot;font-family: 'Courier New', Courier, monospace; font-weight: normal;&quot;&gt;						pubDate = pubDate.text().split(regSpace);&lt;/div&gt;&lt;/li&gt;&lt;li style=&quot;font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;&quot;&gt;&lt;div style=&quot;font-family: 'Courier New', Courier, monospace; font-weight: normal;&quot;&gt;						fullDate = pubDate[2] + ' ' + pubDate[1]; // grab day and month&lt;/div&gt;&lt;/li&gt;&lt;li style=&quot;font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;&quot;&gt;&lt;div style=&quot;font-family: 'Courier New', Courier, monospace; font-weight: normal;&quot;&gt;					}&lt;/div&gt;&lt;/li&gt;&lt;li style=&quot;font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;&quot;&gt;&lt;div style=&quot;font-family: 'Courier New', Courier, monospace; font-weight: normal;&quot;&gt;					// if the item has been published today, make the date stronger&lt;/div&gt;&lt;/li&gt;&lt;li style=&quot;font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;&quot;&gt;&lt;div style=&quot;font-family: 'Courier New', Courier, monospace; font-weight: normal;&quot;&gt;					if (pubDate[2] == month &lt;span style=&quot;color: #ddbb00;&quot;&gt;&amp;amp;&amp;amp; pubDate[1] == day) {&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style=&quot;font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;&quot;&gt;&lt;div style=&quot;font-family: 'Courier New', Courier, monospace; font-weight: normal;&quot;&gt;&lt;span style=&quot;color: #ddbb00;&quot;&gt;						fullDate = &amp;quot;&amp;lt;b&amp;gt;&amp;quot; + fullDate + &amp;quot;&amp;lt;\/b&amp;gt;&amp;quot;;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style=&quot;font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;&quot;&gt;&lt;div style=&quot;font-family: 'Courier New', Courier, monospace; font-weight: normal;&quot;&gt;					}&lt;/div&gt;&lt;/li&gt;&lt;li style=&quot;font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;&quot;&gt;&lt;div style=&quot;font-family: 'Courier New', Courier, monospace; font-weight: normal;&quot;&gt;					// build our final output&lt;/div&gt;&lt;/li&gt;&lt;li style=&quot;font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;&quot;&gt;&lt;div style=&quot;font-family: 'Courier New', Courier, monospace; font-weight: normal;&quot;&gt;					html += &amp;quot;&lt;span style=&quot;color: #009900;&quot;&gt;&amp;lt;a href=\&amp;quot;&lt;/span&gt;&lt;span style=&quot;color: #ff0000;&quot;&gt;&amp;quot; + link + &amp;quot;&lt;/span&gt;\&lt;span style=&quot;color: #ff0000;&quot;&gt;&amp;quot; target=\&amp;quot;&lt;/span&gt;_blank\&lt;span style=&quot;color: #ff0000;&quot;&gt;&amp;quot;&amp;gt;&lt;/span&gt;&amp;quot; + fullDate + &amp;quot; - &amp;quot; + title + &amp;quot;&lt;span style=&quot;color: #009900;&quot;&gt;&amp;lt;\/a&amp;gt;&lt;/span&gt;&lt;span style=&quot;color: #009900;&quot;&gt;&amp;lt;br\/&amp;gt;&lt;/span&gt;&amp;quot;;&lt;/div&gt;&lt;/li&gt;&lt;li style=&quot;font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;&quot;&gt;&lt;div style=&quot;font-family: 'Courier New', Courier, monospace; font-weight: normal;&quot;&gt;&amp;nbsp;&lt;/div&gt;&lt;/li&gt;&lt;li style=&quot;font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;&quot;&gt;&lt;div style=&quot;font-family: 'Courier New', Courier, monospace; font-weight: normal;&quot;&gt;					loop++;&lt;/div&gt;&lt;/li&gt;&lt;li style=&quot;font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;&quot;&gt;&lt;div style=&quot;font-family: 'Courier New', Courier, monospace; font-weight: normal;&quot;&gt;				});&lt;/div&gt;&lt;/li&gt;&lt;li style=&quot;font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;&quot;&gt;&lt;div style=&quot;font-family: 'Courier New', Courier, monospace; font-weight: normal;&quot;&gt;&amp;nbsp;&lt;/div&gt;&lt;/li&gt;&lt;li style=&quot;font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;&quot;&gt;&lt;div style=&quot;font-family: 'Courier New', Courier, monospace; font-weight: normal;&quot;&gt;				// clear the destination div&lt;/div&gt;&lt;/li&gt;&lt;li style=&quot;font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;&quot;&gt;&lt;div style=&quot;font-family: 'Courier New', Courier, monospace; font-weight: normal;&quot;&gt;				$(ContentDiv).empty();&lt;/div&gt;&lt;/li&gt;&lt;li style=&quot;font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;&quot;&gt;&lt;div style=&quot;font-family: 'Courier New', Courier, monospace; font-weight: normal;&quot;&gt;				// populate the div&lt;/div&gt;&lt;/li&gt;&lt;li style=&quot;font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;&quot;&gt;&lt;div style=&quot;font-family: 'Courier New', Courier, monospace; font-weight: normal;&quot;&gt;				$(ContentDiv).append($(html));&lt;/div&gt;&lt;/li&gt;&lt;li style=&quot;font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;&quot;&gt;&lt;div style=&quot;font-family: 'Courier New', Courier, monospace; font-weight: normal;&quot;&gt;			});&lt;/div&gt;&lt;/li&gt;&lt;li style=&quot;font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;&quot;&gt;&lt;div style=&quot;font-family: 'Courier New', Courier, monospace; font-weight: normal;&quot;&gt;		};&lt;/div&gt;&lt;/li&gt;&lt;li style=&quot;font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;&quot;&gt;&lt;div style=&quot;font-family: 'Courier New', Courier, monospace; font-weight: normal;&quot;&gt;&amp;nbsp;&lt;/div&gt;&lt;/li&gt;&lt;li style=&quot;font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;&quot;&gt;&lt;div style=&quot;font-family: 'Courier New', Courier, monospace; font-weight: normal;&quot;&gt;		// general function to display all the feeds&lt;/div&gt;&lt;/li&gt;&lt;li style=&quot;font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;&quot;&gt;&lt;div style=&quot;font-family: 'Courier New', Courier, monospace; font-weight: normal;&quot;&gt;		function get_all_feeds() {&lt;/div&gt;&lt;/li&gt;&lt;li style=&quot;font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;&quot;&gt;&lt;div style=&quot;font-family: 'Courier New', Courier, monospace; font-weight: normal;&quot;&gt;			get_rss_feed('#feed1', 'http%3A%2F%2Fexample.com%2Frss.xml');&lt;/div&gt;&lt;/li&gt;&lt;li style=&quot;font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;&quot;&gt;&lt;div style=&quot;font-family: 'Courier New', Courier, monospace; font-weight: normal;&quot;&gt;			get_rss_feed('#feed2', 'http%3A%2F%2Fexample2.com%2Frss.xmll');&lt;/div&gt;&lt;/li&gt;&lt;li style=&quot;font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;&quot;&gt;&lt;div style=&quot;font-family: 'Courier New', Courier, monospace; font-weight: normal;&quot;&gt;			// and so on if you'd like more feeds (just add a new div)&lt;/div&gt;&lt;/li&gt;&lt;li style=&quot;font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;&quot;&gt;&lt;div style=&quot;font-family: 'Courier New', Courier, monospace; font-weight: normal;&quot;&gt;		};&lt;/div&gt;&lt;/li&gt;&lt;li style=&quot;font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;&quot;&gt;&lt;div style=&quot;font-family: 'Courier New', Courier, monospace; font-weight: normal;&quot;&gt;		//]]&amp;gt;&lt;/div&gt;&lt;/li&gt;&lt;li style=&quot;font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;&quot;&gt;&lt;div style=&quot;font-family: 'Courier New', Courier, monospace; font-weight: normal;&quot;&gt;	&lt;span style=&quot;color: #009900;&quot;&gt;&amp;lt;/script&amp;gt;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style=&quot;font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;&quot;&gt;&lt;div style=&quot;font-family: 'Courier New', Courier, monospace; font-weight: normal;&quot;&gt;&lt;span style=&quot;color: #009900;&quot;&gt;&amp;lt;/head&amp;gt;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style=&quot;font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;&quot;&gt;&lt;div style=&quot;font-family: 'Courier New', Courier, monospace; font-weight: normal;&quot;&gt;&amp;nbsp;&lt;/div&gt;&lt;/li&gt;&lt;li style=&quot;font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;&quot;&gt;&lt;div style=&quot;font-family: 'Courier New', Courier, monospace; font-weight: normal;&quot;&gt;&lt;span style=&quot;color: #009900;&quot;&gt;&amp;lt;body onload=&amp;quot;&lt;/span&gt;get_all_feeds&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt;;&lt;span style=&quot;color: #ff0000;&quot;&gt;&amp;quot;&amp;gt;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style=&quot;font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;&quot;&gt;&lt;div style=&quot;font-family: 'Courier New', Courier, monospace; font-weight: normal;&quot;&gt;	&lt;span style=&quot;color: #009900;&quot;&gt;&amp;lt;div id=&amp;quot;&lt;/span&gt;feed1&lt;span style=&quot;color: #ff0000;&quot;&gt;&amp;quot;&amp;gt;&lt;/span&gt;Loading...&lt;span style=&quot;color: #009900;&quot;&gt;&amp;lt;/div&amp;gt;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style=&quot;font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;&quot;&gt;&lt;div style=&quot;font-family: 'Courier New', Courier, monospace; font-weight: normal;&quot;&gt;	&lt;span style=&quot;color: #009900;&quot;&gt;&amp;lt;div id=&amp;quot;&lt;/span&gt;feed2&lt;span style=&quot;color: #ff0000;&quot;&gt;&amp;quot;&amp;gt;&lt;/span&gt;Loading...&lt;span style=&quot;color: #009900;&quot;&gt;&amp;lt;/div&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;/ol&gt;&lt;/pre&gt;


&lt;p&gt;We're done!
This RSS parser may not be perfect but it perfectly fits my needs. Consider my code to belong to the public domain, so feel free it use, redistrube etc. Please tell me if you're using it.&lt;/p&gt;</description>
    
    
    
          <comments>http://www.handcrafted-games.com/index.php?post/2010/05/05/Writing-a-simple-javascript-RSS-parser#comment-form</comments>
      <wfw:comment>http://www.handcrafted-games.com/index.php?post/2010/05/05/Writing-a-simple-javascript-RSS-parser#comment-form</wfw:comment>
      <wfw:commentRss>http://www.handcrafted-games.com/index.php?feed/atom/comments/7</wfw:commentRss>
      </item>
    
  <item>
    <title>Introducing “The Daily XNA”</title>
    <link>http://www.handcrafted-games.com/index.php?post/2010/04/28/Introducing-%E2%80%9CThe-Daily-XNA%E2%80%9D</link>
    <guid isPermaLink="false">urn:md5:9a8efb5e311f5938367643684a524dfd</guid>
    <pubDate>Wed, 28 Apr 2010 15:43:00 +0100</pubDate>
    <dc:creator>Mister Helmut</dc:creator>
        <category>Blogposts</category>
        <category>daily xna</category><category>windows phone 7</category><category>xbox live indie games</category><category>xna</category>    
    <description>    &lt;p&gt;I would like to introduce my personal portal to you: &lt;a href=&quot;http://www.daily-xna.com/&quot; hreflang=&quot;en&quot;&gt;The Daily XNA&lt;/a&gt;.&lt;/p&gt;


&lt;p&gt;The story behind it: I'm a RSS/Atom feeds fan and my usage of the internet, my various interests and other things imply me to have my web browser crawling under bookmark entries, including cascading RSS. I'm also a mobile user and use about 2 to 4 different devices to access the internet during a single day... So I had to organize my bookmark.&lt;/p&gt;


&lt;p&gt;The Daily XNA is my solution to XNA links organization. I tried to make it an “one-stop” page to have a quick look at the most relevant news feeds. Why not making myself an iGoogle page? Because I wanted something lightweight, quicker to access (remenber I often switch between devices) and more convenient to me. Since it is a public website, I thougth it may profit to people sharing an interest in XNA related news. Feel free to suggest me any change, feeds etc. and if you find it useful.&lt;/p&gt;</description>
    
    
    
          <comments>http://www.handcrafted-games.com/index.php?post/2010/04/28/Introducing-%E2%80%9CThe-Daily-XNA%E2%80%9D#comment-form</comments>
      <wfw:comment>http://www.handcrafted-games.com/index.php?post/2010/04/28/Introducing-%E2%80%9CThe-Daily-XNA%E2%80%9D#comment-form</wfw:comment>
      <wfw:commentRss>http://www.handcrafted-games.com/index.php?feed/atom/comments/6</wfw:commentRss>
      </item>
    
  <item>
    <title>Amateur games: from the intention to the actual making of a game</title>
    <link>http://www.handcrafted-games.com/index.php?post/2010/04/28/Indie-games%3A-from-the-intention-to-the-actual-making-of-a-game</link>
    <guid isPermaLink="false">urn:md5:66273f271cf3b89c7cdd3269cb0d5002</guid>
    <pubDate>Wed, 28 Apr 2010 14:32:00 +0100</pubDate>
    <dc:creator>Mister Helmut</dc:creator>
        <category>Articles &amp; Tutorials</category>
        <category>indie games</category>    
    <description>&lt;p&gt;As an hobbyist game developer, making a video game isn’t just to wake up during a vacation with “well, let’s make a game out of my free time” as a thought. Most amateur development projects are born from boredom, thinking that there’s no problem at releasing a finished project. Some managed
to actually “ship” their game (lucky ones), but that represent maybe 1% of all the amateur projects. Many factors affect such development: starting new projects while the ongoing one isn’t finished, team issues, time, adding new features…&lt;/p&gt;


&lt;p&gt;Here are my personal point of view on the states of mind you should avoid during an amateur project.
Click the “read more” link for further reading.&lt;/p&gt;    &lt;h3&gt;The will is the key&lt;/h3&gt;


&lt;p&gt;There’s no secret in making a complete game, you’ll have to be motivated, for an extended time. Motivation isn’t an issue during the beginning of a project: it’s still fresh and motivating until you reach a satisfying milestone which is usually dependent on your coding skills (some are satisfied with a sprite moving around, others with an almost working game editor…). From then on, things may get complicated. You suddenly lower the priority of your project (since you’ve reached a satisfactory step) and notice that you have less free time (vacations over?) or that you’d like to do something else alongside your project. Stay focused, this is a turning point and there will be more of them. The key is to stay motivated, manage your time, impose yourself regular coding sessions during a week and most importantly: don’t start another project!  One of  the problems of geeky programmers, is to have too much motivation for too much project ideas at the same time. Stick to the one you’ve just started and remind yourself why you started the project every time your motivation drops a bit.&lt;/p&gt;


&lt;h3&gt;Are you good enough at programming?&lt;/h3&gt;


&lt;p&gt;If you are good enough at programming, when starting to think about making a game, you  should have a clear technical vision of where you’re heading, instantly knowing what you’re going to code and in which order just by thinking to make a video game. If no concrete diagram appears in your head, you’d better reconsider making a game and go back learning, maybe making small educative games.&lt;/p&gt;


&lt;h3&gt;Keep it simple and don’t change your original design&lt;/h3&gt;


&lt;p&gt;When starting an amateur project, you’ll most probably begin with a simple idea. Then, you’ll think about how to done it and after some readings you’ll think that it would be nice to feature this and that. Once you’ve started the actual coding, you’ll most likely add features to your design as the project comes along (new top-notch effects, more content, complex gameplay…), ultimately reaching a complicated design not feasible in reasonable time. The more you add time consuming features, the more there are chances you’ll face a motivation drop because it lowers the coming of a release and the frequency of satisfactory milestones.&lt;/p&gt;


&lt;p&gt;Stick to a simple design. Try to define your design with a general single line like “top-down 2D racing game” or “fast paced shoot-them-up” and write it down as the title of your design paper. Then list the things you’ll need (e.g. a 2D engine, a particle system, an editor,…), keeping in mind your capabilities at doing the listed points. Your original design should fit on one page only. Don’t change your original design. You’ll most likely fail at releasing anything if you’re always changing/adding things. Keep your ideas for a potential “2.0” release or a future project. Be wise and think about finishing the project before anything else.&lt;/p&gt;


&lt;h3&gt;Release type&lt;/h3&gt;


&lt;p&gt;The release type or your project license has to be carefully chosen as it will condition many aspects of your project. Commercial release will close to you the doors of free-to-use-for-non-commercial-purpose game assets but it will allow you to invest a little bit, hoping to have a return on investments (but keep in mind that you’re project may commercially fail despite being good). There’s many scheme to adopt: pay-what-want, donation welcomed, fund the development with goodies or exclusive content… Some of them (essentially commercial ones) imply tedious administrative tasks before getting into it. You should think about the release type depending on the following two points.&lt;/p&gt;


&lt;h3&gt;Alone VS team&lt;/h3&gt;


&lt;p&gt;Most team based amateur projects will face troubles managing themselves to the point they may fail. First, try not to team up with strangers, more specifically internet strangers. Why? 1) Because you don’t know their motivation. 2) Because they are possibly at the other side of the Earth. 3) They’re less attached to your project than you, and may leave anytime. 4) Managing a virtual team is a real pain and need an almost professional organization (that’s not amateurish enough). 5) People will most certainly dislike other people in the team. 6) They may be not mature enough. Etc. If you want to team up with somebody, look among your friends, coworkers, or very good internet friends. To be simple: people you know well, trust, know their skills and share interests with. Don’t impose them YOUR game idea, instead, suggest a brainstorming and select something that motivate everybody for better group cohesion.&lt;/p&gt;


&lt;p&gt;Working alone is usually nice: you work at your own pace, know where you’re heading, etc. But if you’re working alone, you'll have nobody to remind you to work on the project and unless you’re a talented genius in all the aspect of game making, you’ll get stuck at some point, the next section point.&lt;/p&gt;


&lt;h3&gt;Paying or not paying for assets?&lt;/h3&gt;


&lt;p&gt;If you’re working alone (or with programmers only), when it comes to game assets (graphics and music), unless you’re an artist, you’ll quickly need to rely on someone else. Let’s cut it short: free and talented artists are almost impossible to find. The reason is that the few artists interested in contributing to a video game are likely to already be part of an interesting/important project or to make profit out of the shortage of free-artists (or just because they're real professionals offering services to amateurs).&lt;/p&gt;


&lt;p&gt;Now, think about it, do you really want to make a game to the point to invest in it? Even if you don’t plan to sell it? Wouldn’t you be proud of it if it has cool graphics and sounds? Consider the fact that hobbies generally cost money and that investing in a game project isn’t that different from investing in any other hobby. There’s a lot of community where you can find nice artists (&lt;a href=&quot;http://www.newgrounds.com/&quot; hreflang=&quot;en&quot;&gt;newgrounds&lt;/a&gt; to name one). It’s a little bit more complicated to find 3D artists but many websites are selling models and textures. If you go with this scheme, prepare yourself to invest more than $100 (a complete soundtrack may cost more). If you’re planning to sell your game, you’re probably thinking that you can freely invest a considerable amount of money. Watch out: even if you consider your game to be great, it may not sell so well, maybe not sell at all (most amateur projects aren't profitable). Take a look at the other amateur projects’ numbers, compare them to your project and ask yourself if you’re still that much confident at hoping a decent return on investments.&lt;/p&gt;


&lt;p&gt;As of non-commercial game, you’ll have way more opportunities, like using free for non-commercial use assets (like all the stuff on newgrounds). If you still need an artist, you may find one in some dedicated forums (&lt;a href=&quot;http://forums.xna.com/forums/42.aspx&quot; hreflang=&quot;en&quot;&gt;xna&lt;/a&gt;, &lt;a href=&quot;http://www.gamedev.net/community/forums/forum.asp?forum_id=8&quot; hreflang=&quot;en&quot;&gt;gamedev&lt;/a&gt;) but pay attention to how you’re going to present your project. The best you can do, is to finish entirely your game prototype (with dummy assets), showing that you’re very serious and motivated and that you have a well prepared plan at finalizing it. This is your best bet on attracting a real artist.&lt;/p&gt;


&lt;p&gt;Another solution, if you’re not an artist and don’t want to “hire” someone for the graphics, is to go for an oldschool art direction, oldschool enough so you could do everything yourself and focus on the gameplay. If you polish everything well, you may end up with something atypical (&lt;a href=&quot;http://www.MonacoIsMine.com&quot; hreflang=&quot;en&quot;&gt;Monaco&lt;/a&gt; is a recent example of polished oldschool game with innovative design).&lt;/p&gt;


&lt;h3&gt;Be clean&lt;/h3&gt;


&lt;p&gt;Don’t use assets or code you’re not allowed to: assets you didn’t asked for permission, assets you didn’t mentioned the author, assets you found on google without knowing if there’re licensed, free but not for commercial use assets while selling your game… Show you’re clean and you’ll get attention from anybody you may work with and much more.&lt;/p&gt;


&lt;p&gt;You’re free to use any assets for prototyping purpose, but try to never show you’re progress using some of them (or at least, thanks the author) and do not let some of them in public releases.&lt;/p&gt;


&lt;h3&gt;Contribute to communities&lt;/h3&gt;


&lt;p&gt;Help others on community websites, try to be a valuable contributor. Creating a network will help you to get some help when you're facing difficulties and will also auto-promote your project. It is always interesting to get in touch with other people. Think about it as your karma.&lt;/p&gt;


&lt;h3&gt;Manage your communication&lt;/h3&gt;


&lt;p&gt;Have this in mind: most gamers don’t care about game development and focus on graphics, gameplay and content. So if you want to advertise your game, try to not be too techish about it and focus on gamers’ interests. Don’t spam forums with your project, stick to the natural web workflow: blog and/or twit about it and hope to get a nice natural webrank. Once your game is nearly complete, make videos, a dedicated website and try to get in touch with specialized websites, ask them for promotion or submit them press releases.&lt;/p&gt;</description>
    
    
    
          <comments>http://www.handcrafted-games.com/index.php?post/2010/04/28/Indie-games%3A-from-the-intention-to-the-actual-making-of-a-game#comment-form</comments>
      <wfw:comment>http://www.handcrafted-games.com/index.php?post/2010/04/28/Indie-games%3A-from-the-intention-to-the-actual-making-of-a-game#comment-form</wfw:comment>
      <wfw:commentRss>http://www.handcrafted-games.com/index.php?feed/atom/comments/5</wfw:commentRss>
      </item>
    
  <item>
    <title>Welcome to Handcrafted-games!</title>
    <link>http://www.handcrafted-games.com/index.php?post/2010/04/09/Welcome-to-Dotclear%21</link>
    <guid isPermaLink="false">urn:md5:92030cbf3e25b683895792f7a10a457f</guid>
    <pubDate>Fri, 09 Apr 2010 11:31:00 +0100</pubDate>
    <dc:creator>Mister Helmut</dc:creator>
        <category>Blogposts</category>
            
    <description>    &lt;p&gt;Welcome to handcrafted-games.com, my personal blog.&lt;/p&gt;
&lt;h2&gt;Who am I?&lt;/h2&gt;
&lt;p&gt;My nickname is Mister Helmut, I am researcher in computer science and addicted to video games and development.&lt;/p&gt;
&lt;p&gt;You may find more about me on &lt;a hreflang=&quot;en&quot; href=&quot;http://www.handcrafted-games.com/index.php?about&quot;&gt;the about page&lt;/a&gt;.&lt;/p&gt;
&lt;h2&gt;What to expect from this website?&lt;/h2&gt;
&lt;p&gt;XNA development, game industry and gamer thoughts related articles.&lt;/p&gt;</description>
    
    
    
          <comments>http://www.handcrafted-games.com/index.php?post/2010/04/09/Welcome-to-Dotclear%21#comment-form</comments>
      <wfw:comment>http://www.handcrafted-games.com/index.php?post/2010/04/09/Welcome-to-Dotclear%21#comment-form</wfw:comment>
      <wfw:commentRss>http://www.handcrafted-games.com/index.php?feed/atom/comments/1</wfw:commentRss>
      </item>
    
</channel>
</rss>
