<?xml version="1.0" encoding="utf-8"?><?xml-stylesheet type='text/xsl' href='http://xna101.spaces.live.com/mmm2008-07-24_12.50/rsspretty.aspx?rssquery=en-US;http%3a%2f%2fxna101.spaces.live.com%2ffeed.rss' version='1.0'?><rss version="2.0" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:msn="http://schemas.microsoft.com/msn/spaces/2005/rss" xmlns:live="http://schemas.microsoft.com/live/spaces/2006/rss" xmlns:dcterms="http://purl.org/dc/terms/" xmlns:cf="http://www.microsoft.com/schemas/rss/core/2005" xmlns:wfw="http://wellformedweb.org/CommentAPI/"><channel><title>XNA 101 .Net</title><description>Game Programming for Beginners in Microsoft's C# and XNA Game Studio.</description><link>http://xna101.spaces.live.com/</link><language>en-US</language><pubDate>Sat, 11 Oct 2008 02:46:58 GMT</pubDate><lastBuildDate>Sat, 11 Oct 2008 02:46:58 GMT</lastBuildDate><generator>Microsoft Spaces v1.1</generator><docs>http://www.rssboard.org/rss-specification</docs><ttl>60</ttl><live:identity><live:id>8641928114040532142</live:id><live:alias>xna101</live:alias></live:identity><image><title>XNA 101 .Net</title><url>http://blufiles.storage.live.com/y1p1bO2-HxFwQaIjlqokQJjxJn6nz-eTOGw21HVWs6cKupFm0c5Q2a8isrLqUZZ7jPA</url><link>http://xna101.spaces.live.com/</link></image><cf:listinfo><cf:group ns="http://schemas.microsoft.com/live/spaces/2006/rss" element="typelabel" label="Type" /><cf:group ns="http://schemas.microsoft.com/live/spaces/2006/rss" element="tag" label="Tag" /><cf:group element="category" label="Category" /><cf:sort element="pubDate" label="Date" data-type="date" default="true" /><cf:sort element="title" label="Title" data-type="string" /><cf:sort ns="http://purl.org/rss/1.0/modules/slash/" element="comments" label="Comments" data-type="number" /></cf:listinfo><item><title>This blog is moving... and being updated to XNA 3.0</title><link>http://xna101.spaces.live.com/Blog/cns!77EE4BD533D8ECAE!1260.entry</link><description>&lt;p&gt;I've been asked for a while now to update these tutorials to a more recent version of XNA, and I've finally decided with the release of XNA 3.0 Beta to go ahead and do that. The new posts will be at the following address: &lt;p&gt;&lt;a href="http://www.bluerosegames.com/xna101"&gt;http://www.bluerosegames.com/xna101&lt;/a&gt; &lt;p&gt;and the RSS feed is at: &lt;p&gt;&lt;a href="http://feeds.feedburner.com/xna101"&gt;http://feeds.feedburner.com/xna101&lt;/a&gt; &lt;p&gt;I'll leave these posts here for reference but all of these tutorials will eventually be available at the new site.&lt;img src="http://c.services.spaces.live.com/CollectionWebService/c.gif?cid=8641928114040532142&amp;page=RSS%3a+This+blog+is+moving...+and+being+updated+to+XNA+3.0&amp;referrer=" width="1px" height="1px" border="0" alt=""&gt;&lt;img style="position:absolute" alt="" width="0px" height="0px" src="http://c.live.com/c.gif?NC=31263&amp;amp;NA=1149&amp;amp;PI=73329&amp;amp;RF=&amp;amp;DI=3919&amp;amp;PS=85545&amp;amp;TP=xna101.spaces.live.com&amp;amp;GT1=xna101"&gt;</description><comments>http://xna101.spaces.live.com/Blog/cns!77EE4BD533D8ECAE!1260.entry#comment</comments><guid isPermaLink="true">http://xna101.spaces.live.com/Blog/cns!77EE4BD533D8ECAE!1260.entry</guid><pubDate>Thu, 09 Oct 2008 23:16:43 GMT</pubDate><slash:comments>2</slash:comments><msn:type>blogentry</msn:type><live:type>blogentry</live:type><live:typelabel>Blog entry</live:typelabel><wfw:commentRss>http://xna101.spaces.live.com/blog/cns!77EE4BD533D8ECAE!1260/comments/feed.rss</wfw:commentRss><wfw:comment>http://xna101.spaces.live.com/Blog/cns!77EE4BD533D8ECAE!1260.entry#comment</wfw:comment><dcterms:modified>2008-10-09T23:16:43Z</dcterms:modified></item><item><title>XNA Community Games on the 360, and coming to a Zune near you!</title><link>http://xna101.spaces.live.com/Blog/cns!77EE4BD533D8ECAE!519.entry</link><description>&lt;p&gt;Microsoft just had their GDC keynote address, and boy was it big for XNA. &lt;p&gt;Microsoft has announced plans to let XNA Creators Club developers write games that any XBox Live subscriber can play, and it's community based. Games developed by the community, peer reviewed by the community, and distributed to the community. I've been dying for a viable distribution mechanism to the masses for XNA, and it looks like we are going to have one.   &lt;p&gt;Add to this Scott Guthrie's post yesterday about the .Net product roadmap: &lt;p&gt;&lt;a title="http://weblogs.asp.net/scottgu/archive/2008/02/19/net-3-5-client-product-roadmap.aspx" href="http://weblogs.asp.net/scottgu/archive/2008/02/19/net-3-5-client-product-roadmap.aspx"&gt;http://weblogs.asp.net/scottgu/archive/2008/02/19/net-3-5-client-product-roadmap.aspx&lt;/a&gt; &lt;p&gt;where packaging of applications using the .NET framework is going to get a lot easier, and it's all good news for XNA.  &lt;p&gt;Add on top of that a surprise announcement of Zune game development using XNA Game Studio, and it's pretty exciting. &lt;p&gt;More details here, &lt;a title="http://creators.xna.com/whatsnew.aspx" href="http://creators.xna.com/whatsnew.aspx"&gt;http://creators.xna.com/whatsnew.aspx&lt;/a&gt;, looks like we're supposed to see a beta of a lot of this &amp;quot;in the spring&amp;quot; of 2008.&lt;img src="http://c.services.spaces.live.com/CollectionWebService/c.gif?cid=8641928114040532142&amp;page=RSS%3a+XNA+Community+Games+on+the+360%2c+and+coming+to+a+Zune+near+you!&amp;referrer=" width="1px" height="1px" border="0" alt=""&gt;&lt;img style="position:absolute" alt="" width="0px" height="0px" src="http://c.live.com/c.gif?NC=31263&amp;amp;NA=1149&amp;amp;PI=73329&amp;amp;RF=&amp;amp;DI=3919&amp;amp;PS=85545&amp;amp;TP=xna101.spaces.live.com&amp;amp;GT1=xna101"&gt;</description><comments>http://xna101.spaces.live.com/Blog/cns!77EE4BD533D8ECAE!519.entry#comment</comments><guid isPermaLink="true">http://xna101.spaces.live.com/Blog/cns!77EE4BD533D8ECAE!519.entry</guid><pubDate>Wed, 20 Feb 2008 20:37:47 GMT</pubDate><slash:comments>30</slash:comments><msn:type>blogentry</msn:type><live:type>blogentry</live:type><live:typelabel>Blog entry</live:typelabel><wfw:commentRss>http://xna101.spaces.live.com/blog/cns!77EE4BD533D8ECAE!519/comments/feed.rss</wfw:commentRss><wfw:comment>http://xna101.spaces.live.com/Blog/cns!77EE4BD533D8ECAE!519.entry#comment</wfw:comment><dcterms:modified>2008-02-20T20:37:47Z</dcterms:modified></item><item><title>Announcing the new Farseer Physics Engine for XNA Game Studio and Silverlight 1.1</title><link>http://xna101.spaces.live.com/Blog/cns!77EE4BD533D8ECAE!428.entry</link><description>&lt;p&gt;I've had the pleasure of working with &lt;a href="http://jeffweber.spaces.live.com/"&gt;Jeff Weber&lt;/a&gt; over the last couple of weeks porting the new release of his Farseer Physics Engine to Silverlight 1.1 and I'm happy to announce that Jeff released the new XNA and Silverlight versions this morning. &lt;p&gt;Just to be completely clear, Jeff did most of the work on this, I was just happy to help out by doing the Silverlight port. &lt;p&gt;You can get the code here: &lt;a title="http://www.codeplex.com/FarseerPhysics/Release/ProjectReleases.aspx" href="http://www.codeplex.com/FarseerPhysics/Release/ProjectReleases.aspx"&gt;http://www.codeplex.com/FarseerPhysics/Release/ProjectReleases.aspx&lt;/a&gt; &lt;p&gt;and you can see the Silverlight demos here: &lt;a href="http://www.bluerosegames.com/farseersilverlightdemos"&gt;http://www.bluerosegames.com/farseersilverlightdemos&lt;/a&gt; &lt;h4&gt;&lt;u&gt;Introduction&lt;/u&gt;&lt;/h4&gt;The Farseer Physics Engine is an easy to use 2D physics engine designed for Microsoft’s &lt;b&gt;XNA&lt;/b&gt; and &lt;b&gt;Silverlight&lt;/b&gt; platforms. The Farseer Physics Engine focuses on simplicity, useful features, and enabling the creation of fun, dynamic games.  &lt;h4&gt;&lt;u&gt;Features&lt;/u&gt;&lt;/h4&gt; &lt;ul&gt; &lt;li&gt;&lt;b&gt;General&lt;/b&gt;  &lt;ul&gt; &lt;li&gt;Easy To Use!  &lt;li&gt;Support for XNA (XBOX 360 and Windows)  &lt;li&gt;Support for Silverlight (1.1 and above)  &lt;li&gt;Support for Managed .Net Languages In General &lt;/ul&gt; &lt;li&gt;&lt;b&gt;Collison&lt;/b&gt;  &lt;ul&gt; &lt;li&gt;Concave and Convex Polygons Supported  &lt;li&gt;Multiple Collision Geometries Per Body  &lt;li&gt;Collision Categories For Complex Interaction Between Physics Objects  &lt;li&gt;Collision Callback Mechanism &lt;/ul&gt; &lt;li&gt;&lt;b&gt;Dynamics&lt;/b&gt;  &lt;ul&gt; &lt;li&gt;Joints  &lt;ul&gt; &lt;li&gt;Revolute Joint (body to body or fixed to world)  &lt;li&gt;Angle Joint (body to body or fixed to world)  &lt;li&gt;Slider (Prismatic) Joint  &lt;li&gt;Pin (Distance) Joint &lt;/ul&gt; &lt;li&gt;Force Controllers  &lt;ul&gt; &lt;li&gt;Linear Spring  &lt;li&gt;Angular Spring  &lt;li&gt;Easy To Build Custom Force Controllers (Explosions, Steering Behaviors, etc.) &lt;/ul&gt;&lt;/ul&gt; &lt;li&gt;&lt;b&gt;Support and Debugging&lt;/b&gt;  &lt;ul&gt; &lt;li&gt;Samples Framework With Samples Covering Most Major Engine Features. (XNA and Silverlight versions)  &lt;li&gt;Debug Viewer To View All Major Physics Objects (part of samples framework)  &lt;li&gt;User Manual (in progress) &lt;/ul&gt;&lt;/ul&gt;&lt;img src="http://c.services.spaces.live.com/CollectionWebService/c.gif?cid=8641928114040532142&amp;page=RSS%3a+Announcing+the+new+Farseer+Physics+Engine+for+XNA+Game+Studio+and+Silverlight+1.1&amp;referrer=" width="1px" height="1px" border="0" alt=""&gt;&lt;img style="position:absolute" alt="" width="0px" height="0px" src="http://c.live.com/c.gif?NC=31263&amp;amp;NA=1149&amp;amp;PI=73329&amp;amp;RF=&amp;amp;DI=3919&amp;amp;PS=85545&amp;amp;TP=xna101.spaces.live.com&amp;amp;GT1=xna101"&gt;</description><comments>http://xna101.spaces.live.com/Blog/cns!77EE4BD533D8ECAE!428.entry#comment</comments><guid isPermaLink="true">http://xna101.spaces.live.com/Blog/cns!77EE4BD533D8ECAE!428.entry</guid><pubDate>Wed, 03 Oct 2007 17:52:13 GMT</pubDate><slash:comments>11</slash:comments><msn:type>blogentry</msn:type><live:type>blogentry</live:type><live:typelabel>Blog entry</live:typelabel><wfw:commentRss>http://xna101.spaces.live.com/blog/cns!77EE4BD533D8ECAE!428/comments/feed.rss</wfw:commentRss><wfw:comment>http://xna101.spaces.live.com/Blog/cns!77EE4BD533D8ECAE!428.entry#comment</wfw:comment><dcterms:modified>2007-10-03T17:52:13Z</dcterms:modified></item><item><title>GameFest videos now available</title><link>http://xna101.spaces.live.com/Blog/cns!77EE4BD533D8ECAE!411.entry</link><description>&lt;div&gt;For those who weren't able to watch the webcasts live from the first day of GameFest, they are now available here:&lt;/div&gt;
&lt;div&gt; &lt;/div&gt;
&lt;div&gt;&lt;a href="http://creators.xna.com/Headlines/presentations/"&gt;http://creators.xna.com/Headlines/presentations/&lt;/a&gt;&lt;/div&gt;
&lt;div&gt; &lt;/div&gt;
&lt;div&gt;There is some good information on the next release of XNA Game Studio, especially Networking support.&lt;/div&gt;
&lt;div&gt; &lt;/div&gt;&lt;img src="http://c.services.spaces.live.com/CollectionWebService/c.gif?cid=8641928114040532142&amp;page=RSS%3a+GameFest+videos+now+available&amp;referrer=" width="1px" height="1px" border="0" alt=""&gt;&lt;img style="position:absolute" alt="" width="0px" height="0px" src="http://c.live.com/c.gif?NC=31263&amp;amp;NA=1149&amp;amp;PI=73329&amp;amp;RF=&amp;amp;DI=3919&amp;amp;PS=85545&amp;amp;TP=xna101.spaces.live.com&amp;amp;GT1=xna101"&gt;</description><comments>http://xna101.spaces.live.com/Blog/cns!77EE4BD533D8ECAE!411.entry#comment</comments><guid isPermaLink="true">http://xna101.spaces.live.com/Blog/cns!77EE4BD533D8ECAE!411.entry</guid><pubDate>Sun, 26 Aug 2007 19:30:01 GMT</pubDate><slash:comments>5</slash:comments><msn:type>blogentry</msn:type><live:type>blogentry</live:type><live:typelabel>Blog entry</live:typelabel><wfw:commentRss>http://xna101.spaces.live.com/blog/cns!77EE4BD533D8ECAE!411/comments/feed.rss</wfw:commentRss><wfw:comment>http://xna101.spaces.live.com/Blog/cns!77EE4BD533D8ECAE!411.entry#comment</wfw:comment><dcterms:modified>2007-08-26T19:30:14Z</dcterms:modified></item><item><title>Relaunch of my Blue Rose Games web site</title><link>http://xna101.spaces.live.com/Blog/cns!77EE4BD533D8ECAE!408.entry</link><description>&lt;p&gt;I've been working on consolidating all of my various game related materials into a single site, and I still have a bit to go, but I have updated my Blue Rose Games site at &lt;a href="http://www.bluerosegames.com"&gt;http://www.bluerosegames.com&lt;/a&gt; with a fresh look and more information. I'll be adding the rest of my content over the next couple of weeks. &lt;p&gt;As for new XNA related information, I have a few tutorials in the works as well as a couple of other projects I can't disclose at this point, and I'll be at GameFest 2007 next week so I'm sure I'll have some information to share after that.&lt;img src="http://c.services.spaces.live.com/CollectionWebService/c.gif?cid=8641928114040532142&amp;page=RSS%3a+Relaunch+of+my+Blue+Rose+Games+web+site&amp;referrer=" width="1px" height="1px" border="0" alt=""&gt;&lt;img style="position:absolute" alt="" width="0px" height="0px" src="http://c.live.com/c.gif?NC=31263&amp;amp;NA=1149&amp;amp;PI=73329&amp;amp;RF=&amp;amp;DI=3919&amp;amp;PS=85545&amp;amp;TP=xna101.spaces.live.com&amp;amp;GT1=xna101"&gt;</description><comments>http://xna101.spaces.live.com/Blog/cns!77EE4BD533D8ECAE!408.entry#comment</comments><guid isPermaLink="true">http://xna101.spaces.live.com/Blog/cns!77EE4BD533D8ECAE!408.entry</guid><pubDate>Fri, 10 Aug 2007 03:29:24 GMT</pubDate><slash:comments>11</slash:comments><msn:type>blogentry</msn:type><live:type>blogentry</live:type><live:typelabel>Blog entry</live:typelabel><wfw:commentRss>http://xna101.spaces.live.com/blog/cns!77EE4BD533D8ECAE!408/comments/feed.rss</wfw:commentRss><wfw:comment>http://xna101.spaces.live.com/Blog/cns!77EE4BD533D8ECAE!408.entry#comment</wfw:comment><dcterms:modified>2007-08-10T03:29:24Z</dcterms:modified></item><item><title>Using Origin with SpriteBatch.Draw (Part 2)</title><link>http://xna101.spaces.live.com/Blog/cns!77EE4BD533D8ECAE!355.entry</link><description>&lt;p&gt;Completed source code for this tutorial: &lt;a href="http://www.bluerosegames.com/brg/OriginTutorial2.zip"&gt;http://www.bluerosegames.com/brg/OriginTutorial2.zip&lt;/a&gt; 
&lt;p&gt;In part 1 of this tutorial, I covered how to use the origin parameter of the SpriteBatch.Draw call to draw a sprite around its center and to rotate around that point. I also showed how the origin values are independent of the destination scale of the drawing. This tutorial will build upon the project from part 1. 
&lt;p&gt;Part 2 covers another use for the origin parameter. 
&lt;p&gt;Let's say we want to create a complex sprite, or a sprite composed of overlaying multiple textures. Ideally we would want to control the position of all of these sprites with a single position field, so that if we update that position, all drawing calls for the sprite will be updated to reflect this position. A good example of this would be if you had a warrior in a 2D RPG game, and wanted to allow the warrior to hold many different types of weapons, and you didn't want to have a separate texture of the warrior for each weapon. 
&lt;p&gt;You could create a texture for each weapon with whitespace or padding around it so that it lines up properly with the warrior texture, but this padding takes up video memory and can make it more difficult to create the weapon textures. By giving the weapon draw call a different origin from the warrior, we can handle the offset of the overlay. 
&lt;p&gt;In our case, I would like to overlay a shadow on the soccer ball. An overlay makes sense in this case since I don't want the shadow to rotate as the soccer ball rotates.  Here is the shadow image: 
&lt;p&gt;&lt;a href="http://www.bluerosegames.com/brg/soccer_ball_shadow.png"&gt;&lt;img src="http://www.bluerosegames.com/brg/soccer_ball_shadow.png"&gt;&lt;/a&gt; 
&lt;p&gt;Save the shadow image as soccer_ball_shadow.png and add it to the project. Now in the Ball class, add the following fields:&lt;pre&gt;    &lt;span style="color:rgb(0,0,255)"&gt;public&lt;/span&gt; &lt;span style="color:rgb(0,0,255)"&gt;static&lt;/span&gt; &lt;span style="color:rgb(43,145,175)"&gt;Texture2D&lt;/span&gt; ShadowTexture;
    &lt;span style="color:rgb(0,0,255)"&gt;public&lt;/span&gt; &lt;span style="color:rgb(0,0,255)"&gt;static&lt;/span&gt; &lt;span style="color:rgb(43,145,175)"&gt;Vector2&lt;/span&gt; ShadowOrigin;
