<?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</title>
	<atom:link href="http://illogictree.com/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>Tue, 24 Aug 2010 22:54: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>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>Navier-Stokes Fluid Dynamics</title>
		<link>http://illogictree.com/blog/2010/08/navier-stokes-fluid-dynamics/</link>
		<comments>http://illogictree.com/blog/2010/08/navier-stokes-fluid-dynamics/#comments</comments>
		<pubDate>Fri, 13 Aug 2010 01:14:30 +0000</pubDate>
		<dc:creator>Eddie</dc:creator>
				<category><![CDATA[Videos]]></category>

		<guid isPermaLink="false">http://illogictree.com/blog/?p=2082</guid>
		<description><![CDATA[
Above is a video of a particle system driven by fluid dynamics that I developed in conjunction with my dear-old Dominican friend Manny Fernandez. The physics of this application is simulated using Navier-Stokes equations.
The Navier-Stokes equations are really quite groovy because they describe the physical properties behind fluid substances, from water and air currents to [...]]]></description>
			<content:encoded><![CDATA[<p><object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" width="570" height="570" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,40,0"><param name="allowfullscreen" value="true" /><param name="allowscriptaccess" value="always" /><param name="src" value="http://vimeo.com/moogaloop.swf?clip_id=13341136&amp;server=vimeo.com&amp;show_title=1&amp;show_byline=1&amp;show_portrait=0&amp;color=00ADEF&amp;fullscreen=1&amp;autoplay=0&amp;loop=0" /><embed type="application/x-shockwave-flash" width="570" height="570" src="http://vimeo.com/moogaloop.swf?clip_id=13341136&amp;server=vimeo.com&amp;show_title=1&amp;show_byline=1&amp;show_portrait=0&amp;color=00ADEF&amp;fullscreen=1&amp;autoplay=0&amp;loop=0" allowscriptaccess="always" allowfullscreen="true"></embed></object></p>
<p>Above is a video of a particle system driven by fluid dynamics that I developed in conjunction with my dear-old Dominican friend <a href="http://frontbuffer.com">Manny Fernandez</a>. The physics of this application is simulated using <a href="http://en.wikipedia.org/wiki/Navier%E2%80%93Stokes_equations">Navier-Stokes equations</a>.</p>
<p>The Navier-Stokes equations are really quite groovy because they describe the physical properties behind fluid substances, from water and air currents to the motion of stars swirling inside a galaxy. Navier-Stokes is also used as the basis for weather forecasts. If you are interested in this learning more about this physics trickery, Jos Stam gave a great <a href="http://www.dgp.toronto.edu/people/stam/reality/Research/pdf/GDC03.pdf">GDC talk</a> about it.</p>
<p>The particle system application is coded in C++ and uses OpenGL/GLUT to render 40,000 particles. Given the vast amount of particles, we decided to take a multi-threaded approach to fork the work into several threads, with each thread handling a block of particles.</p>
<p>The <a href="http://illogictree.com/upload/NavierTokes.zip">source code</a> is available for those who are interested. It&#8217;s public domain goodness.</p>
<p>[ <a href="http://illogictree.com/upload/NavierTokes.zip">Source Code</a> ]</p>
]]></content:encoded>
			<wfw:commentRss>http://illogictree.com/blog/2010/08/navier-stokes-fluid-dynamics/feed/</wfw:commentRss>
		<slash:comments>0</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>Fembot</title>
		<link>http://illogictree.com/blog/2010/06/fembot/</link>
		<comments>http://illogictree.com/blog/2010/06/fembot/#comments</comments>
		<pubDate>Fri, 11 Jun 2010 23:01:26 +0000</pubDate>
		<dc:creator>Eddie</dc:creator>
				<category><![CDATA[Videos]]></category>
		<category><![CDATA[graphics]]></category>
		<category><![CDATA[hlsl]]></category>
		<category><![CDATA[rendering]]></category>

		<guid isPermaLink="false">http://illogictree.com/blog/?p=1926</guid>
		<description><![CDATA[
Above is a video of the Fembot 3ds-Max model which is being rendered by my 3D-engine. I coded a custom plugin for Autodesk&#8217;s 3dsMax that exports 3D models out to my own custom format (XML based). My 3D-engine then reads my custom format and correctly imports it into my engine to be rendered in all [...]]]></description>
			<content:encoded><![CDATA[<p><object width="570" height="375"><param name="allowfullscreen" value="true" /><param name="allowscriptaccess" value="always" /><param name="movie" value="http://vimeo.com/moogaloop.swf?clip_id=12500675&amp;server=vimeo.com&amp;show_title=1&amp;show_byline=1&amp;show_portrait=0&amp;color=00ADEF&amp;fullscreen=1" /><embed src="http://vimeo.com/moogaloop.swf?clip_id=12500675&amp;server=vimeo.com&amp;show_title=1&amp;show_byline=1&amp;show_portrait=0&amp;color=00ADEF&amp;fullscreen=1" type="application/x-shockwave-flash" allowfullscreen="true" allowscriptaccess="always" width="570" height="375"></embed></object></p>
<p>Above is a video of the <a href="http://artist-3d.com/free_3d_models/dnm/model_disp.php?uid=2494">Fembot 3ds-Max model</a> which is being rendered by my 3D-engine. I coded a custom plugin for Autodesk&#8217;s 3dsMax that exports 3D models out to my own custom format (XML based). My 3D-engine then reads my custom format and correctly imports it into my engine to be rendered in all its glory.</p>
<p>The model uses simple <a href="http://en.wikipedia.org/wiki/Phong_shading">phong lighting</a> and <a href="http://en.wikipedia.org/wiki/Specular_reflection">specular highlights</a> to achieve the glossy look. The yellow-blueish tone is achieved by using the coefficient from the phong lighting (n-dot-L) and interpolating between two colors (yellow and blue); this technique is also known as <strong>Gooch shading</strong>. According to the Gooch model, colors range from cool tones to warm tones rather than dark to light, thus giving it an appearance of ambient lighting.</p>
<p>[ <a href="/wp-content/uploads/2010/06/fembg.png">Large Rendered Image</a> ] 1920&#215;1080 PNG</p>
]]></content:encoded>
			<wfw:commentRss>http://illogictree.com/blog/2010/06/fembot/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Sumo Pixels</title>
		<link>http://illogictree.com/blog/2010/06/sumo-pixels/</link>
		<comments>http://illogictree.com/blog/2010/06/sumo-pixels/#comments</comments>
		<pubDate>Fri, 04 Jun 2010 06:47:03 +0000</pubDate>
		<dc:creator>Eddie</dc:creator>
				<category><![CDATA[Pictures]]></category>
		<category><![CDATA[art]]></category>
		<category><![CDATA[mockup]]></category>
		<category><![CDATA[pixel]]></category>

		<guid isPermaLink="false">http://illogictree.com/blog/?p=1891</guid>
		<description><![CDATA[
I was fooling around in my pixel program last night and came up with a small mockup of two sumos wrestling. Maybe I&#8217;ll make a game out of it! Maybe I won&#8217;t! Who knows!
]]></description>
			<content:encoded><![CDATA[<p><img class="size-full wp-image-1892 alignnone" title="2mme3ia" src="http://illogictree.com/wp-content/uploads/2010/06/2mme3ia.png" alt="" width="570" height="413" /></p>
<p>I was fooling around in my pixel program last night and came up with a small mockup of two sumos wrestling. Maybe I&#8217;ll make a game out of it! Maybe I won&#8217;t! Who knows!</p>
]]></content:encoded>
			<wfw:commentRss>http://illogictree.com/blog/2010/06/sumo-pixels/feed/</wfw:commentRss>
		<slash:comments>5</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>Stop Motion Pixel Art</title>
		<link>http://illogictree.com/blog/2010/05/stop-motion-pixel-art/</link>
		<comments>http://illogictree.com/blog/2010/05/stop-motion-pixel-art/#comments</comments>
		<pubDate>Tue, 01 Jun 2010 05:26:23 +0000</pubDate>
		<dc:creator>Eddie</dc:creator>
				<category><![CDATA[Videos]]></category>

		<guid isPermaLink="false">http://illogictree.com/blog/?p=1852</guid>
		<description><![CDATA[
A man by the name of Alex Varanese once wondered what 8-bit video games might look &#8220;in the form of a stop motion animation&#8221;. And while most people would just stop at wondering, this dude actually implements it. It&#8217;s awesome. Please watch it.
]]></description>
			<content:encoded><![CDATA[<p><object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" width="570" height="321" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,40,0"><param name="allowfullscreen" value="true" /><param name="allowscriptaccess" value="always" /><param name="src" value="http://vimeo.com/moogaloop.swf?clip_id=11918221&amp;server=vimeo.com&amp;show_title=1&amp;show_byline=1&amp;show_portrait=0&amp;color=00ADEF&amp;fullscreen=1" /><embed type="application/x-shockwave-flash" width="570" height="321" src="http://vimeo.com/moogaloop.swf?clip_id=11918221&amp;server=vimeo.com&amp;show_title=1&amp;show_byline=1&amp;show_portrait=0&amp;color=00ADEF&amp;fullscreen=1" allowscriptaccess="always" allowfullscreen="true"></embed></object></p>
<p>A man by the name of <a href="http://vimeo.com/user3834976">Alex Varanese</a> once wondered what 8-bit video games might look &#8220;in the form of a stop motion animation&#8221;. And while most people would just stop at wondering, this dude actually implements it. It&#8217;s awesome. Please watch it.</p>
]]></content:encoded>
			<wfw:commentRss>http://illogictree.com/blog/2010/05/stop-motion-pixel-art/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>Edward Sharpe &amp; The Magnetic Zeroes</title>
		<link>http://illogictree.com/blog/2010/05/edward-sharpe-the-magnetic-zeroes/</link>
		<comments>http://illogictree.com/blog/2010/05/edward-sharpe-the-magnetic-zeroes/#comments</comments>
		<pubDate>Sun, 30 May 2010 08:30:59 +0000</pubDate>
		<dc:creator>Eddie</dc:creator>
				<category><![CDATA[Music]]></category>

		<guid isPermaLink="false">http://illogictree.com/blog/?p=1758</guid>
		<description><![CDATA[
Recently, I&#8217;ve been really groovin&#8217; to the music of Edward Sharpe &#38; The Magnetic Zeroes. They are a really unique bunch that sound as if they were all baptised in the waters of 1960s hippie-dom. Their music is incredibly rich and dynamic: one part Beatles (late Sgt. Peppers era), one part Arcade Fire, mix in [...]]]></description>
			<content:encoded><![CDATA[<p><img class="alignnone size-full wp-image-1759" title="l_33428cd7d7924d369dce98591ce37a64" src="http://illogictree.com/wp-content/uploads/2010/05/l_33428cd7d7924d369dce98591ce37a64.jpg" alt="" width="570" height="206" /></p>
<p>Recently, I&#8217;ve been really groovin&#8217; to the music of <a href="http://www.myspace.com/edwardsharpe">Edward Sharpe &amp; The Magnetic Zeroes</a>. They are a really unique bunch that sound as if they were all baptised in the waters of 1960s hippie-dom. Their music is incredibly rich and dynamic: one part Beatles (late Sgt. Peppers era), one part Arcade Fire, mix in some Alberta Cross and Johnny Cash on acid. Each song on their album is unique and their range and breadth is exceptionally eclectic.</p>
<p>I absolutely love everything about this musical band of gypsies &#8212; their terrificly interesting back story, their profuse &#8220;family&#8221; of musicians, their unique sounding music, and most importantly, their simple formula for <strong>happiness</strong>.</p>
<p>The band is led by a <a href="http://en.wikipedia.org/wiki/Alex_Ebert">Alex Ebert</a>, who was formerly the vocalist for the indie-punk group <a href="http://en.wikipedia.org/wiki/Ima_Robot">Ima Robot</a>. During that time which Ebert considers his &#8220;dark era&#8221;, he was a cynical alcoholic who was spiraling into a drug-laden mental obscurity. Desperate to be someone else, he breaks up the band and checks himself into Alcoholics Anonymous. During his stay, Alex writes several pages about a messianic figure named <strong>Edward Sharpe</strong> who is &#8220;sent down to Earth to heal and save mankind&#8221;.</p>
<p>After his release, he acquires an used school bus and forms a band which centers around the ideals of the fictional messiah, Edward Sharpe. Alex Ebert becomes an embodiment of the messiah and their group roams from city to city like a traveling Woodstock. They are truly a living testament to the golden era of the 60s when bands thought of themselves as families and concerts were an unbridled whirlpool of hippie love-joy.</p>
<p>I am planning to go with some friends to see them live on <strong>July 5th</strong> at the <strong>Palladium</strong> in Dallas. I am quite excited and I hope they exude as much happiness and joy as they sound in their albums.</p>
<p>[ <a href="http://www.youtube.com/watch?v=Qb9jY8yAxgs">Video: Live on Letterman</a> ]</p>
]]></content:encoded>
			<wfw:commentRss>http://illogictree.com/blog/2010/05/edward-sharpe-the-magnetic-zeroes/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Flowing Leaves</title>
		<link>http://illogictree.com/blog/2010/05/flowing-leaves/</link>
		<comments>http://illogictree.com/blog/2010/05/flowing-leaves/#comments</comments>
		<pubDate>Fri, 28 May 2010 15:01:32 +0000</pubDate>
		<dc:creator>Eddie</dc:creator>
				<category><![CDATA[Pictures]]></category>

		<guid isPermaLink="false">http://illogictree.com/blog/?p=1752</guid>
		<description><![CDATA[
]]></description>
			<content:encoded><![CDATA[<p><img class="alignnone size-full wp-image-1751" title="flowing_leaves" src="http://illogictree.com/wp-content/uploads/2010/05/flowing_leaves.jpg" alt="" width="628" height="371" /></p>
]]></content:encoded>
			<wfw:commentRss>http://illogictree.com/blog/2010/05/flowing-leaves/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
