<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
		>
<channel>
	<title>Comments on: Extending GamePadState</title>
	<atom:link href="http://blog.nickgravelyn.com/2009/11/extending-gamepadstate/feed/" rel="self" type="application/rss+xml" />
	<link>http://blog.nickgravelyn.com/2009/11/extending-gamepadstate/</link>
	<description></description>
	<lastBuildDate>Fri, 23 Jul 2010 01:34:59 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=abc</generator>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
		<item>
		<title>By: Nick</title>
		<link>http://blog.nickgravelyn.com/2009/11/extending-gamepadstate/comment-page-1/#comment-350</link>
		<dc:creator>Nick</dc:creator>
		<pubDate>Thu, 14 Jan 2010 18:55:39 +0000</pubDate>
		<guid isPermaLink="false">http://blog.nickgravelyn.com/?p=1088#comment-350</guid>
		<description>I just now saw that comment. My bad. :)

The main problem with that is that you&#039;re going to generate garbage (it will allocate a new array each time you use it) and you&#039;ll see a lot of boxing/unboxing costs from casting an enumeration to object and back (you can read more on that here: http://msdn.microsoft.com/en-us/library/yz2be5wk.aspx).

True that your method doesn&#039;t require the static initialization stuff and is a bit simpler, but I personally feel the performance implications aren&#039;t worth it.</description>
		<content:encoded><![CDATA[<p>I just now saw that comment. My bad. <img src='http://blog.nickgravelyn.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<p>The main problem with that is that you&#8217;re going to generate garbage (it will allocate a new array each time you use it) and you&#8217;ll see a lot of boxing/unboxing costs from casting an enumeration to object and back (you can read more on that here: <a href="http://msdn.microsoft.com/en-us/library/yz2be5wk.aspx)" rel="nofollow">http://msdn.microsoft.com/en-us/library/yz2be5wk.aspx)</a>.</p>
<p>True that your method doesn&#8217;t require the static initialization stuff and is a bit simpler, but I personally feel the performance implications aren&#8217;t worth it.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Kainsin</title>
		<link>http://blog.nickgravelyn.com/2009/11/extending-gamepadstate/comment-page-1/#comment-349</link>
		<dc:creator>Kainsin</dc:creator>
		<pubDate>Tue, 15 Dec 2009 14:16:30 +0000</pubDate>
		<guid isPermaLink="false">http://blog.nickgravelyn.com/?p=1088#comment-349</guid>
		<description>How about using a variable argument list instead? Then you would just need the function.

public static bool AreAnyButtonsPressed(this GamePadState state, params object[] buttons)
{
   foreach (Buttons button in buttons)
   {
      if (state.IsButtonDown(button))
         return true;
   }
   return false;
}

You can redefine this as a for loop with an &quot;is&quot; check for object -&gt; Buttons if you&#039;re concerned about the whole foreach garbage thing.

(I don&#039;t know how to format code blocks on this site, just registered.)</description>
		<content:encoded><![CDATA[<p>How about using a variable argument list instead? Then you would just need the function.</p>
<p>public static bool AreAnyButtonsPressed(this GamePadState state, params object[] buttons)<br />
{<br />
   foreach (Buttons button in buttons)<br />
   {<br />
      if (state.IsButtonDown(button))<br />
         return true;<br />
   }<br />
   return false;<br />
}</p>
<p>You can redefine this as a for loop with an &#8220;is&#8221; check for object -&gt; Buttons if you&#8217;re concerned about the whole foreach garbage thing.</p>
<p>(I don&#8217;t know how to format code blocks on this site, just registered.)</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: jamesjlang</title>
		<link>http://blog.nickgravelyn.com/2009/11/extending-gamepadstate/comment-page-1/#comment-348</link>
		<dc:creator>jamesjlang</dc:creator>
		<pubDate>Tue, 01 Dec 2009 16:38:55 +0000</pubDate>
		<guid isPermaLink="false">http://blog.nickgravelyn.com/?p=1088#comment-348</guid>
		<description>Yeah I suppose so.  I would agree that it adds to readability (if I ever have plans of anyone other than me reading my code).</description>
		<content:encoded><![CDATA[<p>Yeah I suppose so.  I would agree that it adds to readability (if I ever have plans of anyone other than me reading my code).</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Nick</title>
		<link>http://blog.nickgravelyn.com/2009/11/extending-gamepadstate/comment-page-1/#comment-347</link>
		<dc:creator>Nick</dc:creator>
		<pubDate>Tue, 01 Dec 2009 16:30:43 +0000</pubDate>
		<guid isPermaLink="false">http://blog.nickgravelyn.com/?p=1088#comment-347</guid>
		<description>It&#039;s a tiny bit but something that occurs frequently:

- Menus should accept A &amp; Start to activate an item
- Menus should accept B &amp; Back to go back
- Sometimes you want multiple buttons mapped to the same action in a game

I don&#039;t personally see it as overkill because it lets me write the code I want to write when handling input. Plus this is actually just a part of my larger set of GamePadState extension methods, so it&#039;s not the only thing I have in there.</description>
		<content:encoded><![CDATA[<p>It&#8217;s a tiny bit but something that occurs frequently:</p>
<p>- Menus should accept A &#038; Start to activate an item<br />
- Menus should accept B &#038; Back to go back<br />
- Sometimes you want multiple buttons mapped to the same action in a game</p>
<p>I don&#8217;t personally see it as overkill because it lets me write the code I want to write when handling input. Plus this is actually just a part of my larger set of GamePadState extension methods, so it&#8217;s not the only thing I have in there.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: jamesjlang</title>
		<link>http://blog.nickgravelyn.com/2009/11/extending-gamepadstate/comment-page-1/#comment-346</link>
		<dc:creator>jamesjlang</dc:creator>
		<pubDate>Tue, 01 Dec 2009 16:10:57 +0000</pubDate>
		<guid isPermaLink="false">http://blog.nickgravelyn.com/?p=1088#comment-346</guid>
		<description>I wonder if the extra class is worth just cutting down that tiny little bit.  Seems that it is a bit overkill for what you are trying to accomplish.  However, the concept of a game pad extension in general is something that I am going to play around with.</description>
		<content:encoded><![CDATA[<p>I wonder if the extra class is worth just cutting down that tiny little bit.  Seems that it is a bit overkill for what you are trying to accomplish.  However, the concept of a game pad extension in general is something that I am going to play around with.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Barnaby Smith</title>
		<link>http://blog.nickgravelyn.com/2009/11/extending-gamepadstate/comment-page-1/#comment-345</link>
		<dc:creator>Barnaby Smith</dc:creator>
		<pubDate>Sun, 29 Nov 2009 16:10:41 +0000</pubDate>
		<guid isPermaLink="false">http://blog.nickgravelyn.com/?p=1088#comment-345</guid>
		<description>That&#039;s a useful little class, thanks for this.</description>
		<content:encoded><![CDATA[<p>That&#8217;s a useful little class, thanks for this.</p>
]]></content:encoded>
	</item>
</channel>
</rss>
