<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	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/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>adc&#124;works &#187; Games</title>
	<atom:link href="http://www.adcworks.com/category/development/games/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.adcworks.com</link>
	<description></description>
	<lastBuildDate>Wed, 06 Jan 2010 15:47:08 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0</generator>
		<item>
		<title>Uckers for Dream Build Play 2009</title>
		<link>http://www.adcworks.com/2009/04/uckers-for-dream-build-play-2009/</link>
		<comments>http://www.adcworks.com/2009/04/uckers-for-dream-build-play-2009/#comments</comments>
		<pubDate>Wed, 08 Apr 2009 13:51:13 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Games]]></category>
		<category><![CDATA[Uckers]]></category>
		<category><![CDATA[XNA]]></category>

		<guid isPermaLink="false">http://www.adcworks.com/?p=29</guid>
		<description><![CDATA[Last year I entered Dream Build Play with the board game Uckers. I didn&#8217;t win of course but it was great to take part and create a game. But there was so much more I wanted for the game and so I withheld it from the Community Games channel. Now Dream Build Play is back]]></description>
			<content:encoded><![CDATA[<p style="text-align: center;"><img class="aligncenter size-full wp-image-30" style="border: 0pt none;" title="uckers" src="http://www.adcworks.com/wp-content/uploads/2009/04/uckers.jpg" alt="uckers" width="180" height="74" /></p>
<p>Last year I entered <a href="http://www.dreambuildplay.com" target="_blank">Dream Build Play</a> with the board game <a href="/uckers/">Uckers</a>. I didn&#8217;t win of course but it was great to take part and create a game. But there was so much more I wanted for the game and so I withheld it from the Community Games channel.</p>
<p>Now Dream Build Play is back and my intention is to get those features into the game. Things like artifical intelligence and Live versus play are crucial for the entry this year (Uckers currently supports only 2 player local play) among other enhancements that will become clear as I update this blog towards August&#8217;s entry date.</p>
<p>In any case I aim to have Uckers on Community Games this autumn/fall.</p>
<p>Wish me luck, it&#8217;s going to be a long summer <img src='http://www.adcworks.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' />  Keep up to date here and on the <a href="/uckers/">Uckers</a> page.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.adcworks.com/2009/04/uckers-for-dream-build-play-2009/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Using XNA DrawableGameComponent</title>
		<link>http://www.adcworks.com/2008/04/using-xna-drawablegamecomponent/</link>
		<comments>http://www.adcworks.com/2008/04/using-xna-drawablegamecomponent/#comments</comments>
		<pubDate>Tue, 08 Apr 2008 21:17:31 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[XNA]]></category>

		<guid isPermaLink="false">http://adcworks/?p=8</guid>
		<description><![CDATA[This post is for those thinking about using the DrawableGameComponent class in the XNA framework. I am going to demonstrate how you might use the class by using the example of dice. Project Files Download Dice.zip for the Visual Studio Express 2005 XNA 2.0 project files. Extract the zip, then run Dice.csproj to open the]]></description>
			<content:encoded><![CDATA[<p>This post is for those thinking about using the DrawableGameComponent class in the XNA framework.</p>
<p>I am going to demonstrate how you might use the class by using the example of dice.</p>
<p><img src="http://www.adcworks.com/repository/Dice.jpg" alt="" width="216" height="136" /></p>
<h2>Project Files</h2>
<p><a href="http://www.adcworks.com/downloads/Dice.zip">Download Dice.zip</a> for the Visual Studio Express 2005 XNA 2.0 project files. Extract the zip, then run Dice.csproj to open the project in VSE 2005. You can then just compile the project by pressing the play icon.</p>
<h2>DrawableGameComponent</h2>
<p>Dice are ideal for illustrating the DrawableGameComponent class because dice, even in the real-world, are reusable across many table games, and that&#8217;s really where DrawableGameComponent comes in handy.</p>
<p>The DrawableGameComponent provides the developer a nice structured way to create modular, self-contained and reusable game components. A component should by definition be able to be dropped into a game and with minimal wiring up, just work.</p>
<h2>Understanding the Source</h2>
<p>The way in which to use DrawableGameComponent is to extend it. By doing this, when we add our component to the game, the XNA framework will know how to call it properly.</p>
<p>The Dice class therefore is made to extend DrawableGameComponent. The constructor for DrawableGameComponent requires the Game instance to be passed, so we need to ensure our component class constructor receives the game instance in addition to any specific variables so that it may pass the game instance on to the superclass for instantiation.</p>
<p>In essence when creating a component, you will want to override 3 of the methods of the DrawableGameComponent superclass; LoadContent, Update and Draw. For beginners, LoadContent is a method in which we instantiate resources like graphics and sounds, Update is used to update game logic (and this is done per game loop cycle &#8211; which is fast), and Draw in which we paint stuff to the screen.</p>
<p>You will see in the Dice class that I have overridden these 3 methods using the override keyword in the method declarations.  Each of these methods as their last statement call the superclass&#8217;s version of the method to ensure the component is fully called.</p>
<p>A die has 6 faces, so I added 6 graphics files to represent each face of a die. These are added to the Content folder in the project. As such, within LoadContent, I am able to load them as Texture2D files.</p>
<p>A separate Die class represents a single die since the actual Dice class supports as many die instances as you want. In practice this will be 1 or 2, but hey, it&#8217;s all about extensibility!</p>
<p>The Die class contains a method for rolling the single die. It uses a static instance of Random to roll a random face between 1 and 6.</p>
<p>The Dice class also contains some logic methods. Roll iterates all the die instances and calls their Roll methods. And Total returns the sum of all die instance faces at the time of call.</p>
<h2>Using the Dice Component</h2>
<p>To use the Dice component, we need to add it to our main game instance. In Game1 we just have to add an instance of Dice to the Game.Components collection. Simple as that.</p>
<p>By doing this, each game update tick, the Dice component&#8217;s Update and Draw methods are called.</p>
<p>The Dice.Update method monitors the keyboard for presses of the Space Bar. This triggers a roll of the active die instances.</p>
<p>Dice.Draw draws the relevant Texture2D graphics for the active die instances.</p>
<p>In the project, I just draw out each die next to each other.</p>
<p>Keep pressing Space Bar and you will see the dice change as you roll them.#</p>
<h2>Final Words</h2>
<p>I hope this article was of use to some of you, particularly those starting out with XNA. The DrawableGameComponent method of encapsulating game logic is a really good pattern to follow.</p>
<p>Some of you may be wondering though &#8211; since the Dice class is constantly monitoring the Space Bar, when you add that to a real game, where you would want to block dice rolls until certain other events take place &#8211; how do you do that?</p>
<p>Well, you&#8217;d need additional wiring in that case. One idea might be to maintain a flag CanDiceRoll for example in the main game. The Dice.Update method would need to use a conditional block based on that flag to determine if it should roll. Suggestions from readers are welcome.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.adcworks.com/2008/04/using-xna-drawablegamecomponent/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
	</channel>
</rss>