&lt;/pre&gt;&lt;a href="http://11011.net/software/vspaste"&gt;&lt;/a&gt;
&lt;p&gt;These fields will store the texture and the origin for the shadow. Now in the Ball.Draw() method, add the following after the other Draw call:&lt;pre&gt;    spriteBatch.Draw(ShadowTexture, Position, &lt;span style="color:rgb(0,0,255)"&gt;null&lt;/span&gt;, &lt;span style="color:rgb(43,145,175)"&gt;Color&lt;/span&gt;.White, 0, ShadowOrigin, Scale, &lt;span style="color:rgb(43,145,175)"&gt;SpriteEffects&lt;/span&gt;.None, 0);&lt;/pre&gt;&lt;a href="http://11011.net/software/vspaste"&gt;&lt;/a&gt;
&lt;p&gt;It needs to be after the other Draw call so that it is drawn on top of the other texture. So now we just need to initialize these new fields in the Game1.LoadGraphicsContent method, as follows:&lt;pre&gt;    &lt;span style="color:rgb(43,145,175)"&gt;Ball&lt;/span&gt;.ShadowTexture = content.Load&amp;lt;&lt;span style="color:rgb(43,145,175)"&gt;Texture2D&lt;/span&gt;&amp;gt;(&lt;span style="color:rgb(163,21,21)"&gt;&amp;quot;soccer_ball_shadow&amp;quot;&lt;/span&gt;);
&lt;span style="color:rgb(43,145,175)"&gt;    Ball&lt;/span&gt;.ShadowOrigin = &lt;span style="color:rgb(43,145,175)"&gt;Ball&lt;/span&gt;.Origin + &lt;span style="color:rgb(0,0,255)"&gt;new&lt;/span&gt; &lt;span style="color:rgb(43,145,175)"&gt;Vector2&lt;/span&gt;(-30, -60);&lt;/pre&gt;&lt;a href="http://11011.net/software/vspaste"&gt;&lt;a href="http://11011.net/software/vspaste"&gt;&lt;/a&gt;
&lt;p&gt;Note that the shadow's origin is offset from the ball's origin by 30 pixels on the X axis and 60 pixels on the Y axis. This is because the shadow image is smaller than the ball image and needs to be shifted to the left and down to line up properly. 
&lt;p&gt;Now if you run the program again, you should see the shadow show up on both soccer balls in the proper position. &lt;/a&gt;&lt;img src="http://c.services.spaces.live.com/CollectionWebService/c.gif?cid=8641928114040532142&amp;page=RSS%3a+Using+Origin+with+SpriteBatch.Draw+(Part+2)&amp;referrer=" width="1px" height="1px" border="0" alt=""&gt;&lt;img style="position:absolute" alt="" width="0px" height="0px" src="http://c.live.com/c.gif?NC=31263&amp;amp;NA=1149&amp;amp;PI=73329&amp;amp;RF=&amp;amp;DI=3919&amp;amp;PS=85545&amp;amp;TP=xna101.spaces.live.com&amp;amp;GT1=xna101"&gt;</description><category>2D</category><comments>http://xna101.spaces.live.com/Blog/cns!77EE4BD533D8ECAE!355.entry#comment</comments><guid isPermaLink="true">http://xna101.spaces.live.com/Blog/cns!77EE4BD533D8ECAE!355.entry</guid><pubDate>Tue, 10 Apr 2007 20:02:46 GMT</pubDate><slash:comments>39</slash:comments><msn:type>blogentry</msn:type><live:type>blogentry</live:type><live:typelabel>Blog entry</live:typelabel><wfw:commentRss>http://xna101.spaces.live.com/blog/cns!77EE4BD533D8ECAE!355/comments/feed.rss</wfw:commentRss><wfw:comment>http://xna101.spaces.live.com/Blog/cns!77EE4BD533D8ECAE!355.entry#comment</wfw:comment><dcterms:modified>2007-05-01T13:14:38Z</dcterms:modified></item><item><title>Thank you for your support</title><link>http://xna101.spaces.live.com/Blog/cns!77EE4BD533D8ECAE!354.entry</link><description>&lt;p&gt;I am pleased to announce that because of my work here as well as my other work in the XNA community that I have been named a Microsoft Most Valuable Professional (MVP) for XNA. Microsoft MVPs are people who are recognized for their contributions in the community. You can read more about the MVP program here: &lt;p&gt;&lt;a title="https://mvp.support.microsoft.com/default.aspx" href="https://mvp.support.microsoft.com/default.aspx"&gt;https://mvp.support.microsoft.com/default.aspx&lt;/a&gt; &lt;p&gt;Thank you for your continued support and I hope that this award can help me provide better support to the community going forward.&lt;img src="http://c.services.spaces.live.com/CollectionWebService/c.gif?cid=8641928114040532142&amp;page=RSS%3a+Thank+you+for+your+support&amp;referrer=" width="1px" height="1px" border="0" alt=""&gt;&lt;img style="position:absolute" alt="" width="0px" height="0px" src="http://c.live.com/c.gif?NC=31263&amp;amp;NA=1149&amp;amp;PI=73329&amp;amp;RF=&amp;amp;DI=3919&amp;amp;PS=85545&amp;amp;TP=xna101.spaces.live.com&amp;amp;GT1=xna101"&gt;</description><comments>http://xna101.spaces.live.com/Blog/cns!77EE4BD533D8ECAE!354.entry#comment</comments><guid isPermaLink="true">http://xna101.spaces.live.com/Blog/cns!77EE4BD533D8ECAE!354.entry</guid><pubDate>Mon, 09 Apr 2007 00:38:52 GMT</pubDate><slash:comments>9</slash:comments><msn:type>blogentry</msn:type><live:type>blogentry</live:type><live:typelabel>Blog entry</live:typelabel><wfw:commentRss>http://xna101.spaces.live.com/blog/cns!77EE4BD533D8ECAE!354/comments/feed.rss</wfw:commentRss><wfw:comment>http://xna101.spaces.live.com/Blog/cns!77EE4BD533D8ECAE!354.entry#comment</wfw:comment><dcterms:modified>2007-04-09T00:38:52Z</dcterms:modified></item><item><title>Using Origin with SpriteBatch.Draw (Part 1)</title><link>http://xna101.spaces.live.com/Blog/cns!77EE4BD533D8ECAE!350.entry</link><description>&lt;p&gt;Source code for finished tutorial: &lt;a href="http://www.bluerosegames.com/brg/origintutorial1.zip"&gt;http://www.bluerosegames.com/brg/origintutorial1.zip&lt;/a&gt; 
&lt;p&gt;There are seven variations of the SpriteBatch.Draw method, and three of them accept an origin as one of the parameters. This tutorial explains some of the useful behaviors of the origin parameter and how it can help you write your game. 
&lt;p&gt;For this tutorial, we'll create a new project called &amp;quot;Origin&amp;quot; of type &amp;quot;Windows Game&amp;quot;. 
&lt;p&gt;Now let's say we want to draw a ball on the screen. This is pretty straightforward, and is one of the first programs most people will write in XNA. Here is a simple class for drawing a ball using one of the Draw methods that accepts an origin as one of the parameters:&lt;pre&gt;&lt;span style="color:rgb(0,0,255)"&gt;using&lt;/span&gt; System;
&lt;span style="color:rgb(0,0,255)"&gt;using&lt;/span&gt; System.Collections.Generic;
&lt;span style="color:rgb(0,0,255)"&gt;using&lt;/span&gt; System.Text;
&lt;span style="color:rgb(0,0,255)"&gt;using&lt;/span&gt; Microsoft.Xna.Framework;
&lt;span style="color:rgb(0,0,255)"&gt;using&lt;/span&gt; Microsoft.Xna.Framework.Graphics;

