<?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>Limegarden.net &#187; demo</title>
	<atom:link href="http://limegarden.net/tag/demo/feed/" rel="self" type="application/rss+xml" />
	<link>http://limegarden.net</link>
	<description>Personal site of Wouter Lindenhof</description>
	<lastBuildDate>Wed, 01 Feb 2012 23:07:09 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
		<item>
		<title>Combo hit!! in code</title>
		<link>http://limegarden.net/2010/04/06/combo-hit-in-code/</link>
		<comments>http://limegarden.net/2010/04/06/combo-hit-in-code/#comments</comments>
		<pubDate>Tue, 06 Apr 2010 07:17:24 +0000</pubDate>
		<dc:creator>Wouter Lindenhof</dc:creator>
				<category><![CDATA[C++]]></category>
		<category><![CDATA[code]]></category>
		<category><![CDATA[Game development]]></category>
		<category><![CDATA[code snippit]]></category>
		<category><![CDATA[demo]]></category>
		<category><![CDATA[example]]></category>
		<category><![CDATA[Programming]]></category>

		<guid isPermaLink="false">http://limegarden.net/?p=302</guid>
		<description><![CDATA[I have always wondered how hard it would be to write a combo system. Not that hard I guess. And after a bit of morning programming I already got it working. The only reason it took longer than anticipated was because of muscle memory. One of the features I wanted to test was the delay. [...]]]></description>
			<content:encoded><![CDATA[<p>I have always wondered how hard it would be to write a combo system. Not that hard I guess. And after a bit of morning programming I already got it working. </p>
<p>The only reason it took longer than anticipated was because of muscle memory. One of the features I wanted to test was the delay. For example you want to do the "asdf" combo, but you are for some reason not fast enough, than the combo should not start. Simulating this is easy, just begin the combo and stop somewhere for a second and then complete the combo. So "asd", pause and then "f".<br />
However when I tried that for some reason the combo was sometimes completed. Only after adding the debug messages I noticed that I often automatically did complete the combo. The problem was muscle memory.</p>
<p>Anyway below is the code and if anyone wants to extend it (wrong next key, combo breakers, roman cancel, and follow-up combos) feel free to do so and let me know.</p>
<pre class="brush: c++; ">

/*******************************************************************************
 * The MIT License
 *
 * Licensed under the MIT license:
 *   http://www.opensource.org/licenses/mit-license.php
 *
 * Copyright (c) 2010 Wouter Lindenhof (http://limegarden.net)
 *
 * Demonstration of a simple ComboHit system
 *******************************************************************************/

#include &lt;Windows.h&gt;
#include &lt;iostream&gt;
#include &lt;vector&gt;
#pragma comment(lib, &quot;Winmm.lib&quot;)

#define DEBUGLOG 1 // Set to 0 to turn debug messages off

class KeyHit
{
public:
	UINT m_Key;
	UINT m_Delay;
	UINT m_Waiting;
public:
	KeyHit(UINT key, UINT delay) : m_Key(key), m_Delay(delay), m_Waiting(0) { }
};

class HitCombo
{
	UINT m_SequenceIndex;
	std::vector&lt;KeyHit&gt; m_Keys;
public:
	HitCombo() : m_SequenceIndex(0) { }

	void Cancel();
	void Update(DWORD ms);
	operator bool();
	HitCombo&amp; operator &lt;&lt; (const KeyHit&amp; hit);
};

int main(int argc, const char* argv[])
{
	std::cout &lt;&lt; &quot;-----------------------------------------------&quot; &lt;&lt; std::endl;
	std::cout &lt;&lt; &quot;This is a combo key tester: &quot; &lt;&lt; std::endl;
	std::cout &lt;&lt; &quot;Press \&quot;ASDF\&quot; quickly to do a combo hit&quot; &lt;&lt; std::endl;
	std::cout &lt;&lt; &quot;Press \&quot;Wouter\&quot; quickly to write my name&quot; &lt;&lt; std::endl;
	std::cout &lt;&lt; &quot;Press SHIFT and then escape to quit&quot; &lt;&lt; std::endl;
	std::cout &lt;&lt; &quot;-----------------------------------------------&quot; &lt;&lt; std::endl;
	HitCombo QuitApplication, ComboHit, WouterCombo;
	QuitApplication &lt;&lt; KeyHit(VK_SHIFT, 250) &lt;&lt; KeyHit(VK_ESCAPE, 250);
	ComboHit		&lt;&lt; KeyHit(&#039;A&#039;, 250) &lt;&lt; KeyHit(&#039;S&#039;, 250) &lt;&lt; KeyHit(&#039;D&#039;, 250)
					&lt;&lt; KeyHit(&#039;F&#039;, 250);
	WouterCombo		&lt;&lt; KeyHit(&#039;W&#039;, 250) &lt;&lt; KeyHit(&#039;O&#039;, 250) &lt;&lt; KeyHit(&#039;U&#039;, 250)
					&lt;&lt; KeyHit(&#039;T&#039;, 250) &lt;&lt; KeyHit(&#039;E&#039;, 250) &lt;&lt; KeyHit(&#039;R&#039;, 250);

	DWORD lastTime = timeGetTime();
	DWORD curTime = lastTime;
	DWORD difference = 0;

	while(true)
	{
		curTime = timeGetTime();
		difference = curTime - lastTime;
		lastTime = curTime;
		if(ComboHit)
		{
			std::cout &lt;&lt; &quot;You did a combo hit!!&quot; &lt;&lt; std::endl;
			WouterCombo.Cancel();
			QuitApplication.Cancel();
		}
		if(WouterCombo)
		{
			std::cout &lt;&lt; &quot;You wrote &#039;Wouter&#039;, good for you!&quot; &lt;&lt; std::endl;
			ComboHit.Cancel();
			QuitApplication.Cancel();
		}
		if(QuitApplication)
		{
			std::cout &lt;&lt; &quot;You quit the application!&quot; &lt;&lt; std::endl;
			ComboHit.Cancel();
			WouterCombo.Cancel();
			break;
		}
		ComboHit.Update(difference);
		QuitApplication.Update(difference);
		WouterCombo.Update(difference);
	}

	return 0;
}

void HitCombo::Cancel() {
	m_SequenceIndex = 0;
}

// Implementation
HitCombo&amp; HitCombo::operator &lt;&lt;(const KeyHit &amp;hit) {
	m_Keys.push_back(hit);
	return *this;
}

HitCombo::operator bool() {
	return m_SequenceIndex == m_Keys.size();
}
void HitCombo::Update(DWORD ms)
{
	if(m_SequenceIndex &lt; m_Keys.size())
	{
		KeyHit&amp; hit = m_Keys[m_SequenceIndex];
		hit.m_Waiting += ms;
		if(GetAsyncKeyState(hit.m_Key) != 0)
		{
			if(hit.m_Waiting &lt; hit.m_Delay)
			{
				hit.m_Waiting = 0;
				m_SequenceIndex++;
#if DEBUGLOG = 1
				std::cout &lt;&lt; &quot;you pressed key &quot; &lt;&lt; (char)hit.m_Key &lt;&lt; std::endl;
#endif
			}else
			{
#if DEBUGLOG = 1
				std::cout &lt;&lt; &quot;Delay too long&quot; &lt;&lt; std::endl;
#endif
				hit.m_Waiting = 0;
				m_SequenceIndex = 0;
			}
			if(m_SequenceIndex == 0)
			{
				hit.m_Waiting = 0;
			}
		}else if(m_SequenceIndex==0)
		{
			hit.m_Waiting = 0;
		}else
		{
			if(hit.m_Waiting &gt; hit.m_Delay)
			{
				m_SequenceIndex = 0;
				hit.m_Waiting = 0;
#if DEBUGLOG
				std::cout &lt;&lt; &quot;Delay too long&quot; &lt;&lt; std::endl;
#endif
			}
		}
	}else
	{
		m_SequenceIndex = 0;
		KeyHit&amp; hit = m_Keys[m_SequenceIndex];
		hit.m_Waiting = 0;
	}
}
</pre>
]]></content:encoded>
			<wfw:commentRss>http://limegarden.net/2010/04/06/combo-hit-in-code/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Shimmer shaders, practical jokes and farts&#8230;</title>
		<link>http://limegarden.net/2008/10/08/shimmer-shaders-practical-jokes-and-farts/</link>
		<comments>http://limegarden.net/2008/10/08/shimmer-shaders-practical-jokes-and-farts/#comments</comments>
		<pubDate>Wed, 08 Oct 2008 11:36:47 +0000</pubDate>
		<dc:creator>Wouter Lindenhof</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[code]]></category>
		<category><![CDATA[demo]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[shader]]></category>
		<category><![CDATA[shimmer]]></category>

		<guid isPermaLink="false">http://limegarden.net/2008/10/08/shimmer-shaders-practical-jokes-and-farts/</guid>
		<description><![CDATA["What? Farts in the title? I bet this must be interesting!" And yes, it is interesting! During one of the SFX lectures at school we were discussing shimmer shaders. Shimmering is an effect when something is extremely hot and you can see the air around it vibrate. In real life we have this with highway [...]]]></description>
			<content:encoded><![CDATA[<p>"What? Farts in the title? I bet this must be interesting!"<br />
And yes, it is interesting!</p>
<p>During one of the SFX lectures at school we were discussing shimmer shaders. Shimmering is an effect when something is extremely hot and you can see the air around it vibrate. In real life we have this with highway or deserts. The air above the ground is then so hot that it will hold a different density which causes the light to refract. In deserts you can get mirage where you think you see water in the desert, but in reality you are looking at the sky. This is because of light refraction.</p>
<p>In games we often use this for our lava monsters or on the lave itself or anything else that represents extreme heat. However as we were discussing this in the class I suddenly got this crazy idea of using to simulate a fart.  Of course only suggesting this idea in class was good for a few laughs, but since I liked the idea, I actually made it and I'm ready to show it in class. Yes, I love practical jokes (the kind that don't piss anyone off).</p>
<p>The example is quite simple. Use WASD to move around and when you hold the left mouse button down you can use the mouse to rotate. Further you might notice that the girl is also shimmering. This is because she is hot as well.</p>
<p>PS: The fart sound is not mine <img src='http://limegarden.net/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<p><strong>Download</strong> <a href=http://static.limegarden.net/Fart.rar>Fart.rar</a><br />
<strong>Requirements:</strong> You need to have the latest DirectX 9.0 installed (June 2008) release<br />If you are missing something like [cci_text]"D3DX9_39.dll"[/cci_text] than you need to run the DirectX webupdate.</p>
]]></content:encoded>
			<wfw:commentRss>http://limegarden.net/2008/10/08/shimmer-shaders-practical-jokes-and-farts/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

