<?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>GouldFish On Games</title>
	<atom:link href="http://thegouldfish.co.uk/feed/" rel="self" type="application/rss+xml" />
	<link>http://thegouldfish.co.uk</link>
	<description>Games and Game Development</description>
	<lastBuildDate>Mon, 26 Dec 2011 00:00:25 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.1.2</generator>
		<item>
		<title>Serialising an array of a base classes thats full of super classes</title>
		<link>http://thegouldfish.co.uk/2011/12/26/serialising-an-array-of-a-base-classes-thats-full-of-super-classes/</link>
		<comments>http://thegouldfish.co.uk/2011/12/26/serialising-an-array-of-a-base-classes-thats-full-of-super-classes/#comments</comments>
		<pubDate>Mon, 26 Dec 2011 00:00:25 +0000</pubDate>
		<dc:creator>GouldFish</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://thegouldfish.co.uk/?p=56</guid>
		<description><![CDATA[You have your base class of Baddie and built Goomba&#8217;s and Turtles with it and held it all in an array. The question now is how do you save that &#8230;<div class="margin10t"><a href="http://thegouldfish.co.uk/2011/12/26/serialising-an-array-of-a-base-classes-thats-full-of-super-classes/" class="more-link">Read More</a></div>]]></description>
			<content:encoded><![CDATA[<p>You have your base class of Baddie and built Goomba&#8217;s and Turtles with it and held it all in an array.<br />
The question now is how do you save that array to XML?</p>
<p>Here is the Base and Super Classes I&#8217;ve made:</p>
<pre class="brush: plain; title: ; notranslate">
    public abstract class Baddie
    {
        public Vector2 Position;

        public Baddie()
        {
            Position = new Vector2();
        }

        public abstract void AI(float gameTime);
    }

    public class Goomba : Baddie
    {
        public Goomba()
        {

        }

        public Goomba(Vector2 position)
        {
            Position = position;
        }

        public override void AI(float gameTime)
        {
            Position.X -= (gameTime * 10);
        }
    }
</pre>
<p>And here is the array and it being filled:</p>
<pre class="brush: plain; title: ; notranslate">
            Baddies = new List&lt;Baddie&gt;();

            Baddies.Add(new Goomba(new Vector2(100,30)));
            Baddies.Add(new Goomba(new Vector2(300, 40)));
            Baddies.Add(new Goomba(new Vector2(320, 40)));
            Baddies.Add(new Goomba(new Vector2(340, 30)));
            Baddies.Add(new Turtle(new Vector2(500, 50)));
            Baddies.Add(new Turtle(new Vector2(700, 10)));
            Baddies.Add(new Turtle(new Vector2(5000, 20)));
</pre>
<p>So to save this we need an array of Types that implement the base class Baddie, this can be done by hand or it can be done automatically via the following function:</p>
<pre class="brush: plain; title: ; notranslate">
        public static Type[] GetAllTypesForCollection&lt;T&gt;()
        {
            List&lt;Type&gt; list = new List&lt;Type&gt;();
            Assembly[] assemblies = System.AppDomain.CurrentDomain.GetAssemblies();

            for (int i = 0; i &lt; assemblies.Length; i++)
            {
                if (!assemblies[i].GlobalAssemblyCache)
                {
                    Type[] types = assemblies[i].GetTypes();

                    for (int j = 0; j &lt; types.Length; j++)
                    {
                        if (typeof(T).IsAssignableFrom(types[j]))
                        {
                            list.Add(types[j]);
                        }
                    }
                }
            }

            return list.ToArray();
        }
</pre>
<p>So the save code looks like this:</p>
<pre class="brush: plain; title: ; notranslate">
            using (FileStream fs = new FileStream(&quot;test.xml&quot;, FileMode.Create))
            {
                XmlSerializer s = new XmlSerializer(typeof(List&lt;Baddie&gt;), GetAllTypesForCollection&lt;Baddie&gt;());

                s.Serialize(fs, Baddies);
            }
</pre>
<p>and the end XML like this:</p>
<pre class="brush: plain; title: ; notranslate">
&lt;?xml version=&quot;1.0&quot;?&gt;
&lt;ArrayOfBaddie xmlns:xsi=&quot;http://www.w3.org/2001/XMLSchema-instance&quot; xmlns:xsd=&quot;http://www.w3.org/2001/XMLSchema&quot;&gt;
  &lt;Baddie xsi:type=&quot;Goomba&quot;&gt;
    &lt;Position&gt;
      &lt;X&gt;100&lt;/X&gt;
      &lt;Y&gt;30&lt;/Y&gt;
    &lt;/Position&gt;
  &lt;/Baddie&gt;
  &lt;Baddie xsi:type=&quot;Goomba&quot;&gt;
    &lt;Position&gt;
      &lt;X&gt;300&lt;/X&gt;
      &lt;Y&gt;40&lt;/Y&gt;
    &lt;/Position&gt;
  &lt;/Baddie&gt;
  &lt;Baddie xsi:type=&quot;Goomba&quot;&gt;
    &lt;Position&gt;
      &lt;X&gt;320&lt;/X&gt;
      &lt;Y&gt;40&lt;/Y&gt;
    &lt;/Position&gt;
  &lt;/Baddie&gt;
  &lt;Baddie xsi:type=&quot;Goomba&quot;&gt;
    &lt;Position&gt;
      &lt;X&gt;340&lt;/X&gt;
      &lt;Y&gt;30&lt;/Y&gt;
    &lt;/Position&gt;
  &lt;/Baddie&gt;
  &lt;Baddie xsi:type=&quot;Turtle&quot;&gt;
    &lt;Position&gt;
      &lt;X&gt;500&lt;/X&gt;
      &lt;Y&gt;50&lt;/Y&gt;
    &lt;/Position&gt;
  &lt;/Baddie&gt;
  &lt;Baddie xsi:type=&quot;Turtle&quot;&gt;
    &lt;Position&gt;
      &lt;X&gt;700&lt;/X&gt;
      &lt;Y&gt;10&lt;/Y&gt;
    &lt;/Position&gt;
  &lt;/Baddie&gt;
  &lt;Baddie xsi:type=&quot;Turtle&quot;&gt;
    &lt;Position&gt;
      &lt;X&gt;5000&lt;/X&gt;
      &lt;Y&gt;20&lt;/Y&gt;
    &lt;/Position&gt;
  &lt;/Baddie&gt;
&lt;/ArrayOfBaddie&gt;
</pre>
]]></content:encoded>
			<wfw:commentRss>http://thegouldfish.co.uk/2011/12/26/serialising-an-array-of-a-base-classes-thats-full-of-super-classes/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>C# 2D array types on Pc, 360 and WP7</title>
		<link>http://thegouldfish.co.uk/2011/05/25/c-2d-array-types-on-pc-360-and-wp7/</link>
		<comments>http://thegouldfish.co.uk/2011/05/25/c-2d-array-types-on-pc-360-and-wp7/#comments</comments>
		<pubDate>Wed, 25 May 2011 10:55:45 +0000</pubDate>
		<dc:creator>GouldFish</dc:creator>
				<category><![CDATA[Game Development]]></category>
		<category><![CDATA[C#]]></category>
		<category><![CDATA[Speed tests]]></category>
		<category><![CDATA[Windows Phone 7]]></category>
		<category><![CDATA[Xbox 360]]></category>

		<guid isPermaLink="false">http://thegouldfish.co.uk/?p=29</guid>
		<description><![CDATA[There are many ways to create 2D arrays in C# so I decided to take a look at 4 different methods and see which one was the fastest. The 4 &#8230;<div class="margin10t"><a href="http://thegouldfish.co.uk/2011/05/25/c-2d-array-types-on-pc-360-and-wp7/" class="more-link">Read More</a></div>]]></description>
			<content:encoded><![CDATA[<p>There are many ways to create 2D arrays in C# so I decided to take a look at 4 different methods and see which one was the fastest.</p>
<p>The 4 types that were chosen:</p>
<ul>
<li>List of lists(List&lt; List &lt; &gt; &gt;)</li>
<li>Jagged arrays ([][])</li>
<li>Multidimensional arrays ([,])</li>
<li>1D array using maths to find the place ((y * size) + x).</li>
</ul>
<p>1000 x 1000 sized arrays were created and tested, these tests included Creation, Filling, finding 1 value (at position 500&#215;500) and iterating across the whole array, time is in milliseconds.</p>
<p>&nbsp;</p>
<h2>Results</h2>
<pre>
<pre><strong>Windows7</strong>
List of Lists
   Create: 0    Build: 29.0016
   Find 1: 0   Iterate: 15.0009
Multi Dimensional
    Create: 0    Build: 12.0007
    Find 1: 1.0001    Iterate: 11.0006
Jagged
    Create: 0    Build: 8.0004
    Find 1: 0    Iterate: 6.0004
1D Array
    Create: 0    Build: 8.0004
    Find 1: 0    Iterate: 6.0004

<strong>WP7</strong>
List of Lists
   Create: 64    Build: 261
   Find 1: 1   Iterate: 142
Multi Dimensional
    Create: 4    Build: 120
    Find 1: 0    Iterate: 120
Jagged
    Create: 0    Build: 64
    Find 1: 0    Iterate: 46
1D Array
    Create: 0    Build: 64
    Find 1: 0    Iterate: 46

<strong>XBOX 360</strong>
List of Lists
   Create: 5    Build: 185
   Find 1: 0   Iterate: 139
Multi Dimensional
    Create: 1    Build: 120
    Find 1: 0    Iterate: 136
Jagged
    Create: 1    Build: 64
    Find 1: 0    Iterate: 62
1D Array
    Create: 1    Build: 64
    Find 1: 0    Iterate: 62</pre>
</pre>
<p>&nbsp;</p>
<p>From the numbers is looks like C# internally works a Jagged array as a 1D array and does that math for us and so from a speed and easy of use point of view it seems Jagged arrays win out.</p>
<p>&nbsp;</p>
<p>Huge thanks to MadNinjas of #XNA (irc.efnet.net) for running the code on the other platforms!</p>
<p>[edit]<br />
It seems I had mixed up the multi dimensional and jagged arrays in my code so my numbers were wrong, this is now fixed.</p>
]]></content:encoded>
			<wfw:commentRss>http://thegouldfish.co.uk/2011/05/25/c-2d-array-types-on-pc-360-and-wp7/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Tools: Key Frame Animation tool, Part 1</title>
		<link>http://thegouldfish.co.uk/2011/05/12/tools-key-frame-animation-tool-part-1/</link>
		<comments>http://thegouldfish.co.uk/2011/05/12/tools-key-frame-animation-tool-part-1/#comments</comments>
		<pubDate>Thu, 12 May 2011 20:07:16 +0000</pubDate>
		<dc:creator>GouldFish</dc:creator>
				<category><![CDATA[Game Development]]></category>
		<category><![CDATA[Development]]></category>
		<category><![CDATA[tools]]></category>
		<category><![CDATA[XNA]]></category>

		<guid isPermaLink="false">http://thegouldfish.co.uk/?p=18</guid>
		<description><![CDATA[I thought I would post up a quick tool I have written to make it easy to animate and create my sprites for my games. This is written in C# &#8230;<div class="margin10t"><a href="http://thegouldfish.co.uk/2011/05/12/tools-key-frame-animation-tool-part-1/" class="more-link">Read More</a></div>]]></description>
			<content:encoded><![CDATA[<p>I thought I would post up a quick tool I have written to make it easy to animate and create my sprites for my games.</p>
<p>This is written in C# and it using XNA for the drawing of the sprite example, time line and animation preview.  It helps that I&#8217;m using XNA for my Indie game development. I&#8217;m also using the great Dock Panel to give me dockable forms.</p>
<p>For starting a tool like this I typically make sure I get the data class (at least the members) right then add the needed methods that are needed while working on the tool.</p>
<p>Now for saving and loading the created animations I just use XML, this because its really easy to serialise classes to XML in C# and it means if anything goes wrong its easy to open the file and edit it.  As we know loading XML in our game can be slow so the best idea is to create a custom content importer to get it in game quickly.</p>
<p>&nbsp;</p>
<p>So with out any more waffling here is the video (yes that is me talking):</p>
<p>&nbsp;<br />
<iframe width="640" height="390" src="http://www.youtube.com/embed/NHakWeDqVgc" frameborder="0" allowfullscreen></iframe></p>
]]></content:encoded>
			<wfw:commentRss>http://thegouldfish.co.uk/2011/05/12/tools-key-frame-animation-tool-part-1/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Start Off Small</title>
		<link>http://thegouldfish.co.uk/2011/05/07/start-off-small/</link>
		<comments>http://thegouldfish.co.uk/2011/05/07/start-off-small/#comments</comments>
		<pubDate>Sat, 07 May 2011 16:13:54 +0000</pubDate>
		<dc:creator>GouldFish</dc:creator>
				<category><![CDATA[Game Development]]></category>
		<category><![CDATA[Novice]]></category>

		<guid isPermaLink="false">http://thegouldfish.co.uk/?p=12</guid>
		<description><![CDATA[So you have decided to make a computer game, that&#8217;s great the question is what game do you want to create first? Most new developers will answer that they want &#8230;<div class="margin10t"><a href="http://thegouldfish.co.uk/2011/05/07/start-off-small/" class="more-link">Read More</a></div>]]></description>
			<content:encoded><![CDATA[<p>So you have decided to make a computer game, that&#8217;s great the question is what game do you want to create first?</p>
<p>Most new developers will answer that they want to create the game they have always wanted to.</p>
<p>This is the first problem, as while you are full of enthusiasm and energy you also lack experience. Game development is hard and time consuming, far more then you would expect when first starting out and as such you are unlikely to pull off your perfect game first time, your first few games will end up buggy and barely working and most people  give up before getting anywhere because they tried to do more then they are currently capable of.</p>
<p>So where do you start?<br />
Do a small simple game, something that will allow you to learn the basics of game development with out the worry of trying to build your perfect game. This could be something as simple as pong or Tetris, which will teach you how to draw graphics, handle  input and basics game systems.<br />
Once you&#8217;ve finished your first few games you will not only have a better understanding of how to make a game but you will also have more enthusiasm for it.</p>
]]></content:encoded>
			<wfw:commentRss>http://thegouldfish.co.uk/2011/05/07/start-off-small/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Welcome to GouldFish On Games</title>
		<link>http://thegouldfish.co.uk/2011/05/07/welcome-to-gouldfish-on-games/</link>
		<comments>http://thegouldfish.co.uk/2011/05/07/welcome-to-gouldfish-on-games/#comments</comments>
		<pubDate>Sat, 07 May 2011 10:49:17 +0000</pubDate>
		<dc:creator>GouldFish</dc:creator>
				<category><![CDATA[Site news]]></category>

		<guid isPermaLink="false">http://thegouldfish.co.uk/?p=10</guid>
		<description><![CDATA[This is going to be my new personal Blog. I&#8217;m planning on using this to talk about games and game development, expect more in the future. The game development posts &#8230;<div class="margin10t"><a href="http://thegouldfish.co.uk/2011/05/07/welcome-to-gouldfish-on-games/" class="more-link">Read More</a></div>]]></description>
			<content:encoded><![CDATA[<p>This is going to be my new personal Blog.</p>
<p>I&#8217;m planning on using this to talk about games and game development, expect more in the future.</p>
<p>The game development posts will cover a wide mix of topics and development levels.  I will be going from complete novice upto expert, I plan on tagging these to help out.</p>
]]></content:encoded>
			<wfw:commentRss>http://thegouldfish.co.uk/2011/05/07/welcome-to-gouldfish-on-games/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