&lt;span style="color:rgb(0,0,255)"&gt;class&lt;/span&gt; &lt;span style="color:rgb(43,145,175)"&gt;Ball
&lt;/span&gt;{
    &lt;span style="color:rgb(0,0,255)"&gt;public&lt;/span&gt; &lt;span style="color:rgb(43,145,175)"&gt;Vector2&lt;/span&gt; Position;
    &lt;span style="color:rgb(0,0,255)"&gt;public&lt;/span&gt; &lt;span style="color:rgb(43,145,175)"&gt;Vector2&lt;/span&gt; Scale = &lt;span style="color:rgb(43,145,175)"&gt;Vector2&lt;/span&gt;.One;
    &lt;span style="color:rgb(0,0,255)"&gt;public&lt;/span&gt; &lt;span style="color:rgb(0,0,255)"&gt;float&lt;/span&gt; Rotation;
    &lt;span style="color:rgb(0,0,255)"&gt;public&lt;/span&gt; &lt;span style="color:rgb(0,0,255)"&gt;static&lt;/span&gt; &lt;span style="color:rgb(43,145,175)"&gt;Texture2D&lt;/span&gt; BallTexture;
    &lt;span style="color:rgb(0,0,255)"&gt;public&lt;/span&gt; &lt;span style="color:rgb(0,0,255)"&gt;static&lt;/span&gt; &lt;span style="color:rgb(43,145,175)"&gt;Vector2&lt;/span&gt; Origin = &lt;span style="color:rgb(43,145,175)"&gt;Vector2&lt;/span&gt;.Zero;

    &lt;span style="color:rgb(0,0,255)"&gt;public&lt;/span&gt; &lt;span style="color:rgb(0,0,255)"&gt;void&lt;/span&gt; Draw(&lt;span style="color:rgb(43,145,175)"&gt;SpriteBatch&lt;/span&gt; spriteBatch)
    {
        spriteBatch.Draw(BallTexture, Position, &lt;span style="color:rgb(0,0,255)"&gt;null&lt;/span&gt;, &lt;span style="color:rgb(43,145,175)"&gt;Color&lt;/span&gt;.White, Rotation, Origin, Scale, &lt;span style="color:rgb(43,145,175)"&gt;SpriteEffects&lt;/span&gt;.None, 0);
    }
}&lt;/pre&gt;&lt;a href="http://11011.net/software/vspaste"&gt;&lt;/a&gt;
&lt;p&gt;Notice that the Origin field defaults to Vector2.Zero, which will make this class, by default, behave as if an origin value wasn't specified. 
&lt;p&gt;For the ball texture, I was playing a little bit with Microsoft's new Expression Design software which is a drawing program. I was going for a cartoony-type look for the soccer ball. Save this ball image as soccer_ball.png and add it to your project. 
&lt;p&gt;&lt;a href="http://www.bluerosegames.com/brg/soccer_ball.png"&gt;&lt;img height=150 src="http://www.bluerosegames.com/brg/soccer_ball.png" width=150&gt;&lt;/a&gt;   
&lt;p&gt;Now to call this class from our Game class. Add the following to the Game1 declarations:&lt;pre&gt;&lt;span style="color:rgb(43,145,175)"&gt;SpriteBatch&lt;/span&gt; spriteBatch;
&lt;span style="color:rgb(43,145,175)"&gt;Ball&lt;/span&gt; ball1 = &lt;span style="color:rgb(0,0,255)"&gt;new&lt;/span&gt; &lt;span style="color:rgb(43,145,175)"&gt;Ball&lt;/span&gt;();&lt;/pre&gt;&lt;a href="http://11011.net/software/vspaste"&gt;&lt;/a&gt;
&lt;p&gt;In the Game1.LoadGraphicsContent method, inside the loadAllContent block, add the following:&lt;pre&gt;&lt;span style="color:rgb(43,145,175)"&gt;Ball&lt;/span&gt;.BallTexture = content.Load&amp;lt;&lt;span style="color:rgb(43,145,175)"&gt;Texture2D&lt;/span&gt;&amp;gt;(&lt;span style="color:rgb(163,21,21)"&gt;&amp;quot;soccer_ball&amp;quot;&lt;/span&gt;);
ball1.Position = &lt;span style="color:rgb(0,0,255)"&gt;new&lt;/span&gt; &lt;span style="color:rgb(43,145,175)"&gt;Vector2&lt;/span&gt;(150, 150);
spriteBatch = &lt;span style="color:rgb(0,0,255)"&gt;new&lt;/span&gt; &lt;span style="color:rgb(43,145,175)"&gt;SpriteBatch&lt;/span&gt;(graphics.GraphicsDevice);&lt;/pre&gt;
&lt;p&gt;And then in the Game1.Draw method, add this:&lt;pre&gt;spriteBatch.Begin();
ball1.Draw(spriteBatch);
spriteBatch.End();&lt;/pre&gt;
&lt;p&gt;Run the program. It should look something like this: 
&lt;p&gt;&lt;a href="http://tk3.storage.msn.com/x1ppUPyqopddk5cZaVa1aZATKshu3XIRFvz548bU_t4--pPygnXWY-kjRl6vJNMPAJIxnK9UU0nlbQD-w284DMJB0uYAFqIdAe-2fh1p89BJOBIR0M68g8pi5BcN97ynnFgH5UgcTfHGSA5W7AdQH5OAg"&gt;&lt;img style="border-top-width:0px;border-left-width:0px;border-bottom-width:0px;border-right-width:0px" height=480 src="http://tk3.storage.msn.com/x1ppUPyqopddk5cZaVa1aZATKshu3XIRFvz548bU_t4--pubp8NBtlitlzXtXURgSzSiJcxDFj6Ek3wsTEip31mpw2h_vECf9iWeeuPe-ozr2zhJAYhB6pVJIsgmoJhE7jEJ2ZNRO2A6I8ia1zJcmFB7g" width=618 border=0&gt;&lt;/a&gt; 
&lt;p&gt;Now what if we want to rotate the ball so that it looks like it's spinning? Add the following line to the Update method:&lt;pre&gt;ball1.Rotation += (&lt;span style="color:rgb(0,0,255)"&gt;float&lt;/span&gt;)(gameTime.ElapsedGameTime.TotalSeconds * 3);&lt;/pre&gt;
&lt;p&gt;And run the program again. You should notice that this isn't really the effect we were looking for. The ball is rotating around its top left corner intead of around its center. In order to make the ball rotate around its center, we can set its origin to half of its width and half of its height. In the Game1.LoadGraphicsContent method, add the following:&lt;pre&gt;&lt;span style="color:rgb(43,145,175)"&gt;Ball&lt;/span&gt;.Origin = &lt;span style="color:rgb(0,0,255)"&gt;new&lt;/span&gt; &lt;span style="color:rgb(43,145,175)"&gt;Vector2&lt;/span&gt;(&lt;span style="color:rgb(43,145,175)"&gt;Ball&lt;/span&gt;.BallTexture.Width / 2, &lt;span style="color:rgb(43,145,175)"&gt;Ball&lt;/span&gt;.BallTexture.Height / 2);&lt;/pre&gt;
&lt;p&gt;Now run the program again. The ball should now rotate about its center. The ball is also being drawn higher and more to the left of the screen, since by setting the origin, the position of the ball also takes the origin into account, so the position of the origin is at the position specified in the draw call. 
&lt;p&gt;OK so now for a second ball that's scaled by a power of 2. Declare a ball2 in the Game1 class as follows:&lt;pre&gt;&lt;span style="color:rgb(43,145,175)"&gt;Ball&lt;/span&gt; ball2 = &lt;span style="color:rgb(0,0,255)"&gt;new&lt;/span&gt; &lt;span style="color:rgb(43,145,175)"&gt;Ball&lt;/span&gt;();
&lt;/pre&gt;
&lt;p&gt;In the Game1.LoadGraphicsContent method add the following:&lt;pre&gt;ball2.Position = &lt;span style="color:rgb(0,0,255)"&gt;new&lt;/span&gt; &lt;span style="color:rgb(43,145,175)"&gt;Vector2&lt;/span&gt;(500, 300);
ball2.Scale = &lt;span style="color:rgb(0,0,255)"&gt;new&lt;/span&gt; &lt;span style="color:rgb(43,145,175)"&gt;Vector2&lt;/span&gt;(2, 2);&lt;/pre&gt;
&lt;p&gt;And in the Game1.Update method add this:&lt;pre&gt;ball2.Rotation += (&lt;span style="color:rgb(0,0,255)"&gt;float&lt;/span&gt;)(gameTime.ElapsedGameTime.TotalSeconds * 4);&lt;/pre&gt;
&lt;p&gt;And finally in the Game1.Draw method, add the draw call for the second ball.&lt;pre&gt;ball2.Draw(spriteBatch);
&lt;/pre&gt;
&lt;p&gt;Run the program again, is this surprising? We didn't scale the origin but the ball still spins around its center. This is because the origin parameter is specified in &lt;strong&gt;source pixels&lt;/strong&gt;. This is a bit confusing at first, but is nice because no matter how we scale the destination, the origin will stay in the same relative position. This is very useful if we're scaling our sprites based on game surface resolution to fill the screen.&lt;img src="http://c.services.spaces.live.com/CollectionWebService/c.gif?cid=8641928114040532142&amp;page=RSS%3a+Using+Origin+with+SpriteBatch.Draw+(Part+1)&amp;referrer=" width="1px" height="1px" border="0" alt=""&gt;&lt;img style="position:absolute" alt="" width="0px" height="0px" src="http://c.live.com/c.gif?NC=31263&amp;amp;NA=1149&amp;amp;PI=73329&amp;amp;RF=&amp;amp;DI=3919&amp;amp;PS=85545&amp;amp;TP=xna101.spaces.live.com&amp;amp;GT1=xna101"&gt;</description><category>2D</category><comments>http://xna101.spaces.live.com/Blog/cns!77EE4BD533D8ECAE!350.entry#comment</comments><guid isPermaLink="true">http://xna101.spaces.live.com/Blog/cns!77EE4BD533D8ECAE!350.entry</guid><pubDate>Sat, 07 Apr 2007 00:21:33 GMT</pubDate><slash:comments>21</slash:comments><msn:type>blogentry</msn:type><live:type>blogentry</live:type><live:typelabel>Blog entry</live:typelabel><wfw:commentRss>http://xna101.spaces.live.com/blog/cns!77EE4BD533D8ECAE!350/comments/feed.rss</wfw:commentRss><wfw:comment>http://xna101.spaces.live.com/Blog/cns!77EE4BD533D8ECAE!350.entry#comment</wfw:comment><dcterms:modified>2007-05-01T13:14:56Z</dcterms:modified></item><item><title>Moving Forward</title><link>http://xna101.spaces.live.com/Blog/cns!77EE4BD533D8ECAE!324.entry</link><description>&lt;p&gt; &lt;p&gt;I've been having a problem with how I have been doing this blog so far, because I kind of painted myself into a corner by adding on to the current project with each lesson. So when I haven't been ready to add a new feature to the current game, I had to wait to post a new entry. This resulted in a long delay between blog entries. &lt;p&gt;So going forward, this is how I'm going to try to manage the blog. If I have one-off topics to post about, like the enhancement to the Font Sample, I'll post them without a lesson number. When I post the final few tutorials in the Air Hockey sequence, I'll number them so that it is clear as to the order of those tutorials. &lt;p&gt;Thank you for your continued support, and I hope that these changes will allow me to post about unrelated topics while preparing the final lessons in the Air Hockey game.&lt;img src="http://c.services.spaces.live.com/CollectionWebService/c.gif?cid=8641928114040532142&amp;page=RSS%3a+Moving+Forward&amp;referrer=" width="1px" height="1px" border="0" alt=""&gt;&lt;img style="position:absolute" alt="" width="0px" height="0px" src="http://c.live.com/c.gif?NC=31263&amp;amp;NA=1149&amp;amp;PI=73329&amp;amp;RF=&amp;amp;DI=3919&amp;amp;PS=85545&amp;amp;TP=xna101.spaces.live.com&amp;amp;GT1=xna101"&gt;</description><comments>http://xna101.spaces.live.com/Blog/cns!77EE4BD533D8ECAE!324.entry#comment</comments><guid isPermaLink="true">http://xna101.spaces.live.com/Blog/cns!77EE4BD533D8ECAE!324.entry</guid><pubDate>Sat, 10 Mar 2007 02:45:29 GMT</pubDate><slash:comments>26</slash:comments><msn:type>blogentry</msn:type><live:type>blogentry</live:type><live:typelabel>Blog entry</live:typelabel><wfw:commentRss>http://xna101.spaces.live.com/blog/cns!77EE4BD533D8ECAE!324/comments/feed.rss</wfw:commentRss><wfw:comment>http://xna101.spaces.live.com/Blog/cns!77EE4BD533D8ECAE!324.entry#comment</wfw:comment><dcterms:modified>2007-03-10T02:45:29Z</dcterms:modified></item><item><title>Improving the Font Sample on Creators Club Online</title><link>http://xna101.spaces.live.com/Blog/cns!77EE4BD533D8ECAE!319.entry</link><description>&lt;div&gt; &lt;div&gt;One of the new samples on the XNA Creators Club Online (&lt;a href="http://creators.xna.com/"&gt;http://creators.xna.com&lt;/a&gt;) is a sample for rendering text in your game. I had created something very similar to this myself, as have a few others, since it's a pretty common need. &lt;/div&gt; &lt;div&gt; &lt;/div&gt; &lt;div&gt;The Font Sample allows you to create a bitmapped font or import a font from the fonts on your computer and then use it to draw text. This functionality is going to be in the April XNA update, but for now it's a good alternative.&lt;/div&gt; &lt;div&gt; &lt;/div&gt; &lt;div&gt;There was one thing, however, that was missing from the Font Sample that I had in my text rendering code that I thought would be useful, and that is a way to rotate the text. If you add the following method to the Font class in the Font sample, you will then be able to pass a rotation value (in radians) into the Draw method.&lt;/div&gt;&lt;font size=2&gt; &lt;p&gt;&lt;/font&gt;&lt;font color="#0000ff" size=2&gt;public&lt;/font&gt;&lt;font size=2&gt; &lt;/font&gt;&lt;font color="#0000ff" size=2&gt;void&lt;/font&gt;&lt;font size=2&gt; Draw(&lt;/font&gt;&lt;font color="#0000ff" size=2&gt;string&lt;/font&gt;&lt;font size=2&gt; text, &lt;/font&gt;&lt;font color="#2b91af" size=2&gt;Vector2&lt;/font&gt;&lt;font size=2&gt; position, &lt;/font&gt;&lt;font color="#0000ff" size=2&gt;float&lt;/font&gt;&lt;font size=2&gt; scale, &lt;/font&gt;&lt;font color="#0000ff" size=2&gt;float&lt;/font&gt;&lt;font size=2&gt; rotation, &lt;/font&gt;&lt;font color="#2b91af" size=2&gt;Color&lt;/font&gt;&lt;font size=2&gt; color, &lt;/font&gt;&lt;font color="#2b91af" size=2&gt;SpriteBatch&lt;/font&gt;&lt;font size=2&gt; spriteBatch)&lt;br&gt;&lt;/font&gt;&lt;font size=2&gt;{&lt;br&gt;   &lt;/font&gt;&lt;font color="#2b91af" size=2&gt;Vector2&lt;/font&gt;&lt;font size=2&gt; origin = &lt;/font&gt;&lt;font color="#2b91af" size=2&gt;Vector2&lt;/font&gt;&lt;font size=2&gt;.Zero;&lt;br&gt;   &lt;/font&gt;&lt;font color="#2b91af" size=2&gt;Vector2&lt;/font&gt;&lt;font size=2&gt; curOrigin = &lt;/font&gt;&lt;font color="#2b91af" size=2&gt;Vector2&lt;/font&gt;&lt;font size=2&gt;.Zero;&lt;br&gt;   &lt;/font&gt;&lt;font color="#0000ff" size=2&gt;foreach&lt;/font&gt;&lt;font size=2&gt; (&lt;/font&gt;&lt;font color="#0000ff" size=2&gt;char&lt;/font&gt;&lt;font size=2&gt; ch &lt;/font&gt;&lt;font color="#0000ff" size=2&gt;in&lt;/font&gt;&lt;font size=2&gt; text)&lt;br&gt;   {&lt;br&gt;      &lt;/font&gt;&lt;font color="#008000" size=2&gt;// Look up what font glyph corresponds to this Unicode character.&lt;br&gt;      &lt;/font&gt;&lt;font color="#0000ff" size=2&gt;int&lt;/font&gt;&lt;font size=2&gt; index;&lt;br&gt;      &lt;/font&gt;&lt;font color="#0000ff" size=2&gt;if&lt;/font&gt;&lt;font size=2&gt; (!characterMap.TryGetValue(ch, &lt;/font&gt;&lt;font color="#0000ff" size=2&gt;out&lt;/font&gt;&lt;font size=2&gt; index))&lt;br&gt;         index = glyphData.Count - 1;&lt;br&gt;&lt;br&gt;      &lt;/font&gt;&lt;font color="#008000" size=2&gt;// Look up what part of the texture represents this character.&lt;br&gt;      &lt;/font&gt;&lt;font color="#2b91af" size=2&gt;Rectangle&lt;/font&gt;&lt;font size=2&gt; glyph = glyphData[index];&lt;br&gt;      &lt;/font&gt;&lt;font color="#2b91af" size=2&gt;Rectangle&lt;/font&gt;&lt;font size=2&gt; cropping = croppingData[index];&lt;br&gt;      curOrigin.X = origin.X - cropping.X;&lt;br&gt;      curOrigin.Y = origin.Y - cropping.Y;&lt;br&gt;      &lt;/font&gt;&lt;font color="#008000" size=2&gt;// Draw the character.&lt;br&gt;      &lt;/font&gt;&lt;font size=2&gt;spriteBatch.Draw(textureValue, position, glyph, color, rotation,&lt;br&gt;            curOrigin, scale, &lt;/font&gt;&lt;font color="#2b91af" size=2&gt;SpriteEffects&lt;/font&gt;&lt;font size=2&gt;.None, 0);&lt;br&gt;&lt;br&gt;      &lt;/font&gt;&lt;font color="#008000" size=2&gt;// Move the origin further to the left, because the origin is relative to the current letter.&lt;br&gt;      &lt;/font&gt;&lt;font size=2&gt;origin.X -= cropping.Width;&lt;br&gt;   }&lt;br&gt;}&lt;/font&gt;  &lt;p&gt;   &lt;div&gt;If you wanted to rotate around a different point, you could create a new method which would take the origin as one of the parameters and use that instead of Vector2.Zero as your starting origin. &lt;/div&gt; &lt;div&gt; &lt;/div&gt; &lt;div&gt;Here is a screen shot of a modified FontSample program with some text rotated:&lt;/div&gt; &lt;div&gt; &lt;/div&gt; &lt;div&gt;&lt;a href="http://tk3.storage.msn.com/x1ppUPyqopddk5cZaVa1aZATKshu3XIRFvz548bU_t4--pG9i0ZaEL71Ftvt2ObzZyxRWDhmJ8PSUmyotodpRrqiyyYN64IUj4HYAHUAMEYDyk8FQ3HECDsu3QaxHvmCKbzH_rRWE6j3xNMtYXVHYOMxA"&gt;&lt;img style="border-right:0px;border-top:0px;border-left:0px;border-bottom:0px" height=376 src="http://tk3.storage.msn.com/x1ppUPyqopddk5cZaVa1aZATKshu3XIRFvz548bU_t4--q7ic2wUt0SAzuT5xTKvL-1RwcV4fIogTPWXu1SKnyQLPAkyj_6ZUMXbhsO9I4rNcQq_ef7HRF-Ea6-a_URqVLJmfkfyMuBW1COatRLqbjt5g" width=640 border=0&gt;&lt;/a&gt; &lt;/div&gt;&lt;/div&gt;&lt;img src="http://c.services.spaces.live.com/CollectionWebService/c.gif?cid=8641928114040532142&amp;page=RSS%3a+Improving+the+Font+Sample+on+Creators+Club+Online&amp;referrer=" width="1px" height="1px" border="0" alt=""&gt;&lt;img style="position:absolute" alt="" width="0px" height="0px" src="http://c.live.com/c.gif?NC=31263&amp;amp;NA=1149&amp;amp;PI=73329&amp;amp;RF=&amp;amp;DI=3919&amp;amp;PS=85545&amp;amp;TP=xna101.spaces.live.com&amp;amp;GT1=xna101"&gt;</description><comments>http://xna101.spaces.live.com/Blog/cns!77EE4BD533D8ECAE!319.entry#comment</comments><guid isPermaLink="true">http://xna101.spaces.live.com/Blog/cns!77EE4BD533D8ECAE!319.entry</guid><pubDate>Fri, 09 Mar 2007 18:50:38 GMT</pubDate><slash:comments>43</slash:comments><msn:type>blogentry</msn:type><live:type>blogentry</live:type><live:typelabel>Blog entry</live:typelabel><wfw:commentRss>http://xna101.spaces.live.com/blog/cns!77EE4BD533D8ECAE!319/comments/feed.rss</wfw:commentRss><wfw:comment>http://xna101.spaces.live.com/Blog/cns!77EE4BD533D8ECAE!319.entry#comment</wfw:comment><dcterms:modified>2007-03-09T22:52:25Z</dcterms:modified></item><item><title>XNA Creators Club Online</title><link>http://xna101.spaces.live.com/Blog/cns!77EE4BD533D8ECAE!318.entry</link><description>&lt;div&gt;There is a new web site from the XNA team called XNA Creators Club Online. The url is &lt;a href="http://creators.xna.com/"&gt;http://creators.xna.com&lt;/a&gt; and it includes code samples, forums, links to resources, a new Starter Kit, and more. &lt;/div&gt;
&lt;div&gt; &lt;/div&gt;
&lt;div&gt;Go check it out!&lt;/div&gt;&lt;img src="http://c.services.spaces.live.com/CollectionWebService/c.gif?cid=8641928114040532142&amp;page=RSS%3a+XNA+Creators+Club+Online&amp;referrer=" width="1px" height="1px" border="0" alt=""&gt;&lt;img style="position:absolute" alt="" width="0px" height="0px" src="http://c.live.com/c.gif?NC=31263&amp;amp;NA=1149&amp;amp;PI=73329&amp;amp;RF=&amp;amp;DI=3919&amp;amp;PS=85545&amp;amp;TP=xna101.spaces.live.com&amp;amp;GT1=xna101"&gt;</description><comments>http://xna101.spaces.live.com/Blog/cns!77EE4BD533D8ECAE!318.entry#comment</comments><guid isPermaLink="true">http://xna101.spaces.live.com/Blog/cns!77EE4BD533D8ECAE!318.entry</guid><pubDate>Fri, 09 Mar 2007 18:47:36 GMT</pubDate><slash:comments>3</slash:comments><msn:type>blogentry</msn:type><live:type>blogentry</live:type><live:typelabel>Blog entry</live:typelabel><wfw:commentRss>http://xna101.spaces.live.com/blog/cns!77EE4BD533D8ECAE!318/comments/feed.rss</wfw:commentRss><wfw:comment>http://xna101.spaces.live.com/Blog/cns!77EE4BD533D8ECAE!318.entry#comment</wfw:comment><dcterms:modified>2007-03-09T18:47:36Z</dcterms:modified></item><item><title>Sorry for the Hiatus</title><link>http://xna101.spaces.live.com/Blog/cns!77EE4BD533D8ECAE!294.entry</link><description>&lt;div&gt;It's been a while since I've posted here and I just wanted to let everyone know that I haven't abandoned this blog. &lt;/div&gt;
&lt;div&gt; &lt;/div&gt;
&lt;div&gt;Real life (work) has gotten in the way a bit (wish I could do this full time but something has to pay the bills) and I've been spending all of my free time creating an XNA project called XNAStage. You can find the XNAStage project at &lt;a href="http://www.codeplex.com/xnastage"&gt;http://www.codeplex.com/xnastage&lt;/a&gt; and it basically came from the need to do splash intro screens and dialog boxes in an easier way. &lt;/div&gt;
&lt;div&gt; &lt;/div&gt;
&lt;div&gt;Basically what XNAStage does is let you give a start state and an end state and a start time and an end time for a sprite and XNAStage will fill in the gaps. This is typically called &amp;quot;tweening&amp;quot; in Flash or other similar technologies. For example, you can give a starting position and an ending position for a sprite and it will move smoothly between the positions and stop once it gets there. The same can be done with color tinting and fading, and pretty much anything else you can think of a tween for. You can get some samples of XNAStage here: &lt;a href="http://www.bluerosegames.com/brg/XnaStageSamples.zip"&gt;http://www.bluerosegames.com/brg/XnaStageSamples.zip&lt;/a&gt;&lt;/div&gt;
&lt;div&gt; &lt;/div&gt;
&lt;div&gt;The next lesson will incorporate the XNAStage library into the air hockey game and we will use it for a game over screen.&lt;/div&gt;&lt;img src="http://c.services.spaces.live.com/CollectionWebService/c.gif?cid=8641928114040532142&amp;page=RSS%3a+Sorry+for+the+Hiatus&amp;referrer=" width="1px" height="1px" border="0" alt=""&gt;&lt;img style="position:absolute" alt="" width="0px" height="0px" src="http://c.live.com/c.gif?NC=31263&amp;amp;NA=1149&amp;amp;PI=73329&amp;amp;RF=&amp;amp;DI=3919&amp;amp;PS=85545&amp;amp;TP=xna101.spaces.live.com&amp;amp;GT1=xna101"&gt;</description><comments>http://xna101.spaces.live.com/Blog/cns!77EE4BD533D8ECAE!294.entry#comment</comments><guid isPermaLink="true">http://xna101.spaces.live.com/Blog/cns!77EE4BD533D8ECAE!294.entry</guid><pubDate>Sat, 27 Jan 2007 13:28:56 GMT</pubDate><slash:comments>5</slash:comments><msn:type>blogentry</msn:type><live:type>blogentry</live:type><live:typelabel>Blog entry</live:typelabel><wfw:commentRss>http://xna101.spaces.live.com/blog/cns!77EE4BD533D8ECAE!294/comments/feed.rss</wfw:commentRss><wfw:comment>http://xna101.spaces.live.com/Blog/cns!77EE4BD533D8ECAE!294.entry#comment</wfw:comment><dcterms:modified>2007-01-27T13:28:56Z</dcterms:modified></item><item><title>South Florida .NET Code Camp 2007</title><link>http://xna101.spaces.live.com/Blog/cns!77EE4BD533D8ECAE!285.entry</link><description>&lt;p&gt;Just a quick note letting everyone know that I'll be doing a session at the South Florida .NET Code Camp on February 10, 2007 in Miramar, Florida. If you've never been to a Code Camp, it's an unusual event in that local speakers (especially those with little or no speaking experience) are given first choice, followed by regional and big name speakers, and finally the regular Microsoft speakers. I'll post up my presentation materials and samples afterward. &lt;p&gt;For more information and registration, go to &lt;a title="http://codecamp07.fladotnet.com/codecamp.aspx" href="http://codecamp07.fladotnet.com/codecamp.aspx"&gt;http://codecamp07.fladotnet.com/codecamp.aspx&lt;/a&gt;, hope to see you there!&lt;img src="http://c.services.spaces.live.com/CollectionWebService/c.gif?cid=8641928114040532142&amp;page=RSS%3a+South+Florida+.NET+Code+Camp+2007&amp;referrer=" width="1px" height="1px" border="0" alt=""&gt;&lt;img style="position:absolute" alt="" width="0px" height="0px" src="http://c.live.com/c.gif?NC=31263&amp;amp;NA=1149&amp;amp;PI=73329&amp;amp;RF=&amp;amp;DI=3919&amp;amp;PS=85545&amp;amp;TP=xna101.spaces.live.com&amp;amp;GT1=xna101"&gt;</description><comments>http://xna101.spaces.live.com/Blog/cns!77EE4BD533D8ECAE!285.entry#comment</comments><guid isPermaLink="true">http://xna101.spaces.live.com/Blog/cns!77EE4BD533D8ECAE!285.entry</guid><pubDate>Tue, 09 Jan 2007 21:08:26 GMT</pubDate><slash:comments>3</slash:comments><msn:type>blogentry</msn:type><live:type>blogentry</live:type><live:typelabel>Blog entry</live:typelabel><wfw:commentRss>http://xna101.spaces.live.com/blog/cns!77EE4BD533D8ECAE!285/comments/feed.rss</wfw:commentRss><wfw:comment>http://xna101.spaces.live.com/Blog/cns!77EE4BD533D8ECAE!285.entry#comment</wfw:comment><dcterms:modified>2007-01-09T21:08:26Z</dcterms:modified></item><item><title>Lesson 26: Mixing 2D and 3D</title><link>http://xna101.spaces.live.com/Blog/cns!77EE4BD533D8ECAE!279.entry</link><description>&lt;p&gt;Source for this lesson: &lt;a href="http://www.bluerosegames.com/brg/XnaLesson26.zip"&gt;http://www.bluerosegames.com/brg/XnaLesson26.zip&lt;/a&gt;
&lt;p&gt;When developing a 3D game, there will be occasions where some visuals you want to display are easier done with 2D graphics. It may be a scoreboard, a heads-up-display, a health meter, or crosshairs for a gun, or something totally different. In XNA, 2D and 3D graphics can be displayed simultaneously as long as certain care is taken. 
&lt;p&gt;For the air hockey game, let's use 2D sprites to display the score. I have generated this image which is meant to look like numbers on an LED display:
&lt;p&gt;&lt;img src="http://www.bluerosegames.com/brg/lednumbers.png"&gt;
&lt;p&gt;The image has a trasparent background. Save the image to your computer as lednumbers.png and add it to your project. 
&lt;p&gt;Notice that all of the numbers are in the same image. This technique is one of the easiest and best ways to implement sprite animation. Each part of the image could just as easily be different positions of a running plumber in a red hat or the frames of an explosion. 
&lt;p&gt;So just like in our 2D examples previously, we need a SpriteBatch object. In the Game1 Field declarations add the following:
&lt;p&gt;&lt;font face="Courier New" color="#0000ff"&gt;SpriteBatch spriteBatch;&lt;/font&gt; 
&lt;p&gt;and then in the Game1.Initialize() method, we can instantiate the SpriteBatch object as follows: 
&lt;p&gt;&lt;font face="Courier New" color="#0000ff"&gt;spriteBatch = new SpriteBatch(graphics.GraphicsDevice);&lt;/font&gt; 
&lt;p&gt;Now we need the logic to draw the numbers. As we did with the BouncingBall class, let's create a class to hold the logic related to drawing the numbers. Create a new class called LedDisplay. The code for the LedDisplay class should look as follows: 
&lt;p&gt;&lt;font face="Courier New" color="#0000ff"&gt;using System;&lt;br&gt;using System.Collections.Generic;&lt;br&gt;using System.Text;&lt;br&gt;using Microsoft.Xna.Framework;&lt;br&gt;using Microsoft.Xna.Framework.Graphics; &lt;/font&gt;
&lt;p&gt;&lt;font face="Courier New" color="#0000ff"&gt;namespace AirHockey&lt;br&gt;{&lt;br&gt;   class LedDisplay&lt;br&gt;   {&lt;br&gt;      public static Texture2D Texture;&lt;br&gt;      private int _value;&lt;br&gt;      public Vector2 Position;&lt;br&gt;      Rectangle _sourceRect; &lt;/font&gt;
&lt;p&gt;&lt;font face="Courier New" color="#0000ff"&gt;      public int Value&lt;br&gt;      {&lt;br&gt;         set&lt;br&gt;         {&lt;br&gt;            _value = value;&lt;br&gt;            _sourceRect = new Rectangle(_value * 60, 0, 60, 90);&lt;br&gt;         }&lt;br&gt;      } &lt;/font&gt;
&lt;p&gt;&lt;font face="Courier New" color="#0000ff"&gt;      public void Update(int value)&lt;br&gt;      {&lt;br&gt;         Value = value;&lt;br&gt;      } &lt;/font&gt;
&lt;p&gt;&lt;font face="Courier New" color="#0000ff"&gt;      public void Draw(SpriteBatch spriteBatch)&lt;br&gt;      {&lt;br&gt;         spriteBatch.Draw(Texture, Position, _sourceRect, Color.White);&lt;br&gt;      }&lt;br&gt;   }&lt;br&gt;}&lt;/font&gt; 
&lt;p&gt;Some of this code should look familiar. There are a couple of differences, we are using a different variation of the SpriteBatch.Draw() method which accepts a source rectangle which defines what portion of the source texture we want to draw. The source rectangle is determined by the value of Value, which will control which number is displayed. Since each &amp;quot;frame&amp;quot; in our animation is 60 pixels wide and 90 pixels high, the X value of the top left corner of the source rectangle is equal to the width of a frame times the value to display. When Value is 0, X is 0. When Value is 1, X is 60, and so on. So from the Game1 class, by simply setting the Value property, the source rect parameters will be automatically set to the correct values. 
&lt;p&gt;Now in the Game1 class, we need two LedDisplay objects, one for each score. In the Game1 Field declarations add the following: 
&lt;p&gt;&lt;font face="Courier New" color="#0000ff"&gt;LedDisplay playerScoreDisplay;&lt;br&gt;LedDisplay computerScoreDisplay;&lt;/font&gt; 
&lt;p&gt;and then we need to instantiate and initialize these objects. In the Game1.Initialize() method, add the following: 
&lt;p&gt;&lt;font face="Courier New" color="#0000ff"&gt;playerScoreDisplay = new LedDisplay();&lt;br&gt;playerScoreDisplay.Position = new Vector2(25, 25);&lt;br&gt;playerScoreDisplay.Value = 0;&lt;br&gt;computerScoreDisplay = new LedDisplay();&lt;br&gt;computerScoreDisplay.Position = new Vector2(715, 25);&lt;br&gt;computerScoreDisplay.Value = 0;&lt;/font&gt; 
&lt;p&gt;And in the Game1.LoadGraphicsContent() method, we need to load the Texture that contains the number and associate it with the LedDisplay class. Since it's a static Field in the class, we only have to associate it with the class and not a specific instance of the class. So in the Game1.LoadGraphicsContent() method, inside the conditional block, add the following statement:
&lt;p&gt;&lt;font face="Courier New, Courier, Monospace" color="#0000ff"&gt;LedDisplay.Texture = content.Load&amp;lt;Texture2D&amp;gt;(&amp;quot;lednumbers&amp;quot;);&lt;/font&gt;
&lt;p&gt;Now to draw the scores. In the Game1.Draw() method, just before the base.Draw(gameTime); statement, add this: 
&lt;p&gt;&lt;font face="Courier New" color="#0000ff"&gt;spriteBatch.Begin();&lt;br&gt;playerScoreDisplay.Draw(spriteBatch);&lt;br&gt;computerScoreDisplay.Draw(spriteBatch);&lt;br&gt;spriteBatch.End();&lt;/font&gt; 
&lt;p&gt;We haven't yet added the logic to tie the actual scores to these objects, but we can at least see how it looks dsiplaying zeroes. Run the program and see how it looks. 
&lt;p&gt;Well the numbers look good, but what happened to our paddles and table? The answer is that the SpriteBatch uses render state settings that are very efficient for drawing 2D sprites but are not capable of correctly rendering 3D models. When spriteBatch.Begin() is called, the spriteBatch object set the render state settings to what it likes best, and then leaves them that way. Fortunately we can tell the SpriteBatch to set things back the way they were after it's done (when SpriteBatch.End() is called). 
&lt;p&gt;To do this, change the SpriteBatch.Begin(); statement in the Game1.Draw() method to look like this: 
&lt;p&gt;&lt;font face="Courier New" color="#0000ff"&gt;spriteBatch.Begin(SpriteBlendMode.AlphaBlend, SpriteSortMode.Deferred, SaveStateMode.SaveState);&lt;/font&gt; 
&lt;p&gt;The first two arguments are just set to the defaults, the important one is the third. It tells the SpriteBatch to save off the current render settings and then restore them when done. Now run it again and it should look better. 
&lt;p&gt;So now to update the scores when someone scores. In the Game1.CheckForScore() method, just after the computerScore++; statement add the following: 
&lt;p&gt;&lt;font face="Courier New" color="#0000ff"&gt;computerScoreDisplay.Value = computerScore % 10;&lt;/font&gt; 
&lt;p&gt;The % sign is a &amp;quot;mod&amp;quot; operator where the value is divided by the number specified and the result is set to the remainder of the division. Since we only have a single digit display, we can only display 0 to 9. By doing this mod operator, the display will start over at 0 when it gets greater than 9. This won't matter later since the first player to 7 will win, but for now this will keep the display from displaying invalid results. Now do the same for the player's score by adding the following line after the playerScore++; statement: 
&lt;p&gt;&lt;font face="Courier New" color="#0000ff"&gt;playerScoreDisplay.Value = playerScore % 10;&lt;/font&gt; 
&lt;p&gt;Now when you score a goal (or the computer scores) you should see the score get updated. The final result should look something like this: 
&lt;p&gt;&lt;a href="http://tk3.storage.msn.com/x1ppUPyqopddk5cZaVa1aZATKshu3XIRFvz548bU_t4--oCheCWd4DR-RgG1gRAy9wPnzDHgsFItzTwtInWWXp6TZXRENU7TUJxzp3pZwzkAYY2iVXg-__QSDbrWdZk-GV7jJsT_1RQP5vVZl2aV1vcPg"&gt;&lt;img style="border-right:0px;border-top:0px;border-left:0px;border-bottom:0px" height=480 src="http://tk3.storage.msn.com/x1ppUPyqopddk5cZaVa1aZATKshu3XIRFvz548bU_t4--rTPY3O_ztVaALoIubP__0zX0x71UogLW2LXusPq8LLVKEUP03EhWdNaxuC-oPclElOEHwaFXkkfe1W_snATl3e5OZZOgLfqyYLU5OELNizRQ" width=612 border=0&gt;&lt;/a&gt;&lt;img src="http://c.services.spaces.live.com/CollectionWebService/c.gif?cid=8641928114040532142&amp;page=RSS%3a+Lesson+26%3a+Mixing+2D+and+3D&amp;referrer=" width="1px" height="1px" border="0" alt=""&gt;&lt;img style="position:absolute" alt="" width="0px" height="0px" src="http://c.live.com/c.gif?NC=31263&amp;amp;NA=1149&amp;amp;PI=73329&amp;amp;RF=&amp;amp;DI=3919&amp;amp;PS=85545&amp;amp;TP=xna101.spaces.live.com&amp;amp;GT1=xna101"&gt;</description><comments>http://xna101.spaces.live.com/Blog/cns!77EE4BD533D8ECAE!279.entry#comment</comments><guid isPermaLink="true">http://xna101.spaces.live.com/Blog/cns!77EE4BD533D8ECAE!279.entry</guid><pubDate>Sun, 07 Jan 2007 04:01:33 GMT</pubDate><slash:comments>63</slash:comments><msn:type>blogentry</msn:type><live:type>blogentry</live:type><live:typelabel>Blog entry</live:typelabel><wfw:commentRss>http://xna101.spaces.live.com/blog/cns!77EE4BD533D8ECAE!279/comments/feed.rss</wfw:commentRss><wfw:comment>http://xna101.spaces.live.com/Blog/cns!77EE4BD533D8ECAE!279.entry#comment</wfw:comment><dcterms:modified>2007-01-12T02:43:55Z</dcterms:modified></item><item><title>Lesson 25: Improving the Collision Handling</title><link>http://xna101.spaces.live.com/Blog/cns!77EE4BD533D8ECAE!276.entry</link><description>&lt;p&gt;Source code for this lesson: &lt;a href="http://www.bluerosegames.com/brg/XnaLesson25.zip"&gt;http://www.bluerosegames.com/brg/XnaLesson25.zip&lt;/a&gt;  &lt;p&gt;Sometimes (actually pretty regularly) you get to a point in a program where you're just not happy with how something works. In my effort to keep the collision handling simple, I had the unfortunate side effect of the puck getting jammed frequently against the wall by the paddle. The code in this lesson will attempt to alleviate some of this. The changes are just a few lines of code, but sometimes a small change can make a big difference.  &lt;p&gt;In the Game1.Update() method, add the lines in red: &lt;p&gt;&lt;font color="#0000ff"&gt;&lt;font face="Courier New"&gt;if (CollisionHandler.CheckForCollisionXZ(roPuck, roPlayerPaddle) == false)&lt;br&gt;{&lt;br&gt;   playerPaddle.Position = roPlayerPaddle.Position;&lt;br&gt;}&lt;br&gt;&lt;font color="#ff0000"&gt;else&lt;br&gt;{&lt;br&gt;   playerPaddle.TargetPosition = playerPaddle.Position;&lt;br&gt;}&lt;br&gt;&lt;/font&gt;if (CollisionHandler.CheckForCollisionXZ(roPuck, roComputerPaddle) == false)&lt;br&gt;{&lt;br&gt;   computerPaddle.Position = roComputerPaddle.Position;&lt;br&gt;}&lt;br&gt;&lt;/font&gt;&lt;font face="Courier New" color="#ff0000"&gt;else&lt;br&gt;{&lt;br&gt;   computerPaddle.TargetPosition = computerPaddle.Position;&lt;br&gt;}&lt;/font&gt;&lt;/font&gt; &lt;p&gt;These new lines make it so that if there will be an overlap by repositioning the paddle, we will instead set the paddle's TargetPosition to the current position. By doing this, we give the puck the rest of the Update cycle to get out of the way. If we're near the end of the Update cycle, we may need the next cycle as well to clear the puck, but it's quick enough that the player won't notice.&lt;img src="http://c.services.spaces.live.com/CollectionWebService/c.gif?cid=8641928114040532142&amp;page=RSS%3a+Lesson+25%3a+Improving+the+Collision+Handling&amp;referrer=" width="1px" height="1px" border="0" alt=""&gt;&lt;img style="position:absolute" alt="" width="0px" height="0px" src="http://c.live.com/c.gif?NC=31263&amp;amp;NA=1149&amp;amp;PI=73329&amp;amp;RF=&amp;amp;DI=3919&amp;amp;PS=85545&amp;amp;TP=xna101.spaces.live.com&amp;amp;GT1=xna101"&gt;</description><comments>http://xna101.spaces.live.com/Blog/cns!77EE4BD533D8ECAE!276.entry#comment</comments><guid isPermaLink="true">http://xna101.spaces.live.com/Blog/cns!77EE4BD533D8ECAE!276.entry</guid><pubDate>Fri, 05 Jan 2007 03:53:10 GMT</pubDate><slash:comments>4</slash:comments><msn:type>blogentry</msn:type><live:type>blogentry</live:type><live:typelabel>Blog entry</live:typelabel><wfw:commentRss>http://xna101.spaces.live.com/blog/cns!77EE4BD533D8ECAE!276/comments/feed.rss</wfw:commentRss><wfw:comment>http://xna101.spaces.live.com/Blog/cns!77EE4BD533D8ECAE!276.entry#comment</wfw:comment><dcterms:modified>2007-01-05T03:53:10Z</dcterms:modified></item><item><title>Lesson 24: Controlling the Computer Paddle</title><link>http://xna101.spaces.live.com/Blog/cns!77EE4BD533D8ECAE!270.entry</link><description>&lt;p&gt;Source code for lesson 24: &lt;a href="http://www.bluerosegames.com/brg/XnaLesson24.zip"&gt;http://www.bluerosegames.com/brg/XnaLesson24.zip&lt;/a&gt; &lt;p&gt;In Lesson 21, we added code to control the player's paddle based on mouse movements. In this lesson, we will add some simple logic to control the computer's paddle based on the puck's position. &lt;p&gt;Artificial Intelligence (AI) is a general term which is used to describe the logic put in place to make the computer exhibit behaviors that mimic the behaviors of living creatures. In our case, we need to mimic the behavior of an air hockey player. First, we need to come up with a set of rules that we can turn into code. These rules can be very complex based on how intricate the behvior that we are trying to mimic is. If we wanted to mimic a professional air hockey player, we would have to research all of the advanced techniques involved in air hockey and write code to perform these techniques. For this beginner game, we'll keep the rules much simpler. These are the rules we will use: &lt;p&gt;&lt;strong&gt;1. If the center of the puck is anywhere on the player's side of the table or in the first 10 inches of the computer's side, set computer paddle's target position to its &amp;quot;home defensive position&amp;quot; at (0, 0, -23).&lt;/strong&gt; &lt;p&gt;&lt;strong&gt;2. Otherwise if the puck is in the area 10 inches away from center ice to 20 inches away from center ice, set the computer paddle's target position to the puck's center position.&lt;/strong&gt; &lt;p&gt;&lt;strong&gt;3. Otherwise do the following:&lt;/strong&gt; &lt;p&gt;&lt;strong&gt;   a. If the puck is to the left (from the player's perspective) of the &amp;quot;left defensive position&amp;quot; at (-hockeyTable.GoalRadius, 0, -32f) set the computer paddle's target position to its &amp;quot;left defensive position&amp;quot;.&lt;/strong&gt; &lt;p&gt;&lt;strong&gt;   b. Otherwise if the puck is to the right (again from the player's perspective) of the &amp;quot;right defensive position&amp;quot; at (hockeyTable.GoalRadius, 0, -32f) set the computer paddle's target position to its &amp;quot;right defensive position&amp;quot;.&lt;/strong&gt; &lt;p&gt;   &lt;strong&gt;c. Otherwise set the puck's target position to the &amp;quot;home defensive position&amp;quot;.&lt;/strong&gt; &lt;p&gt;Now to implement these rules. First let's define 3 new Vector3 Fields in the Game1 class to hold the home, left, and right defensive positions. In the Game1 declarations, add the following: &lt;p&gt;&lt;font face="Courier New" color="#0000ff"&gt;Vector3 computerHomePosition;&lt;br&gt;Vector3 computerLeftPosition;&lt;br&gt;Vector3 computerRightPosition;&lt;/font&gt; &lt;p&gt;and in the Game1.Initialize() method add the following to initialize the values of the computer defensive positions: &lt;p&gt;&lt;font face="Courier New" color="#0000ff"&gt;computerLeftPosition = new Vector3(-hockeyTable.GoalRadius, 0, -32f);&lt;br&gt;computerRightPosition = new Vector3(hockeyTable.GoalRadius, 0, -32f);&lt;br&gt;computerHomePosition = new Vector3(0, 0, -23f);&lt;/font&gt;  &lt;p&gt;Now that we have these positions defined and initialized, we can add a method to the Game1 class which will execute the rules we defined above. Let's call the method DoComputerAI() and it will look like this: &lt;p&gt;&lt;font face="Courier New" color="#0000ff"&gt;void DoComputerAI()&lt;br&gt;{&lt;br&gt;   Vector3 targetPosition;&lt;br&gt;   if (puck.Position.Z &amp;gt; -10f)&lt;br&gt;   {&lt;br&gt;      targetPosition = computerHomePosition;&lt;br&gt;   }&lt;br&gt;   else if (puck.Position.Z &amp;gt; -20f)&lt;br&gt;   {&lt;br&gt;      targetPosition = puck.Position;&lt;br&gt;   }&lt;br&gt;   else&lt;br&gt;   {&lt;br&gt;      if (puck.Position.X &amp;lt; computerLeftPosition.X)&lt;br&gt;      {&lt;br&gt;         targetPosition = computerLeftPosition;&lt;br&gt;      }&lt;br&gt;      else if (puck.Position.X &amp;gt; computerRightPosition.X)&lt;br&gt;      {&lt;br&gt;         targetPosition = computerRightPosition;&lt;br&gt;      }&lt;br&gt;      else&lt;br&gt;      {&lt;br&gt;         targetPosition = computerHomePosition;&lt;br&gt;      }&lt;br&gt;   }&lt;br&gt;   &lt;font color="#008000"&gt;// make sure that the computer paddle's target position is still on the table and not jamming the puck against a wall.&lt;br&gt;&lt;/font&gt;   float maxX = (hockeyTable.Width / 2f) - computerPaddle.Radius - puck.Radius - 2f;&lt;br&gt;   float minX = - maxX;&lt;br&gt;   if (targetPosition.X &amp;gt; maxX)&lt;br&gt;   {&lt;br&gt;      targetPosition.X = maxX;&lt;br&gt;   }&lt;br&gt;   else if (targetPosition.X &amp;lt; minX)&lt;br&gt;   {&lt;br&gt;      targetPosition.X = minX;&lt;br&gt;   }&lt;br&gt;   computerPaddle.TargetPosition = targetPosition;&lt;br&gt;}&lt;/font&gt;  &lt;p&gt;Notice the extra code at the end of the method. Instead of checking throughout the method to make sure that the target position is valid, we can check it once at the end and fix it appropriately.  &lt;p&gt;Now to call this method. In the Game1.Update() method, after the HandleMouse(); statement, add the following:  &lt;p&gt;&lt;font face="Courier New" color="#0000ff"&gt;DoComputerAI();&lt;/font&gt;  &lt;p&gt;So now every time we enter the Update loop, the target position of the computer paddle will be recalculated. Run the program. You will probably notice a problem. It looks like the computer's AI rules are a bit too good, and you will have a hard time scoring a goal. To make it a bit easier to play, let's slow down the computer's paddle. If you look in the Paddle class, you'll see the following:  &lt;p&gt;&lt;font face="Courier New" color="#0000ff"&gt;public static float MaxVelocity = 200f;&lt;/font&gt;  &lt;p&gt;Since the MaxVelocity is static, both paddles have the same max velocity. Remove the &amp;quot;static&amp;quot; keyword from the above line. Now we will be able to set the max velocities of the paddles independently. In the Game1.Initialize() method, add the following statement:  &lt;p&gt;&lt;font face="Courier New" color="#0000ff"&gt;computerPaddle.MaxVelocity = 50f;&lt;/font&gt;  &lt;p&gt;This should give you a fighting chance. Run the program again and try your luck. One last thing...we had some test code in the Game1.HandleMouse() method to reset the puck if we right clicked the mouse. We don't need that code any more so you can remove it. Just delete the &amp;quot;if&amp;quot; statement and its accompanying conditional block.&lt;img src="http://c.services.spaces.live.com/CollectionWebService/c.gif?cid=8641928114040532142&amp;page=RSS%3a+Lesson+24%3a+Controlling+the+Computer+Paddle&amp;referrer=" width="1px" height="1px" border="0" alt=""&gt;&lt;img style="position:absolute" alt="" width="0px" height="0px" src="http://c.live.com/c.gif?NC=31263&amp;amp;NA=1149&amp;amp;PI=73329&amp;amp;RF=&amp;amp;DI=3919&amp;amp;PS=85545&amp;amp;TP=xna101.spaces.live.com&amp;amp;GT1=xna101"&gt;</description><comments>http://xna101.spaces.live.com/Blog/cns!77EE4BD533D8ECAE!270.entry#comment</comments><guid isPermaLink="true">http://xna101.spaces.live.com/Blog/cns!77EE4BD533D8ECAE!270.entry</guid><pubDate>Wed, 03 Jan 2007 03:12:42 GMT</pubDate><slash:comments>9</slash:comments><msn:type>blogentry</msn:type><live:type>blogentry</live:type><live:typelabel>Blog entry</live:typelabel><wfw:commentRss>http://xna101.spaces.live.com/blog/cns!77EE4BD533D8ECAE!270/comments/feed.rss</wfw:commentRss><wfw:comment>http://xna101.spaces.live.com/Blog/cns!77EE4BD533D8ECAE!270.entry#comment</wfw:comment><dcterms:modified>2007-01-03T03:12:42Z</dcterms:modified></item><item><title>Share what you're working on and what you'd like to hear about</title><link>http://xna101.spaces.live.com/Blog/cns!77EE4BD533D8ECAE!252.entry</link><description>&lt;p&gt;I'm going out of town until Christmas, so no new entries for a while, but in the meantime, I'd like to know if there are any games you're working on. I strongly believe that the best way to learn any programming is to come up with a program you want to write and then start working through it. As you hit roadblocks, you learn new things. I haven't really done any 3D before this blog, so I have learned a lot so far and I'm looking forward to digging into shaders and effects. &lt;p&gt;Also if there are any topics that you would like me to cover, let me know and I'll try my best to work it in. &lt;p&gt;Happy Holidays and I wanted to say I'm thankful for everyone who follows this blog and enjoys it, it has exceeded my expectations thus far and I plan on continuing heading into the new year and in 2007.&lt;img src="http://c.services.spaces.live.com/CollectionWebService/c.gif?cid=8641928114040532142&amp;page=RSS%3a+Share+what+you're+working+on+and+what+you'd+like+to+hear+about&amp;referrer=" width="1px" height="1px" border="0" alt=""&gt;&lt;img style="position:absolute" alt="" width="0px" height="0px" src="http://c.live.com/c.gif?NC=31263&amp;amp;NA=1149&amp;amp;PI=73329&amp;amp;RF=&amp;amp;DI=3919&amp;amp;PS=85545&amp;amp;TP=xna101.spaces.live.com&amp;amp;GT1=xna101"&gt;</description><comments>http://xna101.spaces.live.com/Blog/cns!77EE4BD533D8ECAE!252.entry#comment</comments><guid isPermaLink="true">http://xna101.spaces.live.com/Blog/cns!77EE4BD533D8ECAE!252.entry</guid><pubDate>Fri, 15 Dec 2006 03:46:22 GMT</pubDate><slash:comments>8</slash:comments><msn:type>blogentry</msn:type><live:type>blogentry</live:type><live:typelabel>Blog entry</live:typelabel><wfw:commentRss>http://xna101.spaces.live.com/blog/cns!77EE4BD533D8ECAE!252/comments/feed.rss</wfw:commentRss><wfw:comment>http://xna101.spaces.live.com/Blog/cns!77EE4BD533D8ECAE!252.entry#comment</wfw:comment><dcterms:modified>2006-12-15T05:22:29Z</dcterms:modified></item><item><title>Some great information about SpriteBatches</title><link>http://xna101.spaces.live.com/Blog/cns!77EE4BD533D8ECAE!251.entry</link><description>&lt;p&gt;Shawn Hargreaves of the XNA development team has posted a very informative blog entry of what you can do to improve the performance of drawing 2D sprites in your game. You can read the post here: &lt;a title="http://blogs.msdn.com/shawnhar/archive/2006/12/13/spritebatch-and-spritesortmode.aspx" href="http://blogs.msdn.com/shawnhar/archive/2006/12/13/spritebatch-and-spritesortmode.aspx"&gt;http://blogs.msdn.com/shawnhar/archive/2006/12/13/spritebatch-and-spritesortmode.aspx&lt;/a&gt; 
&lt;p&gt;He also gives a very useful piece of advice...&amp;quot;remember that optimizing is only worth doing after you really do run into performance problems&amp;quot;. 
&lt;p&gt;I encourage you to check it out and to read the other informative posts he has on XNA.
&lt;p&gt;UPDATE: This has turned into a 3 part series by Shawn and it really gives good insight into how SpriteBatches work and can be optimized. Great reading.&lt;img src="http://c.services.spaces.live.com/CollectionWebService/c.gif?cid=8641928114040532142&amp;page=RSS%3a+Some+great+information+about+SpriteBatches&amp;referrer=" width="1px" height="1px" border="0" alt=""&gt;&lt;img style="position:absolute" alt="" width="0px" height="0px" src="http://c.live.com/c.gif?NC=31263&amp;amp;NA=1149&amp;amp;PI=73329&amp;amp;RF=&amp;amp;DI=3919&amp;amp;PS=85545&amp;amp;TP=xna101.spaces.live.com&amp;amp;GT1=xna101"&gt;</description><comments>http://xna101.spaces.live.com/Blog/cns!77EE4BD533D8ECAE!251.entry#comment</comments><guid isPermaLink="true">http://xna101.spaces.live.com/Blog/cns!77EE4BD533D8ECAE!251.entry</guid><pubDate>Thu, 14 Dec 2006 20:52:42 GMT</pubDate><slash:comments>4</slash:comments><msn:type>blogentry</msn:type><live:type>blogentry</live:type><live:typelabel>Blog entry</live:typelabel><wfw:commentRss>http://xna101.spaces.live.com/blog/cns!77EE4BD533D8ECAE!251/comments/feed.rss</wfw:commentRss><wfw:comment>http://xna101.spaces.live.com/Blog/cns!77EE4BD533D8ECAE!251.entry#comment</wfw:comment><dcterms:modified>2006-12-15T04:07:16Z</dcterms:modified></item><item><title>Lesson 23: He shoots, he scores!</title><link>http://xna101.spaces.live.com/Blog/cns!77EE4BD533D8ECAE!245.entry</link><description>&lt;p&gt;This lesson focuses on adding collision handling for the goal mouth and goal scoring logic. &lt;p&gt;Source code for this lesson: &lt;a href="http://www.bluerosegames.com/brg/XnaLesson23.zip"&gt;http://www.bluerosegames.com/brg/XnaLesson23.zip&lt;/a&gt;  &lt;p&gt;I promise this will be easier to follow that the last one, since we will be using the existing collision routines to handle the goal areas. To handle the goal areas, we need some new logic. This new logic needs to: &lt;ul&gt; &lt;li&gt;Detect if the puck is in the goal area so that we can override the wall collision logic.  &lt;li&gt;Allow the puck to pass through the goal area if it doesn't collide with any walls.  &lt;li&gt;Handle the goal post collisions  &lt;li&gt;Detect if the puck has completely left the playing surface, increasing the score for the scoring player, and putting the puck back on the playing surface.&lt;/ul&gt; &lt;p&gt;It's a common practice in programming in general and game programming in particular to do less processor intensive comparisons on big chunks first and then get into finer detail if necessary. The goal mouth is 16 inches wide, and so when the center of the puck is anywhere in the 16 inch strip down the middle of the table, we can do something else instead of the default wall collision checking. In this collision checking for the middle strip of the table can first check to see if the puck is close enough to either goal mouth to be in danger of colliding with part of the goal by doing a simple check on the Z component of the position, and if it's not, we're done with the wall collision checks.  &lt;p&gt;If it is close enough on the Z axis to potentially collide with part of the goal, we can then do a collision check with the &amp;quot;goal posts&amp;quot; which are actually just the corners of the wall on either side of the goal mouth. Now this is where it gets interesting. Since the puck is round, and only a single point of its exterior will hit the goal post, we can treat each goal post as a rigid round object of radius 0 and do exactly the same calls into the CollisionHandler class that we did for the paddle-puck collisions.  &lt;p&gt;In order to not hard-code the width of the goal mouth, let's add a Field to the HockeyTable class to store the value. We will actually store the radius of the goal mouth (half the width) to make calculations simpler. Add the declaration to the HockeyTable class as follows: &lt;p&gt;&lt;font face="Courier New" color="#0000ff"&gt;public float GoalRadius = 8f;&lt;/font&gt; &lt;p&gt;Now let's declare the RoundObjects for the goal posts. Since they do not move or change, we can declare and initialize them once in the Game1 class and then reference them where needed. There are four goal posts but there are really two groups of two. The groups are the posts for the player goal and for the computer goal, and there are two goal posts for each goal. In lesson 15 &lt;a title="http://xna101.spaces.live.com/blog/cns!77EE4BD533D8ECAE!159.entry" href="http://xna101.spaces.live.com/blog/cns!77EE4BD533D8ECAE!159.entry"&gt;http://xna101.spaces.live.com/blog/cns!77EE4BD533D8ECAE!159.entry&lt;/a&gt; we discussed arrays and loops. The arrays were actually one dimensional arrays. In C# you can have multi-dimensional arrays, where it takes more than one index to point to a single array element. For the goal post RoundObjects it makes sense to store them in a two dimensional array of size 2 by 2. We will declare the array as a Field of the Game1 class as follows: &lt;p&gt;&lt;font face="Courier New" color="#0000ff"&gt;RoundObject[,] goalPosts = new RoundObject[2,2];&lt;/font&gt; &lt;p&gt;Notice the slightly different format for declaring a multidimensional array. Now in the Game1.Initialize() method, add the following at the end just before the base.Initialize() call: &lt;p&gt;&lt;font face="Courier New" color="#0000ff"&gt;goalPosts[0, 0] = new RoundObject(new Vector3(hockeyTable.GoalRadius, 0, hockeyTable.Depth / 2), Vector3.Zero, 0f, 0f, true); // player goal post 1&lt;br&gt;goalPosts[0, 1] = new RoundObject(new Vector3(-hockeyTable.GoalRadius, 0, hockeyTable.Depth / 2), Vector3.Zero, 0f, 0f, true); // player goal post 2&lt;br&gt;goalPosts[1, 0] = new RoundObject(new Vector3(hockeyTable.GoalRadius, 0, -hockeyTable.Depth / 2), Vector3.Zero, 0f, 0f, true); // computer goal post 1&lt;br&gt;goalPosts[1, 1] = new RoundObject(new Vector3(-hockeyTable.GoalRadius, 0, -hockeyTable.Depth / 2), Vector3.Zero, 0f, 0f, true); // computer goal post 2&lt;/font&gt; &lt;p&gt;So all of the goal posts RoundObjects are initialized based on their respective positions and with a velocity of 0, weight of 0, and IsRigid=true. The weight can be 0 or any other number because the post is rigid and unmoving so only the puck figures into the conservation of momentum. &lt;p&gt;Instead of adding a whole new chunk of code to the Game1.CheckForCollisions() method to handle the goal mouth collisions, let's create a new method in the Game1 class that we can call from the Game1.CheckForCollisions() method: &lt;p&gt;&lt;font face="Courier New" color="#0000ff"&gt;bool CheckForGoalMouthCollisions(float seconds, RoundObject roPuck)&lt;br&gt;{&lt;br&gt;   Vector3 p = roPuck.Position;&lt;br&gt;   float goalCollisionDepth = hockeyTable.Depth / 2f - puck.Radius;&lt;br&gt;   float goalRadius = hockeyTable.GoalRadius;&lt;br&gt;   int goalIndex;&lt;br&gt;   if (p.Z &amp;gt; goalCollisionDepth)&lt;br&gt;   {&lt;br&gt;      // set index to 0 for player's goal posts&lt;br&gt;      goalIndex = 0;&lt;br&gt;   }&lt;br&gt;   else if (p.Z &amp;lt; -goalCollisionDepth)&lt;br&gt;   {&lt;br&gt;      // set index to 1 for computer's goal posts&lt;br&gt;      goalIndex = 1;&lt;br&gt;   }&lt;br&gt;   else&lt;br&gt;   {&lt;br&gt;      return false;&lt;br&gt;   }&lt;br&gt;   for (int i = 0; i &amp;lt; 2; i++)&lt;br&gt;   {&lt;br&gt;      if (CollisionHandler.CheckForCollisionXZ(roPuck, goalPosts[goalIndex, i]) == true)&lt;br&gt;      {&lt;br&gt;         CollisionHandler.HandleCollisionXZ(ref roPuck, ref goalPosts[goalIndex, i]);&lt;br&gt;         puck.Velocity = roPuck.Velocity;&lt;br&gt;         return true;&lt;br&gt;      }&lt;br&gt;   }&lt;br&gt;   return false;&lt;br&gt;}&lt;/font&gt; &lt;p&gt;So first we calculate the &amp;quot;safe zone&amp;quot; of the table, where there is no chance for a goal mouth collision. This is stored in goalCollisionDepth and is equal to half of the depth of the table minus the puck radius. Then based on this number, we can tell if it's close enough to the player's goal to collide, then the computer's goal, then if neither of those are true, we know that there wasn't a wall collision, and we can return false. Now in the goalPosts array, the player's goal posts have a first array index of 0, and the computer's goal posts have a first array index of 1. So by setting the array indexer variable appropriately we can use the same code to handle checking and handling both goal's collisions. Then we have a for loop. The first time through the loop, i will be 0, and the second time i will be 1. So by doing this loop and using i as our second array indexer, we can check for collisions with both goal posts an handle them appropriately. If there is a collision with a goal post, we don't need to check the other, since it is physically impossible to collide with both goal posts at the same time. If there is a collision, we return true to indicate there was a collision. &lt;p&gt;Now to modify Game1.CheckForCollisions() to call this method. Remember that we only want to call it if we are in the middle 16 inches of the table, or X values of -8 to 8. The new CheckForCollisions method will look as follows (changes are in red): &lt;p&gt;&lt;font color="#0000ff"&gt;&lt;font face="Courier New"&gt;CollisionStates CheckForCollisions(float seconds, RoundObject roPuck, RoundObject roPlayerPaddle, RoundObject roComputerPaddle)&lt;br&gt;{&lt;br&gt;   CollisionStates collision = CollisionStates.None;&lt;br&gt;   float maxX = (hockeyTable.Width / 2) - puck.Radius;&lt;br&gt;   float minX = -maxX;&lt;br&gt;   float maxZ = (hockeyTable.Depth / 2) - puck.Radius;&lt;br&gt;   float minZ = -maxZ;&lt;br&gt;   Vector3 p = roPuck.Position;&lt;br&gt;   if (CollisionHandler.CheckForCollisionXZ(roPuck, roPlayerPaddle) == true) &lt;br&gt;   {&lt;br&gt;      CollisionHandler.HandleCollisionXZ(ref roPlayerPaddle, ref roPuck);&lt;br&gt;      puck.Velocity = roPuck.Velocity;&lt;br&gt;      collision |= CollisionStates.PlayerPaddle;&lt;br&gt;   }&lt;br&gt;   if (CollisionHandler.CheckForCollisionXZ(roPuck, roComputerPaddle) == true)&lt;br&gt;   {&lt;br&gt;      CollisionHandler.HandleCollisionXZ(ref roComputerPaddle, ref roPuck);&lt;br&gt;      puck.Velocity = roPuck.Velocity;&lt;br&gt;      collision |= CollisionStates.ComputerPaddle;&lt;br&gt;   }&lt;br&gt;   p = puck.Position + puck.Velocity * seconds;&lt;br&gt;   roPuck.Position = p;&lt;br&gt;&lt;/font&gt;&lt;font face="Courier New"&gt;&lt;font color="#ff0000"&gt;   if (p.X &amp;lt; hockeyTable.GoalRadius &amp;amp;&amp;amp; p.X &amp;gt; -hockeyTable.GoalRadius)&lt;br&gt;   {&lt;br&gt;      if (CheckForGoalMouthCollisions(seconds, roPuck) == true)&lt;br&gt;      {&lt;br&gt;         collision |= CollisionStates.Wall;&lt;br&gt;      }&lt;br&gt;   }&lt;br&gt;   else&lt;br&gt;   {&lt;br&gt;&lt;/font&gt;      if (p.X &amp;lt; minX || p.X &amp;gt; maxX)&lt;br&gt;      {&lt;br&gt;         collision |= CollisionStates.Wall;&lt;br&gt;         puck.Velocity.X = -puck.Velocity.X;&lt;br&gt;      }&lt;br&gt;      if (p.Z &amp;lt; minZ || p.Z &amp;gt; maxZ)&lt;br&gt;      {&lt;br&gt;         collision |= CollisionStates.Wall;&lt;br&gt;         puck.Velocity.Z = -puck.Velocity.Z;&lt;br&gt;      }&lt;br&gt;&lt;font color="#ff0000"&gt;   }&lt;br&gt;&lt;/font&gt;   if (puck.Velocity.Length() &amp;gt; 125f)&lt;br&gt;   {&lt;br&gt;      puck.Velocity *= 125f / puck.Velocity.Length();&lt;br&gt;   }&lt;br&gt;   return collision;&lt;br&gt;}&lt;/font&gt;&lt;/font&gt; &lt;p&gt;Notice the new conditional logic which checks to see if the puck is in the middle of the table, and if so, calls our new method and if it returns true, we know there was a goal mouth collision and we can set the collision variable appropriately. If the puck is not in the middle of the table, we do what we always did before. &lt;p&gt;Now if you run the program, if the puck goes into a goal, it will never come out. We need logic to determine if a goal was scored, and to act appropriately. Even though we're not displaying the score yet, we can get ready for it. In the Game1 class, declare the following Fields: &lt;p&gt;int playerScore = 0;&lt;br&gt;int computerScore = 0; &lt;p&gt;Now for the code to check if a goal has taken place and if so, to handle it. Let's put this code in a new method called Game1.CheckForGoal() like this: &lt;p&gt;&lt;font face="Courier New" color="#0000ff"&gt;bool CheckForGoal(Vector3 puckPosition)&lt;br&gt;{&lt;br&gt;   float scoringDistance = hockeyTable.Depth / 2f + puck.Radius;&lt;br&gt;   bool scored = false;&lt;br&gt;   if (puckPosition.Z &amp;gt; scoringDistance)&lt;br&gt;   {&lt;br&gt;      computerScore++;&lt;br&gt;      ResetPuck(true);&lt;br&gt;      scored = true; &lt;br&gt;   }&lt;br&gt;   else if (puckPosition.Z &amp;lt; -scoringDistance)&lt;br&gt;   {&lt;br&gt;      playerScore++;&lt;br&gt;      ResetPuck(false);&lt;br&gt;      scored = true;&lt;br&gt;   }&lt;br&gt;   if (scored==false) return scored;&lt;br&gt;   return scored;&lt;br&gt;}&lt;/font&gt; &lt;p&gt;So if the center of the puck is further away from the center of the table along the Z axis than half of the table depth plus the radius of the puck, then we know a goal hs occurred. Based on whether it's negative or positive, we know which goal was scored upon and can update the score appropriately. We then need to get the puck back on the table so we can play some more. For this, we'll create a Game1.ResetPuck method, which will be passed a 0 if we want the puck to be placed on the player's side and 1 if we want it to be placed on the computer's side. &lt;p&gt;&lt;font face="Courier New" color="#0000ff"&gt;void ResetPuck(bool player)&lt;br&gt;{&lt;br&gt;   puck.Velocity = Vector3.Zero;&lt;br&gt;   if (player == true)&lt;br&gt;   {&lt;br&gt;      puck.Position = new Vector3(0f, 0f, hockeyTable.Depth / 5f);&lt;br&gt;   }&lt;br&gt;   else&lt;br&gt;   {&lt;br&gt;      puck.Position = new Vector3(0f, 0f, -hockeyTable.Depth / 5f);&lt;br&gt;   }&lt;br&gt;   if (Vector3.Distance(puck.Position, playerPaddle.Position) &amp;lt; puck.Radius + playerPaddle.CollisionRadius)&lt;br&gt;   {&lt;br&gt;      puck.Position += new Vector3(0, 0, -playerPaddle.Radius * 2.5f);&lt;br&gt;   }&lt;br&gt;   if (Vector3.Distance(puck.Position, computerPaddle.Position) &amp;lt; puck.Radius + computerPaddle.CollisionRadius)&lt;br&gt;   {&lt;br&gt;      puck.Position += new Vector3(0, 0, computerPaddle.Radius * 2.5f);&lt;br&gt;   }&lt;br&gt;}&lt;/font&gt; &lt;p&gt;So we're setting the puck's velocity to 0, and then putting the puck on one side or the other. There is, however, one problem. The place we're putting the puck may already be occupied by the paddle. So the loast 2 conditionals check to see if the distance between the centers of the puck and the paddle is less than the combined radius of the puck and the paddle indicating an overlap, and if so, reposition the puck to a position 2.5 paddle radius' away along the Z axis. &lt;p&gt;Now in the Game1.Update(), in the loop after we declare and initialize the next puck position, add the following: &lt;p&gt;&lt;font face="Courier New" color="#0000ff"&gt;if (CheckForGoal(p) == true)&lt;br&gt;{&lt;br&gt;   break;&lt;br&gt;}&lt;/font&gt; &lt;p&gt;if we have a goal scored, we get out of the update loop and start all over again next time Update is called. The &lt;strong&gt;break &lt;/strong&gt;statement says that we want to exit the loop immediately and continue execution with the next statement after the loop. &lt;p&gt;Now in the Game1.Initialize() method, for testing purposes a few lessons ago, we added some code which positioned the puck at center ice and gave it a velocity. This was so that we could test out the wall bouncing logic since we couldn't hit the puck with the paddle yet. Now we can replace that code with a call to ResetPuck, passing 0 to position the puck on the player's side to start. Replace the code in Game1.Initialize() that sets the puck's position and velocity with the following: &lt;p&gt;&lt;font face="Courier New" color="#0000ff"&gt;ResetPuck(true);&lt;/font&gt; &lt;p&gt;Run the program again. You should now be able to score goals. One problem. Once we score on the computer's goal, we have no way to keep playing right now since the computer paddle doesn't move. As a temporary fix, add the following to the Game1.HandleMouse() method just after the MouseState ms = Mouse.GetState(); call: &lt;p&gt;&lt;font face="Courier New" color="#0000ff"&gt;if (ms.RightButton == ButtonState.Pressed) &lt;br&gt;{&lt;br&gt;   &lt;/font&gt;&lt;font face="Courier New" color="#0000ff"&gt;ResetPuck(true);&lt;br&gt;}&lt;/font&gt; &lt;p&gt;where if we right click the mouse, the puck will be put back on our side so we can keep playing. Run the program again and see how it behaves.&lt;img src="http://c.services.spaces.live.com/CollectionWebService/c.gif?cid=8641928114040532142&amp;page=RSS%3a+Lesson+23%3a+He+shoots%2c+he+scores!&amp;referrer=" width="1px" height="1px" border="0" alt=""&gt;&lt;img style="position:absolute" alt="" width="0px" height="0px" src="http://c.live.com/c.gif?NC=31263&amp;amp;NA=1149&amp;amp;PI=73329&amp;amp;RF=&amp;amp;DI=3919&amp;amp;PS=85545&amp;amp;TP=xna101.spaces.live.com&amp;amp;GT1=xna101"&gt;</description><comments>http://xna101.spaces.live.com/Blog/cns!77EE4BD533D8ECAE!245.entry#comment</comments><guid isPermaLink="true">http://xna101.spaces.live.com/Blog/cns!77EE4BD533D8ECAE!245.entry</guid><pubDate>Wed, 13 Dec 2006 03:24:46 GMT</pubDate><slash:comments>16</slash:comments><msn:type>blogentry</msn:type><live:type>blogentry</live:type><live:typelabel>Blog entry</live:typelabel><wfw:commentRss>http://xna101.spaces.live.com/blog/cns!77EE4BD533D8ECAE!245/comments/feed.rss</wfw:commentRss><wfw:comment>http://xna101.spaces.live.com/Blog/cns!77EE4BD533D8ECAE!245.entry#comment</wfw:comment><dcterms:modified>2006-12-13T03:24:46Z</dcterms:modified></item><item><title>XNA 1.0 Has Arrived!</title><link>http://xna101.spaces.live.com/Blog/cns!77EE4BD533D8ECAE!240.entry</link><description>&lt;p&gt;David Weller has announced on his blog &lt;a title="http://letskilldave.com/archive/2006/12/11/XNA-Launch-Day-is-here_2100_.aspx" href="http://letskilldave.com/archive/2006/12/11/XNA-Launch-Day-is-here_2100_.aspx"&gt;http://letskilldave.com/archive/2006/12/11/XNA-Launch-Day-is-here_2100_.aspx&lt;/a&gt; that XNA 1.0 is now available for download. I have tested Dr. Popper against XNA 1.0 and it required a rebuild but no other changes. I have also tested the sample code for the lessons to make sure they all work as well. Everything looks fine, let me know if you have any issues. Enjoy!&lt;img src="http://c.services.spaces.live.com/CollectionWebService/c.gif?cid=8641928114040532142&amp;page=RSS%3a+XNA+1.0+Has+Arrived!&amp;referrer=" width="1px" height="1px" border="0" alt=""&gt;&lt;img style="position:absolute" alt="" width="0px" height="0px" src="http://c.live.com/c.gif?NC=31263&amp;amp;NA=1149&amp;amp;PI=73329&amp;amp;RF=&amp;amp;DI=3919&amp;amp;PS=85545&amp;amp;TP=xna101.spaces.live.com&amp;amp;GT1=xna101"&gt;</description><comments>http://xna101.spaces.live.com/Blog/cns!77EE4BD533D8ECAE!240.entry#comment</comments><guid isPermaLink="true">http://xna101.spaces.live.com/Blog/cns!77EE4BD533D8ECAE!240.entry</guid><pubDate>Mon, 11 Dec 2006 14:27:25 GMT</pubDate><slash:comments>8</slash:comments><msn:type>blogentry</msn:type><live:type>blogentry</live:type><live:typelabel>Blog entry</live:typelabel><wfw:commentRss>http://xna101.spaces.live.com/blog/cns!77EE4BD533D8ECAE!240/comments/feed.rss</wfw:commentRss><wfw:comment>http://xna101.spaces.live.com/Blog/cns!77EE4BD533D8ECAE!240.entry#comment</wfw:comment><dcterms:modified>2006-12-11T14:27:25Z</dcterms:modified></item><item><title>Custom List: Links</title><link>http://xna101.spaces.live.com/Lists/cns!77EE4BD533D8ECAE!104</link><description>&lt;p&gt;Links&lt;/p&gt;&lt;div&gt;&lt;ul&gt;&lt;li&gt;&lt;p&gt;&lt;a href="http://www.freelunchdesign.com"&gt;Free Lunch Design&lt;/a&gt;&lt;/p&gt;&lt;p&gt;Download great free games &amp;#40;not XNA&amp;#41; for the PC&lt;/p&gt;&lt;/li&gt;&lt;li&gt;&lt;p&gt;&lt;a href="http://www.bluerosegames.com"&gt;Dr. Popper Game for XNA 1.0&lt;/a&gt;&lt;/p&gt;&lt;p&gt;Download the game and source code free&lt;/p&gt;&lt;/li&gt;&lt;li&gt;&lt;p&gt;&lt;a href="http://silverlightrocks.com&amp;#47;Community&amp;#47;blogs&amp;#47;silverlight_games_101&amp;#47;"&gt;Silverlight Games 101&lt;/a&gt;&lt;/p&gt;&lt;p&gt;Beginning Game Programming in Silverlight 1.1&lt;/p&gt;&lt;/li&gt;&lt;li&gt;&lt;p&gt;&lt;a href="http://www.lutzfamilylaw.com"&gt;Tampa Divorce Lawyer&lt;/a&gt;&lt;/p&gt;&lt;p&gt;The Law Offices of Roberta Kohn, PA provides service in the areas of divorce, family and real estate law for the Tampa Bay area and the state of Florida.&lt;/p&gt;&lt;/li&gt;&lt;li&gt;&lt;p&gt;&lt;a href="http://www.teamzonesports.com"&gt;Free Team Websites&lt;/a&gt;&lt;/p&gt;&lt;p&gt;Create a community for your team or group. Share information, schedule, photos, and videos at this free team management site.&lt;/p&gt;&lt;/li&gt;&lt;/ul&gt;&lt;/div&gt;&lt;img src="http://c.services.spaces.live.com/CollectionWebService/c.gif?cid=8641928114040532142&amp;page=RSS%3a+Custom+List%3a+Links&amp;referrer=" width="1px" height="1px" border="0" alt=""&gt;&lt;img style="position:absolute" alt="" width="0px" height="0px" src="http://c.live.com/c.gif?NC=31263&amp;amp;NA=1149&amp;amp;PI=73329&amp;amp;RF=&amp;amp;DI=3919&amp;amp;PS=85545&amp;amp;TP=xna101.spaces.live.com&amp;amp;GT1=xna101"&gt;</description><guid isPermaLink="false">cns!77EE4BD533D8ECAE!104</guid><pubDate>Thu, 17 Jul 2008 14:37:32 GMT</pubDate><msn:type>list</msn:type><live:type>list</live:type><live:typelabel>List</live:typelabel><cf:itemRSS>http://xna101.spaces.live.com/Lists/cns!77EE4BD533D8ECAE!104/feed.rss</cf:itemRSS><dcterms:modified>2008-07-17T14:37:32Z</dcterms:modified></item><item><title>Book List: Books</title><link>http://xna101.spaces.live.com/Lists/cns!77EE4BD533D8ECAE!225</link><description>&lt;p&gt;Books&lt;/p&gt;&lt;div&gt;&lt;ul&gt;&lt;li&gt;&lt;p&gt;&lt;a href="http://www.amazon.com&amp;#47;gp&amp;#47;redirect.html&amp;#37;3FASIN&amp;#61;1598220160&amp;#37;26tag&amp;#61;xna101-20&amp;#37;26lcode&amp;#61;sp1&amp;#37;26cID&amp;#61;2025&amp;#37;26ccmID&amp;#61;165953&amp;#37;26location&amp;#61;&amp;#47;o&amp;#47;ASIN&amp;#47;1598220160&amp;#37;253FSubscriptionId&amp;#61;1KDHEGDEXZNBKYAEECR2"&gt;Frank Luna: &amp;#39;Introduction to 3D Game Programming with Direct X 9.0c&amp;#58; A Shader Approach&amp;#39;&lt;/a&gt;&lt;/p&gt;&lt;p&gt;&lt;a href="http://www.amazon.com&amp;#47;gp&amp;#47;redirect.html&amp;#37;3FASIN&amp;#61;1598220160&amp;#37;26tag&amp;#61;xna101-20&amp;#37;26lcode&amp;#61;sp1&amp;#37;26cID&amp;#61;2025&amp;#37;26ccmID&amp;#61;165953&amp;#37;26location&amp;#61;&amp;#47;o&amp;#47;ASIN&amp;#47;1598220160&amp;#37;253FSubscriptionId&amp;#61;1KDHEGDEXZNBKYAEECR2"&gt;&lt;img src="http://ec1.images-amazon.com&amp;#47;images&amp;#47;P&amp;#47;1598220160.01._SCTHUMBZZZ_.jpg" valign="top" border="0"&gt;&lt;/a&gt;&lt;/p&gt;&lt;/li&gt;&lt;li&gt;&lt;p&gt;&lt;a href="http://www.amazon.com&amp;#47;gp&amp;#47;redirect.html&amp;#37;3FASIN&amp;#61;007149071X&amp;#37;26tag&amp;#61;xna101-20&amp;#37;26lcode&amp;#61;sp1&amp;#37;26cID&amp;#61;2025&amp;#37;26ccmID&amp;#61;165953&amp;#37;26location&amp;#61;&amp;#47;o&amp;#47;ASIN&amp;#47;007149071X&amp;#37;253FSubscriptionId&amp;#61;1KDHEGDEXZNBKYAEECR2"&gt;Stephen Cawood: Microsoft XNA Game Studio Creators Guide&lt;/a&gt;&lt;/p&gt;&lt;p&gt;&lt;a href="http://www.amazon.com&amp;#47;gp&amp;#47;redirect.html&amp;#37;3FASIN&amp;#61;007149071X&amp;#37;26tag&amp;#61;xna101-20&amp;#37;26lcode&amp;#61;sp1&amp;#37;26cID&amp;#61;2025&amp;#37;26ccmID&amp;#61;165953&amp;#37;26location&amp;#61;&amp;#47;o&amp;#47;ASIN&amp;#47;007149071X&amp;#37;253FSubscriptionId&amp;#61;1KDHEGDEXZNBKYAEECR2"&gt;&lt;img src="http://ec1.images-amazon.com&amp;#47;images&amp;#47;P&amp;#47;007149071X.01._SCTHUMBZZZ_.jpg" valign="top" border="0"&gt;&lt;/a&gt;&lt;/p&gt;&lt;/li&gt;&lt;li&gt;&lt;p&gt;&lt;a href="http://www.amazon.com&amp;#47;gp&amp;#47;redirect.html&amp;#37;3FASIN&amp;#61;0672329646&amp;#37;26tag&amp;#61;xna101-20&amp;#37;26lcode&amp;#61;sp1&amp;#37;26cID&amp;#61;2025&amp;#37;26ccmID&amp;#61;165953&amp;#37;26location&amp;#61;&amp;#47;o&amp;#47;ASIN&amp;#47;0672329646&amp;#37;253FSubscriptionId&amp;#61;1KDHEGDEXZNBKYAEECR2"&gt;Chad Carter: Microsoft&amp;#40;R&amp;#41; XNA&amp;#40;TM&amp;#41; Unleashed&amp;#58; Graphics and Game Programming for Xbox 360 and Windows &amp;#40;Unleashed&amp;#41;&lt;/a&gt;&lt;/p&gt;&lt;p&gt;&lt;a href="http://www.amazon.com&amp;#47;gp&amp;#47;redirect.html&amp;#37;3FASIN&amp;#61;0672329646&amp;#37;26tag&amp;#61;xna101-20&amp;#37;26lcode&amp;#61;sp1&amp;#37;26cID&amp;#61;2025&amp;#37;26ccmID&amp;#61;165953&amp;#37;26location&amp;#61;&amp;#47;o&amp;#47;ASIN&amp;#47;0672329646&amp;#37;253FSubscriptionId&amp;#61;1KDHEGDEXZNBKYAEECR2"&gt;&lt;img src="http://ec1.images-amazon.com&amp;#47;images&amp;#47;I&amp;#47;11UTNC1l0SL.jpg" valign="top" border="0"&gt;&lt;/a&gt;&lt;/p&gt;&lt;/li&gt;&lt;li&gt;&lt;p&gt;&lt;a href="http://www.amazon.com&amp;#47;gp&amp;#47;redirect.html&amp;#37;3FASIN&amp;#61;0470126779&amp;#37;26tag&amp;#61;xna101-20&amp;#37;26lcode&amp;#61;sp1&amp;#37;26cID&amp;#61;2025&amp;#37;26ccmID&amp;#61;165953&amp;#37;26location&amp;#61;&amp;#47;o&amp;#47;ASIN&amp;#47;0470126779&amp;#37;253FSubscriptionId&amp;#61;1KDHEGDEXZNBKYAEECR2"&gt;B. Nitschke: Professional XNA Game Programming&lt;/a&gt;&lt;/p&gt;&lt;p&gt;&lt;a href="http://www.amazon.com&amp;#47;gp&amp;#47;redirect.html&amp;#37;3FASIN&amp;#61;0470126779&amp;#37;26tag&amp;#61;xna101-20&amp;#37;26lcode&amp;#61;sp1&amp;#37;26cID&amp;#61;2025&amp;#37;26ccmID&amp;#61;165953&amp;#37;26location&amp;#61;&amp;#47;o&amp;#47;ASIN&amp;#47;0470126779&amp;#37;253FSubscriptionId&amp;#61;1KDHEGDEXZNBKYAEECR2"&gt;&lt;img src="http://ec1.images-amazon.com&amp;#47;images&amp;#47;P&amp;#47;0470126779.01._SCTHUMBZZZ_V43384270_.jpg" valign="top" border="0"&gt;&lt;/a&gt;&lt;/p&gt;&lt;/li&gt;&lt;/ul&gt;&lt;/div&gt;&lt;img src="http://c.services.spaces.live.com/CollectionWebService/c.gif?cid=8641928114040532142&amp;page=RSS%3a+Book+List%3a+Books&amp;referrer=" width="1px" height="1px" border="0" alt=""&gt;&lt;img style="position:absolute" alt="" width="0px" height="0px" src="http://c.live.com/c.gif?NC=31263&amp;amp;NA=1149&amp;amp;PI=73329&amp;amp;RF=&amp;amp;DI=3919&amp;amp;PS=85545&amp;amp;TP=xna101.spaces.live.com&amp;amp;GT1=xna101"&gt;</description><guid isPermaLink="false">cns!77EE4BD533D8ECAE!225</guid><pubDate>Wed, 08 Aug 2007 16:04:20 GMT</pubDate><msn:type>booklist</msn:type><live:type>booklist</live:type><live:typelabel>Book list</live:typelabel><cf:itemRSS>http://xna101.spaces.live.com/Lists/cns!77EE4BD533D8ECAE!225/feed.rss</cf:itemRSS><dcterms:modified>2007-08-08T16:04:20Z</dcterms:modified></item><item><title>Custom List: XNA Community</title><link>http://xna101.spaces.live.com/Lists/cns!77EE4BD533D8ECAE!206</link><description>&lt;p&gt;XNA Community&lt;/p&gt;&lt;div&gt;&lt;ul&gt;&lt;li&gt;&lt;p&gt;&lt;a href="http://www.xnalinks.net"&gt;XNA Links.Net&lt;/a&gt;&lt;/p&gt;&lt;p&gt;Mega List of XNA helpful links.&lt;/p&gt;&lt;/li&gt;&lt;/ul&gt;&lt;/div&gt;&lt;img src="http://c.services.spaces.live.com/CollectionWebService/c.gif?cid=8641928114040532142&amp;page=RSS%3a+Custom+List%3a+XNA+Community&amp;referrer=" width="1px" height="1px" border="0" alt=""&gt;&lt;img style="position:absolute" alt="" width="0px" height="0px" src="http://c.live.com/c.gif?NC=31263&amp;amp;NA=1149&amp;amp;PI=73329&amp;amp;RF=&amp;amp;DI=3919&amp;amp;PS=85545&amp;amp;TP=xna101.spaces.live.com&amp;amp;GT1=xna101"&gt;</description><guid isPermaLink="false">cns!77EE4BD533D8ECAE!206</guid><pubDate>Thu, 15 Feb 2007 02:27:00 GMT</pubDate><msn:type>list</msn:type><live:type>list</live:type><live:typelabel>List</live:typelabel><cf:itemRSS>http://xna101.spaces.live.com/Lists/cns!77EE4BD533D8ECAE!206/feed.rss</cf:itemRSS><dcterms:modified>2007-02-15T02:27:00Z</dcterms:modified></item></channel></rss>