<?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>Illogic Tree &#187; Game Development</title>
	<atom:link href="http://illogictree.com/category/game-development/feed/" rel="self" type="application/rss+xml" />
	<link>http://illogictree.com/blog</link>
	<description>Development In Any Colour You Like, Logical or Otherwise</description>
	<lastBuildDate>Sat, 04 Sep 2010 21:21:16 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.2</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Real-Time Grass Video</title>
		<link>http://illogictree.com/blog/2010/09/real-time-grass-in-hd/</link>
		<comments>http://illogictree.com/blog/2010/09/real-time-grass-in-hd/#comments</comments>
		<pubDate>Sat, 04 Sep 2010 21:12:06 +0000</pubDate>
		<dc:creator>Eddie</dc:creator>
				<category><![CDATA[Game Development]]></category>
		<category><![CDATA[Videos]]></category>

		<guid isPermaLink="false">http://illogictree.com/blog/?p=2121</guid>
		<description><![CDATA[
I finally got around to posting a video of the current progress. So far the project is going quite swimmingly, if I do say so myself. One thing I want to say is that I am amazed on the sheer power of the GPU&#8217;s geometry shader. I had no idea it was able to generate [...]]]></description>
			<content:encoded><![CDATA[<p><iframe src="http://player.vimeo.com/video/14641479?portrait=0" width="570" height="321" frameborder="0"></iframe></p>
<p>I finally got around to posting a video of the current progress. So far the project is going quite swimmingly, if I do say so myself. One thing I want to say is that I am amazed on the sheer power of the GPU&#8217;s <a href="http://en.wikipedia.org/wiki/Geometry_shader">geometry shader</a>. I had no idea it was able to generate so many vertices at such interactive speeds. Each of the blades that are rendered is being generated procedurally in the geometry shader given only root positions, which is passed in the <a href="http://en.wikipedia.org/wiki/Vertex_Buffer_Object">vertex buffer</a>. Currently I render about 40,000 blades of grass at a solid FPS of 50FPS. </p>
<p>The swaying of the grass is being modeled by simple oscillators such as sine and cosine. There currently is no interaction that the player can have with the grass. However, my next step is to allow the user to affect the wind conditions of the scene. The wind condition vectors will be modeled using Navier-Stokes equations. Hopefully it comes out as cool as I see it in my mind&#8217;s eye. Stay tuned.</p>
]]></content:encoded>
			<wfw:commentRss>http://illogictree.com/blog/2010/09/real-time-grass-in-hd/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Master&#8217;s Thesis: Real-Time Grass Rendering</title>
		<link>http://illogictree.com/blog/2010/08/real-time-grass-rendering/</link>
		<comments>http://illogictree.com/blog/2010/08/real-time-grass-rendering/#comments</comments>
		<pubDate>Tue, 24 Aug 2010 22:30:12 +0000</pubDate>
		<dc:creator>Eddie</dc:creator>
				<category><![CDATA[Game Development]]></category>

		<guid isPermaLink="false">http://illogictree.com/blog/?p=2104</guid>
		<description><![CDATA[
Grass is the most prevalent form of vegetation on the Earth’s surface. Thus, it is an essential element in rendering realistic outdoor scenes. But due to the geometric complexity of grass, rendering it realistically in real-time can be difficult and computationally expensive. Furthermore, to produce life-like representations of grass requires faithful physical simulations of movement [...]]]></description>
			<content:encoded><![CDATA[<p><img class="alignnone size-full wp-image-2105" title="grassssun" src="http://illogictree.com/wp-content/uploads/2010/08/grassssun.jpg" alt="" width="570" height="413" /></p>
<p><strong>Grass</strong> is the most prevalent form of vegetation on the Earth’s surface. Thus, it is an essential element in rendering realistic outdoor scenes. But due to the geometric complexity of grass, rendering it realistically in real-time can be difficult and computationally expensive. Furthermore, to produce life-like representations of grass requires faithful physical simulations of movement provided by wind currents.</p>
<p>Ticking away are the moments that make up my final months in graduate school. And as my academic career winds to a conclusion,  I&#8217;ve been working hard and coding away at my <strong>master&#8217;s thesis project</strong>. My master&#8217;s thesis is all about discovering and implementing an algorithm to render luscious grass in real-time. My ultimate goal is to have hyper-realistic fields grass all over the place and all up in yo&#8217; face!</p>
<p>Above is a <strong>screenshot</strong> I took of the current state of my project. It looks quite groovy so far, but my journey has just begun.</p>
]]></content:encoded>
			<wfw:commentRss>http://illogictree.com/blog/2010/08/real-time-grass-rendering/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>ArmorGames.com Sponsors Wasabi!</title>
		<link>http://illogictree.com/blog/2010/08/armorgames-sponsors-wasabi/</link>
		<comments>http://illogictree.com/blog/2010/08/armorgames-sponsors-wasabi/#comments</comments>
		<pubDate>Wed, 11 Aug 2010 20:43:43 +0000</pubDate>
		<dc:creator>Eddie</dc:creator>
				<category><![CDATA[Game Development]]></category>
		<category><![CDATA[News]]></category>

		<guid isPermaLink="false">http://illogictree.com/blog/?p=2068</guid>
		<description><![CDATA[Wasabi was recently picked up and sponsored by the fantabulous Flash-portal site, ArmorGames. Thanks to all of you who play-tested my game and provided me with such great in-depth feedback on the gameplay. Without your love and funkitude, this game wouldn&#8217;t have been what it is today.
And if I ever see you internet folks in [...]]]></description>
			<content:encoded><![CDATA[<p><img class="alignright size-full wp-image-2072" title="screenshot" src="http://illogictree.com/wp-content/uploads/2010/08/screenshot.png" alt="" width="320" height="224" /><a href="http://armorgames.com/play/6433/wasabi">Wasabi</a> was recently picked up and sponsored by the fantabulous Flash-portal site, <a href="http://armorgames.com">ArmorGames</a>. Thanks to <a href="http://forums.tigsource.com/index.php?topic=12857.0">all of you</a> who play-tested my game and provided me with such great in-depth feedback on the gameplay. Without your love and funkitude, this game wouldn&#8217;t have been what it is today.</p>
<p>And if I ever see you internet folks in real-life, remind me to give you a high-five! You are all wonderful people.</p>
<p>[ <a href="http://armorgames.com/play/6433/wasabi">Play Wasabi at ArmorGames!</a> ]</p>
]]></content:encoded>
			<wfw:commentRss>http://illogictree.com/blog/2010/08/armorgames-sponsors-wasabi/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Carmack&#8217;s Fast Inverse Square Root</title>
		<link>http://illogictree.com/blog/2010/06/carmacks-fast-inverse-square-root/</link>
		<comments>http://illogictree.com/blog/2010/06/carmacks-fast-inverse-square-root/#comments</comments>
		<pubDate>Fri, 04 Jun 2010 04:52:29 +0000</pubDate>
		<dc:creator>Eddie</dc:creator>
				<category><![CDATA[Game Development]]></category>
		<category><![CDATA[engine]]></category>
		<category><![CDATA[math]]></category>

		<guid isPermaLink="false">http://illogictree.com/blog/?p=1880</guid>
		<description><![CDATA[You don&#8217;t need to be an graphics expert to appreciate why square roots are so useful. It&#8217;s used in calculating distance, normalizing vectors, physics simulations, and all other Euclidean and Newtonian tomfoolery.
The number of CPU cycles required to calculate a square root is dozens of times more expensive than that is required to execute a [...]]]></description>
			<content:encoded><![CDATA[<p><img class="alignright size-full wp-image-1889" title="square_root" src="/wp-content/uploads/2010/06/square_root.gif" alt="" width="341" height="253" />You don&#8217;t need to be an graphics expert to appreciate why <a href="http://en.wikipedia.org/wiki/Square_root">square roots</a> are so useful. It&#8217;s used in calculating distance, normalizing vectors, physics simulations, and all other Euclidean and Newtonian tomfoolery.</p>
<p>The number of CPU cycles required to calculate a square root is dozens of times more expensive than that is required to execute a simple math operation. A basic 3D engine can have tens-of-thousands of square root operations per update, so any opportunity to approximate the square root will save you a good number of frame rates.</p>
<p>The code below approximates <strong>1/sqrt(x)</strong> using only multiplication and bit-shift operations. This code was heavily used in the <strong>Quake II</strong> engine:</p>

<div class="wp_syntax"><div class="code"><pre class="cpp" style="font-family:monospace;"><span style="color: #0000ff;">float</span> InvSqrt<span style="color: #008000;">&#40;</span><span style="color: #0000ff;">float</span> x<span style="color: #008000;">&#41;</span>
<span style="color: #008000;">&#123;</span>
   <span style="color: #0000ff;">float</span> xhalf <span style="color: #000080;">=</span> <span style="color:#800080;">0.5f</span> <span style="color: #000040;">*</span> x<span style="color: #008080;">;</span>
   <span style="color: #0000ff;">int</span> i <span style="color: #000080;">=</span> <span style="color: #000040;">*</span><span style="color: #008000;">&#40;</span><span style="color: #0000ff;">int</span><span style="color: #000040;">*</span><span style="color: #008000;">&#41;</span><span style="color: #000040;">&amp;</span>x<span style="color: #008080;">;</span>
   i <span style="color: #000080;">=</span> <span style="color: #208080;">0x5f3759d5</span> <span style="color: #000040;">-</span> <span style="color: #008000;">&#40;</span>i <span style="color: #000080;">&gt;&gt;</span><span style="color: #008080;">;</span> <span style="color: #0000dd;">1</span><span style="color: #008000;">&#41;</span><span style="color: #008080;">;</span>
   x <span style="color: #000080;">=</span> <span style="color: #000040;">*</span><span style="color: #008000;">&#40;</span><span style="color: #0000ff;">float</span><span style="color: #000040;">*</span><span style="color: #008000;">&#41;</span><span style="color: #000040;">&amp;</span>i<span style="color: #008080;">;</span>
   x <span style="color: #000080;">=</span> x<span style="color: #000040;">*</span><span style="color: #008000;">&#40;</span><span style="color:#800080;">1.5f</span> <span style="color: #000040;">-</span> xhalf<span style="color: #000040;">*</span>x<span style="color: #000040;">*</span>x<span style="color: #008000;">&#41;</span><span style="color: #008080;">;</span>
   <span style="color: #0000ff;">return</span> x<span style="color: #008080;">;</span>
<span style="color: #008000;">&#125;</span></pre></div></div>

<p>For those who are mathematically curious: The code above approximates the <em>inverse square root</em> by using <a href="http://en.wikipedia.org/wiki/Newton's_method">Newton&#8217;s method</a>.</p>
<p>[ <a href="http://betterexplained.com/articles/understanding-quakes-fast-inverse-square-root/">Reference</a> ]</p>
]]></content:encoded>
			<wfw:commentRss>http://illogictree.com/blog/2010/06/carmacks-fast-inverse-square-root/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>How to Code a Rhythm Game</title>
		<link>http://illogictree.com/blog/2010/05/how-to-code-a-rhythm-game/</link>
		<comments>http://illogictree.com/blog/2010/05/how-to-code-a-rhythm-game/#comments</comments>
		<pubDate>Mon, 31 May 2010 14:20:00 +0000</pubDate>
		<dc:creator>Eddie</dc:creator>
				<category><![CDATA[Game Development]]></category>
		<category><![CDATA[How To]]></category>
		<category><![CDATA[beats]]></category>
		<category><![CDATA[bpm]]></category>
		<category><![CDATA[ddr]]></category>
		<category><![CDATA[gamedev]]></category>
		<category><![CDATA[Music]]></category>
		<category><![CDATA[programming]]></category>
		<category><![CDATA[rhythm]]></category>
		<category><![CDATA[sound]]></category>

		<guid isPermaLink="false">http://illogictree.com/?p=1673</guid>
		<description><![CDATA[So you want to program a rhythm game but you don&#8217;t know exactly how to begin? Well, during the development process of my rhythm-based mini-game, Funkbot3000, I learned a few things about creating a rhythm game that might be valuable for anyone looking to code one of their own.
In games that use rhythm as its [...]]]></description>
			<content:encoded><![CDATA[<p><img class="alignright size-full wp-image-1803" title="Sound Equalizer Rhythm Music Beats" src="http://illogictree.com/wp-content/uploads/2010/05/981847-xs.jpg" alt="" width="340" height="227" />So you want to program a <strong>rhythm game</strong> but you don&#8217;t know exactly how to begin? Well, during the development process of my rhythm-based mini-game, <a href="/games/funkbot/">Funkbot3000</a>, I learned a few things about creating a rhythm game that might be valuable for anyone looking to code one of their own.</p>
<p>In games that use rhythm as its core mechanic, the most important aspect is detecting if the user executes a certain action in the correct <strong>position</strong> in time. For example, in games such as DDR, the user must step on positional arrows at certain <strong>intervals</strong> in the musical sequence in order for the game to register the input as a successful action.</p>
<p>In this post, I will depart some knowledge that I learned while creating a rhythm game that will hopefully help you in your journey of making a <strong>beat-tastic love adventure</strong>!</p>
<p><span id="more-1673"></span></p>
<p>First and foremost, it definitely helps (but is not required) to have some musical background. If you haven&#8217;t had any experience, you might want to brush up on some of the musical terminology.</p>
<p><strong>BPM (Beats Per Minute)</strong></p>
<p>Regardless if you use a full-length song or a small sound-loop, the most important aspect of any song is calculating its <strong>BPM</strong>. If the song&#8217;s BPM is not provided, the two things that you need to calculate the BPM is the <strong>length </strong>(in seconds) and the <strong>number of beats</strong> in the song/loop. Then, to calculate the BPM, you simply use the formula:</p>

<div class="wp_syntax"><div class="code"><pre class="cpp" style="font-family:monospace;">BPM <span style="color: #000080;">=</span> <span style="color: #008000;">&#40;</span>num beats in song<span style="color: #008000;">&#41;</span> <span style="color: #000040;">*</span> <span style="color: #0000dd;">60</span> <span style="color: #000040;">/</span> <span style="color: #008000;">&#40;</span>num secs in song<span style="color: #008000;">&#41;</span></pre></div></div>

<p>The <strong>BPM</strong> provides a foundation on which you can start testing for user inputs.</p>
<p><strong>Break It Down</strong></p>
<p>In the general case, we can assume that our song is in <strong>4/4</strong> time (also known as <em>common time</em>). What 4/4 means is that the song uses four <a href="http://en.wikipedia.org/wiki/Quarter-note">quarter-note</a> beats per <a href="http://en.wikipedia.org/wiki/Bar_(music)">bar</a>.</p>
<p>What you want to do next is figure out how accurate you want your input to be.  Using <a href="http://en.wikipedia.org/wiki/Eighth_note">eighth note</a> seems to provide enough accuracy for most sequences. But depending on how complicated you want your player&#8217;s input sequence to be, you might want to go all the way to <a href="http://en.wikipedia.org/wiki/Sixteenth_note">sixteeth</a> or <a href="http://en.wikipedia.org/wiki/Sixty-fourth_note">sixty-fourth</a> if you plan to really punish your players with <a href="http://www.youtube.com/watch?v=aS_IYe5JTZ4">Yngwie Malmsteen</a>-style arpeggios.</p>
<p>Below is a depiction of how a whole note is broken down.</p>
<p><img title="note_hierarchy" src="http://illogictree.com/wp-content/uploads/2010/05/note_hierarchy.gif" alt="" width="560" height="293" /></p>
<p style="text-align: center;"><em>Musical note values</em></p>
<p><strong>Register Correct Beats</strong></p>
<p>Now, you want to create a cool button sequence that you want players to press when the song is playing. What you want to do is store all the notes in the song that you want the user to hit in an <strong>array</strong>.</p>
<p>For example, say thatI have a funky, 1-bar drum-loop. And say when the then song is playing, I want to user to press down on a button every first, second, and third beat in the loop.</p>
<p>If I am using <strong>sixteenth</strong> notes as my input sequence&#8217;s precision, I would create an array like this:</p>

<div class="wp_syntax"><div class="code"><pre class="cpp" style="font-family:monospace;">Array beats <span style="color: #000080;">=</span> <span style="color: #008000;">&#91;</span> <span style="color: #0000dd;">4</span>, <span style="color: #0000dd;">8</span>, <span style="color: #0000dd;">12</span> <span style="color: #008000;">&#93;</span><span style="color: #008080;">;</span> <span style="color: #666666;">// 1st, 2nd, 3rd quarter note</span></pre></div></div>

<p>So for <strong>each </strong>quarter note, there are <strong>four </strong>sixteenth notes.  The array above suggests that we want to detect the first, second and third sixteenth-note of each bar, so we multiply each value (quarter note) by <strong>four</strong> to get its corresponding value in sixteenth notes.</p>
<p><strong>Detecting User Input</strong></p>
<p>Now that you have your input sequence laid out, you can start detecting if players correctly pressed your sequence in time.</p>
<p>Every time the user hits a button, you must calculate which note (or which sixteenth note in our funk drum-loop example) the input corresponds to. To calculate that, you must know when, in the <strong>local time</strong> of the song, the button was pressed. What I mean by <strong>local time</strong> is the current time in the song that your game state is currently at. Say your song loop is only <strong>10</strong> seconds long but the game has elapsed a total time of <strong>14</strong> seconds. That means the local time of the song loop is 14-10=<strong>4 seconds</strong>.</p>
<p>To calculate the <strong>note position</strong> given the local time in the song, you can use this formula:</p>

<div class="wp_syntax"><div class="code"><pre class="cpp" style="font-family:monospace;">nth sixteenth<span style="color: #000040;">-</span>note <span style="color: #000080;">=</span> <span style="color: #008000;">&#40;</span><span style="color: #0000dd;">time</span> in secs in song<span style="color: #008000;">&#41;</span> <span style="color: #000040;">*</span> BPM <span style="color: #000040;">*</span> <span style="color: #008000;">&#40;</span><span style="color: #0000dd;">1</span><span style="color: #000040;">/</span><span style="color: #0000dd;">60</span><span style="color: #008000;">&#41;</span> <span style="color: #000040;">*</span> <span style="color: #008000;">&#40;</span>num_vals _per_beat<span style="color: #008000;">&#41;</span></pre></div></div>

<p>In my example, we are using <strong>sixteenth</strong> notes. Say I have a local-time of <strong>1.5</strong> seconds of a song with <strong>50</strong> BPM. Since there are <strong>4</strong> sixteenth notes per beat, we can calculate the nth sixteenth note:</p>

<div class="wp_syntax"><div class="code"><pre class="cpp" style="font-family:monospace;"><span style="color: #666666;">// BPM = 50, secs = 4, num_vals_per_beat = 4</span>
nth sixteenth<span style="color: #000040;">-</span>note <span style="color: #000080;">=</span> <span style="color: #008000;">&#40;</span><span style="color:#800080;">1.5</span><span style="color: #008000;">&#41;</span> <span style="color: #000040;">*</span> <span style="color: #0000dd;">50</span> <span style="color: #000040;">*</span> <span style="color: #008000;">&#40;</span><span style="color: #0000dd;">1</span><span style="color: #000040;">/</span><span style="color: #0000dd;">60</span><span style="color: #008000;">&#41;</span> <span style="color: #000040;">*</span> <span style="color: #008000;">&#40;</span><span style="color: #0000dd;">4</span><span style="color: #008000;">&#41;</span> <span style="color: #000080;">=</span> <span style="color: #0000dd;">5</span></pre></div></div>

<p>That means we were at the <strong>5th</strong> sixteenth note in the song/loop. Since there is no <strong>5</strong> in our array <strong>[4, 8, 12]</strong>, that means that the user did not press the button at the correct position in time according to what we set as our input sequence.</p>
<p><strong>Go Easy, Bro</strong></p>
<p>We can assume that the user will not press the input button at the <em>exact</em> moment in time that corresponds to your beat sequence (virtually impossible). So, what I did to remedy that is to give an acceptable <strong>buffer</strong> which provides the user a <strong>range of time</strong> such that if the user presses the button within this buffer, the game will register the input as correct. For example, if the user presses the button within 0.5 beats of the target beat, the input would register as a success.</p>
<p>So there you have it, a way to structure your code to provide a framework for rhythm games. Now go make some sweet, musical lovin&#8217;.</p>
]]></content:encoded>
			<wfw:commentRss>http://illogictree.com/blog/2010/05/how-to-code-a-rhythm-game/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Introducing: Wasabi</title>
		<link>http://illogictree.com/blog/2010/05/introducing-wasabi/</link>
		<comments>http://illogictree.com/blog/2010/05/introducing-wasabi/#comments</comments>
		<pubDate>Thu, 27 May 2010 06:44:50 +0000</pubDate>
		<dc:creator>Eddie</dc:creator>
				<category><![CDATA[Game Development]]></category>
		<category><![CDATA[News]]></category>

		<guid isPermaLink="false">http://illogictree.com/blog/?p=1720</guid>
		<description><![CDATA[While eating sushi with my wonderful girlfriend last week, I came up with this little simulation game involving a man and his struggling sushi bar. The game is called Wasabi and it&#8217;s a bastard child of two of my greatly-liked genres: farming sims and platformers.
So I&#8217;ve been furiously coding away in my underwater lab. And [...]]]></description>
			<content:encoded><![CDATA[<p><a href="/games/wasabi"><img class="alignright size-full wp-image-1721" title="Wasabi Screenshot" src="http://illogictree.com/wp-content/uploads/2010/05/wasabiscren.png" alt="" width="320" height="224" /></a>While eating <a href="/wp-content/uploads/2010/05/nemo-sushi.jpg">sushi</a> with my wonderful girlfriend last week, I came up with this little simulation game involving a man and his struggling sushi bar. The game is called <strong>Wasabi</strong> and it&#8217;s a bastard child of two of my greatly-liked genres: <strong>farming sims</strong> and <strong>platformers</strong>.</p>
<p>So I&#8217;ve been furiously coding away in my underwater lab. And now, I feel that Wasabi is at a good state in which it can be released out to the public in hopes to receive some critically delicious feedback.</p>
<p>I consider the game to be in <strong>alpha</strong> right now, which means it still needs alot of balancing and tweaking to do to make the fun truly shine like a star!!!</p>
<p>Anyhow, I hope you enjoy my interpretation of how the sushi business works in the real-world. I tried to be as accurate as possible. Also, feel free to leave me some <strong>feedback</strong> in any colour you like.</p>
<p>[ <a href="/games/wasabi/">Play Wasabi</a> ]</p>
]]></content:encoded>
			<wfw:commentRss>http://illogictree.com/blog/2010/05/introducing-wasabi/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Funkbot 3000 Finished!</title>
		<link>http://illogictree.com/blog/2010/05/funkbot-3000-finished/</link>
		<comments>http://illogictree.com/blog/2010/05/funkbot-3000-finished/#comments</comments>
		<pubDate>Sun, 02 May 2010 22:11:57 +0000</pubDate>
		<dc:creator>Eddie</dc:creator>
				<category><![CDATA[Game Development]]></category>
		<category><![CDATA[flash]]></category>
		<category><![CDATA[flixel]]></category>
		<category><![CDATA[funkbot]]></category>
		<category><![CDATA[game]]></category>

		<guid isPermaLink="false">http://illogictree.com/?p=1653</guid>
		<description><![CDATA[After several weeks of hard work, I am proud to say that I have finished my (mini-) game, Funkbot 3000. It all started as an experiment to develop a Flash game with rhythm-based mechanics and ended up as a silly mini-game where you must build a robot with the power of love, funk and soul.
It has [...]]]></description>
			<content:encoded><![CDATA[<p><img class="alignright size-full wp-image-1654" title="lvl3" src="http://illogictree.com/wp-content/uploads/2010/05/lvl3.png" alt="" width="320" height="240" />After several weeks of hard work, I am proud to say that I have finished my (mini-) game, <a href="/games/funkbot/">Funkbot 3000</a>. It all started as an experiment to develop a Flash game with rhythm-based mechanics and ended up as a silly mini-game where you must build a robot with the power of <strong>love</strong>, <strong>funk</strong> and <strong>soul</strong>.</p>
<p>It has been a fun experience. And during the development process, <strong>Funkbot</strong> has been features on several sites:</p>
<ul>
<li><a href="http://www.pixelprospector.com/indev/2010/04/funkbot3000/">Pixel Prospector</a></li>
<li><a href="http://fuxter.ru/funkbot3000/">Fuxter</a> (Russian)</li>
<li><a href="http://www.superlevel.de/spiele/funkbot">SuperLevel</a> (German)</li>
</ul>
<p>However, there are still some <strong>desyncing</strong> issues if you start doing something else while in the game (like browsing the web). Not exactly sure how to fix that, but if you stay in the game from start to finish, the music and the beat should be in sync.</p>
<p>Anyhow, it is time to move on to bigger and more <a href="http://thisiswhyyourefat.com/">delicious</a> things. Hope y&#8217;all enjoy!</p>
<p>[ <a href="/games/funkbot/">Play Funkbot3000</a> ]</p>
]]></content:encoded>
			<wfw:commentRss>http://illogictree.com/blog/2010/05/funkbot-3000-finished/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Actionscript 3 &#8211; Singleton</title>
		<link>http://illogictree.com/blog/2010/04/actionscript-3-singleton/</link>
		<comments>http://illogictree.com/blog/2010/04/actionscript-3-singleton/#comments</comments>
		<pubDate>Wed, 28 Apr 2010 20:29:55 +0000</pubDate>
		<dc:creator>Eddie</dc:creator>
				<category><![CDATA[Game Development]]></category>
		<category><![CDATA[actionscript]]></category>
		<category><![CDATA[c++]]></category>
		<category><![CDATA[design pattern]]></category>
		<category><![CDATA[flash]]></category>
		<category><![CDATA[singleton]]></category>

		<guid isPermaLink="false">http://illogictree.com/?p=1592</guid>
		<description><![CDATA[The Singleton design pattern is popular method that is used quite ubiquitously in software engineering. Sometimes, it is appropriate to have only one instance of a class. For example, the window manager, sprite manager, and filesystems are all good examples of classes that would neatly follow the singleton paradigm (since you only need one of [...]]]></description>
			<content:encoded><![CDATA[<p><img class="size-full wp-image-1606 alignright" title="Scheme of Singleton" src="http://illogictree.com/wp-content/uploads/2010/04/Scheme-of-Singleton.png" alt="" width="275" height="80" />The <strong>Singleton</strong> design pattern is popular method that is used quite ubiquitously in software engineering. Sometimes, it is appropriate to have only <strong>one </strong>instance of a class. For example, the window manager, sprite manager, and filesystems are all good examples of classes that would neatly follow the singleton paradigm (since you only need one of them in your application). Singletons are extremely useful when you have exactly one instance of an object that requires <strong>global access</strong>.</p>
<p>In C++ code, one would derive singleton classes from a singletons template. Doing this prevents the coder from polluting your global space with nasty variables. (Also, the compiler does not guarantee the order that globals or statics are instantiated.)</p>
<p>Although Actionscript does not have templating functionality like C++, you can still make your desired class a singleton by simply adding a few functions:</p>

<div class="wp_syntax"><div class="code"><pre class="actionscript3" style="font-family:monospace;"><span style="color: #9900cc; font-weight: bold;">package</span> com.example
<span style="color: #000000;">&#123;</span>
	<span style="color: #0033ff; font-weight: bold;">public</span> <span style="color: #9900cc; font-weight: bold;">class</span> SpriteManager
	<span style="color: #000000;">&#123;</span>
		<span style="color: #0033ff; font-weight: bold;">public</span> <span style="color: #339966; font-weight: bold;">function</span> SpriteManager<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span>
		<span style="color: #000000;">&#123;</span>;<span style="color: #000000;">&#125;</span>
&nbsp;
		<span style="color: #009900;">// Singleton methods</span>
		<span style="color: #009900;">//</span>
		<span style="color: #0033ff; font-weight: bold;">private</span> static <span style="color: #6699cc; font-weight: bold;">var</span> _instance<span style="color: #000000; font-weight: bold;">:</span>SpriteManager = <span style="color: #0033ff; font-weight: bold;">null</span>;
		<span style="color: #0033ff; font-weight: bold;">public</span> static <span style="color: #339966; font-weight: bold;">function</span> CreateInst<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><span style="color: #000000; font-weight: bold;">:</span><span style="color: #0033ff; font-weight: bold;">void</span> <span style="color: #000000;">&#123;</span> _instance = <span style="color: #0033ff; font-weight: bold;">new</span> SpriteManager<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span>; <span style="color: #000000;">&#125;</span>
		<span style="color: #0033ff; font-weight: bold;">public</span> static <span style="color: #339966; font-weight: bold;">function</span> Get<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><span style="color: #000000; font-weight: bold;">:</span>SpriteManager <span style="color: #000000;">&#123;</span> <span style="color: #0033ff; font-weight: bold;">return</span> _instance; <span style="color: #000000;">&#125;</span>
		<span style="color: #0033ff; font-weight: bold;">public</span> static <span style="color: #339966; font-weight: bold;">function</span> InstExists<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><span style="color: #000000; font-weight: bold;">:</span><span style="color: #004993;">Boolean</span> <span style="color: #000000;">&#123;</span> <span style="color: #0033ff; font-weight: bold;">return</span> _instance <span style="color: #000000; font-weight: bold;">!</span>= <span style="color: #0033ff; font-weight: bold;">null</span>; <span style="color: #000000;">&#125;</span>
		<span style="color: #0033ff; font-weight: bold;">public</span> static <span style="color: #339966; font-weight: bold;">function</span> DestroyInst<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><span style="color: #000000; font-weight: bold;">:</span><span style="color: #0033ff; font-weight: bold;">void</span> <span style="color: #000000;">&#123;</span> _instance = <span style="color: #0033ff; font-weight: bold;">null</span>; <span style="color: #000000;">&#125;</span>
	<span style="color: #000000;">&#125;</span>
&nbsp;
<span style="color: #000000;">&#125;</span></pre></div></div>

<p>As you can see, you use a <strong>private static var _instance</strong> to hold the single instance of the class. The <strong>CreateInst()</strong> function creates a the single instance of that particular class:</p>

<div class="wp_syntax"><div class="code"><pre class="actionscript3" style="font-family:monospace;">SpriteManager.CreateInst<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span>;</pre></div></div>

<p>You access the class by calling <strong>Get()</strong>. For example, if I wanted to fetch the instance of the SpriteManager, I call:</p>

<div class="wp_syntax"><div class="code"><pre class="actionscript3" style="font-family:monospace;"><span style="color: #6699cc; font-weight: bold;">var</span> manager<span style="color: #000000; font-weight: bold;">:</span>SpriteManager = SpriteManager.Get<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span>;</pre></div></div>

<p>And there you go, a simple Actionscript 3 singleton class for the win. And on a related matter, there is a Playboy bunny named <a href="http://en.wikipedia.org/wiki/Sasha_Singleton">Sasha Singleton</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://illogictree.com/blog/2010/04/actionscript-3-singleton/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Introducing: FunkBot3000</title>
		<link>http://illogictree.com/blog/2010/04/introducing-funkbot3000/</link>
		<comments>http://illogictree.com/blog/2010/04/introducing-funkbot3000/#comments</comments>
		<pubDate>Fri, 23 Apr 2010 04:30:27 +0000</pubDate>
		<dc:creator>Eddie</dc:creator>
				<category><![CDATA[Game Development]]></category>
		<category><![CDATA[News]]></category>
		<category><![CDATA[actionscript]]></category>
		<category><![CDATA[flash]]></category>
		<category><![CDATA[flixel]]></category>
		<category><![CDATA[game]]></category>

		<guid isPermaLink="false">http://illogictree.com/?p=1538</guid>
		<description><![CDATA[Earlier this week, I was noodling around in Graphics Gale (my favorite pixel-art program) of which I haphazardly gave birth to this pixelated robot (shown on right). Yearning to get back into Flash game proramming, I decided to quickly prototype a small Flash demo using Actionscript and the spankin&#8217; new flixel 2.0 engine.
I&#8217;ve always been interested [...]]]></description>
			<content:encoded><![CDATA[<p><img class="alignright size-full wp-image-1539" title="Funkbot 3000" src="http://illogictree.com/wp-content/uploads/2010/04/Funkbot-3000.gif" alt="" width="82" height="235" />Earlier this week, I was noodling around in <a href="http://www.humanbalance.net/gale/us/">Graphics Gale</a> (my favorite pixel-art program) of which I haphazardly gave birth to this pixelated robot (shown on right). Yearning to get back into Flash game proramming, I decided to quickly prototype a <a href="/games/funkbot/">small Flash demo</a> using Actionscript and the spankin&#8217; new <a href="http://flixel.org/">flixel 2.0 engine</a>.</p>
<p>I&#8217;ve always been interested in <strong>rhythm games</strong>. But oftentimes, I feel that music takes a backseat to gameplay. And rightly so since most games focus on providing gameplay that merely uses music as support for building the ambiance or to convey emotion to the player.</p>
<p>However, once in a while, a game is developed which mend <strong>music </strong>and <strong>gameplay </strong>in innovative and fun ways that it makes you wonder about the vast possibilities of game design. Games such as DDR, Rockband, Parappa the Rappa and Rhythm Tengoku are all prime examples of games that were able to creatively integrate music and rhythm into its core gameplay to fully immerse the player in the music.</p>
<p>I am currently developing this Flash game on the side in hopes to learn more about using rhythm-based game mechanics. It&#8217;s called <a href="/games/funkbot/">FunkBot3000</a>, and it is game about funky robots which are fueled by the power of music. I am currently not sure on how much time I can devote to this project because of my busy academic schedule. But  I&#8217;ll try my best to bring it to some playable state.</p>
<p>[ <a href="/games/funkbot/">Play FunkBot3000</a> ]</p>
]]></content:encoded>
			<wfw:commentRss>http://illogictree.com/blog/2010/04/introducing-funkbot3000/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>DirectX10 (D3D10) &amp; DevIL Image Library</title>
		<link>http://illogictree.com/blog/2010/02/directx10-devil-image-library/</link>
		<comments>http://illogictree.com/blog/2010/02/directx10-devil-image-library/#comments</comments>
		<pubDate>Mon, 15 Feb 2010 05:19:06 +0000</pubDate>
		<dc:creator>Eddie</dc:creator>
				<category><![CDATA[Game Development]]></category>
		<category><![CDATA[How To]]></category>

		<guid isPermaLink="false">http://illogictree.com/?p=1455</guid>
		<description><![CDATA[After extensively searching online for some documentation on how to use the DevIL Image Library with DirectX10 to no avail, I have brought it upon myself to write a brief post on how to get them two to coexist in love. 
Although DirectX10 (Direct3D10) already has functionality that allows users to load images directly, it [...]]]></description>
			<content:encoded><![CDATA[<p><img src="http://illogictree.com/wp-content/uploads/2010/02/devil-image-library-300x143.jpg" alt="" title="devil-image-library" width="300" height="143" class="alignright size-medium wp-image-1459" />After extensively searching online for some documentation on how to use the <a href="http://openil.sourceforge.net/">DevIL</a> Image Library with DirectX10 to no avail, I have brought it upon myself to write a brief post on how to get them two to coexist in love. </p>
<p>Although DirectX10 (Direct3D10) already has <a href="http://msdn.microsoft.com/en-us/library/ee416716(VS.85).aspx">functionality</a> that allows users to load images directly, it might not be enough. For example, DirectX is unable to load some image types such as TARGA (.tga) files.  And if you are writing a OpenGL &#038; DirectX10 dual-renderer, you might want unite both renderers under a common image library API. Plus, DevIL has a lot of great functionality, and you want to take full advantage of it. Below, I provided the code to load an image given the filename.</p>

<div class="wp_syntax"><div class="code"><pre class="cpp" style="font-family:monospace;"><span style="color: #339900;">#include &lt;IL/il.h&gt;</span>
<span style="color: #339900;">#include &lt;string&gt;</span>
<span style="color: #339900;">#include &lt;assert.h&gt;</span>
&nbsp;
<span style="color: #666666;">// Use this macro to verify if D3D10 function succeeded</span>
<span style="color: #339900;">#define HV(x) if(!SUCCEEDED(x)) MessageBox(NULL, #x, &quot;HRESULT fail&quot;, MB_OK)</span>
&nbsp;
<span style="color: #666666;">// Creates a shader resource view given a filepath &amp; D3D10 device</span>
<span style="color: #666666;">//	@filePath - String of the file path of the image file</span>
<span style="color: #666666;">//	@pDevice - Pointer to the D3D10 device</span>
ID3D10ShaderResourceView<span style="color: #000040;">*</span> MakeSRV<span style="color: #008000;">&#40;</span> <span style="color: #0000ff;">const</span> std<span style="color: #008080;">::</span><span style="color: #007788;">string</span><span style="color: #000040;">&amp;</span> filePath, ID3D10Device<span style="color: #000040;">*</span> pDevice <span style="color: #008000;">&#41;</span>
<span style="color: #008000;">&#123;</span>
	<span style="color: #666666;">// Will be filled and returned</span>
	ID3D10ShaderResourceView<span style="color: #000040;">*</span> pSRV <span style="color: #000080;">=</span> <span style="color: #0000ff;">NULL</span><span style="color: #008080;">;</span>
&nbsp;
	<span style="color: #666666;">// Load image from DevIL</span>
	ILuint idImage<span style="color: #008080;">;</span>
	ilGenImages<span style="color: #008000;">&#40;</span> <span style="color: #0000dd;">1</span>, <span style="color: #000040;">&amp;</span>idImage <span style="color: #008000;">&#41;</span><span style="color: #008080;">;</span>
	ilBindImage<span style="color: #008000;">&#40;</span> idImage <span style="color: #008000;">&#41;</span><span style="color: #008080;">;</span>
	ilLoadImage<span style="color: #008000;">&#40;</span> filePath.<span style="color: #007788;">c_str</span><span style="color: #008000;">&#40;</span><span style="color: #008000;">&#41;</span> <span style="color: #008000;">&#41;</span><span style="color: #008080;">;</span>
	<span style="color: #0000dd;">assert</span> <span style="color: #008000;">&#40;</span> IL_NO_ERROR <span style="color: #000080;">==</span> ilGetError<span style="color: #008000;">&#40;</span><span style="color: #008000;">&#41;</span> <span style="color: #008000;">&#41;</span><span style="color: #008080;">;</span>
&nbsp;
	<span style="color: #666666;">// Fetch dimensions of image</span>
	<span style="color: #0000ff;">int</span> width <span style="color: #000080;">=</span> ilGetInteger<span style="color: #008000;">&#40;</span> IL_IMAGE_WIDTH <span style="color: #008000;">&#41;</span><span style="color: #008080;">;</span>
	<span style="color: #0000ff;">int</span> height <span style="color: #000080;">=</span> ilGetInteger<span style="color: #008000;">&#40;</span> IL_IMAGE_HEIGHT <span style="color: #008000;">&#41;</span><span style="color: #008080;">;</span>
&nbsp;
	<span style="color: #666666;">// Load the data</span>
	ilConvertImage<span style="color: #008000;">&#40;</span> IL_RGBA,IL_UNSIGNED_BYTE <span style="color: #008000;">&#41;</span><span style="color: #008080;">;</span>
	<span style="color: #0000ff;">unsigned</span> <span style="color: #0000ff;">char</span> <span style="color: #000040;">*</span> pData <span style="color: #000080;">=</span> ilGetData<span style="color: #008000;">&#40;</span><span style="color: #008000;">&#41;</span><span style="color: #008080;">;</span>
&nbsp;
	<span style="color: #666666;">// Build the texture header descriptor</span>
	D3D10_TEXTURE2D_DESC descTex<span style="color: #008080;">;</span>
	descTex.<span style="color: #007788;">Width</span> <span style="color: #000080;">=</span> width<span style="color: #008080;">;</span>
	descTex.<span style="color: #007788;">Height</span> <span style="color: #000080;">=</span> height<span style="color: #008080;">;</span>
	descTex.<span style="color: #007788;">Format</span> <span style="color: #000080;">=</span> DXGI_FORMAT_R8G8B8A8_UNORM<span style="color: #008080;">;</span>
	descTex.<span style="color: #007788;">Usage</span> <span style="color: #000080;">=</span> D3D10_USAGE_DEFAULT<span style="color: #008080;">;</span>
	descTex.<span style="color: #007788;">BindFlags</span> <span style="color: #000080;">=</span> D3D10_BIND_SHADER_RESOURCE <span style="color: #000040;">|</span> D3D10_BIND_RENDER_TARGET<span style="color: #008080;">;</span>
	descTex.<span style="color: #007788;">CPUAccessFlags</span> <span style="color: #000080;">=</span> <span style="color: #0000dd;">0</span><span style="color: #008080;">;</span>
	descTex.<span style="color: #007788;">MipLevels</span> <span style="color: #000080;">=</span> <span style="color: #0000dd;">1</span><span style="color: #008080;">;</span>
	descTex.<span style="color: #007788;">ArraySize</span> <span style="color: #000080;">=</span> <span style="color: #0000dd;">1</span><span style="color: #008080;">;</span>
	descTex.<span style="color: #007788;">SampleDesc</span>.<span style="color: #007788;">Count</span> <span style="color: #000080;">=</span> <span style="color: #0000dd;">1</span><span style="color: #008080;">;</span>
	descTex.<span style="color: #007788;">SampleDesc</span>.<span style="color: #007788;">Quality</span> <span style="color: #000080;">=</span> <span style="color: #0000dd;">0</span><span style="color: #008080;">;</span>
	descTex.<span style="color: #007788;">MiscFlags</span> <span style="color: #000080;">=</span> D3D10_RESOURCE_MISC_GENERATE_MIPS<span style="color: #008080;">;</span>
&nbsp;
	<span style="color: #666666;">// Resource data descriptor</span>
	D3D10_SUBRESOURCE_DATA data <span style="color: #008080;">;</span>
	<span style="color: #0000dd;">memset</span><span style="color: #008000;">&#40;</span> <span style="color: #000040;">&amp;</span>data, <span style="color: #0000dd;">0</span>, <span style="color: #0000dd;">sizeof</span><span style="color: #008000;">&#40;</span>D3D10_SUBRESOURCE_DATA<span style="color: #008000;">&#41;</span><span style="color: #008000;">&#41;</span><span style="color: #008080;">;</span>
	data.<span style="color: #007788;">pSysMem</span> <span style="color: #000080;">=</span> pData<span style="color: #008080;">;</span>
	data.<span style="color: #007788;">SysMemPitch</span> <span style="color: #000080;">=</span> <span style="color: #0000dd;">4</span> <span style="color: #000040;">*</span> width<span style="color: #008080;">;</span>
&nbsp;
	<span style="color: #666666;">// Create the 2d texture from data</span>
	ID3D10Texture2D <span style="color: #000040;">*</span> pTexture <span style="color: #000080;">=</span> <span style="color: #0000ff;">NULL</span><span style="color: #008080;">;</span>
	HV<span style="color: #008000;">&#40;</span> pDevice<span style="color: #000040;">-</span><span style="color: #000080;">&gt;</span>CreateTexture2D<span style="color: #008000;">&#40;</span> <span style="color: #000040;">&amp;</span>descTex, <span style="color: #000040;">&amp;</span>data, <span style="color: #000040;">&amp;</span>pTexture <span style="color: #008000;">&#41;</span><span style="color: #008000;">&#41;</span><span style="color: #008080;">;</span>
&nbsp;
	<span style="color: #666666;">// Create resource view descriptor</span>
	D3D10_SHADER_RESOURCE_VIEW_DESC srvDesc<span style="color: #008080;">;</span>
	srvDesc.<span style="color: #007788;">Format</span> <span style="color: #000080;">=</span> descTex.<span style="color: #007788;">Format</span><span style="color: #008080;">;</span>
	srvDesc.<span style="color: #007788;">ViewDimension</span> <span style="color: #000080;">=</span> D3D10_SRV_DIMENSION_TEXTURE2D<span style="color: #008080;">;</span>
	srvDesc.<span style="color: #007788;">Texture2D</span>.<span style="color: #007788;">MostDetailedMip</span> <span style="color: #000080;">=</span> <span style="color: #0000dd;">0</span><span style="color: #008080;">;</span>
	srvDesc.<span style="color: #007788;">Texture2D</span>.<span style="color: #007788;">MipLevels</span> <span style="color: #000080;">=</span> D3D10_RESOURCE_MISC_GENERATE_MIPS <span style="color: #008080;">;</span>
&nbsp;
	<span style="color: #666666;">// Create the shader resource view</span>
	HV<span style="color: #008000;">&#40;</span> pDevice<span style="color: #000040;">-</span><span style="color: #000080;">&gt;</span>CreateShaderResourceView<span style="color: #008000;">&#40;</span> pTexture, <span style="color: #000040;">&amp;</span>srvDesc, <span style="color: #000040;">&amp;</span>pSRV <span style="color: #008000;">&#41;</span><span style="color: #008000;">&#41;</span><span style="color: #008080;">;</span>
&nbsp;
	<span style="color: #666666;">// Delete from IL buffer after image loaded correctly</span>
	ilDeleteImages<span style="color: #008000;">&#40;</span> <span style="color: #0000dd;">1</span>, <span style="color: #000040;">&amp;</span>idImage <span style="color: #008000;">&#41;</span><span style="color: #008080;">;</span>
	idImage <span style="color: #000080;">=</span> <span style="color: #0000dd;">0</span><span style="color: #008080;">;</span>
&nbsp;
	<span style="color: #0000ff;">return</span> pSRV<span style="color: #008080;">;</span>
<span style="color: #008000;">&#125;</span></pre></div></div>

<p>There you have it. Let me know if you got any woes getting it to work. Thanks to my bud Manny for helping with the code.</p>
]]></content:encoded>
			<wfw:commentRss>http://illogictree.com/blog/2010/02/directx10-devil-image-library/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
	</channel>
</rss>
