<?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>Tiny Subversions &#187; programming</title>
	<atom:link href="http://tinysubversions.com/category/programming/feed/" rel="self" type="application/rss+xml" />
	<link>http://tinysubversions.com</link>
	<description></description>
	<lastBuildDate>Mon, 06 Feb 2012 15:16:07 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3</generator>
		<item>
		<title>Getting Started with Akihabara: A Beginner&#8217;s Tutorial</title>
		<link>http://tinysubversions.com/2010/05/getting-started-with-akihabara-a-beginners-tutorial/</link>
		<comments>http://tinysubversions.com/2010/05/getting-started-with-akihabara-a-beginners-tutorial/#comments</comments>
		<pubDate>Thu, 06 May 2010 17:57:19 +0000</pubDate>
		<dc:creator>Darius Kazemi</dc:creator>
				<category><![CDATA[akihabara]]></category>
		<category><![CDATA[programming]]></category>
		<category><![CDATA[tutorial]]></category>

		<guid isPermaLink="false">http://tinysubversions.com/?p=1597</guid>
		<description><![CDATA[A few weeks ago KesieV released Akihabara, a set of JavaScript tools and libraries that take advantage of some HTML5 features that are already available on Firefox, Chrome, and many mobile web browsers on platforms including the iPhone, iPad, and Palm Pre. I got very excited about these tools, especially since the demos were so impressive. [...]]]></description>
			<content:encoded><![CDATA[<p></p><div>
<p>A few weeks ago KesieV released <a href="http://www.kesiev.com/akihabara/" >Akihabara</a>, a set of JavaScript tools and libraries that take advantage of some HTML5 features that are already available on Firefox, Chrome, and many mobile web browsers on platforms including the iPhone, iPad, and Palm Pre. I got very excited about these tools, especially since the demos were so impressive. I spent a few days messing around with it, and Darren got a bunch of people using it at the <a href="http://bostongamejams.com/dino-jams/april-dino-jam/" >April DINO Jam</a>.</p>
<p>Talking to Darren, we both had the same experience with the code: it was nice that it came with some commented code, but it would have  been a huge help even to have a basic &#8220;Hello world&#8221; style tutorial available. So partly inspired by my excitement over Akihabara, and partly inspired by <a href="http://forums.tigsource.com/index.php?topic=3142.0" >Derek Yu&#8217;s excellent Game Maker tutorials</a>, I suggested to Darren that we write a multi-part tutorial for Akihabara. To my delight, he agreed.</p>
<p>The tutorials will take you through the process of creating an 8-way shooter along the lines of <a href="http://www.everydayshooter.com/" >Everyday Shooter</a>. <a href="http://bostongamejams.com/akihabara-tutorials/akihabara-1/" >Part 1 is available</a> and is a basic overview of Akihabara&#8217;s structure and shows you how to create a title splash screen. Future parts will cover input and character movement, tile maps, enemy behavior, HUDs, and more.</p>
<p>For now, <a href="http://bostongamejams.com/akihabara-tutorials/akihabara-1/" >check out the tutorial</a>. It&#8217;s hosted on a <a href="http://bostongamejams.com" >Boston Game Jams</a>, a project of Darren&#8217;s. It should only take about 30 minutes and at the end you&#8217;ll have something that runs in modern web browsers and on many mobile devices!</p>
</div>
]]></content:encoded>
			<wfw:commentRss>http://tinysubversions.com/2010/05/getting-started-with-akihabara-a-beginners-tutorial/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Tutorial: Adding a New Inventory Item to Spelunky</title>
		<link>http://tinysubversions.com/2010/01/tutorial-adding-new-inventory-spelunky/</link>
		<comments>http://tinysubversions.com/2010/01/tutorial-adding-new-inventory-spelunky/#comments</comments>
		<pubDate>Wed, 20 Jan 2010 18:58:28 +0000</pubDate>
		<dc:creator>Darius Kazemi</dc:creator>
				<category><![CDATA[modding]]></category>
		<category><![CDATA[programming]]></category>
		<category><![CDATA[Spelunky]]></category>
		<category><![CDATA[tutorial]]></category>

		<guid isPermaLink="false">http://tinysubversions.com/?p=1423</guid>
		<description><![CDATA[Here&#8217;s another Spelunky modding tutorial I posted over on the Mossmouth Forums. This shows how you might add a third inventory element to the game, something that behaves like a bomb or a rope in terms of always having a limited number of it in your inventory. This can even be modified slightly to provide [...]]]></description>
			<content:encoded><![CDATA[<p></p><p>Here&#8217;s another Spelunky modding tutorial I <a href="http://mossmouth.com/forums/index.php?topic=703.0" >posted over on the Mossmouth Forums</a>. This shows how you might add a third inventory element to the game, something that behaves like a bomb or a rope in terms of always having a limited number of it in your inventory. This can even be modified slightly to provide you with something like an ammo count.</p>
<h3>Overview</h3>
<p>So let&#8217;s say you want to add a new inventory item to Spelunky &#8212; something like bombs and ropes, but different. For the sake of this tutorial, let&#8217;s have you be able to hold up to 99 rocks in your pockets. We&#8217;ll make it so that rocks behave kind of like bombs: if you run across one, you can pick it up and it is added to your inventory when you switch away from it.</p>
<p>What we&#8217;re going to do in this mod is: set the appropriate global variable, figure out how to switch to the new inventory item, and set up the new HUD element so we know how many rocks we have.</p>
<h3>Setting the Global Variable</h3>
<p>The amount of bombs and ropes you have are stored as global variables. The game sets them in the scrClearGlobals. This script is run at the beginning of every game, and it sets every global to false/0, except for bombs, ropes, and plife (player life), which all get set to 4. So in scrClearGlobals you want to make the following change at line 109:</p>
<blockquote>
<pre>else
{
    global.plife = 4;
    global.bombs = 4;
    global.rope = 4;
    // ADD THIS LINE (we're starting the player out with 1 rock)
    global.rocks = 1;
}</pre>
</blockquote>
<h3>Switching to Our Rocks</h3>
<p>Here&#8217;s where we change the code so that pressing the &#8220;switch item&#8221; button will put a rock in our hands if we have more than 0 rocks. We also want to put in some code so that when we have the rock equipped, our global.rocks is reduced by 1 (so it works the same way bombs and ropes do).</p>
<p>Let&#8217;s look at the code from oPlayer1 Step, in the second Action Block, line 952:</p>
<blockquote><p><span style="font-family: Consolas, Monaco, 'Courier New', Courier, monospace; font-size: small;" >
<pre>else if (inGame and kItemPressed and not whipping)
{
    // switch items
    if (holdItem)
    {

// If we're holding a bomb and it's armed, we can't switch away.

        if (holdItem.sprite_index == sBombArmed)
        {
            // do nothing
        }

// If we're holding a bomb and it's not armed, then put it back in your
// inventory (increment the global), and then destroy it so you're not
// holding it anymore. Then, if there's more than 0 ropes, switch to
// ropes. Otherwise, switch to what you're holding (or nothing if
// you're not holding anything.)

        else if (holdItem.sprite_index == sBomb)
        {
            with holdItem
            {
                global.bombs += 1;
                instance_destroy();
            }

            if (global.rope &gt; 0)
            {
                holdItem = instance_create(x, y, oRopeThrow);
                holdItem.held = true;
                global.rope -= 1;
                whoaTimer = whoaTimerMax;
            }
            else
            {
                scrHoldItem(pickupItemType);
            }
        }

// If we're holding a rope then put it back in your inventory
// (increment the global), and then destroy it so you're not
// holding it anymore. Then switch to what you're holding
// (or nothing if you're not holding anything.)

        else if (holdItem.sprite_index == sRopeEnd)
        {
            with holdItem
            {
                global.rope += 1;
                instance_destroy();
            }            

            scrHoldItem(pickupItemType);
        }

// If we're holding an item that's not heavy (damsel or Idol)
// and we have a bomb or a rope, then store it away as
// pickupItemType for later. If we have bombs, switch
// to bombs, if not, then switch to ropes.

        else if (not holdItem.heavy and holdItem.cost == 0)
        {
            if (global.bombs &gt; 0 or global.rope &gt; 0)
            {
                pickupItemType = holdItem.type;
                if (holdItem.type == "Bow" and bowArmed)
                {
                    scrFireBow();
                }
                with holdItem
                {
                    breakPieces = false;
                    instance_destroy();
                }
            }

            if (global.bombs &gt; 0)
            {
                holdItem = instance_create(x, y, oBomb);
                if (global.hasStickyBombs) holdItem.sticky = true;
                holdItem.held = true;
                global.bombs -= 1;
                whoaTimer = whoaTimerMax;
            }
            else if (global.rope &gt; 0)
            {
                holdItem = instance_create(x, y, oRopeThrow);
                holdItem.held = true;
                global.rope -= 1;
                whoaTimer = whoaTimerMax;
            }
        }
    }
// If you're not holding anything, switch to bombs if available.
// Otherwise switch to ropes if available.
    else
    {
        if (global.bombs &gt; 0)
        {
            holdItem = instance_create(x, y, oBomb);
            if (global.hasStickyBombs) holdItem.sticky = true;
            holdItem.held = true;
            global.bombs -= 1;
            whoaTimer = whoaTimerMax;
        }
        else if (global.rope &gt; 0)
        {
            holdItem = instance_create(x, y, oRopeThrow);
            holdItem.held = true;
            global.rope -= 1;
            whoaTimer = whoaTimerMax;
        }
    }
}</pre>
</blockquote>
<p>It&#8217;s a little complex so you should read through my comments there. Basically, we take this structure and extend it so we have the logic for switching to rock. It&#8217;s a good exercise to read through this code and figure out why I made the changes I did:</p>
<blockquote><p><span style="font-family: Consolas, Monaco, 'Courier New', Courier, monospace; font-size: small;" ></p>
<pre>else if (inGame and kItemPressed and not whipping)
{
    // switch items
    if (holdItem)
    {
        if (holdItem.sprite_index == sBombArmed)
        {
            // do nothing
        }
        else if (holdItem.sprite_index == sBomb)
        {
            with holdItem
            {
                global.bombs += 1;
                instance_destroy();
            }

            if (global.rope &gt; 0)
            {
                holdItem = instance_create(x, y, oRopeThrow);
                holdItem.held = true;
                global.rope -= 1;
                whoaTimer = whoaTimerMax;
            }
            else
            {
                scrHoldItem(pickupItemType);
            }
        }
        else if (holdItem.sprite_index == sRopeEnd)
        {
            with holdItem
            {
                global.rope += 1;
                instance_destroy();
            }

            if (global.rocks &gt; 0)
            {
                holdItem = instance_create(x, y, oRock);
                holdItem.held = true;
                global.rocks -= 1;
                whoaTimer = whoaTimerMax;
            }

            else
            {
                scrHoldItem(pickupItemType);
            }
        }
        else if (holdItem.sprite_index == sRock)
        {

//           global.plife = 0;

            with holdItem
            {
                global.rocks += 1;
                instance_destroy();
            }

            if (pickupItemType == "Rock") pickupItemType = "";
            scrHoldItem(pickupItemType);
        }

        else if (not holdItem.heavy and holdItem.cost == 0)
        {
            if (global.bombs &gt; 0 or global.rope &gt; 0 or global.rocks &gt; 0)
            {
                pickupItemType = holdItem.type;
                if (holdItem.type == "Bow" and bowArmed)
                {
                    scrFireBow();
                }
                with holdItem
                {
                    breakPieces = false;
                    instance_destroy();
                }
            }

            if (global.bombs &gt; 0)
            {
                holdItem = instance_create(x, y, oBomb);
                if (global.hasStickyBombs) holdItem.sticky = true;
                holdItem.held = true;
                global.bombs -= 1;
                whoaTimer = whoaTimerMax;
            }
            else if (global.rope &gt; 0)
            {
                holdItem = instance_create(x, y, oRopeThrow);
                holdItem.held = true;
                global.rope -= 1;
                whoaTimer = whoaTimerMax;
            }
            else if (global.rocks &gt; 0)
            {
                holdItem = instance_create(x, y, oRock);
                holdItem.held = true;
                global.rocks -= 1;
                whoaTimer = whoaTimerMax;
            }
        }
    }
    else
    {
        if (global.bombs &gt; 0)
        {
            holdItem = instance_create(x, y, oBomb);
            if (global.hasStickyBombs) holdItem.sticky = true;
            holdItem.held = true;
            global.bombs -= 1;
            whoaTimer = whoaTimerMax;
        }
        else if (global.rope &gt; 0)
        {
            holdItem = instance_create(x, y, oRopeThrow);
            holdItem.held = true;
            global.rope -= 1;
            whoaTimer = whoaTimerMax;
        }
        else if (global.rocks &gt; 0)
        {
            holdItem = instance_create(x, y, oRock);
            holdItem.held = true;
            global.rocks -= 1;
            whoaTimer = whoaTimerMax;
        }
    }
}</pre>
<p></span>
</p></blockquote>
<h3>Adding Rocks to the UI</h3>
<p>Next we want to add a new UI element to the top of the screen that shows how many rocks we have. To do this, open up scrDrawHUD and you&#8217;ll see this:</p>
<blockquote><p><span style="font-family: Consolas, Monaco, 'Courier New', Courier, monospace; font-size: small;" ></p>
<pre>if (global.drawHUD and instance_exists(oPlayer1))
{
    lifeX = 8;
    bombX = 64;
    ropeX = 120;
    moneyX = 176;
    draw_set_font(global.myFont);
    draw_set_color(c_white);
    draw_sprite(sHeart, -1, lifeX, 8);
    life = global.plife;
    if (life &lt; 0) life = 0;
    draw_text(lifeX+16, 8, life);
    if (global.hasStickyBombs) draw_sprite(sStickyBombIcon, -1, bombX, 8);
    else draw_sprite(sBombIcon, -1, bombX, 8);
    draw_text(bombX+16, 8, global.bombs);
    draw_sprite(sRopeIcon, -1, ropeX, 8);
    draw_text(ropeX+16, 8, global.rope);
    draw_sprite(sDollarSign, -1, moneyX, 8);
    draw_text(moneyX+16, 8, global.money);</pre>
<p></span>
</p></blockquote>
<p>What you&#8217;ll want to do is create rockX, which is the X offset of the new rock UI element. I would put it in between rope and money, because money is variable length so you want it at the far right hand side. Then you just add the draw_text() and draw_sprite() functions. I used the sprite for the rock in the example below:</p>
<blockquote><p><span style="font-family: Consolas, Monaco, 'Courier New', Courier, monospace; font-size: small;" ></p>
<pre>if (global.drawHUD and instance_exists(oPlayer1))
{
    lifeX = 8;
    bombX = 64;
    ropeX = 120;
    rockX = 176;
    moneyX = 232;
    draw_set_font(global.myFont);
    draw_set_color(c_white);
    draw_sprite(sHeart, -1, lifeX, 8);
    life = global.plife;
    if (life &lt; 0) life = 0;
    draw_text(lifeX+16, 8, life);
    if (global.hasStickyBombs) draw_sprite(sStickyBombIcon, -1, bombX, 8);
    else draw_sprite(sBombIcon, -1, bombX, 8);
    draw_text(bombX+16, 8, global.bombs);
    draw_sprite(sRopeIcon, -1, ropeX, 8);
    draw_text(ropeX+16, 8, global.rope);
    // I messed around with the Y value until I  got something I liked
    draw_sprite(sRock, -1, rockX, 16);
    draw_text(rockX+16, 8, global.rocks);
    draw_sprite(sDollarSign, -1, moneyX, 8);
    draw_text(moneyX+16, 8, global.money);</pre>
<p></span>
</p></blockquote>
<p>And we end up with this:</p>
<p style="text-align: center;" ><img class="aligncenter"  src="http://tinysubversions.com/spelunky/s7.PNG"  alt="s7.PNG"  width="483"  height="376" /></p>
]]></content:encoded>
			<wfw:commentRss>http://tinysubversions.com/2010/01/tutorial-adding-new-inventory-spelunky/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Jeff on Distributed Version Control</title>
		<link>http://tinysubversions.com/2008/08/jeff-on-distributed-version-control/</link>
		<comments>http://tinysubversions.com/2008/08/jeff-on-distributed-version-control/#comments</comments>
		<pubDate>Thu, 14 Aug 2008 17:02:00 +0000</pubDate>
		<dc:creator>Darius Kazemi</dc:creator>
				<category><![CDATA[process]]></category>
		<category><![CDATA[programming]]></category>

		<guid isPermaLink="false">http://tinysubversions.com/?p=1067</guid>
		<description><![CDATA[Jeff just posted a long-but-good article on distributed version control over at his blog. &#8230;okay, so I haven&#8217;t read it yet. But we&#8217;re switching over to Mercurial at the office, and he spent the morning working on the blog post, so I feel I should point you to it. Especially if you&#8217;re a programmer or [...]]]></description>
			<content:encoded><![CDATA[<p></p><p>Jeff just posted a long-but-good <a href="http://www.jeffongames.com/2008/08/on-distributed-version-control/" >article on distributed version control</a> over at his blog.</p>
<p>&#8230;okay, so I haven&#8217;t read it yet. But we&#8217;re switching over to <a href="http://www.selenic.com/mercurial/wiki/" >Mercurial</a> at the office, and he spent the morning working on the blog post, so I feel I should point you to it. Especially if you&#8217;re a programmer or someone who manages programmers.</p>
<p>Jeff smart. Jeff program good. <a href="http://www.jeffongames.com/2008/08/on-distributed-version-control/" >Read Jeff.</a></p>
]]></content:encoded>
			<wfw:commentRss>http://tinysubversions.com/2008/08/jeff-on-distributed-version-control/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Steve&#8217;s Got a Blog</title>
		<link>http://tinysubversions.com/2008/07/steves-got-a-blog/</link>
		<comments>http://tinysubversions.com/2008/07/steves-got-a-blog/#comments</comments>
		<pubDate>Tue, 15 Jul 2008 11:47:00 +0000</pubDate>
		<dc:creator>Darius Kazemi</dc:creator>
				<category><![CDATA[friends]]></category>
		<category><![CDATA[memories]]></category>
		<category><![CDATA[programming]]></category>

		<guid isPermaLink="false">http://tinysubversions.com/?p=1059</guid>
		<description><![CDATA[I just discovered that my friend Steve Gargolinski has a blog, called On Games and Code. He&#8217;s a programmer at Blue Fang Games, and you&#8217;ll definitely want to check out these posts: the slides from Steve&#8217;s lecture on genetic algorithms in games the video and slides from Steve&#8217;s talk on games and intelligence if you&#8217;re [...]]]></description>
			<content:encoded><![CDATA[<p></p><p>I just discovered that my friend Steve Gargolinski has a blog, called <a href="http://www.ongamesandcode.com/" >On Games and Code</a>. He&#8217;s a programmer at Blue Fang Games, and you&#8217;ll definitely want to check out these posts:
<ul>
<li><a href="http://www.onlinewebpage.com/gamecodeblog/?p=10" >the slides from Steve&#8217;s lecture on genetic algorithms in games</a></li>
<li><a href="http://www.onlinewebpage.com/gamecodeblog/?p=8" >the video and slides from Steve&#8217;s talk on games and intelligence</a></li>
<li>if you&#8217;re a programmer, even an armchair programmer like me, <a href="http://www.onlinewebpage.com/gamecodeblog/?p=7" >his post on &#8220;primitive obsession&#8221; is helpful</a></li>
</ul>
<p>Strange fact: Steve and I lived across the hall from each other our freshman year at WPI. I always used to wonder how there were these game industry people who seemed to know each other <span style="font-weight: bold;" >forever</span> but I&#8217;m guessing that in 10 years we&#8217;ll get together at some event and reminisce about playing <span style="font-style: italic;" >Counterstrike</span> with the guys on our floor. Or maybe Steve&#8217;s tendency to play nothing but Jethro Tull on repeat all day every day :)</p>
]]></content:encoded>
			<wfw:commentRss>http://tinysubversions.com/2008/07/steves-got-a-blog/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Programming Anecdote</title>
		<link>http://tinysubversions.com/2007/06/programming-anecdote/</link>
		<comments>http://tinysubversions.com/2007/06/programming-anecdote/#comments</comments>
		<pubDate>Tue, 19 Jun 2007 17:31:00 +0000</pubDate>
		<dc:creator>Darius Kazemi</dc:creator>
				<category><![CDATA[programming]]></category>

		<guid isPermaLink="false">http://tinysubversions.com/?p=902</guid>
		<description><![CDATA[I&#8217;m currently reading a great book on Microsoft SQL Server called Inside Microsoft SQL Server 2005 T-SQL Querying, by Itzik Ben-Gan. I just came across a particularly funny anecdote in one of the chapters that I thought I&#8217;d share. [This] reminds me of a programmer and an IT manager at a company I worked for [...]]]></description>
			<content:encoded><![CDATA[<p></p><p>I&#8217;m currently reading a great book on Microsoft SQL Server called <span style="font-style: italic;" >Inside Microsoft SQL Server 2005 T-SQL Querying</span>, by <span></span>Itzik Ben-Gan. I just came across a particularly funny anecdote in one of the chapters that I thought I&#8217;d share.<br/>
<blockquote>[This] reminds me of a programmer and an IT manager at a company I worked for years ago. The programmer had to finish writing a component and deploy it, but there was a bug in his code that he couldn&#8217;t find. He produced a printout of the code (which was pretty thick) and went to the IT manager, who was in a meeting. The IT manager was extremely good at detecting bugs, which is why the programmer sought him. The IT manager took the thick printout, opened it, and immediately pointed to a certain line of code. &#8220;Here&#8217;s your bug,&#8221; he said. &#8220;Now go.&#8221; After the meeting was over, the programmer asked the IT manager how he found the bug so fast? The IT manager replied, &#8220;I knew that anywhere I pointed there would be a bug.</p></blockquote>
]]></content:encoded>
			<wfw:commentRss>http://tinysubversions.com/2007/06/programming-anecdote/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
	</channel>
</rss>

