<?xml version="1.0" encoding="UTF-8" ?>
<?xml-stylesheet type="text/xsl" href="http://blogs.msdn.com/utility/FeedStylesheets/rss.xsl" media="screen"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:wfw="http://wellformedweb.org/CommentAPI/"><channel><title>The Right Moves : PGC</title><link>http://blogs.msdn.com/ben_anderson/archive/tags/PGC/default.aspx</link><description>Tags: PGC</description><dc:language>en-US</dc:language><generator>CommunityServer 2.1 SP1 (Build: 61025.2)</generator><item><title>Moving the Popfly Game Creator engine from Silverlight 1 to 2</title><link>http://blogs.msdn.com/ben_anderson/archive/2008/12/05/moving-the-popfly-game-creator-engine-from-silverlight-1-to-2.aspx</link><pubDate>Sat, 06 Dec 2008 05:52:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:9180923</guid><dc:creator>Ben Anderson</dc:creator><slash:comments>0</slash:comments><comments>http://blogs.msdn.com/ben_anderson/comments/9180923.aspx</comments><wfw:commentRss>http://blogs.msdn.com/ben_anderson/commentrss.aspx?PostID=9180923</wfw:commentRss><description>&lt;p&gt;In our most recent &lt;a href="http://www.popfly.com" target="_blank" mce_href="http://www.popfly.com"&gt;Popfly&lt;/a&gt; update, we shipped the project I’ve been working on for the last couple months (along with Patrick Wong, Tim Rice and help from the rest of the team), which is a fully backwards compatible game engine, completely rewritten from browser based JavaScript rendering using &lt;a href="http://silverlight.net" mce_href="http://silverlight.net"&gt;Silverlight&lt;/a&gt; 1 to a C# based engine using Silverlight 2.&amp;nbsp; As noted &lt;a href="http://popflyteam.spaces.live.com/blog/cns%2151018025071FD37F%21327.entry" target="_blank" mce_href="http://popflyteam.spaces.live.com/blog/cns!51018025071FD37F!327.entry"&gt;elsewhere&lt;/a&gt;, the new engine is a heck of a lot faster than the old (both due to switching to a compiled language from an interpreted one, and due to many efficiency improvements), but the most impressive thing about the switch in my mind is the fact that it’s as fully backwards compatible as any incremental change we’ve made since the original release.&amp;nbsp; Think about it – the engine’s written in C#, but all the custom code is still in JavaScript.&amp;nbsp; &lt;/p&gt;  &lt;p&gt;That is largely thanks to Patrick’s efforts.&amp;nbsp; In order to keep custom code working, what we did was take the current version of the Silverlight version of the &lt;a href="http://www.codeplex.com/sdlsdk" target="_blank" mce_href="http://www.codeplex.com/sdlsdk"&gt;DLR&lt;/a&gt; (the “Silverlight Dynamic Languages SDK”).&amp;nbsp; We did tweak the JavaScript implementation a bit to make code intended to work with the JavaScript Silverlight interfaces play nice with the managed interfaces, but overall, it was pretty much plug and play aside from all the hard work figuring out a largely undocumented piece of prerelease software :) (I think it’s on version 0.4.0 currently).&amp;nbsp; If you haven’t checked it out, the DLR is a pretty slick piece of technology – despite the fact we’re running a bunch of JavaScript code, it’s still miles and away faster than the old engine which ran on the browser’s JavaScript engine (although I’m sure efforts in IE8, Chrome and Firefox 3.1 will narrow the gap).&lt;/p&gt;  &lt;p&gt;What does this mean for you?&amp;nbsp; If your a Popfly game creator, it means a much faster engine that is more consistent from browser to browser.&amp;nbsp; That means you can add more actors and other craziness to your games.&amp;nbsp; If your a software developer with a lot of code in Silverlight 1?&amp;nbsp; Well, for you I’d say it means you should feel free to move to C# and Silverlight 2.&amp;nbsp; It took me a couple months, largely on my own with about a month of help from Patrick to rewrite a large chunk of code that had been developed over the previous year or so by a team that grew from one to three (and occasionally more) devs.&amp;nbsp; The cost was larger than it might have been because I also used it as an opportunity to re-architect and clean up the game engine, and I had to maintain compatibility with a large and complex set of existing data (the thousands of games already on popfly.com).&amp;nbsp; I would expect that for most other Silverlight applications, the cost would be significantly less.&amp;nbsp; What I got out of the experience was the vastly superior tooling experience of C# and Silverlight 2, a huge perf boost by moving to a compiled language, the maintainability of C#, the chance to follow the computer science adage of "throw one away”, and a much better code browsing and IntelliSense experience (again due to the fact that C# is strongly typed and compiled).&amp;nbsp; My advice if your considering a similar move would be to take a look on what code you’re likely to touch again, and if you can see yourself working on it regularly, or if it has strong perf requirements take the leap.&amp;nbsp; &lt;/p&gt;  &lt;p&gt;If you’d like to hear more about Silverlight 2, working with the DLR, the port, or the engine, let me know in the comments and I can go into more details on the areas that interest you.&lt;/p&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=9180923" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/ben_anderson/archive/tags/Popfly+Game+Creator/default.aspx">Popfly Game Creator</category><category domain="http://blogs.msdn.com/ben_anderson/archive/tags/Silverlight/default.aspx">Silverlight</category><category domain="http://blogs.msdn.com/ben_anderson/archive/tags/JavaScript/default.aspx">JavaScript</category><category domain="http://blogs.msdn.com/ben_anderson/archive/tags/PGC/default.aspx">PGC</category></item><item><title>Performance Tips (Part 1)</title><link>http://blogs.msdn.com/ben_anderson/archive/2008/10/13/performance-tips-part-1.aspx</link><pubDate>Mon, 13 Oct 2008 18:54:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:8996804</guid><dc:creator>Ben Anderson</dc:creator><slash:comments>1</slash:comments><comments>http://blogs.msdn.com/ben_anderson/comments/8996804.aspx</comments><wfw:commentRss>http://blogs.msdn.com/ben_anderson/commentrss.aspx?PostID=8996804</wfw:commentRss><description>&lt;P&gt;While we’re constantly working to improve the performance of the &lt;A href="http://www.popfly.com/" target=_blank mce_href="http://www.popfly.com"&gt;&lt;A href="http://www.popfly.com/GameCreator/" target=_blank mce_href="http://www.popfly.com/GameCreator/"&gt;Popfly Game Creator&lt;/A&gt;,&lt;/A&gt; there are a number of tweaks you can make to your games right now to improve your users’ frame rate.&lt;/P&gt;
&lt;P&gt;Right now, there are two main bottlenecks for games created using &lt;A href="http://www.popfly.com/" target=_blank mce_href="http://www.popfly.com"&gt;Popfly&lt;/A&gt; and depending on the characteristics of your game, one or the other can probably help you.&lt;/P&gt;
&lt;P&gt;Today we’ll talk about the biggest perf. hit for most games, which is collision detection between a large number of actors.&amp;nbsp; There are a number of ways to address this.&amp;nbsp; &lt;/P&gt;
&lt;P&gt;The easiest trick is to make as many actors as possible non-solid:&lt;/P&gt;
&lt;P&gt;&lt;A href="http://blogs.msdn.com/blogfiles/ben_anderson/WindowsLiveWriter/PerformanceTipsPart1_B579/non-solid_2.png" mce_href="http://blogs.msdn.com/blogfiles/ben_anderson/WindowsLiveWriter/PerformanceTipsPart1_B579/non-solid_2.png"&gt;&lt;IMG title=non-solid style="BORDER-RIGHT: 0px; BORDER-TOP: 0px; DISPLAY: inline; BORDER-LEFT: 0px; BORDER-BOTTOM: 0px" height=68 alt=non-solid src="http://blogs.msdn.com/blogfiles/ben_anderson/WindowsLiveWriter/PerformanceTipsPart1_B579/non-solid_thumb.png" width=244 border=0 mce_src="http://blogs.msdn.com/blogfiles/ben_anderson/WindowsLiveWriter/PerformanceTipsPart1_B579/non-solid_thumb.png"&gt;&lt;/A&gt; &lt;/P&gt;
&lt;P&gt;This is a per state property, so if your actor has multiple states, make sure you set it for each one.&amp;nbsp; When an actor is non-solid, it’s collision bounds will be drawn in blue instead of red.&amp;nbsp; &lt;/P&gt;
&lt;P&gt;When an actor is non-solid, it will no longer push or get pushed when it collides with other actors.&amp;nbsp; This allows us to skip testing it for collisions except when there is a collision listener whose event includes the actor.&amp;nbsp; Even then we only have to test it against other actors that are included as the other actor on the same event.&amp;nbsp; &lt;/P&gt;
&lt;P&gt;The next approach is to limit the number of actors you use on any scene.&amp;nbsp; While this can lead to a less compelling game, but if your game is bottlenecked on collision checking, it is guaranteed to increase performance.&amp;nbsp; &lt;/P&gt;
&lt;P&gt;If neither of the above is desirable, you can also increase performance by limiting the motion of your actors.&amp;nbsp; When an actor has not moved, it often allows us to skip testing it in parts of our collision detection.&amp;nbsp; This also improves &lt;A href="http://silverlight.net/" target=_blank mce_href="http://silverlight.net"&gt;Silverlight&lt;/A&gt; drawing performance (which we’ll talk more about tomorrow) since we will not have to update the Silverlight plugin and Silverlight will not have to re-render the actor in its new position.&amp;nbsp; &lt;/P&gt;
&lt;P&gt;Finally, if you are spawning new actors throughout the course of your game (through shoot behaviors, Appear behaviors, effects etc) there are a couple of things you can do to keep things snappy.&amp;nbsp; &lt;/P&gt;
&lt;P&gt;First, make sure you limit the lifetime of the spawned actors.&amp;nbsp; Leaving the “disappear on scene leave” behaviors intact helps with this since once the actor reaches the edge of the screen, the actor will be removed from the game keeping the total number of actors low.&amp;nbsp; Second, limit the rate at which new actors are added.&amp;nbsp; For example, if you allow the player to shoot, try limiting the rate of fire by setting a property to 1 on your actor when the player presses the fire button, then clear the property to 0 on a timer.&amp;nbsp; Then simply add a filter to the fire behavior to only allow the player to fire when the property is 0.&amp;nbsp; Alternately, you can limit the # of bullets the player can fire at once by filtering on the # of BulletName property (you may have to copy the value of this property locally to your actor from the scene using an “every frame” timer).&amp;nbsp; Lastly, you can throttle down the rate at which your enemies fire when there are a lot of enemies on the screen through custom code or using a filter on # of EnemyBulletName.&amp;nbsp; &lt;/P&gt;
&lt;P&gt;Hopefully these tips will help those of you with games whose performance is bound by the total number of actors.&amp;nbsp; Because naive collision detection’s performance is an O(N^2 ) problem (where N is the number of actors, adding one more actor will cause another N + 1 collision checks to take place), adding actors can quickly cause problems.&amp;nbsp; Using the tips above can really improve performance.&amp;nbsp; If you’re having trouble after following these tips or they aren’t helping, be sure to head to the &lt;A href="http://forums.microsoft.com/MSDN/ShowForum.aspx?ForumID=2125&amp;amp;SiteID=1" target=_blank mce_href="http://forums.microsoft.com/MSDN/ShowForum.aspx?ForumID=2125&amp;amp;SiteID=1"&gt;forums&lt;/A&gt; where other users and members of the Popfly team can help.&lt;/P&gt;
&lt;P&gt;Tomorrow I’ll follow up with Part 2 where I will provide some tips for creating actors that are easy for Silverlight to draw and also help keep Popfly’s game engine running fast.&amp;nbsp; Stay tuned.&lt;/P&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=8996804" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/ben_anderson/archive/tags/Popfly/default.aspx">Popfly</category><category domain="http://blogs.msdn.com/ben_anderson/archive/tags/Popfly+Game+Creator/default.aspx">Popfly Game Creator</category><category domain="http://blogs.msdn.com/ben_anderson/archive/tags/Silverlight/default.aspx">Silverlight</category><category domain="http://blogs.msdn.com/ben_anderson/archive/tags/PGC/default.aspx">PGC</category><category domain="http://blogs.msdn.com/ben_anderson/archive/tags/How+To/default.aspx">How To</category><category domain="http://blogs.msdn.com/ben_anderson/archive/tags/performance/default.aspx">performance</category></item><item><title>Popfly September Update</title><link>http://blogs.msdn.com/ben_anderson/archive/2008/09/30/popfly-september-update.aspx</link><pubDate>Wed, 01 Oct 2008 03:09:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:8970931</guid><dc:creator>Ben Anderson</dc:creator><slash:comments>0</slash:comments><comments>http://blogs.msdn.com/ben_anderson/comments/8970931.aspx</comments><wfw:commentRss>http://blogs.msdn.com/ben_anderson/commentrss.aspx?PostID=8970931</wfw:commentRss><description>&lt;P&gt;While I’ve been working on a super secret (ok, just regular secret and probably not exciting to anyone but me) project the last month which you won’t see for a bit, the rest of the Popfly team found time in between actually super (and secret) projects of their own to provide a couple cool updates to &lt;A href="http://www.popfly.com/" mce_href="http://www.popfly.com"&gt;Popfly&lt;/A&gt;.&amp;nbsp; One is a perennial request.&amp;nbsp; You’ll now be able to track which projects are ripped from which to see whose based projects on yours and what other projects were based on.&amp;nbsp; There’s also a new badge and more info on your news feed.&amp;nbsp; You can read more about the updates &lt;A href="http://popflyteam.spaces.live.com/Blog/cns!51018025071FD37F!326.entry" mce_href="http://popflyteam.spaces.live.com/Blog/cns!51018025071FD37F!326.entry"&gt;here&lt;/A&gt; on the team blog or check them out yourself at &lt;A href="http://www.popfly.com/" mce_href="http://www.popfly.com"&gt;http://www.popfly.com&lt;/A&gt;! &lt;/P&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=8970931" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/ben_anderson/archive/tags/Popfly/default.aspx">Popfly</category><category domain="http://blogs.msdn.com/ben_anderson/archive/tags/Popfly+Game+Creator/default.aspx">Popfly Game Creator</category><category domain="http://blogs.msdn.com/ben_anderson/archive/tags/PGC/default.aspx">PGC</category></item><item><title>Popfly Game Creator at PAX</title><link>http://blogs.msdn.com/ben_anderson/archive/2008/08/26/popfly-game-creator-at-pax.aspx</link><pubDate>Wed, 27 Aug 2008 00:07:54 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:8898364</guid><dc:creator>Ben Anderson</dc:creator><slash:comments>0</slash:comments><comments>http://blogs.msdn.com/ben_anderson/comments/8898364.aspx</comments><wfw:commentRss>http://blogs.msdn.com/ben_anderson/commentrss.aspx?PostID=8898364</wfw:commentRss><description>&lt;p&gt;For those of you in the Seattle area this coming weekend for &lt;a href="http://www.pennyarcadeexpo.com/"&gt;PAX&lt;/a&gt;, be sure to stop by the Microsoft booth if you’re interested in checking out the Popfly Game Creator.&amp;#160; I will be giving a demos of the PGC Friday at 5:00, as well as Saturday and Sunday at 11:30 AM.&amp;#160; I’ll also hang around at the booth for a while after each talk if you want to stop by and chat.&amp;#160; &lt;/p&gt;  &lt;p&gt;&lt;/p&gt;  &lt;p&gt;For a schedule of other MS demos, check out the full listing at Gamerscoreblog: &lt;a title="http://gamerscoreblog.com/team/archive/2008/08/22/560668.aspx" href="http://gamerscoreblog.com/team/archive/2008/08/22/560668.aspx"&gt;http://gamerscoreblog.com/team/archive/2008/08/22/560668.aspx&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;&lt;a href="http://blogs.msdn.com/blogfiles/ben_anderson/WindowsLiveWriter/PopflyGameCreatoratPAX_C6B4/pax_4.jpg"&gt;&lt;img title="pax" style="border-right: 0px; border-top: 0px; border-left: 0px; border-bottom: 0px" height="141" alt="pax" src="http://blogs.msdn.com/blogfiles/ben_anderson/WindowsLiveWriter/PopflyGameCreatoratPAX_C6B4/pax_thumb_1.jpg" width="244" border="0" /&gt;&lt;/a&gt;&lt;/p&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=8898364" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/ben_anderson/archive/tags/Popfly/default.aspx">Popfly</category><category domain="http://blogs.msdn.com/ben_anderson/archive/tags/Popfly+Game+Creator/default.aspx">Popfly Game Creator</category><category domain="http://blogs.msdn.com/ben_anderson/archive/tags/PGC/default.aspx">PGC</category><category domain="http://blogs.msdn.com/ben_anderson/archive/tags/demo/default.aspx">demo</category><category domain="http://blogs.msdn.com/ben_anderson/archive/tags/Penny+Arcade/default.aspx">Penny Arcade</category><category domain="http://blogs.msdn.com/ben_anderson/archive/tags/PAX/default.aspx">PAX</category></item><item><title>Rainbow Duckies - Great post on creating games with grandchildren</title><link>http://blogs.msdn.com/ben_anderson/archive/2008/05/07/rainbow-duckies-great-post-on-creating-games-with-grandchildren.aspx</link><pubDate>Thu, 08 May 2008 06:18:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:8468566</guid><dc:creator>Ben Anderson</dc:creator><slash:comments>0</slash:comments><comments>http://blogs.msdn.com/ben_anderson/comments/8468566.aspx</comments><wfw:commentRss>http://blogs.msdn.com/ben_anderson/commentrss.aspx?PostID=8468566</wfw:commentRss><description>&lt;P&gt;Michael Leonard is another engineer on the Popfly team and just posted a great entry on the experience he had testing the Popfly Game Creator with his granddaughters.&amp;nbsp; It really is a great example of the interactions you can have when you're not just playing games, but actually &lt;A class="" title="Making games with a grandchild" href="http://thesoftwarestories.com/blogger/2008/05/creating-computer-game-with-my.html" mce_href="http://thesoftwarestories.com/blogger/2008/05/creating-computer-game-with-my.html"&gt;making them&lt;/A&gt;.&amp;nbsp; &lt;/P&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=8468566" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/ben_anderson/archive/tags/Popfly/default.aspx">Popfly</category><category domain="http://blogs.msdn.com/ben_anderson/archive/tags/Popfly+Game+Creator/default.aspx">Popfly Game Creator</category><category domain="http://blogs.msdn.com/ben_anderson/archive/tags/Casual+Games/default.aspx">Casual Games</category><category domain="http://blogs.msdn.com/ben_anderson/archive/tags/Games/default.aspx">Games</category><category domain="http://blogs.msdn.com/ben_anderson/archive/tags/PGC/default.aspx">PGC</category><category domain="http://blogs.msdn.com/ben_anderson/archive/tags/Family/default.aspx">Family</category><category domain="http://blogs.msdn.com/ben_anderson/archive/tags/Kids/default.aspx">Kids</category></item><item><title>Capping your actor’s speed</title><link>http://blogs.msdn.com/ben_anderson/archive/2008/05/07/capping-your-actor-s-speed.aspx</link><pubDate>Thu, 08 May 2008 01:23:32 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:8467525</guid><dc:creator>Ben Anderson</dc:creator><slash:comments>1</slash:comments><comments>http://blogs.msdn.com/ben_anderson/comments/8467525.aspx</comments><wfw:commentRss>http://blogs.msdn.com/ben_anderson/commentrss.aspx?PostID=8467525</wfw:commentRss><description>&lt;p&gt;If you’ve been playing around with Popfly Game Creator long enough, you’ve probably noticed that if actors get going fast enough, they can sometimes manage to fly right through a wall.&amp;#160; There are some things you can do to get around this like making your walls extra thick, or making sure your actors go slow, but I’ll be the first to admit that this can get kind of annoying.&amp;#160; &lt;/p&gt;  &lt;p align="center"&gt;&lt;img src="http://blogs.msdn.com/photos/ben_anderson/images/8467216/original.aspx" /&gt; &lt;/p&gt;  &lt;p&gt;The issue is that with the alpha release of PGC, we only check for collisions once during each frame.&amp;#160; If your actor is moving so fast that one frame it’s on the left side of the wall and on the next it’s on the right, we will never know that in between it should have collided.&amp;#160; We have to actually catch the actors colliding during a frame in order to realize they collided and then resolve the collision.&amp;#160; This was due to both time limitations and the performance limitations of running on the browser’s JavaScript engine (we could probably do it, but given our short timeframe before releasing the Alpha, we chose to go with the “good enough” method you see in the Alpha) since doing continuous collision checking is both harder to code and less performant [yes, I know this is &lt;a href="http://weblogs.asp.net/jgalloway/archive/2007/05/10/performant-isn-t-a-word.aspx"&gt;not&lt;/a&gt; a &lt;a href="http://boulter.com/blog/2004/08/19/performant-is-not-a-word/"&gt;word&lt;/a&gt; that &lt;a href="http://dictionary.reference.com/browse/performant"&gt;means&lt;/a&gt; &lt;a href="http://dictionary.oed.com/cgi/entry/30003374?single=1&amp;amp;query_type=word&amp;amp;queryword=performant&amp;amp;first=1&amp;amp;max_to_show=10"&gt;fast&lt;/a&gt; – but dude, English is a living language] due to all the math.&lt;/p&gt;  &lt;p&gt;We’ll probably do something about this down the road sometime after Silverlight 2.0 RTMs, we begin requiring it and can begin using C# (no promises as usual).&amp;#160; But in the meantime, I figured I’d post some quick custom code which you can help dealing with this by capping the speed of your actor.&lt;/p&gt;  &lt;p&gt;You might think that you can just use the “Max Speed” value in the motion dialog and be done, however there are many cases where this isn’t good enough.&amp;#160; While Max Speed does work, it only concerns itself with the current behavior.&amp;#160; What Max Speed does under the covers is calculate the amount of acceleration to apply such that the contribution from that behavior will reach terminal velocity at the value you enter.&amp;#160; If you have two behaviors, both with a Max Speed of 100, and they both are pushing in the same direction, your max speed will actually be 200.&amp;#160; While that example is a little contrived, there are many times, especially in physics based games like &lt;a href="http://www.popfly.com/users/team/Badly%20Built%20Wall"&gt;Badly Built Wall&lt;/a&gt;, that over time, the contribution from various behaviors and collisions will add up to making you go really fast.&amp;#160; &lt;/p&gt;  &lt;p&gt;How do you overcome this?&amp;#160; Why with a custom behavior of course!&amp;#160; Adding a custom behavior with the following code should do the trick:&lt;/p&gt;  &lt;blockquote&gt;   &lt;div style="font-size: 10pt; font-family: monospace; background-color: #d5d5d5"&gt;&lt;span style="color: blue"&gt;var&lt;/span&gt;&lt;span style="color: black"&gt; maxSpeed = 200;        &lt;br /&gt;&lt;/span&gt;&lt;span style="color: blue"&gt;var&lt;/span&gt;&lt;span style="color: black"&gt; maxSpeedSquared = maxSpeed * maxSpeed;        &lt;br /&gt;        &lt;br /&gt;&lt;/span&gt;&lt;span style="color: blue"&gt;var&lt;/span&gt;&lt;span style="color: black"&gt; velX = &lt;/span&gt;&lt;span style="color: blue"&gt;this&lt;/span&gt;&lt;span style="color: black"&gt;.GetValue(&lt;/span&gt;&lt;span style="color: #a31515"&gt;&amp;quot;XVelocity&amp;quot;&lt;/span&gt;&lt;span style="color: black"&gt;);        &lt;br /&gt;&lt;/span&gt;&lt;span style="color: blue"&gt;var&lt;/span&gt;&lt;span style="color: black"&gt; velY = &lt;/span&gt;&lt;span style="color: blue"&gt;this&lt;/span&gt;&lt;span style="color: black"&gt;.GetValue(&lt;/span&gt;&lt;span style="color: #a31515"&gt;&amp;quot;YVelocity&amp;quot;&lt;/span&gt;&lt;span style="color: black"&gt;);        &lt;br /&gt;        &lt;br /&gt;&lt;/span&gt;&lt;span style="color: blue"&gt;var&lt;/span&gt;&lt;span style="color: black"&gt; velocity = {X: velX, Y: velY};        &lt;br /&gt;&lt;/span&gt;&lt;span style="color: blue"&gt;var&lt;/span&gt;&lt;span style="color: black"&gt; speedSquared = Vector2.MagnitudeSquared(velocity);        &lt;br /&gt;        &lt;br /&gt;&lt;/span&gt;&lt;span style="color: blue"&gt;if&lt;/span&gt;&lt;span style="color: black"&gt; (speedSquared &amp;gt; maxSpeedSquared)        &lt;br /&gt;{ &lt;/span&gt;&lt;span style="color: black"&gt;       &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; &lt;/span&gt;&lt;span style="color: blue"&gt;var&lt;/span&gt;&lt;span style="color: black"&gt; normalizedVelocity = Vector2.Normalize(velocity);        &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; &lt;/span&gt;&lt;span style="color: blue"&gt;this&lt;/span&gt;&lt;span style="color: black"&gt;.SetValue(&lt;/span&gt;&lt;span style="color: #a31515"&gt;&amp;quot;XVelocity&amp;quot;&lt;/span&gt;&lt;span style="color: black"&gt;, normalizedVelocity.X * maxSpeed);        &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; &lt;/span&gt;&lt;span style="color: blue"&gt;this&lt;/span&gt;&lt;span style="color: black"&gt;.SetValue(&lt;/span&gt;&lt;span style="color: #a31515"&gt;&amp;quot;YVelocity&amp;quot;&lt;/span&gt;&lt;span style="color: black"&gt;, normalizedVelocity.Y * maxSpeed);        &lt;br /&gt;}&lt;/span&gt; &lt;/div&gt; &lt;/blockquote&gt;  &lt;p&gt;Add this as a the last behavior to your actor and set its event to Timer-&amp;gt;Every Frame.&amp;#160; What this code does is check your speed every frame after all your motion behaviors have contributed to it and if it exceeds the value you set for maxSpeed at the top, resets your velocity to point in the same direction as before, but to go only as fast as maxSpeed.&amp;#160; You can set maxSpeed to a whatever value you want, and as long as that value is low enough that your actor can’t pass through the thickness of your walls in a single frame, you should avoid any unexpected jumping through walls. &lt;em&gt; [Note:&lt;/em&gt;&amp;#160; All the *Squared values are used as a programmer’s trick to avoid the square root operation (Math.sqrt) which is fairly costly in terms of processing time.&lt;em&gt;] &lt;/em&gt; For even simpler code, check out the following from Badly Built Wall:&lt;/p&gt;  &lt;blockquote&gt;   &lt;div style="font-size: 10pt; font-family: monospace; background-color: #d5d5d5"&gt;&lt;span style="color: blue"&gt;var&lt;/span&gt;&lt;span style="color: black"&gt; velX = &lt;/span&gt;&lt;span style="color: blue"&gt;this&lt;/span&gt;&lt;span style="color: black"&gt;.GetValue(&lt;/span&gt;&lt;span style="color: #a31515"&gt;&amp;quot;XVelocity&amp;quot;&lt;/span&gt;&lt;span style="color: black"&gt;);        &lt;br /&gt;&lt;/span&gt;&lt;span style="color: blue"&gt;var&lt;/span&gt;&lt;span style="color: black"&gt; velY = &lt;/span&gt;&lt;span style="color: blue"&gt;this&lt;/span&gt;&lt;span style="color: black"&gt;.GetValue(&lt;/span&gt;&lt;span style="color: #a31515"&gt;&amp;quot;YVelocity&amp;quot;&lt;/span&gt;&lt;span style="color: black"&gt;);        &lt;br /&gt;        &lt;br /&gt;&lt;/span&gt;&lt;span style="color: blue"&gt;if&lt;/span&gt;&lt;span style="color: black"&gt; (velX &amp;gt; 201) &lt;/span&gt;&lt;span style="color: blue"&gt;this&lt;/span&gt;&lt;span style="color: black"&gt;.SetValue(&lt;/span&gt;&lt;span style="color: #a31515"&gt;&amp;quot;XVelocity&amp;quot;&lt;/span&gt;&lt;span style="color: black"&gt;, 200);        &lt;br /&gt;&lt;/span&gt;&lt;span style="color: blue"&gt;if&lt;/span&gt;&lt;span style="color: black"&gt; (velY &amp;gt; 201) &lt;/span&gt;&lt;span style="color: blue"&gt;this&lt;/span&gt;&lt;span style="color: black"&gt;.SetValue(&lt;/span&gt;&lt;span style="color: #a31515"&gt;&amp;quot;YVelocity&amp;quot;&lt;/span&gt;&lt;span style="color: black"&gt;, 200);&lt;/span&gt; &lt;/div&gt; &lt;/blockquote&gt;  &lt;p&gt;This code doesn't actually cap the max speed, but rather the velocity in the vertical and horizontal directions. This is subtly different in that it means you could actually end up going 200 in the horizontal and 200 in the vertical directions, which, if we remember our distance formula means we end up going sqrt(200^2 + 200^2) altogether or about 283 pixels / second total.&amp;#160; Basically, it means you can go faster in the diagonals than you can just straight up and down or left and right.&amp;#160; As you can probably tell it’s quite a bit less complicated (and therefore faster) and even though it’s less general can actually be desirable in games like Badly Built Wall where you are colliding mostly against axis aligned rectangles (their sides are horizontal or vertical rather than at an angle).&amp;#160; &lt;/p&gt;  &lt;p&gt;Happy creating!&lt;/p&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=8467525" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/ben_anderson/archive/tags/Popfly/default.aspx">Popfly</category><category domain="http://blogs.msdn.com/ben_anderson/archive/tags/Popfly+Game+Creator/default.aspx">Popfly Game Creator</category><category domain="http://blogs.msdn.com/ben_anderson/archive/tags/Casual+Games/default.aspx">Casual Games</category><category domain="http://blogs.msdn.com/ben_anderson/archive/tags/Silverlight/default.aspx">Silverlight</category><category domain="http://blogs.msdn.com/ben_anderson/archive/tags/Games/default.aspx">Games</category><category domain="http://blogs.msdn.com/ben_anderson/archive/tags/JavaScript/default.aspx">JavaScript</category><category domain="http://blogs.msdn.com/ben_anderson/archive/tags/PGC/default.aspx">PGC</category><category domain="http://blogs.msdn.com/ben_anderson/archive/tags/Custom+Code/default.aspx">Custom Code</category><category domain="http://blogs.msdn.com/ben_anderson/archive/tags/Code/default.aspx">Code</category></item><item><title>Mailbag: Even Easier Music</title><link>http://blogs.msdn.com/ben_anderson/archive/2008/05/07/mailbag-even-easier-music.aspx</link><pubDate>Wed, 07 May 2008 23:36:09 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:8466990</guid><dc:creator>Ben Anderson</dc:creator><slash:comments>1</slash:comments><comments>http://blogs.msdn.com/ben_anderson/comments/8466990.aspx</comments><wfw:commentRss>http://blogs.msdn.com/ben_anderson/commentrss.aspx?PostID=8466990</wfw:commentRss><description>&lt;p align="center"&gt;&lt;img src="http://blogs.msdn.com/photos/ben_anderson/images/8466985/original.aspx" /&gt; &lt;/p&gt;  &lt;p&gt;Reader &lt;a href="http://allthingsstrive.blogspot.com/"&gt;Michael Sterling&lt;/a&gt; pointed out today (or rather late last night) a &lt;a href="http://www.jamstudio.com/Studio/index.htm"&gt;neat tool&lt;/a&gt; that lets you create music even more easily than with Finale:&lt;/p&gt;  &lt;blockquote&gt;   &lt;p&gt;For people who want even easier music creation so are willing to give up some of the nuance that Finale offers, they could try JamStudio.com. It's kind of like GarageBand for the mac (I'm sure there's a non-apple analogy), but even a bit simpler. You just choose the instruments you want to use and then assign chords to each measure. They want you to sign up, and there's a little tutorial video that plays when you first start, but you can skip it and don't have to sign up (although you might need to if you want to export the music, I'm not sure).&amp;quot;&lt;/p&gt; &lt;/blockquote&gt;  &lt;p&gt;I took a look and it indeed looks pretty cool.&amp;#160; You can sign up for free, but to export an mp3 of your work requires a $10/month subscription.&amp;#160; Might be worth it if you create a bunch of songs, sign up for a month, then export everything at once for your game.&amp;#160; After playing with it a bit, it sounds like it’s using samples instead of midi for at least some of the instruments (which sounds a lot better although you lose the retro vibe) and is indeed super easy to use, even if you know little or nothing about music.&amp;#160; &lt;/p&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=8466990" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/ben_anderson/archive/tags/Popfly+Game+Creator/default.aspx">Popfly Game Creator</category><category domain="http://blogs.msdn.com/ben_anderson/archive/tags/Casual+Games/default.aspx">Casual Games</category><category domain="http://blogs.msdn.com/ben_anderson/archive/tags/Games/default.aspx">Games</category><category domain="http://blogs.msdn.com/ben_anderson/archive/tags/PGC/default.aspx">PGC</category><category domain="http://blogs.msdn.com/ben_anderson/archive/tags/Audio/default.aspx">Audio</category><category domain="http://blogs.msdn.com/ben_anderson/archive/tags/Music/default.aspx">Music</category><category domain="http://blogs.msdn.com/ben_anderson/archive/tags/Mailbag/default.aspx">Mailbag</category></item><item><title>Creating Music for Popfly Game Creator</title><link>http://blogs.msdn.com/ben_anderson/archive/2008/05/06/creating-music-for-popfly-game-creator.aspx</link><pubDate>Wed, 07 May 2008 01:19:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:8464089</guid><dc:creator>Ben Anderson</dc:creator><slash:comments>2</slash:comments><comments>http://blogs.msdn.com/ben_anderson/comments/8464089.aspx</comments><wfw:commentRss>http://blogs.msdn.com/ben_anderson/commentrss.aspx?PostID=8464089</wfw:commentRss><description>&lt;P align=center&gt;&lt;IMG src="http://blogs.msdn.com/photos/ben_anderson/images/8463932/original.aspx" mce_src="http://blogs.msdn.com/photos/ben_anderson/images/8463932/original.aspx"&gt; &lt;/P&gt;
&lt;P&gt;Sound and music is probably one of the most overlooked areas of new hobbyist game developers.&amp;nbsp; Just adding a cheesy soundtrack and cute hopping and squishing noises subtly changes a boring, simple game into one that feels &lt;A href="http://www.mazapan.se/games/BurnTheRope.php" mce_href="http://www.mazapan.se/games/BurnTheRope.php"&gt;professional and complete&lt;/A&gt;.&amp;nbsp; The funny thing is that usually this process is completely subliminal with most people not realizing the difference sound makes.&amp;nbsp; Even great games can be vastly improved through the use of audio as anyone who has completed &lt;A href="http://orange.half-life2.com/portal.html" mce_href="http://orange.half-life2.com/portal.html"&gt;Portal&lt;/A&gt; can tell you.&amp;nbsp; &lt;/P&gt;
&lt;P&gt;PGC allows you to upload your own music and sounds as .WMA or .MP3 files to use in your games.&amp;nbsp; You can find a “How To” explaining the process of uploading and playing back audio on the Popfly wiki &lt;A href="http://www.popflywiki.com/How%20do%20I%20add%20my%20own%20sound%20effects%20and%20music.ashx" mce_href="http://www.popflywiki.com/How%20do%20I%20add%20my%20own%20sound%20effects%20and%20music.ashx"&gt;here&lt;/A&gt;.&amp;nbsp; There are many programs which allow you to record audio on your computer from very basic programs (Windows Sound Recorder) to very advanced interface/software packages such as &lt;A href="http://www.digidesign.com/index.cfm?navid=28&amp;amp;langid=100&amp;amp;" mce_href="http://www.digidesign.com/index.cfm?navid=28&amp;amp;langid=100&amp;amp;"&gt;Pro Tools&lt;/A&gt;.&amp;nbsp; However, this all assumes you are in possession of musical instruments, recording equipment and are musically capable or willing to invest the time to become so.&amp;nbsp; That’s a lot of commitment for most folks.&lt;/P&gt;
&lt;P&gt;While I can’t help you with the becoming musically capable part, I recently dug up a free program called &lt;A href="http://www.finalemusic.com/notepad/" mce_href="http://www.finalemusic.com/notepad/"&gt;Finale Notepad&lt;/A&gt; which I had played around with during my freshman year of college.&amp;nbsp; The full version of Finale is a professional tool for creating music scores on the computer.&amp;nbsp; At least back when I first used it, it was pretty much the standard for creating music notation.&amp;nbsp; The Notepad version probably isn’t full featured enough for that crowd, but it’s great for composing simple songs which can then be exported as MIDI.&amp;nbsp; MIDI is an electronic format which isn’t an actual recording, but rather the instructions to synthesize a piece (what notes to play, what synth instruments to use and when to play them).&amp;nbsp; As such, it’s a great tool for making retro game music, because that’s exactly&amp;nbsp;the kind of music that was used&amp;nbsp;back in the 8 and 16-bit days of Super Nintendo and Genesis.&amp;nbsp; I usually just play around on the staff in the key of C to get what I want, but I believe you can also hook up a keyboard to record the notes.&amp;nbsp; Even if you aren’t musically inclined, you can probably put together some basic tracks by trial and error.&amp;nbsp; Once you’re happy with your piece, just click File-&amp;gt;Save As… and change the file type to MIDI.&amp;nbsp; &lt;/P&gt;
&lt;P&gt;Since PGC requires files to be of type .WMA or .MP3, you’ll now have to convert the MIDI file.&amp;nbsp; The easiest way I’ve found to do this is to change your recording device to “What You Hear” in the sound settings in control panel.&amp;nbsp; If this option isn’t available (I think some drivers don’t support this option) like on my work machine, an easy workaround is to plug a cable into your headphone jack and back again into the microphone jack on your computer.&amp;nbsp; You may have to play around with the volume settings to get it just right.&amp;nbsp; Once you’ve done this, you can easily use Windows Media Player to playback the MIDI and Windows Sound Recorder to record a WMA file (Vista) or a WAV file (XP) which you can then convert to a WMA or MP3 using a tool like &lt;A href="http://cdexos.sourceforge.net/" mce_href="http://cdexos.sourceforge.net/"&gt;CDex&lt;/A&gt;.&amp;nbsp; There might be an easier way to do this – if so, let us know in the comments.&amp;nbsp; &lt;/P&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=8464089" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/ben_anderson/archive/tags/Popfly/default.aspx">Popfly</category><category domain="http://blogs.msdn.com/ben_anderson/archive/tags/Popfly+Game+Creator/default.aspx">Popfly Game Creator</category><category domain="http://blogs.msdn.com/ben_anderson/archive/tags/PGC/default.aspx">PGC</category><category domain="http://blogs.msdn.com/ben_anderson/archive/tags/Audio/default.aspx">Audio</category><category domain="http://blogs.msdn.com/ben_anderson/archive/tags/Music/default.aspx">Music</category></item></channel></rss>