<?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>GBGames - Thoughts on Indie Game Development &#187; Learning Kyra Series</title>
	<atom:link href="http://gbgames.com/blog/category/learning-kyra-series/feed/" rel="self" type="application/rss+xml" />
	<link>http://gbgames.com/blog</link>
	<description>An Indie Game Developer's somewhat interesting thoughts</description>
	<lastBuildDate>Wed, 08 Feb 2012 10:30:09 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
		<item>
		<title>Learning Kyra: Installing the New Version</title>
		<link>http://gbgames.com/blog/2005/10/learning-kyra-installing-the-new-version/</link>
		<comments>http://gbgames.com/blog/2005/10/learning-kyra-installing-the-new-version/#comments</comments>
		<pubDate>Thu, 27 Oct 2005 07:00:06 +0000</pubDate>
		<dc:creator>GBGames</dc:creator>
				<category><![CDATA[Learning Kyra Series]]></category>
		<category><![CDATA[Linux Game Development]]></category>

		<guid isPermaLink="false">http://gbgames.com/blog/?p=235</guid>
		<description><![CDATA[<p>I decided to install the latest version of the Kyra Sprite Engine since I am still so early in the Oracle&#8217;s Eye project. Historically, Kyra allowed you to dynamically link to the library, and so I had it installed on my system as any other library. </p> <p>I wanted to install the latest version similarly. <span style="color:#777"> . . . &#8594; Read More: <a href="http://gbgames.com/blog/2005/10/learning-kyra-installing-the-new-version/">Learning Kyra: Installing the New Version</a></span><p><a href="http://gbgames.com/blog/2005/10/learning-kyra-installing-the-new-version/">Learning Kyra: Installing the New Version</a> is a post from: <a href="http://gbgames.com/blog">GBGames - Thoughts on Indie Game Development</a></p>
]]></description>
			<content:encoded><![CDATA[<p>I decided to install the latest version of the <a href="http://kyra.sf.net">Kyra Sprite Engine</a> since I am still so early in the <a href="http://gbgames.com/blog/index.php?p=114"><i>Oracle&#8217;s Eye</i></a> project.  Historically, Kyra allowed you to dynamically link to the library, and so I had it installed on my system as any other library.  </p>
<p>I wanted to install the latest version similarly.  I found that the latest version doesn&#8217;t have a working <i>configure</i> file; I was expecting to be able to use the standard ./configure; make; make install.  It still worked for the most part without the ./configure part.  In fact I took advantage of <a href="http://www.linux.com/article.pl?sid=05/10/07/1523201">checkinstall</a> to create a nice Debian package for me so I can uninstall and install easily.  </p>
<p>So it builds, but I found that there are a few differences. For one, kyra-config doesn&#8217;t exist.  I normally used it to get the cflags and the lib arguments for my Makefile, similar to the way you would use sdl-config.   So, how do you build a project now?</p>
<p>I asked on the <a href="https://sourceforge.net/forum/forum.php?thread_id=1374328&#038;forum_id=149869">Kyra forums</a>, and the maintainer was actually just sitting in front of it waiting for my posts.  He was that quick!  Eventually I found that the way I wanted to use Kyra wasn&#8217;t the way it was supposed to be used anymore.  </p>
<p>Kyra isn&#8217;t currently capable of being backwards compatible, meaning that different versions of the same library can&#8217;t be installed at the same time.  So basically statically linking is easier and less likely to cause problems.  My only concern is the fact that the LGPL license requires different things for code that statically links to it, but I was planning on releasing my code under the GPL anyway so it isn&#8217;t a huge problem.  </p>
<p>To make one of my famously long stories short, I ended up working on my Makefile and the library until I found out how to get it to work dynamically&#8230;just in time to read that I shouldn&#8217;t use it that way.  I managed to get my project to build with the new library only to find out that I should use it a different way.  I spent some more time until I finally managed to get it to build the preferred way.  I have a source directory with all of my source files as well as a subdirectory with the Kyra library source.  </p>
<p>It was definitely a good learning experience, as I learned more about linking and libraries on my Gnu/Linux system.  I actually built my project successfully three different times: once with the old dynamic library, once with the new library fixed up to be dynamic, and once with the code statically linked.  The last option is actually cool because I can actually add the Kyra library directory to my Subversion repository for <a href="http://gbgames.com/blog/index.php?p=114"><i>Oracle&#8217;s Eye</i></a>.  </p>
<p>Still, I would have liked to schedule my learning experiences better.  I was supposed to be working on my game project instead of the supporting library.  I really wanted to try to work on what William Willing mentioned on his blog about <a href="http://ronkes.nl/blog/?2005-10-26-compositionvsinheritance">Composition vs Inheritance</a>.  I&#8217;ll probably be able to work on it this Friday though.  At least the new library seems to be working great now.  </p>
<p><a href="http://gbgames.com/blog/2005/10/learning-kyra-installing-the-new-version/">Learning Kyra: Installing the New Version</a> is a post from: <a href="http://gbgames.com/blog">GBGames - Thoughts on Indie Game Development</a></p>
]]></content:encoded>
			<wfw:commentRss>http://gbgames.com/blog/2005/10/learning-kyra-installing-the-new-version/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Oracle&#8217;s Eye Development:  The Room 2</title>
		<link>http://gbgames.com/blog/2005/10/oracles-eye-development-the-room-2/</link>
		<comments>http://gbgames.com/blog/2005/10/oracles-eye-development-the-room-2/#comments</comments>
		<pubDate>Thu, 06 Oct 2005 07:00:14 +0000</pubDate>
		<dc:creator>GBGames</dc:creator>
				<category><![CDATA[Game Development]]></category>
		<category><![CDATA[Learning Kyra Series]]></category>

		<guid isPermaLink="false">http://gbgames.com/blog/?p=212</guid>
		<description><![CDATA[<p>Last night&#8217;s Oracle&#8217;s Eye programming session was still productive, although not as much as I would have liked. I last had a Room that would get created, and the Player would be able to walk over it.</p> <p>I wanted the Player and the Walls to be on the same hiearchical level, and the Floors should <span style="color:#777"> . . . &#8594; Read More: <a href="http://gbgames.com/blog/2005/10/oracles-eye-development-the-room-2/">Oracle&#8217;s Eye Development:  The Room 2</a></span><p><a href="http://gbgames.com/blog/2005/10/oracles-eye-development-the-room-2/">Oracle&#8217;s Eye Development:  The Room 2</a> is a post from: <a href="http://gbgames.com/blog">GBGames - Thoughts on Indie Game Development</a></p>
]]></description>
			<content:encoded><![CDATA[<p>Last night&#8217;s <i><a href="http://gbgames.com/blog/index.php?p=114">Oracle&#8217;s Eye</a></i> programming session was still productive, although not as much as I would have liked.    I last had a Room that would get created, and the Player would be able to walk over it.</p>
<p>I wanted the Player and the Walls to be on the same hiearchical level, and the Floors should be underneath.  That way, Floors can be added to <a href="http://kyra.sf.net">Kyra</a>&#8216;s KrImageTree as much as I want without the Player getting covered.</p>
<p>I already knew that I could setup the Tree by creating KrImNodes to act as the root of subtrees.  Normally if you just add nodes to the tree, the later nodes will cover the earlier ones.  I could instead add nodes to the child nodes instead to control the hiearchy.  For instance, I could create a background and a foreground by adding background and foreground KrImNodes:</p>
<p><code>    KrImNode* background = new KrImNode;<br />
    KrImNode* foreground = new KrImNode;<br />
    engine_-&gt;Tree()-&gt;AddNode( 0, background );<br />
    engine_-&gt;Tree()-&gt;AddNode( 0, foreground );</code></p>
<p>AddNode() takes as arguments the parent node and the node you want to add.  In the above example, I am adding two new nodes to the root node.  Now I can put as many items in the background as I want, and I won&#8217;t have to worry about covering up anything in the foreground tree.  I already used this technique before with my <a href="http://gbgames.com/blog/index.php?p=70">Game in a Day</a> in June.</p>
<p>What I learned was that I could also name a node.  Kyra doesn&#8217;t care about the name, but I found that I could name a node and than search for a node with that name.</p>
<p><code>    KrImNode* background = new KrImNode;<br />
    KrImNode* foreground = new KrImNode;<br />
    background-&gt;SetNodeName( "background" );<br />
    foreground-&gt;SetNodeName( "foreground" );<br />
    engine_-&gt;Tree()-&gt;AddNode( 0, background );<br />
    engine_-&gt;Tree()-&gt;AddNode( 0, foreground );</code></p>
<p>Now if another section of my code doesn&#8217;t know the specific pointers to the nodes in question, I can still do a search and get the information I need.  For instance, in my GameWorldFactory&#8217;s createRoom() function:</p>
<p><code>engine_-&gt;Tree()-&gt;AddNode(<br />
                engine_-&gt;Tree()-&gt;FindNodeByName( "background" ),<br />
                floor-&gt;getSprite()<br />
                );</code></p>
<p>The result is that the Player can walk over the FloorTiles and gets covered by the WallTiles if the Player sprite was added to the foreground before the Room&#8217;s Tiles were.</p>
<p>The cool thing is that the separation of the Tiles into the hierarchy also makes it a lot easier to do collision detection.  My previous code to move the player:</p>
<p><code>void GameWorld::moveY( const double distance )<br />
{<br />
    player_-&gt;moveY( distance );<br />
}</code></p>
<p>My current code to move the player:</p>
<p><code>void GameWorld::moveY( const double distance )<br />
{<br />
    engine_-&gt;Tree()-&gt;Walk();<br />
    //! Check if moving Player sprite would intersect a wall.<br />
    //! If so, do not move the Player.<br />
    player_-&gt;moveY( distance );<br />
    if ( engine_-&gt;Tree()-&gt;CheckSiblingCollision (<br />
                player_-&gt;getSprite(),<br />
                &#038;spritesHit,<br />
                0<br />
                ) )<br />
    {<br />
        //! Reverse direction to restore position.<br />
        player_-&gt;moveY( -distance );<br />
    }<br />
}<br />
</code></p>
<p>Since the Player&#8217;s sprite and the WallTiles&#8217; sprites are siblings, and the FloorTiles&#8217; sprites aren&#8217;t, I can simply check for collision with the siblings.  CheckSiblingCollision() returns true if there was a collision, and so what I do is move the Player back the same distance, which should place it where it was before the move.</p>
<p>Unfortunately, it doesn&#8217;t quite seem to work.  The Player does obey the WallTiles, but it then gets stuck.  I think the problem is the double precision used for the distance.  The sprite makes use of integers to move, and so I am probably losing precision.  When I move the player back, it might be just short of where it should be.</p>
<p>Before this week, I was looking at a single Tile and a Player that moved around it.  Now I have an actual Room and simple, although flawed, collision detection to keep the Player in the Room.</p>
<p>I&#8217;m also wondering if PlayState should still own the Kyra engine.  I think that maybe GameWorld should own it instead since it makes use of it more, but for now I at least know that the project is working.  I can always optimize later, and in the meantime I am making steady progress.</p>
<p><a href="http://gbgames.com/blog/2005/10/oracles-eye-development-the-room-2/">Oracle&#8217;s Eye Development:  The Room 2</a> is a post from: <a href="http://gbgames.com/blog">GBGames - Thoughts on Indie Game Development</a></p>
]]></content:encoded>
			<wfw:commentRss>http://gbgames.com/blog/2005/10/oracles-eye-development-the-room-2/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Learning Kyra:  A New Version Released</title>
		<link>http://gbgames.com/blog/2005/09/learning-kyra-a-new-version-released/</link>
		<comments>http://gbgames.com/blog/2005/09/learning-kyra-a-new-version-released/#comments</comments>
		<pubDate>Wed, 28 Sep 2005 07:00:44 +0000</pubDate>
		<dc:creator>GBGames</dc:creator>
				<category><![CDATA[Learning Kyra Series]]></category>
		<category><![CDATA[Linux Game Development]]></category>

		<guid isPermaLink="false">http://gbgames.com/blog/?p=201</guid>
		<description><![CDATA[<p>Recently I received an email from the Kyra mailing list announcing the newest update to the Kyra Sprite Engine. It is now at version 2.1.1, and the tutorials and installation notes seem to have an upgrade as well. </p> <p>A big change is the license. It used to be dual licensed. You could either make <span style="color:#777"> . . . &#8594; Read More: <a href="http://gbgames.com/blog/2005/09/learning-kyra-a-new-version-released/">Learning Kyra:  A New Version Released</a></span><p><a href="http://gbgames.com/blog/2005/09/learning-kyra-a-new-version-released/">Learning Kyra:  A New Version Released</a> is a post from: <a href="http://gbgames.com/blog">GBGames - Thoughts on Indie Game Development</a></p>
]]></description>
			<content:encoded><![CDATA[<p>Recently I received an email from the Kyra mailing list announcing the newest update to the <a href="http://kyra.sf.net">Kyra Sprite Engine</a>.  It is now at version 2.1.1, and the tutorials and installation notes seem to have an upgrade as well.  </p>
<p>A big change is the license.  It used to be dual licensed.  You could either make use of the GPL or the LGPL.  Now it is under the LGPL for any purpose and without the requirement to display a splash screen.</p>
<p>One of the new features is <a href="http://www.grinninglizard.com/kyra/isogen.htm">Isogen</a>, a tool for quickly and easily generating seamless tiles and walls for isometric games.   It looks pretty cool and makes me think about the possibility of developing isometric games.</p>
<p>It can compile with Gnu/Linux, BSD, and MinGW32.  There is the ability to compile for Mac OS X, but apparently the run-time performance leaves much to be desired&#8230;but the source is freely available to those who would be able to submit patches!</p>
<p>Another thing I&#8217;ve been interested in is learning the Python programming language.  People have been suggesting it to me recently, and I think after I finish <i><a href="http://gbgames.com/blog/index.php?p=114">Oracle&#8217;s Eye</a></i> I will look into the language.  The cool thing is that I won&#8217;t necessarily have to find a new graphics library since there is a Python binding called <a href="http://www.alobbs.com/modules.php?op=modload&amp;name=pykyra&amp;file=index" class="broken_link">PyKyra</a>.  It isn&#8217;t new, but I just noticed it was a possibility. </p>
<p>I&#8217;ll need to check and see how much it breaks backwards compatibility with the old version, but I am really looking forward to giving Kyra 2.1.1 a spin.</p>
<p><a href="http://gbgames.com/blog/2005/09/learning-kyra-a-new-version-released/">Learning Kyra:  A New Version Released</a> is a post from: <a href="http://gbgames.com/blog">GBGames - Thoughts on Indie Game Development</a></p>
]]></content:encoded>
			<wfw:commentRss>http://gbgames.com/blog/2005/09/learning-kyra-a-new-version-released/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Learning Kyra:  Sprite Loading</title>
		<link>http://gbgames.com/blog/2005/08/learning-kyra-sprite-loading/</link>
		<comments>http://gbgames.com/blog/2005/08/learning-kyra-sprite-loading/#comments</comments>
		<pubDate>Thu, 18 Aug 2005 07:00:54 +0000</pubDate>
		<dc:creator>GBGames</dc:creator>
				<category><![CDATA[Learning Kyra Series]]></category>

		<guid isPermaLink="false">/?p=141</guid>
		<description><![CDATA[<p>While working on Oracle&#8217;s Eye, I learned something new about the Kyra Sprite Engine. For some time I&#8217;ve wondered how I would load sprites from a script. Normally, I would load a sprite resource with:</p> <p> GetSpriteResource( Char_Player) </p> <p>where Char_Player is a constant defined in a .h file generated by Kyra&#8217;s Sprite Editor. While <span style="color:#777"> . . . &#8594; Read More: <a href="http://gbgames.com/blog/2005/08/learning-kyra-sprite-loading/">Learning Kyra:  Sprite Loading</a></span><p><a href="http://gbgames.com/blog/2005/08/learning-kyra-sprite-loading/">Learning Kyra:  Sprite Loading</a> is a post from: <a href="http://gbgames.com/blog">GBGames - Thoughts on Indie Game Development</a></p>
]]></description>
			<content:encoded><![CDATA[<p>While working on <a href="http://gbgames.com/blog/index.php?p=114">Oracle&#8217;s Eye</a>,  I learned something new about the <a href="http://kyra.sf.net">Kyra Sprite Engine</a>.  For some time I&#8217;ve wondered how I would load sprites from a script.  Normally, I would load a sprite resource with:</p>
<p><code> GetSpriteResource( Char_Player) </code></p>
<p>where Char_Player is a constant defined in a .h file generated by Kyra&#8217;s Sprite Editor.  While I could write a file to load the U32 that the constant referred to, it seemed unwieldy to have a script file that looked like:</p>
<p><code><br />
Player  1 &lt; &lt; 0<br />
Enemy 2 &lt; &lt; 0<br />
...<br />
</code></p>
<p>I would think that updating such a file would be confusing, if not a nightmare.  </p>
<p>So while perusing the code files looking for information on how to do something else entirely, I saw that the test programs provided with Kyra had lines that looked like:</p>
<p><code>bigRes = engine-&gt;Vault()-&gt;GetSpriteResource( "LARGE" );<br />
medRes = engine-&gt;Vault()-&gt;GetSpriteResource( "MED" );<br />
smallRes = engine-&gt;Vault()-&gt;GetSpriteResource( "SMALL" );<br />
</code></p>
<p>I was excited that I could apparently load sprites by name, but I didn&#8217;t remember seeing anything about how to do it in the documentation.  I looked more closely and found something about how to refer to a sprite&#8217;s action by name, but not the sprite itself.  After some more hunting through the code, API, and documentation, I figured it out.</p>
<p>The name of the constant Character_Player was made by creating a sprite called Player.  Character_ was just a prefix I used for all characters.  Kyra allows me to refer to the name of the sprite as &#8220;Player&#8221;, however.  So:</p>
<p><code> GetSpriteResource( Char_Player) </code><br />
is interchangeable with<br />
<code> GetSpriteResource( "Player") </code></p>
<p>and naturally that means that I can do something like this:</p>
<p><code>string name = GetEntityName();<br />
GetSpriteResource( name.c_str() );</code></p>
<p>Voila!  Sprite loading by script is possible!  The only thing I need to do is make sure that the names that I give my sprites using the Sprite Editor are the same as the names in my script, but it is definitely better than syncing the names with things like ( 1 << 0 ).</p>
<p><a href="http://gbgames.com/blog/2005/08/learning-kyra-sprite-loading/">Learning Kyra:  Sprite Loading</a> is a post from: <a href="http://gbgames.com/blog">GBGames - Thoughts on Indie Game Development</a></p>
]]></content:encoded>
			<wfw:commentRss>http://gbgames.com/blog/2005/08/learning-kyra-sprite-loading/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Learning Kyra: Some Tidbits of Info</title>
		<link>http://gbgames.com/blog/2005/07/learning-kyra-minor-updates/</link>
		<comments>http://gbgames.com/blog/2005/07/learning-kyra-minor-updates/#comments</comments>
		<pubDate>Tue, 12 Jul 2005 07:00:06 +0000</pubDate>
		<dc:creator>GBGames</dc:creator>
				<category><![CDATA[Learning Kyra Series]]></category>

		<guid isPermaLink="false">/?p=51</guid>
		<description><![CDATA[<p>The Learning Kyra series to date:</p> Learning Kyra Learning More Kyra Learning Kyra: Attack of the Clones Learning Kyra: Tiles and Z-Ordering Learning Kyra: Hit Detection <p></p> <p>I&#8217;ve spent some time just reading through the documentation for SDL and Kyra. I&#8217;ve also tried to pick up what I can at Kyra&#8217;s forums on SourceForge. </p> <span style="color:#777"> . . . &#8594; Read More: <a href="http://gbgames.com/blog/2005/07/learning-kyra-minor-updates/">Learning Kyra: Some Tidbits of Info</a></span><p><a href="http://gbgames.com/blog/2005/07/learning-kyra-minor-updates/">Learning Kyra: Some Tidbits of Info</a> is a post from: <a href="http://gbgames.com/blog">GBGames - Thoughts on Indie Game Development</a></p>
]]></description>
			<content:encoded><![CDATA[<p><i>The Learning Kyra series to date:</p>
<ol>
<li><a href="http://gbgames.com/blog/index.php?p=27">Learning Kyra</a></li>
<li><a href="http://gbgames.com/blog/index.php?p=29">Learning More Kyra</a></li>
<li><a href="http://gbgames.com/blog/index.php?p=30">Learning Kyra: Attack of the Clones</a></li>
<li><a href="http://gbgames.com/blog/index.php?p=43">Learning Kyra: Tiles and Z-Ordering</a></li>
<li><a href="http://gbgames.com/blog/index.php?p=45">Learning Kyra: Hit Detection</a></li>
</ol>
<p></i></p>
<p>I&#8217;ve spent some time just reading through the documentation for <a href="http://www.libsdl.org">SDL</a> and <a href="http://kyra.sf.net">Kyra</a>.  I&#8217;ve also tried to pick up what I can at Kyra&#8217;s forums on <a href="http://www.sf.net">SourceForge</a>.  </p>
<p>For instance, GlDynArray has been removed from the library for the next update.  I can substitute std::vector&lt;&gt; though, which for all intents and purposes means very little has changed except for a redirection/abstraction.  For now, I need to use it when doing hit detection, but I shouldn&#8217;t rely on it for my own code.</p>
<p>I was thinking about the need for more complex animations and Actions for an individual sprite.  For example, a sprite may have a standing animation.  When you press the space bar, an attack animation should run, but I might not want it to loop over and over.   Was I going to have to keep track of how many frames of animation there were for a given Action in order to make sure it doesn&#8217;t loop?</p>
<p>Nope!  Turns out that Kyra&#8217;s KrSprite class has functions for determining the number of frames for an animation and for getting the current frame.  Now I can do something like the following:</p>
<p><code><br />
if ( theSprite-&gt;Frame() &gt;= numFrames )<br />
{<br />
// then the ATTACKING animation is over and should change state<br />
}<br />
</code></p>
<p>I also found that a sprite can clone itself.  In my <a href="http://gbgames.com/blog/index.php?p=70">June GID</a>, I had these fuzzy creatures multiplying, but I loaded in a resource from a file and created a sprite from the resource.  I originally thought that I could optimize it by storing the resource to be used later, but I could further optimize by just using the Clone() function to create a new sprite.  I could also use GetResource to get a pointer to the resource used by an existing sprite if I really needed it.  </p>
<p>I want to work on some code to test what I&#8217;ve learned to see how well it works.  I can get something substantial completed this week.</p>
<p><a href="http://gbgames.com/blog/2005/07/learning-kyra-minor-updates/">Learning Kyra: Some Tidbits of Info</a> is a post from: <a href="http://gbgames.com/blog">GBGames - Thoughts on Indie Game Development</a></p>
]]></content:encoded>
			<wfw:commentRss>http://gbgames.com/blog/2005/07/learning-kyra-minor-updates/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Learning Kyra: Hit Detection</title>
		<link>http://gbgames.com/blog/2005/05/learning-kyra-hit-detection/</link>
		<comments>http://gbgames.com/blog/2005/05/learning-kyra-hit-detection/#comments</comments>
		<pubDate>Wed, 11 May 2005 04:06:39 +0000</pubDate>
		<dc:creator>GBGames</dc:creator>
				<category><![CDATA[Learning Kyra Series]]></category>

		<guid isPermaLink="false">/?p=45</guid>
		<description><![CDATA[<p>The Learning Kyra series to date:</p> Learning Kyra Learning More Kyra Learning Kyra: Attack of the Clones Learning Kyra: Tiles and Z-Ordering <p></p> <p>I covered collision detection already, but it was in a limited capacity in Attack of the Clones. Basically, I checked if a sprite was colliding with a specific object. But what happens <span style="color:#777"> . . . &#8594; Read More: <a href="http://gbgames.com/blog/2005/05/learning-kyra-hit-detection/">Learning Kyra: Hit Detection</a></span><p><a href="http://gbgames.com/blog/2005/05/learning-kyra-hit-detection/">Learning Kyra: Hit Detection</a> is a post from: <a href="http://gbgames.com/blog">GBGames - Thoughts on Indie Game Development</a></p>
]]></description>
			<content:encoded><![CDATA[<p><i>The Learning Kyra series to date:</p>
<ol>
<li><a href="http://gbgames.com/blog/index.php?p=27">Learning Kyra</a></li>
<li><a href="http://gbgames.com/blog/index.php?p=29">Learning More Kyra</a></li>
<li><a href="http://gbgames.com/blog/index.php?p=30">Learning Kyra: Attack of the Clones</a></li>
<li><a href="http://gbgames.com/blog/index.php?p=43">Learning Kyra: Tiles and Z-Ordering</a></li>
</ol>
<p></i></p>
<p>I covered collision detection already, but it was in a limited capacity in Attack of the Clones.   Basically, I checked if a sprite was colliding with a specific object.  But what happens when I want to check for collisions with objects that have been added dynamically and prevent me from anticipating them at compile time?</p>
<p>The code below creates a number of sprites from the same resource.  Kyra comes with the Grinning Lizard Utilities, so those are prefaced with Gl.  I think that it makes it confusing if you want to mix your code with OpenGL, but whatever.  One of the utilities is <i>GlDynArray</i>, which acts very much like the C++ Standard Library&#8217;s <i>vector</i> class.  While it is in the provided demo code, I couldn&#8217;t find any mention of it in the documentation.  I simply followed along with the demo in shooter.cpp.  I created an array and added 10 ghost sprites to it.  In the code below, MAX_GHOSTS  is equal to 10.  I also add those sprites to the tree.</p>
<p><code>KrSpriteResource* ghostRes = engine-&gt;Vault()-&gt;GetSpriteResource(GHOST_ghost);<br />
GLASSERT( ghostRes );</code></p>
<p><code>KrSprite* ghost = new KrSprite( ghostRes );<br />
ghost-&gt;SetPos( GHOST_START_X, GHOST_START_Y - 64);<br />
engine-&gt;Tree()-&gt;AddNode( midgroundTree, ghost ); </code></p>
<p><code>GlDynArray&lt; KrImage* &gt; otherGhost;<br />
for (int i = 0; i &lt; MAX_GHOSTS; ++i)<br />
     otherGhost.PushBack( new KrSprite( ghostRes ));<br />
for (int i = 0; i &lt; (int)otherGhost.Count(); ++i) {<br />
     otherGhost[i]-&gt;SetPos( GHOST_START_X, GHOST_START_Y );<br />
     engine-&gt;Tree()-&gt;AddNode( midgroundTree, otherGhost[i] );<br />
}</code></p>
<p>So now I have a bunch of ghosts bunched up in the center, which is where GHOST_START_X, GHOST_START_Y sets them.  I placed the player&#8217;s ghost about two tiles higher.  Since I was going for simplicity, and I mostly hacked out this code without  designing it first, I just made the sprites in otherGhost move around randomly.   Another utility is <i>GlRandom</i>, which provides random number generators that are superior to <i>rand()</i> provided by C++.   The following code demonstrates how I used it:</p>
<p><code>GlRandom random;</code></p>
<p><code> ...<br />
//the following is in the main loop<br />
for (int i = 0; i &lt; otherGhost.Count(); ++i) { </code></p>
<p><code> ...<br />
  otherGhost[i]-&gt;SetPos( otherGhost[i]-&gt;X() + (random.Rand(3) - 1) * moveSpeed , otherGhost[i]-&gt;Y() + ( random.Rand(3) - 1) * moveSpeed);</code><br />
<code> ...<br />
}</code></p>
<p>So now each of the sprites in otherGhost move in random directions.  I move the original ghost much the same way as I moved my clone sprite in previous Learning Kyra entry.  Well, there is movement for the player and other objects, but what about collision?</p>
<p><a title="Those darn ghosts...  You can also see the tile map I created." href="http://www.gbgames.com/downloads/kyra_game/" class="broken_link"><img src="http://www.gbgames.com/blog/images/kyraGhostGame1.png"></a></p>
<p><code>if (engine-&gt;Tree()-&gt;CheckSiblingCollision(ghost, &#038;hit, 0) ) {<br />
for (int i = 0; i &lt; (int)hit.Count(); ++i) {<br />
engine-&gt;Tree()-&gt;DeleteNode(hit[i]);<br />
int j = otherGhost.Find(hit[i]);<br />
otherGhost.Remove(j);<br />
}<br />
if (otherGhost.Count() &lt; 1 )<br />
done = true;<br />
}</code></p>
<p>Very simply, if the main ghost collides with any of the other ghosts, those ghosts disappear.  When the last one disappears, the main loop ends, and since I hacked this out instead of designing it, so does the program.   Still, it is game-like.  I experimented with other options to see what else I could do.  </p>
<p>Instead of removing the ghosts from the tree, you could make them stationary, sort of like in Freeze Tag.  As they get hit, I remove them from the otherGhost vector to keep them from moving about, but I also added the following to fade them a bit:</p>
<p><code>KrColorTransform color = hit[i]-&gt;CTransform( 0 );<br />
color.SetAlpha( 50 );<br />
hit[i]-&gt;SetColor(color, 0);</code></p>
<p>While it isn&#8217;t fun or polished in any way, I don&#8217;t think I can expect too much more from this specific project, at least not without struggling through painful changes.  I didn&#8217;t set specific goals so the project simply evolved.   I&#8217;ll consider this project complete and move on to a new project that will benefit from my new experience and some better design.  You can download the project as it stands from one of the links below:</p>
<p><i><br />
<a href="../downloads/kyra_game/KyraGame-r1.tar.gz" class="broken_link">KyraGame-r1.tar.gz</a><br />
<a href="../downloads/kyra_game/KyraGame-r1.zip" class="broken_link">KyraGame-r1.zip</a><br />
<a href="../downloads/kyra_test/kyra_src_2_0_7.tar.gz" class="broken_link">Kyra Source in .tar.gz format</a><br />
<a href="../downloads/kyra_test/kyra_src_2_0_7.zip" class="broken_link">Kyra Source in .zip format</a></p>
<p>NOTE: You will need Kyra v2.0.7 to use this code.  Also, the comments in the code weren&#8217;t all updated to reflect the fact that I&#8217;ve changed it.  It is licensed under the GPL or LGPL as specified.  </i></p>
<p><a href="http://gbgames.com/blog/2005/05/learning-kyra-hit-detection/">Learning Kyra: Hit Detection</a> is a post from: <a href="http://gbgames.com/blog">GBGames - Thoughts on Indie Game Development</a></p>
]]></content:encoded>
			<wfw:commentRss>http://gbgames.com/blog/2005/05/learning-kyra-hit-detection/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Learning Kyra: Tiles and Z-Ordering</title>
		<link>http://gbgames.com/blog/2005/05/learning-kyra-tiles-and-z-ordering/</link>
		<comments>http://gbgames.com/blog/2005/05/learning-kyra-tiles-and-z-ordering/#comments</comments>
		<pubDate>Fri, 06 May 2005 18:47:18 +0000</pubDate>
		<dc:creator>GBGames</dc:creator>
				<category><![CDATA[Learning Kyra Series]]></category>

		<guid isPermaLink="false">/?p=43</guid>
		<description><![CDATA[<p>Another entry in the Learning Kyra series. The series to date:</p> Learning Kyra Learning More Kyra Learning Kyra: Attack of the Clones <p></p> <p>The first three entries in the series documented my attempts at learning about the engine. I had a goal to become more familiar with the engine by the end of the month, <span style="color:#777"> . . . &#8594; Read More: <a href="http://gbgames.com/blog/2005/05/learning-kyra-tiles-and-z-ordering/">Learning Kyra: Tiles and Z-Ordering</a></span><p><a href="http://gbgames.com/blog/2005/05/learning-kyra-tiles-and-z-ordering/">Learning Kyra: Tiles and Z-Ordering</a> is a post from: <a href="http://gbgames.com/blog">GBGames - Thoughts on Indie Game Development</a></p>
]]></description>
			<content:encoded><![CDATA[<p><i>Another entry in the  </i>Learning Kyra<i> series.  The series to date:</p>
<ol>
<li><a href="http://gbgames.com/blog/index.php?p=27">Learning Kyra</a></li>
<li><a href="http://gbgames.com/blog/index.php?p=29">Learning More Kyra</a></li>
<li><a href="http://gbgames.com/blog/index.php?p=30">Learning Kyra: Attack of the Clones</a></li>
</ol>
<p></i></p>
<p>The first three entries in the series documented my attempts at learning about the engine.  I had a goal to become more familiar with the engine by the end of the month, so those articles were more focused.   While that month has since passed, I am still learning plenty about the engine.  </p>
<p>Recently I learned how to create tiles.  Originally I was creating sprites, and they are sufficient for making games.  However, I can also use tiles, but the documentation warns:</p>
<blockquote><p>
<i>A Tile &#8212; in contrast to a sprite &#8212; is always square (width == height.) It can be rotated and flipped, however. You should always use Sprites unless you need to rotate and flip the image.</i></p></blockquote>
<p>Making sprite images and making tile images are similar activities.  When I use the Kyra Sprite Editor, I need to specify <code>tile</code> instead of <code>sprite</code>.  Tiles are simpler since I do not need to mark hotspots and verify that they are aligned correctly.  I was able to get three tiles very quickly, and saving created the .xml file to use.  Then I used the Kyra Encoder and created the appropriate .dat and .h files.  I copied those over to my source code directory.</p>
<p>The code to load a tile is different from the code to load a sprite, and the tutorial doesn&#8217;t cover it.  I had to look at the Bug-Eyed Monster (BEM) demo code to find an example that I could use.  To load a sprite, you have to do a few steps:</p>
<ol>
<li>Load the .dat file</li>
<li>Get the KrSpriteResource as specified in the header file you created</li>
<li>Create the KrSprite from the KrSpriteResource</li>
</ol>
<p>Loading a tile is a little more complex:</p>
<ol>
<li>Load the .dat file</li>
<li>Get the KrResource</li>
<li>Get the KrTileResource by using KrResource::ToTileResource()</li>
<li>Create the KrSprite from the KrTileResource</li>
</ol>
<p>Ok, so there is only one more step, but it took me some time to find how to retrieve a KrTileResource.  For instance, to get the KrSpriteResource, there is a function: GetSpriteResource(name_of_resource).  To get a KrTileResource, however, you first need a generic resource by using GetResource(ALLCAPS_TAG, name_of_resource), and I couldn&#8217;t find the documentation on what that tag should be.  It turned out that they were defined in kyraresource.h, and the one I needed was KYRATAG_TILE.   Again, it was not in the tutorial so it took some work for me to learn what was needed.  Here is the relevant code, keeping in mind that when I used the encoder, I prefaced everything with <i>Tiles2_</i> (I already had a previous attempt with <i>Tiles_</i>) :</p>
<p><i>KrResource* res = engine->Vault()->GetResource( KYRATAG_TILE, Tiles2_tile2 );<br />
GLASSERT( res );<br />
KrTileResource* tileRes = res->ToTileResource();<br />
GLASSERT( tileRes );<br />
KrTile* tile = new KrTile( tileRes );<br />
GLASSERT( tile );</p>
<p>tile->SetPos( 130, 98 );<br />
tile->SetRotation(1);<br />
engine->Tree()->AddNode(0, tile);</i></p>
<p>Anyway, I imagined that the tiles I created would be pretty cool to work with since they have alpha transparency.  I could make clouds or chain-link fences, for instance. As I moved a sprite to the tile, I expected that the sprite would show through the tile&#8217;s transparent spots; however, when adding an image to the engine&#8217;s tree, the order matters.  Since I added the sprite after the tile, the sprite image overlapped the tile image.  I switched the order in the code, and it worked perfectly fine.  </p>
<p>But then I was concerned.  In a game, elements will get added dynamically.  I wouldn&#8217;t want to find that a new enemy can walk over tunnels, or that the hero walks under floor tiles!  Then I learned how the BEM demo handled Z-Ordering.  </p>
<p>Everything that can be in the engine&#8217;s tree inherents from the base class KrImNode.  KrSprite and KrTile are both KrImage classes, and KrImage is a KrImNode.  KrImNode isn&#8217;t an abstract class, and it is the key to handling Z-Ordering.</p>
<p>Usually when I add a sprite or tile to the engine, I use the following code:</p>
<p><i>engine->Tree()->AddNode(0, tile); </i></p>
<p>AddNode()&#8217;s first parameter in this case is 0, which means that in the tree, it is a child of the root.  If I add a second child, it will be drawn over the first child when the following code gets run:</p>
<p><i>engine->Draw()</i></p>
<p>BEM handles Z-Ordering by creating subtrees.  Background images should be added to the backgroundTree while foreground images should be added to the foregroundTree.  You create those trees in the following way:</p>
<p><i>KrImNode* backgroundTree = new KrImNode;<br />
KrImNode* foregroundTree = new KrImNode;</p>
<p>engine->Tree()->AddNode(0, backgroundTree);<br />
engine->Tree()->AddNode(0, foregroundTree);</i></p>
<p>Now, when I create a tile that goes in the background, I use AddNode(backgroundTree, tile1).  Naturally I would have a separate subtree or two for entities I want to always be between the background and the foreground.   If I need to create tiles for the foreground, I can add them to the foregroundTree:</p>
<p><i>engine->Tree()->AddNode(foregroundTree, tile2);</i></p>
<p>And tile2 will always be drawn on top of any images that are siblings to tile1, even if I add an image to backgroundTree after adding tile2. </p>
<p>Now that tiles and the Z-Ordering methods are added to my toolbox, I&#8217;m becoming much more dangerous with the Kyra Sprite Engine.  Using just what I know now, I can probably make a fairly simple game without struggling with an unfamiliar library.  There are still a few features to learn, however, including:</p>
<ul>
<li> Fonts </li>
<li> Alpha blending and color transformations </li>
<li> Scaling </li>
<li> Canvases </li>
<li> Sub-window views </li>
</ul>
<p>I may tackle one or two of these in the next Learning Kyra post.</p>
<p><a href="http://gbgames.com/blog/2005/05/learning-kyra-tiles-and-z-ordering/">Learning Kyra: Tiles and Z-Ordering</a> is a post from: <a href="http://gbgames.com/blog">GBGames - Thoughts on Indie Game Development</a></p>
]]></content:encoded>
			<wfw:commentRss>http://gbgames.com/blog/2005/05/learning-kyra-tiles-and-z-ordering/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Learning Kyra:  Attack of The Clones</title>
		<link>http://gbgames.com/blog/2005/03/learning-kyra-attack-of-the-clones/</link>
		<comments>http://gbgames.com/blog/2005/03/learning-kyra-attack-of-the-clones/#comments</comments>
		<pubDate>Sat, 26 Mar 2005 05:17:16 +0000</pubDate>
		<dc:creator>GBGames</dc:creator>
				<category><![CDATA[Game Development]]></category>
		<category><![CDATA[Learning Kyra Series]]></category>

		<guid isPermaLink="false">/?p=30</guid>
		<description><![CDATA[<p>The third entry in the Learning Kyra series. The series to date:</p> Learning Kyra Learning More Kyra <p></p> <p>Last time I was able to create a non-interactive moving body with a head attached. It simply walked from the top to the bottom of the window. Fairly simple, just like the graphics created for it.</p> <p>In <span style="color:#777"> . . . &#8594; Read More: <a href="http://gbgames.com/blog/2005/03/learning-kyra-attack-of-the-clones/">Learning Kyra:  Attack of The Clones</a></span><p><a href="http://gbgames.com/blog/2005/03/learning-kyra-attack-of-the-clones/">Learning Kyra:  Attack of The Clones</a> is a post from: <a href="http://gbgames.com/blog">GBGames - Thoughts on Indie Game Development</a></p>
]]></description>
			<content:encoded><![CDATA[<p><i>The third entry in the  </i>Learning Kyra<i> series.  The series to date:</p>
<ol>
<li><a href="http://gbgames.com/blog/index.php?p=27">Learning Kyra</a></li>
<li><a href="http://gbgames.com/blog/index.php?p=29">Learning More Kyra</a></li>
</ol>
<p></i></p>
<p>Last time I was able to create a non-interactive moving body with a head attached.  It simply walked from the top to the bottom of the window.  Fairly simple, just like the graphics created for it.</p>
<p>In this entry, I will describe how I tackled the following tasks:</p>
<ul>
<li> Adding multiple characters to move around at once </li>
<li> Adding interactivity </li>
<li> Adding collision detection </li>
</ul>
<p>I began with trying to add multiple characters to the program since it seemed like the simplest task.  I did run into some problems, but in the end I managed to accomplish what I wanted.</p>
<p>To start, I needed to create a new character.  I decided to make a clone of myself, goatee and all, as I described in the first part of this series.<br />
<a title="Me and Evil Clone Me" href="http://www.gbgames.com/downloads/kyra_test/" class="broken_link"><img src="images/kyraTest-clone-walk.png"></a><br />
I figure that as a clone he didn&#8217;t need his own body, so I can just reuse the existing one.  Kyra allows you to change the colors on the fly, so I could always tint his appearance later.  For now, he also gets a blue shirt with brown pants.</p>
<p>Kyra creates sprites based on resources.  I already had two resources: gbHeadRes and gbBodyRes, both of which can make the sprites gbHead and gbBody.  I simply used similar code to create the first clone:  I grabbed the new resource gbCloneHeadRes and created gbCloneHead from it. </p>
<p>I then created a new sprite from  gbBodyRes called gbCloneBody.  For all intents and purposes, it is a copy of the already existing gbBody, but Kyra needs to know about each sprite.  I then added the gbCloneHead as a child of the clone body.  I set the position of the clone so that it would start a little higher than the regular character.  This way, it will look like he is chasing him.  </p>
<p>It actually turned out decent.  I then tried to add multiple clones.  I thought they would be great in a triangle formation, chasing after the poor original.  It was at this point that I started having problems.  I thought that since the head would be the same I could probably just add it as a child of all of the new bodies, but Kyra didn&#8217;t like that since it would seg fault when I run it.  I just created multiple heads to go with the multiple bodies.  I then found I had an off-by-one error.  I wanted to create a triangle of characters, but I forgot to actually count how many I would need.  I needed six, but I only created five, but then I was trying to set six, and so I kept getting seg faults until I figured this one out.  /me smacks self in head for that one.</p>
<p>Still, I was victorious in, as you can see:<br />
<a title="Come back! We just want to eat your brains ... er, give you a hug!" href="http://www.gbgames.com/downloads/kyra_test/" class="broken_link"><img src="images/kyraTest-clone-walk2.png"></a><br />
Objective accomplished!  Now onto the next.</p>
<p>Interactivity is the stuff that games are made of.  Up until now, I&#8217;ve only had an animated graphics demo.  Once I get it to be interactive, I&#8217;m that much closer to making simple game demos.  w00t!!  </p>
<p>Kyra did not provide facilities to handle input, so I just followed the demo&#8217;s lead and used <a href="http://www.libsdl.org">Simple Directmedia Layer</a> to do so.  Since I didn&#8217;t want to create multiple images just to have the body move left, right, and up, it would be fairly simplistic.  I wanted to make it so the user can press the arrow keys left and right, and the main character would move accordingly while running down the screen.  </p>
<p>It was actually fairly simple to implement, and I managed to get it working quite quickly.  I simply added a variable for the movement speed  and then if SDL detects that the left or right arrow is pressed, I would set the movement speed accordingly.  For example:</p>
<p><code></p>
<p>// These will control the movement based on input<br />
        int moveX = 0;<br />
        int moveSpeed = 6;</p>
<p>...</p>
<p>                        case SDL_KEYDOWN:<br />
                        {</p>
<p>// NEW CODE<br />
                                if (event.key.keysym.sym == SDLK_LEFT) {<br />
                                        moveX = -moveSpeed;<br />
                                }<br />
                                else if (event.key.keysym.sym == SDLK_RIGHT) {<br />
                                        moveX = moveSpeed;<br />
                                }<br />
//END OF NEW CODE<br />
                                else {<br />
                                        done = true;<br />
                                }<br />
                        }<br />
                        break;</p>
<p>// MORE NEW CODE<br />
                        case SDL_KEYUP:<br />
                        {<br />
                                moveX = 0;<br />
                        }<br />
                        break;<br />
//END OF NEW CODE</p>
<p></code></p>
<p>I then modified it so that the SetPos for the gbBody would always modify the X coordinate by moveX.  Then, just to add some useless complexity, I made it so that two of the clones would also move as you moved.  The two middle clones will separate and move together as you move from left to right.  It was here that I experienced the issue of z-ordering.  Kyra will draw the sprites in the order that you added them to the engine, so while the top row would rightly be behind the second row, the second row would walk over the head of the first clone!  To correct this issue, I simply added the clones from front to back.  </p>
<p>But what happens when I want to make a sprite run in multiple directions?  For example, <a href="http://www.grinninglizard.com/kyra/demo.html">the Kyra demo</a> shows the Bug Eyed Monster program where the creatures can walk around in a circle, which means that a creature that might be closer to the viewer must be drawn on top of the other creatures, but that same creature can move to a point where another creature will become closer.  The demo obviously handles it correctly, so dynamically changing the z-order is clearly possible. I&#8217;ll save learning this task for another day.</p>
<p>For now, another objective can be stricken off my todo list.  It may not be very complex, but it&#8217;s a start.  </p>
<p>Time to tackle collision avoidance.  At the moment, the clones in the middle row can walk through each other, which is not something I want them to do.  I found that the shooter demo makes use of collision detection, so I tried to follow what it did. Unfortunately it wasn&#8217;t very clear to me how it was handling it:</p>
<p><code><br />
 KrSprite* newMonster = AddMonsters();</p>
<p>        // Flush the changes to this point and then look for<br />
        // collisions between the bullets and everything else.<br />
        engine->Tree()->Walk();</p>
<p>        GlDynArray&lt; KrImage* &gt; hit;<br />
        // Can we keep the monster we just added -- or did it collide?<br />
        if ( newMonster &#038;&#038; engine-&gt;Tree()->CheckSiblingCollision( newMonster, &#038;hit, mainWindow ) )<br />
        {<br />
                engine->Tree()-&gt;DeleteNode( newMonster );<br />
                newMonster = 0;<br />
        }<br />
        else if ( newMonster )<br />
        {<br />
                // This add will not be collision detected.<br />
                StatusAdd( newMonster );<br />
        }<br />
</code></p>
<p>So it creates a creature, but somehow it is able to determine if there is a collision even if it didn&#8217;t set its position?  I plan on asking about that on the Kyra forums.  (<i>NOTE: I have since discovered that AddMonsters() actually sets the position, so nevermind</i>)  For now, I was able to determine that I needed to use the Walk() function to set the tree to check for collisions.  I also needed to compare what I had to what was in the list of collided sprites returned by CheckSiblingCollision().  I spent a bit of time here because I was unfortunately trying to grab the wrong information.</p>
<p>I was trying to do this:</p>
<p><code><br />
 if (gbCloneBody[2] == (KrSprite*)(hit.ItemPointer(i))<br />
</code></p>
<p>but I was supposed to do this:</p>
<p><code><br />
 if (gbCloneBody[2] == (KrSprite*)(hit.Item(i))<br />
</code></p>
<p>It turns out that Item() already returns the pointer I needed, so I was getting a pointer to the pointer, which is why I couldn&#8217;t detect the collision.  Once I figured out this part, I was able to add code to move the clones away from each other if they intersect.  They now bounce off of each other, which is closer to what I want.</p>
<p>So hours later, the third task is solved.  Mission accomplished!</p>
<p>Recap:  Today, I learned how to create multiple characters and display them on the screen simultaneously.  I learned how to reuse existing sprites to make new composite sprites.  I learned how to add interactivity to my project while also adding  some crude collision detection.  What does it all mean?  It means that I can not only have the clones avoid walking into each other, but I can also check if they intersect other objects, such as powerups or projectiles or anything I can throw at them.   I&#8217;m excited about the possibilities, and my own demos are fairly crude.  </p>
<p>Next time:</p>
<ul>
<li> I want to learn about dynamic z-ordering. </li>
<li> I want to create tiles and backgrounds. </li>
<li> I want to make a simple game using what I&#8217;ve learned, probably something like Pac-man or Lock-n-Chase. </li>
</ul>
<p>For now, I&#8217;ve accomplished enough to go to the Chicago Indie Game Developer meeting on Sunday with pride.  B-)</p>
<p><i><br />
You can download the updated version of the code:<br />
<a href="../downloads/kyra_test/KyraTest-r15.tar.gz" class="broken_link">KyraTest-r15.tar.gz</a><br />
<a href="../downloads/kyra_test/KyraTest-r15.zip" class="broken_link">KyraTest-r15.zip</a><br />
<a href="../downloads/kyra_test/kyra_src_2_0_7.tar.gz" class="broken_link">Kyra Source in .tar.gz format</a><br />
<a href="../downloads/kyra_test/kyra_src_2_0_7.zip" class="broken_link">Kyra Source in .zip format</a></p>
<p>NOTE: You will need Kyra v2.0.7 to use this code.  Also, the comments in the code weren&#8217;t all updated to reflect the fact that I&#8217;ve changed it.  It is licensed under the GPL or LGPL as specified.  </i></p>
<p><a href="http://gbgames.com/blog/2005/03/learning-kyra-attack-of-the-clones/">Learning Kyra:  Attack of The Clones</a> is a post from: <a href="http://gbgames.com/blog">GBGames - Thoughts on Indie Game Development</a></p>
]]></content:encoded>
			<wfw:commentRss>http://gbgames.com/blog/2005/03/learning-kyra-attack-of-the-clones/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Learning More Kyra</title>
		<link>http://gbgames.com/blog/2005/03/learning-more-kyra/</link>
		<comments>http://gbgames.com/blog/2005/03/learning-more-kyra/#comments</comments>
		<pubDate>Thu, 24 Mar 2005 23:10:33 +0000</pubDate>
		<dc:creator>GBGames</dc:creator>
				<category><![CDATA[Game Development]]></category>
		<category><![CDATA[Learning Kyra Series]]></category>

		<guid isPermaLink="false">/?p=29</guid>
		<description><![CDATA[<p>I&#8217;ve decided that I should probably create a Learning Kyra series. You can read the first one to get some background: Learning Kyra</p> <p>When I last worked with Kyra, I managed to get my head floating on a black background. Since then, I found out why lines like #include &#8220;SDL.h&#8221; are preferred, so I updated <span style="color:#777"> . . . &#8594; Read More: <a href="http://gbgames.com/blog/2005/03/learning-more-kyra/">Learning More Kyra</a></span><p><a href="http://gbgames.com/blog/2005/03/learning-more-kyra/">Learning More Kyra</a> is a post from: <a href="http://gbgames.com/blog">GBGames - Thoughts on Indie Game Development</a></p>
]]></description>
			<content:encoded><![CDATA[<p><i>I&#8217;ve decided that I should probably create a </i>Learning Kyra<i> series.  You can read the first one to get some background:<br />
<a href="http://gbgames.com/blog/index.php?p=27">Learning Kyra</a></i></p>
<p>When I last worked with Kyra, I managed to get my head floating on a black background.  Since then, I found out why lines like #include &#8220;SDL.h&#8221; are preferred, so I updated my code to reflect that change.  I&#8217;m definitely becoming more aware of the issues I&#8217;ll encounter in development, much more than I was a month ago.  Good. It means I&#8217;m learning.  My goals for my next iteration in development:</p>
<ul>
<li> I want to make the head&#8217;s background transparent. </li>
<li> I want to make the head move.</li>
<li> I want an animated body to go with it.  </li>
</ul>
<p>Geting the head transparent was weird. I was under the impression that Kyra&#8217;s sprite editor would actually pick a color to make transparent based on which corner I told it to use, but apparently I was mistaken or there is a bug when it uses something other than certain graphic file formats.  I switched to using .tga files from .png, and I also found that I could  set the transparency within The Gimp.  First task: completed.</p>
<p>It didn&#8217;t take me long to get the head moving.  I didn&#8217;t even have to change my code since I already programmed it to move.  The data file just didn&#8217;t have the information to know how to move it.  To change it,  I entered the Kyra editor and set it up so that the head would move a few pixels in some arbitrary direction each frame.  It was quite easy to do, and I even experimented with creating multiple frames.  With only one image, it wasn&#8217;t very good looking, but it was good progress.  A <a href="http://www.rampantgames.com/blog/2004/10/black-triangle.html">Black Triangle</a>,  if you would.  Second task: completed.</p>
<p>Once I accomplished movement, I set out to create a cartoon body.  I fired up The Gimp again, and was able to create three images for the body.  The total walking package is below, and as you can see, I should stick to programming:</p>
<p><a title="Of course it&#039;s programmer art! Duh." href="http://www.gbgames.com/downloads/kyra_test/" class="broken_link"><img src="./images/kyraTest-gb-walk.png" ></a></p>
<p>After getting the data encoded properly, it only took a few tweaks of the code to get the walking body on the screen.  Check it out:</p>
<p><a title="I&#039;m too sexy for my shirt..." href="http://www.gbgames.com/downloads/kyra_test/" class="broken_link"><img src="./images/kyraTest-gb-walk2.png" ></a></p>
<p>So now I have a walking character.  He only moves in one direction, but he walks.  Third task: completed.</p>
<p>So I managed to accomplish what I set out to do, and it was much easier than I expected.  I managed to get more familiar with the mechanics of Kyra&#8217;s sprite editor and the code itself.  I learned how to use The Gimp for more than just capturing screenshots and cropping photos.  I also am learning that content development will probably require a lot more planning than I originally thought was needed.  </p>
<p>My goals for my next iteration: </p>
<ul>
<li> I want interactivity: the character should walk in the direction indicated by input.</li>
<li> I want multiple characters at once. </li>
<li> I want them to practice collision avoidance: a character shouldn&#8217;t be able to &#8220;walk into&#8221; another</li>
</ul>
<p><i><br />
You can download the updated version of the code:<br />
<a href="../downloads/kyra_test/KyraTest-r8.tar.gz" class="broken_link">KyraTest-r8.tar.gz</a><br />
<a href="../downloads/kyra_test/KyraTest-r8.zip" class="broken_link">KyraTest-r8.zip</a><br />
<a href="../downloads/kyra_test/kyra_src_2_0_7.tar.gz" class="broken_link">Kyra Source in .tar.gz format</a><br />
<a href="../downloads/kyra_test/kyra_src_2_0_7.zip" class="broken_link">Kyra Source in .zip format</a></p>
<p>NOTE: You will need Kyra v2.0.7 to use this code.  Also, the comments in the code weren&#8217;t all updated to reflect the fact that I&#8217;ve changed it.  It is licensed under the GPL or LGPL as specified.  </i></p>
<p><a href="http://gbgames.com/blog/2005/03/learning-more-kyra/">Learning More Kyra</a> is a post from: <a href="http://gbgames.com/blog">GBGames - Thoughts on Indie Game Development</a></p>
]]></content:encoded>
			<wfw:commentRss>http://gbgames.com/blog/2005/03/learning-more-kyra/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Learning Kyra</title>
		<link>http://gbgames.com/blog/2005/03/learning-kyra/</link>
		<comments>http://gbgames.com/blog/2005/03/learning-kyra/#comments</comments>
		<pubDate>Tue, 22 Mar 2005 05:13:50 +0000</pubDate>
		<dc:creator>GBGames</dc:creator>
				<category><![CDATA[Game Development]]></category>
		<category><![CDATA[Learning Kyra Series]]></category>

		<guid isPermaLink="false">/?p=27</guid>
		<description><![CDATA[<p>Today was my first Monday without worrying about homework in a long time. Sunday will be the Chicago Indie Game Developer meeting, and I want to make sure I can say I&#8217;ve accomplished something. </p> <p>One of my goals was to program 5 hours per week at the minimum. While I wasn&#8217;t able to do <span style="color:#777"> . . . &#8594; Read More: <a href="http://gbgames.com/blog/2005/03/learning-kyra/">Learning Kyra</a></span><p><a href="http://gbgames.com/blog/2005/03/learning-kyra/">Learning Kyra</a> is a post from: <a href="http://gbgames.com/blog">GBGames - Thoughts on Indie Game Development</a></p>
]]></description>
			<content:encoded><![CDATA[<p>Today was my first Monday without worrying about homework in a long time.  Sunday will be the Chicago Indie Game Developer meeting, and I want to make sure I can say I&#8217;ve accomplished something.  </p>
<p>One of my goals was to program 5 hours per week at the minimum.  While I wasn&#8217;t able to do it consistently, I did program on my own projects much more often than I did last month.   I even managed to fix up <a href="http://gbgames.com/blog/index.php?p=26">my Tic-Tac-Toe game</a> so that it is a completed project under my belt.  I&#8217;ve been learning, but now that school is no longer a worry I can accomplish much more in the coming month.</p>
<p>Another goal was to learn how to use <a href="http://kyra.sourceforge.net/">Kyra</a>.  I haven&#8217;t touched it since I got the demo running on my machine.  The demo was quite impressive and showed the power of the Sprite Engine.  So I set to work, but I had some issues.</p>
<p>I created a directory in my Projects directory called KyraTest.  I setup a Subversion repository and setup my documentation, source, and resource directories.  Kyra comes with a <a href="http://www.grinninglizard.com/kyra/tutorial.htm">tutorial</a>, so I started there.  The tutorial involves using a few images together.  I wanted to start simply, so I cropped a photo of my head and shrunk it.  I figured I could later add a cartoon body to it and have a bunch of characters running around on a screen.  For the moment though, I just had this head.  </p>
<p>I was able to create the .dat and .xml files from the sprite editory provided.  I then copied one of the tutorial code files into my source directory and edited it to make the references to my own data.  For some reason the file was written as if you wouldn&#8217;t have Kyra or SDL actually installed.  It would have lines like:<br />
<code><br />
#include "SDL.h"<br />
</code></p>
<p>All well and good, but why not use the system include instead of a local one?  If you know, please let me know why the first way would be preferable.</p>
<p>Anyway, once I got that part squared away, and fixed the bugs I introduced when I edited the file, I got it to compile.  Unfortunately it wouldn&#8217;t run because it couldn&#8217;t find libkyra.so.0.  I found that it was installed on my Debian system, but there wasn&#8217;t a link created in the standard location for libraries.  Once I created the link, it worked fine.  </p>
<p>The end result:  A black background with an image of my head in the middle.  B-)<br />
<a title="kyra_test: The cloning beings..." href="../downloads/kyra_test/" class="broken_link"><img src = "images/kyraTest.png" ></a></p>
<p>It was what I set out to do for today before going to bed, but it was kind of frustrating getting to that point.  I sent an email to the author explaining the issues I had and how I fixed them, and I also asked for explanations on some of the code decisions.  </p>
<p>My goal for this week:  I want to make an application where a bunch of clones (with goatees, of course) are chasing after the real me (sans-goatee) before the meeting on Sunday.  </p>
<p>And for the code collectors:<br />
<a href="../downloads/kyra_test/KyraTest.tar.gz" class="broken_link">KyraTest.tar.gz</a><br />
<a href="../downloads/kyra_test/KyraTest.zip" class="broken_link">KyraTest.zip</a><br />
<a href="../downloads/kyra_test/kyra_src_2_0_7.tar.gz" class="broken_link">Kyra Source in .tar.gz format</a><br />
<a href="../downloads/kyra_test/kyra_src_2_0_7.zip" class="broken_link">Kyra Source in .zip format</a></p>
<p>NOTE: You will need Kyra v2.0.7 to use this code.  Also, the comments in the code weren&#8217;t all updated to reflect the fact that I&#8217;ve changed it.  It is licensed under the GPL or LGPL as specified.  </p>
<p><a href="http://gbgames.com/blog/2005/03/learning-kyra/">Learning Kyra</a> is a post from: <a href="http://gbgames.com/blog">GBGames - Thoughts on Indie Game Development</a></p>
]]></content:encoded>
			<wfw:commentRss>http://gbgames.com/blog/2005/03/learning-kyra/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
	</channel>
</rss>

