<?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>GuShH&#039;s Development Blog &#187; animation</title>
	<atom:link href="http://gushh.net/blog/tag/animation/feed/" rel="self" type="application/rss+xml" />
	<link>http://gushh.net/blog</link>
	<description>This blog is about software, electronics and game development.</description>
	<lastBuildDate>Wed, 08 Sep 2010 03:02:37 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0.1</generator>
		<item>
		<title>Animation lib</title>
		<link>http://gushh.net/blog/2009/08/06/animation-lib/</link>
		<comments>http://gushh.net/blog/2009/08/06/animation-lib/#comments</comments>
		<pubDate>Thu, 06 Aug 2009 21:43:43 +0000</pubDate>
		<dc:creator>GuShH</dc:creator>
				<category><![CDATA[Programming]]></category>
		<category><![CDATA[PureBasic]]></category>
		<category><![CDATA[animation]]></category>
		<category><![CDATA[clipsprite]]></category>
		<category><![CDATA[Game Development]]></category>
		<category><![CDATA[library]]></category>
		<category><![CDATA[purebasic]]></category>
		<category><![CDATA[sprite]]></category>
		<category><![CDATA[sprite sheet]]></category>
		<category><![CDATA[timelapse]]></category>

		<guid isPermaLink="false">http://gushh.net/blog/?p=192</guid>
		<description><![CDATA[Dependent on the time-lapse lib, the animation code provides you with several count methods to manipulate your animations in an easy and comprehensible way. If you add a sprite atlas library (I&#8217;ll share later) you&#8217;ll be able to manipulate sprites with animation in quite a flexible way without too much hassle. The idea is to [...]]]></description>
			<content:encoded><![CDATA[<!-- AdSense Now! V1.95 -->
<!-- Post[count: 3] -->
<div class="adsense adsense-leadin" style="text-align:center;margin: 12px;"><script type="text/javascript"><!--
google_ad_client = "pub-2462949361920197";
/* 468x15, created 4/6/10 */
google_ad_slot = "8315313616";
google_ad_width = 468;
google_ad_height = 15;
//-->
</script>
<script type="text/javascript"
src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
</script></div><p>Dependent on the <a href="http://gushh.net/blog/2009/08/05/timelapse-lib/">time-lapse</a> lib, the animation code provides you with several count methods to manipulate your animations in an easy and comprehensible way.</p>
<p>If you add a sprite atlas library (I&#8217;ll share later) you&#8217;ll be able to manipulate sprites with animation in quite a flexible way without too much hassle.</p>
<p>The idea is to encapsulate the animation functionality in such a way that it makes it easy to work with. You have the ability to start, stop, pause, change speed, etc. You can create animations that range from any frame to any frame and that can animate in many ways such as sequential (loop), play-once and ping-pong (back and forth, or rather the inverse). By making use of the time-lapse library we can easily create time-based animation.</p>
<p><span id="more-192"></span></p>
<p>The base code:</p>

<div class="wp_syntax"><div class="code"><pre class="purebasic" style="font-family:monospace;"><span style="color: #ff0000; font-style: italic;">;##############################################################################</span>
<span style="color: #ff0000; font-style: italic;">;$$$	file: Animation.pb - date: 05:05 p.m. 06/08/2009			$$$</span>
<span style="color: #ff0000; font-style: italic;">;$$$	author: Gustavo Julio Fiorenza (info@gushh.net || info@gushh.com.ar)	$$$</span>
<span style="color: #ff0000; font-style: italic;">;$$$					aka: gushh, dagcrack.			$$$</span>
<span style="color: #ff0000; font-style: italic;">;$$$ 	description: provides several count modes for animation purposes	$$$</span>
<span style="color: #ff0000; font-style: italic;">;##############################################################################</span>
&nbsp;
<span style="color: #000066; font-weight: bold;">EnableExplicit</span>
<span style="color: #000066; font-weight: bold;">XIncludeFile</span> <span style="color: #009900;">&quot;TimeLapse.pb&quot;</span> <span style="color: #ff0000; font-style: italic;">; Used for timing.</span>
&nbsp;
<span style="color: #000066; font-weight: bold;">Structure</span> ANIMATION
	<span style="color: #000066;">*</span>timer.TIMELAPSE	<span style="color: #ff0000; font-style: italic;">; The timer's speed is &quot;per frame&quot;, use the Get/SetLength functions to overcome this.</span>
	frame_max.i		<span style="color: #ff0000; font-style: italic;">; Maximum global frame</span>
	frame_min.i		<span style="color: #ff0000; font-style: italic;">; Minimum global frame</span>
	frame_now.i		<span style="color: #ff0000; font-style: italic;">; Current local frame</span>
	mode.i			<span style="color: #ff0000; font-style: italic;">; The animation mode (loop, play once, ping-pong, etc).</span>
	status.i		<span style="color: #ff0000; font-style: italic;">; Internal var used for keeping track of the animation &quot;status&quot;. It's used as a bool.</span>
	is_playing.i		<span style="color: #ff0000; font-style: italic;">; Used to determine whether the animation is playing or not.</span>
<span style="color: #000066; font-weight: bold;">EndStructure</span>
&nbsp;
<span style="color: #000066; font-weight: bold;">Enumeration</span> <span style="color: #CC0000;">1</span>
	#ANIMATION_LOOP
	#ANIMATION_PLAYONCE
	#ANIMATION_PINGPONG
<span style="color: #000066; font-weight: bold;">EndEnumeration</span>
&nbsp;
&nbsp;
<span style="color: #000066; font-weight: bold;">Procedure</span>.i AnimationCreate<span style="color: #000066;">&#40;</span> Speed.i, MinFrame.i, MaxFrame.i, CurrentFrame.i <span style="color: #000066;">=</span> <span style="color: #CC0000;">0</span>, Mode.i <span style="color: #000066;">=</span> #ANIMATION_LOOP, <span style="color: #000066;">*</span>callback.i <span style="color: #000066;">=</span> #Null <span style="color: #000066;">&#41;</span>
&nbsp;
	<span style="color: #000066; font-weight: bold;">Define</span>.ANIMATION <span style="color: #000066;">*</span>this <span style="color: #000066;">=</span> <span style="color: #0000ff;">AllocateMemory</span><span style="color: #000066;">&#40;</span> <span style="color: #0000ff;">SizeOf</span><span style="color: #000066;">&#40;</span>ANIMATION<span style="color: #000066;">&#41;</span> <span style="color: #000066;">&#41;</span>
&nbsp;
	<span style="color: #000066; font-weight: bold;">If</span> <span style="color: #000066;">*</span>this
&nbsp;
		<span style="color: #000066; font-weight: bold;">With</span> <span style="color: #000066;">*</span>this
			<span style="color: #000066;">\</span>timer		<span style="color: #000066;">=</span> TimeLapseCreate<span style="color: #000066;">&#40;</span> Speed, <span style="color: #000066;">*</span>callback, <span style="color: #000066;">*</span>this <span style="color: #000066;">&#41;</span> <span style="color: #ff0000; font-style: italic;">; We're passing this instance as the timer's user-data, useful in callbacks.</span>
			<span style="color: #000066;">\</span>frame_max 	<span style="color: #000066;">=</span> MaxFrame
			<span style="color: #000066;">\</span>frame_min	<span style="color: #000066;">=</span> MinFrame
			<span style="color: #000066;">\</span>frame_now	<span style="color: #000066;">=</span> MinFrame <span style="color: #000066;">+</span> CurrentFrame
			<span style="color: #000066;">\</span>mode 		<span style="color: #000066;">=</span> Mode
			<span style="color: #000066;">\</span>status		<span style="color: #000066;">=</span> <span style="color: #CC0000;">0</span>
			<span style="color: #000066;">\</span>is_playing	<span style="color: #000066;">=</span> #True
		<span style="color: #000066; font-weight: bold;">EndWith</span>
&nbsp;
		<span style="color: #000066; font-weight: bold;">ProcedureReturn</span> <span style="color: #000066;">*</span>this
&nbsp;
	<span style="color: #000066; font-weight: bold;">EndIf</span>
&nbsp;
<span style="color: #000066; font-weight: bold;">EndProcedure</span>
&nbsp;
<span style="color: #000066; font-weight: bold;">Procedure</span>.i AnimationDestroy<span style="color: #000066;">&#40;</span> <span style="color: #000066;">*</span>this.ANIMATION <span style="color: #000066;">&#41;</span>
&nbsp;
	<span style="color: #000066; font-weight: bold;">If</span> <span style="color: #000066;">*</span>this
&nbsp;
		<span style="color: #000066; font-weight: bold;">If</span> <span style="color: #000066;">*</span>this<span style="color: #000066;">\</span>timer
			TimeLapseDestroy<span style="color: #000066;">&#40;</span><span style="color: #000066;">*</span>this<span style="color: #000066;">\</span>timer<span style="color: #000066;">&#41;</span>
		<span style="color: #000066; font-weight: bold;">EndIf</span>
&nbsp;
		<span style="color: #0000ff;">FreeMemory</span><span style="color: #000066;">&#40;</span><span style="color: #000066;">*</span>this<span style="color: #000066;">&#41;</span>
		<span style="color: #000066;">*</span>this <span style="color: #000066;">=</span> #Null
		<span style="color: #000066; font-weight: bold;">ProcedureReturn</span> <span style="color: #000066;">*</span>this
&nbsp;
	<span style="color: #000066; font-weight: bold;">EndIf</span>
&nbsp;
<span style="color: #000066; font-weight: bold;">EndProcedure</span>
&nbsp;
<span style="color: #000066; font-weight: bold;">Procedure</span>.i AnimationUpdate<span style="color: #000066;">&#40;</span> <span style="color: #000066;">*</span>this.ANIMATION <span style="color: #000066;">&#41;</span>
&nbsp;
	<span style="color: #000066; font-weight: bold;">If</span> <span style="color: #000066;">*</span>this
		<span style="color: #000066; font-weight: bold;">If</span> <span style="color: #000066;">*</span>this<span style="color: #000066;">\</span>is_playing
			<span style="color: #000066; font-weight: bold;">If</span> TimeLapseUpdate<span style="color: #000066;">&#40;</span> <span style="color: #000066;">*</span>this<span style="color: #000066;">\</span>timer <span style="color: #000066;">&#41;</span>
&nbsp;
				<span style="color: #000066; font-weight: bold;">Select</span> <span style="color: #000066;">*</span>this<span style="color: #000066;">\</span>mode
&nbsp;
					<span style="color: #000066; font-weight: bold;">Case</span> #ANIMATION_LOOP
&nbsp;
						<span style="color: #000066;">*</span>this<span style="color: #000066;">\</span>frame_now <span style="color: #000066;">+</span> <span style="color: #CC0000;">1</span>
&nbsp;
						<span style="color: #000066; font-weight: bold;">If</span> <span style="color: #000066;">*</span>this<span style="color: #000066;">\</span>frame_now <span style="color: #000066;">&gt;</span> <span style="color: #000066;">*</span>this<span style="color: #000066;">\</span>frame_max
							<span style="color: #000066;">*</span>this<span style="color: #000066;">\</span>frame_now <span style="color: #000066;">=</span> <span style="color: #000066;">*</span>this<span style="color: #000066;">\</span>frame_min
						<span style="color: #000066; font-weight: bold;">EndIf</span>
&nbsp;
					<span style="color: #000066; font-weight: bold;">Case</span> #ANIMATION_PINGPONG
&nbsp;
						<span style="color: #000066; font-weight: bold;">If</span> <span style="color: #000066;">*</span>this<span style="color: #000066;">\</span>status
&nbsp;
							<span style="color: #000066;">*</span>this<span style="color: #000066;">\</span>frame_now <span style="color: #000066;">-</span> <span style="color: #CC0000;">1</span>
&nbsp;
							<span style="color: #000066; font-weight: bold;">If</span> <span style="color: #000066;">*</span>this<span style="color: #000066;">\</span>frame_now <span style="color: #000066;">&lt;</span> <span style="color: #000066;">=</span> <span style="color: #000066;">*</span>this<span style="color: #000066;">\</span>frame_min
								<span style="color: #000066;">*</span>this<span style="color: #000066;">\</span>status <span style="color: #000066;">=</span> #True <span style="color: #000066;">-</span> <span style="color: #000066;">*</span>this<span style="color: #000066;">\</span>status
							<span style="color: #000066; font-weight: bold;">EndIf</span>
&nbsp;
						<span style="color: #000066; font-weight: bold;">Else</span>
&nbsp;
							<span style="color: #000066;">*</span>this<span style="color: #000066;">\</span>frame_now <span style="color: #000066;">+</span> <span style="color: #CC0000;">1</span>
&nbsp;
							<span style="color: #000066; font-weight: bold;">If</span> <span style="color: #000066;">*</span>this<span style="color: #000066;">\</span>frame_now <span style="color: #000066;">=&gt;</span> <span style="color: #000066;">*</span>this<span style="color: #000066;">\</span>frame_max
								<span style="color: #000066;">*</span>this<span style="color: #000066;">\</span>status <span style="color: #000066;">=</span> #True <span style="color: #000066;">-</span> <span style="color: #000066;">*</span>this<span style="color: #000066;">\</span>status
							<span style="color: #000066; font-weight: bold;">EndIf</span>
&nbsp;
						<span style="color: #000066; font-weight: bold;">EndIf</span>
&nbsp;
					<span style="color: #000066; font-weight: bold;">Case</span> #ANIMATION_PLAYONCE
&nbsp;
						<span style="color: #000066; font-weight: bold;">If</span> <span style="color: #000066;">*</span>this<span style="color: #000066;">\</span>status
							<span style="color: #ff0000; font-style: italic;">; status is set to one, this means we already played the animation.</span>
						<span style="color: #000066; font-weight: bold;">Else</span>
&nbsp;
							<span style="color: #000066;">*</span>this<span style="color: #000066;">\</span>frame_now <span style="color: #000066;">+</span> <span style="color: #CC0000;">1</span>
&nbsp;
							<span style="color: #000066; font-weight: bold;">If</span> <span style="color: #000066;">*</span>this<span style="color: #000066;">\</span>frame_now <span style="color: #000066;">=&gt;</span> <span style="color: #000066;">*</span>this<span style="color: #000066;">\</span>frame_max
								<span style="color: #000066;">*</span>this<span style="color: #000066;">\</span>status <span style="color: #000066;">=</span> #True <span style="color: #000066;">-</span> <span style="color: #000066;">*</span>this<span style="color: #000066;">\</span>status
							<span style="color: #000066; font-weight: bold;">EndIf</span>
&nbsp;
						<span style="color: #000066; font-weight: bold;">EndIf</span>
&nbsp;
				<span style="color: #000066; font-weight: bold;">EndSelect</span>	
&nbsp;
				<span style="color: #000066; font-weight: bold;">ProcedureReturn</span> #True <span style="color: #ff0000; font-style: italic;">; always return true unless you want to invalidate the update call!</span>
&nbsp;
			<span style="color: #000066; font-weight: bold;">EndIf</span>
		<span style="color: #000066; font-weight: bold;">EndIf</span>
	<span style="color: #000066; font-weight: bold;">EndIf</span>
&nbsp;
<span style="color: #000066; font-weight: bold;">EndProcedure</span></pre></div></div>

<p>The helper functions:</p>

<div class="wp_syntax"><div class="code"><pre class="purebasic" style="font-family:monospace;"><span style="color: #000066; font-weight: bold;">Procedure</span>.i AnimationGetCurrentFrame<span style="color: #000066;">&#40;</span> <span style="color: #000066;">*</span>this.ANIMATION <span style="color: #000066;">&#41;</span>
	<span style="color: #000066; font-weight: bold;">ProcedureReturn</span> <span style="color: #000066;">*</span>this<span style="color: #000066;">\</span>frame_now <span style="color: #000066;">-</span> <span style="color: #000066;">*</span>this<span style="color: #000066;">\</span>frame_min
<span style="color: #000066; font-weight: bold;">EndProcedure</span>
&nbsp;
<span style="color: #000066; font-weight: bold;">Procedure</span>.i AnimationSetCurrentFrame<span style="color: #000066;">&#40;</span> <span style="color: #000066;">*</span>this.ANIMATION, Frame.i <span style="color: #000066;">&#41;</span>
	<span style="color: #000066;">*</span>this<span style="color: #000066;">\</span>frame_now <span style="color: #000066;">=</span> <span style="color: #000066;">&#40;</span>Frame <span style="color: #000066;">-</span> <span style="color: #000066;">*</span>this<span style="color: #000066;">\</span>frame_min<span style="color: #000066;">&#41;</span>
<span style="color: #000066; font-weight: bold;">EndProcedure</span>
&nbsp;
<span style="color: #000066; font-weight: bold;">Procedure</span>.i AnimationGetTotalFrames<span style="color: #000066;">&#40;</span> <span style="color: #000066;">*</span>this.ANIMATION <span style="color: #000066;">&#41;</span>
	<span style="color: #000066; font-weight: bold;">ProcedureReturn</span> <span style="color: #000066;">&#40;</span><span style="color: #000066;">*</span>this<span style="color: #000066;">\</span>frame_max <span style="color: #000066;">-</span> <span style="color: #000066;">*</span>this<span style="color: #000066;">\</span>frame_min<span style="color: #000066;">&#41;</span>
<span style="color: #000066; font-weight: bold;">EndProcedure</span>
&nbsp;
<span style="color: #000066; font-weight: bold;">Procedure</span>.i AnimationGetMode<span style="color: #000066;">&#40;</span> <span style="color: #000066;">*</span>this.ANIMATION <span style="color: #000066;">&#41;</span>
	<span style="color: #000066; font-weight: bold;">ProcedureReturn</span> <span style="color: #000066;">*</span>this<span style="color: #000066;">\</span>mode
<span style="color: #000066; font-weight: bold;">EndProcedure</span>
&nbsp;
<span style="color: #000066; font-weight: bold;">Procedure</span>.i AnimationSetMode<span style="color: #000066;">&#40;</span> <span style="color: #000066;">*</span>this.ANIMATION, NewMode.i <span style="color: #000066;">&#41;</span>
	<span style="color: #000066;">*</span>this<span style="color: #000066;">\</span>mode <span style="color: #000066;">=</span> NewMode
<span style="color: #000066; font-weight: bold;">EndProcedure</span>
&nbsp;
<span style="color: #000066; font-weight: bold;">Procedure</span>.i AnimationGetSpeed<span style="color: #000066;">&#40;</span> <span style="color: #000066;">*</span>this.ANIMATION <span style="color: #000066;">&#41;</span>
	<span style="color: #000066; font-weight: bold;">ProcedureReturn</span> TimeLapseGet<span style="color: #000066;">&#40;</span> <span style="color: #000066;">*</span>this<span style="color: #000066;">\</span>timer <span style="color: #000066;">&#41;</span>
<span style="color: #000066; font-weight: bold;">EndProcedure</span>
&nbsp;
<span style="color: #000066; font-weight: bold;">Procedure</span>.i AnimationSetSpeed<span style="color: #000066;">&#40;</span> <span style="color: #000066;">*</span>this.ANIMATION, Speed.i <span style="color: #000066;">&#41;</span>
	TimeLapseSet<span style="color: #000066;">&#40;</span> <span style="color: #000066;">*</span>this<span style="color: #000066;">\</span>timer, Speed <span style="color: #000066;">&#41;</span>
<span style="color: #000066; font-weight: bold;">EndProcedure</span>
&nbsp;
<span style="color: #000066; font-weight: bold;">Procedure</span>.i AnimationPlay<span style="color: #000066;">&#40;</span> <span style="color: #000066;">*</span>this.ANIMATION <span style="color: #000066;">&#41;</span>
	<span style="color: #000066;">*</span>this<span style="color: #000066;">\</span>is_playing	<span style="color: #000066;">=</span> #True
<span style="color: #000066; font-weight: bold;">EndProcedure</span>
&nbsp;
<span style="color: #000066; font-weight: bold;">Procedure</span>.i AnimationPause<span style="color: #000066;">&#40;</span> <span style="color: #000066;">*</span>this.ANIMATION <span style="color: #000066;">&#41;</span>
	<span style="color: #000066;">*</span>this<span style="color: #000066;">\</span>is_playing	<span style="color: #000066;">=</span> #False
<span style="color: #000066; font-weight: bold;">EndProcedure</span>
&nbsp;
<span style="color: #000066; font-weight: bold;">Procedure</span>.i AnimationStop<span style="color: #000066;">&#40;</span> <span style="color: #000066;">*</span>this.ANIMATION <span style="color: #000066;">&#41;</span>
	<span style="color: #000066;">*</span>this<span style="color: #000066;">\</span>is_playing	<span style="color: #000066;">=</span> #False
	<span style="color: #000066;">*</span>this<span style="color: #000066;">\</span>frame_now		<span style="color: #000066;">=</span> <span style="color: #000066;">*</span>this<span style="color: #000066;">\</span>frame_min
<span style="color: #000066; font-weight: bold;">EndProcedure</span>
&nbsp;
<span style="color: #000066; font-weight: bold;">Procedure</span>.i AnimationReset<span style="color: #000066;">&#40;</span> <span style="color: #000066;">*</span>this.ANIMATION <span style="color: #000066;">&#41;</span>
	AnimationStop<span style="color: #000066;">&#40;</span><span style="color: #000066;">*</span>this<span style="color: #000066;">&#41;</span>
	AnimationPlay<span style="color: #000066;">&#40;</span><span style="color: #000066;">*</span>this<span style="color: #000066;">&#41;</span>
<span style="color: #000066; font-weight: bold;">EndProcedure</span>
&nbsp;
<span style="color: #000066; font-weight: bold;">Procedure</span>.i AnimationGetLength<span style="color: #000066;">&#40;</span> <span style="color: #000066;">*</span>this.ANIMATION <span style="color: #000066;">&#41;</span>
	<span style="color: #000066; font-weight: bold;">ProcedureReturn</span> AnimationGetTotalFrames<span style="color: #000066;">&#40;</span> <span style="color: #000066;">*</span>this <span style="color: #000066;">&#41;</span> <span style="color: #000066;">*</span> AnimationGetSpeed<span style="color: #000066;">&#40;</span> <span style="color: #000066;">*</span>this <span style="color: #000066;">&#41;</span>
<span style="color: #000066; font-weight: bold;">EndProcedure</span>
&nbsp;
<span style="color: #000066; font-weight: bold;">Procedure</span>.i AnimationSetLength<span style="color: #000066;">&#40;</span> <span style="color: #000066;">*</span>this.ANIMATION, NewLength.i <span style="color: #000066;">&#41;</span>
	AnimationSetSpeed<span style="color: #000066;">&#40;</span> <span style="color: #000066;">*</span>this, NewLength <span style="color: #000066;">/</span> AnimationGetTotalFrames<span style="color: #000066;">&#40;</span> <span style="color: #000066;">*</span>this <span style="color: #000066;">&#41;</span> <span style="color: #000066;">&#41;</span>
<span style="color: #000066; font-weight: bold;">EndProcedure</span></pre></div></div>

<p>Thanks to the base lib, you can also use callbacks, this are useful for executing events on known frames (say you&#8217;re writing a game and you want a sound to be played at frame 12 from the jumping cycle&#8230; easy!)</p>
<p>A minimal example:</p>

<div class="wp_syntax"><div class="code"><pre class="purebasic" style="font-family:monospace;"><span style="color: #000066; font-weight: bold;">Define</span>.ANIMATION <span style="color: #000066;">*</span>anim
&nbsp;
<span style="color: #000066; font-weight: bold;">If</span> <span style="color: #0000ff;">OpenConsole</span><span style="color: #000066;">&#40;</span><span style="color: #000066;">&#41;</span>
	<span style="color: #000066;">*</span>anim <span style="color: #000066;">=</span> AnimationCreate<span style="color: #000066;">&#40;</span> <span style="color: #CC0000;">250</span>, <span style="color: #CC0000;">0</span>, <span style="color: #CC0000;">9</span>, <span style="color: #CC0000;">0</span>, #ANIMATION_PINGPONG <span style="color: #000066;">&#41;</span>
	<span style="color: #000066; font-weight: bold;">If</span> <span style="color: #000066;">*</span>anim
		<span style="color: #000066; font-weight: bold;">Repeat</span>
			<span style="color: #000066; font-weight: bold;">If</span> AnimationUpdate<span style="color: #000066;">&#40;</span> <span style="color: #000066;">*</span>anim <span style="color: #000066;">&#41;</span> <span style="color: #ff0000; font-style: italic;">; the reason frame 0 is not seen in the first print is because we update before we display.</span>
				<span style="color: #0000ff;">PrintN</span><span style="color: #000066;">&#40;</span> <span style="color: #0000ff;">Str</span><span style="color: #000066;">&#40;</span> AnimationGetCurrentFrame<span style="color: #000066;">&#40;</span> <span style="color: #000066;">*</span>anim <span style="color: #000066;">&#41;</span> <span style="color: #000066;">&#41;</span> <span style="color: #000066;">&#41;</span>
			<span style="color: #000066; font-weight: bold;">EndIf</span>
			<span style="color: #0000ff;">Delay</span><span style="color: #000066;">&#40;</span><span style="color: #CC0000;">10</span><span style="color: #000066;">&#41;</span>
		<span style="color: #000066; font-weight: bold;">Until</span> <span style="color: #0000ff;">Inkey</span><span style="color: #000066;">&#40;</span><span style="color: #000066;">&#41;</span> <span style="color: #000066;">=</span> <span style="color: #0000ff;">Chr</span><span style="color: #000066;">&#40;</span><span style="color: #CC0000;">27</span><span style="color: #000066;">&#41;</span>
&nbsp;
		AnimationDestroy<span style="color: #000066;">&#40;</span><span style="color: #000066;">*</span>anim<span style="color: #000066;">&#41;</span>
	<span style="color: #000066; font-weight: bold;">EndIf</span>
	<span style="color: #0000ff;">CloseConsole</span><span style="color: #000066;">&#40;</span><span style="color: #000066;">&#41;</span>
<span style="color: #000066; font-weight: bold;">EndIf</span></pre></div></div>

<p><em>A somewhat bloated example with callbacks can be found in <a href="http://gushh.net/dev/?file=pb/animation_example2.pb">here</a>.</em></p>
<p>The playback functionality could be extended, however I found little need for other methods &#8212; That&#8217;s basically my excuse for &#8220;I ran out of ideas&#8221; &#8212; One thing I&#8217;d do is decouple the &#8220;play once&#8221; functionality from the playing mode, so essentially you&#8217;d be able to play a loop or ping-pong animation just once.</p>
<p>That&#8217;s pretty much it. Once again, this is trivial code but it&#8217;s a must and I&#8217;m sure someone will benefit from it. </p>
<p>The only reason I didn&#8217;t post a graphical example is because you need a way of dealing with sprite sheets and that&#8217;s the job for yet another library. Should you use the sprite library, you&#8217;d still need to feed the ClipSprite() function with meaningful data, there is no point in doing it by hand. That said, I&#8217;ll post the &#8220;sprite atlas&#8221; library tomorrow, hopefully.</p>
<p>Cheers</p>
<div id="crp_related"><h3>Related Posts:</h3><ul><li><a href="http://gushh.net/blog/2009/08/05/timelapse-lib/" rel="bookmark" class="crp_title">TimeLapse lib</a></li><li><a href="http://gushh.net/blog/2009/08/28/structuring-libraries-basic-design-tips/" rel="bookmark" class="crp_title">Structuring libraries, basic design tips.</a></li><li><a href="http://gushh.net/blog/2010/06/04/icmp-ping-routine/" rel="bookmark" class="crp_title">ICMP Ping Routine (Windows only)</a></li><li><a href="http://gushh.net/blog/2010/08/02/wuline-antialiased-lines/" rel="bookmark" class="crp_title">WuLine (Antialiased lines)</a></li><li><a href="http://gushh.net/blog/2009/08/05/average-template/" rel="bookmark" class="crp_title">Average template</a></li></ul></div>]]></content:encoded>
			<wfw:commentRss>http://gushh.net/blog/2009/08/06/animation-lib/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>TimeLapse lib</title>
		<link>http://gushh.net/blog/2009/08/05/timelapse-lib/</link>
		<comments>http://gushh.net/blog/2009/08/05/timelapse-lib/#comments</comments>
		<pubDate>Wed, 05 Aug 2009 18:48:02 +0000</pubDate>
		<dc:creator>GuShH</dc:creator>
				<category><![CDATA[Programming]]></category>
		<category><![CDATA[PureBasic]]></category>
		<category><![CDATA[animation]]></category>
		<category><![CDATA[callback]]></category>
		<category><![CDATA[Game Development]]></category>
		<category><![CDATA[gettickcount]]></category>
		<category><![CDATA[lib]]></category>
		<category><![CDATA[library]]></category>
		<category><![CDATA[purebasic]]></category>
		<category><![CDATA[time lapse]]></category>
		<category><![CDATA[timelapse]]></category>
		<category><![CDATA[timer]]></category>
		<category><![CDATA[timing]]></category>
		<category><![CDATA[Windows]]></category>

		<guid isPermaLink="false">http://gushh.net/blog/?p=171</guid>
		<description><![CDATA[This little lib is used to keep track of time using the low resolution timer provided by the OS (in Windows &#8220;GetTickCount&#8221;). The goal of this type of library is to encapsulate timing actions. It was originally designed for game development in mind but needless to say you can use it and adapt it to [...]]]></description>
			<content:encoded><![CDATA[<p>This little lib is used to keep track of time using the low resolution timer provided by the OS (in Windows &#8220;GetTickCount&#8221;). The goal of this type of library is to encapsulate timing actions. It was originally designed for game development in mind but needless to say you can use it and adapt it to your own needs.</p>
<p>Basically you define a time interval as you create the &#8220;timelapse&#8221; instance. Every time you call the update function a simple check determines whether the time was reached or not. This is trivial, but encapsulating it makes sense. Specially if you plan to create an animation system in the future!</p>
<p><span id="more-171"></span><br />
The code:</p>

<div class="wp_syntax"><div class="code"><pre class="purebasic" style="font-family:monospace;"><span style="color: #000066; font-weight: bold;">EnableExplicit</span>
&nbsp;
<span style="color: #000066; font-weight: bold;">Prototype</span>.i TimeLapse_Callback<span style="color: #000066;">&#40;</span> <span style="color: #000066;">*</span>this.i <span style="color: #000066;">&#41;</span>
&nbsp;
<span style="color: #000066; font-weight: bold;">Structure</span> TIMELAPSE
	old_time.i			<span style="color: #ff0000; font-style: italic;">; Stores the &quot;old&quot; time value.</span>
	new_time.i			<span style="color: #ff0000; font-style: italic;">; Stores the &quot;new&quot; time value.</span>
	time_out.i			<span style="color: #ff0000; font-style: italic;">; Time period for the TimeLapse , in ms.</span>
	<span style="color: #000066;">*</span>callback.TimeLapse_Callback	<span style="color: #ff0000; font-style: italic;">; User callback.</span>
	userdata.i			<span style="color: #ff0000; font-style: italic;">; User data.</span>
<span style="color: #000066; font-weight: bold;">EndStructure</span>
&nbsp;
<span style="color: #000066; font-weight: bold;">CompilerSelect</span> #PB_Compiler_OS
	<span style="color: #000066; font-weight: bold;">CompilerCase</span> #PB_OS_Windows
		<span style="color: #000066; font-weight: bold;">Macro</span> _time<span style="color: #000066;">&#40;</span><span style="color: #000066;">&#41;</span> : timeGetTime_<span style="color: #000066;">&#40;</span><span style="color: #000066;">&#41;</span>		: <span style="color: #000066; font-weight: bold;">EndMacro</span>
	<span style="color: #000066; font-weight: bold;">CompilerDefault</span>
		<span style="color: #000066; font-weight: bold;">Macro</span> _time<span style="color: #000066;">&#40;</span><span style="color: #000066;">&#41;</span> : <span style="color: #0000ff;">ElapsedMilliseconds</span><span style="color: #000066;">&#40;</span><span style="color: #000066;">&#41;</span>	: <span style="color: #000066; font-weight: bold;">EndMacro</span>
<span style="color: #000066; font-weight: bold;">CompilerEndSelect</span>
&nbsp;
<span style="color: #000066; font-weight: bold;">Procedure</span>.i TimeLapseCreate<span style="color: #000066;">&#40;</span> Timeout.i, <span style="color: #000066;">*</span>Callback.TimeLapse_Callback <span style="color: #000066;">=</span> #Null, UserData.i <span style="color: #000066;">=</span> #Null <span style="color: #000066;">&#41;</span>
&nbsp;
	<span style="color: #000066; font-weight: bold;">Define</span>.TimeLapse  <span style="color: #000066;">*</span>this <span style="color: #000066;">=</span> <span style="color: #0000ff;">AllocateMemory</span><span style="color: #000066;">&#40;</span> <span style="color: #0000ff;">SizeOf</span><span style="color: #000066;">&#40;</span>TimeLapse <span style="color: #000066;">&#41;</span> <span style="color: #000066;">&#41;</span>
&nbsp;
	<span style="color: #000066; font-weight: bold;">If</span> <span style="color: #000066;">*</span>this
&nbsp;
		<span style="color: #000066; font-weight: bold;">With</span> <span style="color: #000066;">*</span>this
			<span style="color: #000066;">\</span>new_time 	<span style="color: #000066;">=</span> _time<span style="color: #000066;">&#40;</span><span style="color: #000066;">&#41;</span>
			<span style="color: #000066;">\</span>old_time 	<span style="color: #000066;">=</span> <span style="color: #000066;">*</span>this<span style="color: #000066;">\</span>new_time
			<span style="color: #000066;">\</span>time_out	<span style="color: #000066;">=</span> Timeout
			<span style="color: #000066;">\</span>callback	<span style="color: #000066;">=</span> <span style="color: #000066;">*</span>Callback
			<span style="color: #000066;">\</span>userdata	<span style="color: #000066;">=</span> UserData
		<span style="color: #000066; font-weight: bold;">EndWith</span>
&nbsp;
		<span style="color: #000066; font-weight: bold;">ProcedureReturn</span> <span style="color: #000066;">*</span>this
&nbsp;
	<span style="color: #000066; font-weight: bold;">EndIf</span>
&nbsp;
<span style="color: #000066; font-weight: bold;">EndProcedure</span>
&nbsp;
<span style="color: #000066; font-weight: bold;">Procedure</span>.i TimeLapseDestroy<span style="color: #000066;">&#40;</span> <span style="color: #000066;">*</span>this.TIMELAPSE  <span style="color: #000066;">&#41;</span>
&nbsp;
	<span style="color: #000066; font-weight: bold;">If</span> <span style="color: #000066;">*</span>this
&nbsp;
		<span style="color: #0000ff;">FreeMemory</span><span style="color: #000066;">&#40;</span><span style="color: #000066;">*</span>this<span style="color: #000066;">&#41;</span>
		<span style="color: #000066;">*</span>this <span style="color: #000066;">=</span> #Null
		<span style="color: #000066; font-weight: bold;">ProcedureReturn</span> <span style="color: #000066;">*</span>this
&nbsp;
	<span style="color: #000066; font-weight: bold;">EndIf</span>
&nbsp;
<span style="color: #000066; font-weight: bold;">EndProcedure</span>
&nbsp;
<span style="color: #000066; font-weight: bold;">Procedure</span>.i TimeLapseUpdate<span style="color: #000066;">&#40;</span> <span style="color: #000066;">*</span>this.TIMELAPSE  <span style="color: #000066;">&#41;</span>
&nbsp;
	<span style="color: #000066; font-weight: bold;">If</span> <span style="color: #000066;">*</span>this
&nbsp;
		<span style="color: #000066;">*</span>this<span style="color: #000066;">\</span>new_time <span style="color: #000066;">=</span> _time<span style="color: #000066;">&#40;</span><span style="color: #000066;">&#41;</span>
&nbsp;
		<span style="color: #000066; font-weight: bold;">If</span> <span style="color: #000066;">&#40;</span><span style="color: #000066;">&#40;</span><span style="color: #000066;">*</span>this<span style="color: #000066;">\</span>new_time <span style="color: #000066;">-</span> <span style="color: #000066;">*</span>this<span style="color: #000066;">\</span>old_time<span style="color: #000066;">&#41;</span> <span style="color: #000066;">=&gt;</span> <span style="color: #000066;">*</span>this<span style="color: #000066;">\</span>time_out<span style="color: #000066;">&#41;</span>
&nbsp;
			<span style="color: #000066;">*</span>this<span style="color: #000066;">\</span>old_time <span style="color: #000066;">=</span> <span style="color: #000066;">*</span>this<span style="color: #000066;">\</span>new_time
&nbsp;
			<span style="color: #000066; font-weight: bold;">If</span> <span style="color: #000066;">*</span>this<span style="color: #000066;">\</span>callback
				<span style="color: #000066; font-weight: bold;">ProcedureReturn</span> <span style="color: #000066;">*</span>this<span style="color: #000066;">\</span>callback<span style="color: #000066;">&#40;</span> <span style="color: #000066;">*</span>this <span style="color: #000066;">&#41;</span>
			<span style="color: #000066; font-weight: bold;">EndIf</span>
&nbsp;
			<span style="color: #000066; font-weight: bold;">ProcedureReturn</span> #True
&nbsp;
		<span style="color: #000066; font-weight: bold;">EndIf</span>
&nbsp;
	<span style="color: #000066; font-weight: bold;">EndIf</span>
&nbsp;
<span style="color: #000066; font-weight: bold;">EndProcedure</span>
&nbsp;
&nbsp;
<span style="color: #ff0000; font-style: italic;">; Helper routines</span>
&nbsp;
<span style="color: #000066; font-weight: bold;">Procedure</span>.i TimeLapseSet<span style="color: #000066;">&#40;</span> <span style="color: #000066;">*</span>this.TIMELAPSE , Timeout.i <span style="color: #000066;">&#41;</span>
&nbsp;
 	<span style="color: #000066; font-weight: bold;">If</span> Timeout <span style="color: #000066;">&gt;</span> <span style="color: #CC0000;">0</span>
		<span style="color: #000066;">*</span>this<span style="color: #000066;">\</span>time_out <span style="color: #000066;">=</span> Timeout
	<span style="color: #000066; font-weight: bold;">EndIf</span>
&nbsp;
<span style="color: #000066; font-weight: bold;">EndProcedure</span>
&nbsp;
<span style="color: #000066; font-weight: bold;">Procedure</span>.i TimeLapseGet<span style="color: #000066;">&#40;</span> <span style="color: #000066;">*</span>this.TIMELAPSE  <span style="color: #000066;">&#41;</span>
&nbsp;
 	<span style="color: #000066; font-weight: bold;">ProcedureReturn</span> <span style="color: #000066;">*</span>this<span style="color: #000066;">\</span>time_out
&nbsp;
<span style="color: #000066; font-weight: bold;">EndProcedure</span></pre></div></div>

<p>Example:</p>

<div class="wp_syntax"><div class="code"><pre class="purebasic" style="font-family:monospace;"><span style="color: #000066; font-weight: bold;">If</span> <span style="color: #0000ff;">OpenConsole</span><span style="color: #000066;">&#40;</span><span style="color: #000066;">&#41;</span>
	<span style="color: #000066; font-weight: bold;">Define</span>.TIMELAPSE  <span style="color: #000066;">*</span>test_timer  <span style="color: #000066;">=</span> TimeLapseCreate<span style="color: #000066;">&#40;</span> <span style="color: #CC0000;">500</span> <span style="color: #000066;">&#41;</span>
	<span style="color: #000066; font-weight: bold;">Repeat</span>
&nbsp;
		<span style="color: #000066; font-weight: bold;">If</span> TimeLapseUpdate<span style="color: #000066;">&#40;</span> <span style="color: #000066;">*</span>test_timer  <span style="color: #000066;">&#41;</span>
			<span style="color: #0000ff;">PrintN</span><span style="color: #000066;">&#40;</span><span style="color: #009900;">&quot; Timer says hi!&quot;</span> <span style="color: #000066;">&#41;</span>
		<span style="color: #000066; font-weight: bold;">EndIf</span>
&nbsp;
		<span style="color: #0000ff;">Delay</span><span style="color: #000066;">&#40;</span><span style="color: #CC0000;">10</span><span style="color: #000066;">&#41;</span>
	<span style="color: #000066; font-weight: bold;">Until</span> <span style="color: #0000ff;">Inkey</span><span style="color: #000066;">&#40;</span><span style="color: #000066;">&#41;</span> <span style="color: #000066;">=</span> <span style="color: #0000ff;">Chr</span><span style="color: #000066;">&#40;</span><span style="color: #CC0000;">27</span><span style="color: #000066;">&#41;</span>
	<span style="color: #0000ff;">CloseConsole</span><span style="color: #000066;">&#40;</span><span style="color: #000066;">&#41;</span>
<span style="color: #000066; font-weight: bold;">EndIf</span>
<span style="color: #000066; font-weight: bold;">End</span></pre></div></div>

<p>The nice thing about this library is the ability to use callbacks. Whenever a callback is defined, once the timer reaches the maximum allowed time-lapse, it&#8217;ll return by executing the callback.</p>
<p>In the callback you can do anything you want; From simple event triggering to manipulating another timer depending on XYZ conditions: it&#8217;s up to you!.</p>
<p><strong>Just keep in mind:</strong> Always return &#8220;true&#8221; unless you want to invalidate the update call.</p>
<p>Here is a more advanced example with a callback, user data and multiple timers:</p>

<div class="wp_syntax"><div class="code"><pre class="purebasic" style="font-family:monospace;"><span style="color: #000066; font-weight: bold;">Procedure</span>.i MyCallback<span style="color: #000066;">&#40;</span> <span style="color: #000066;">*</span>this.TIMELAPSE  <span style="color: #000066;">&#41;</span>
&nbsp;
	<span style="color: #ff0000; font-style: italic;">; It's imperative that you return #true (1) in your callbacks if you want the &quot;Update&quot; calls to pass once the timeout is reached.</span>
	<span style="color: #ff0000; font-style: italic;">; This is a design choice for flexibility and nothing else.</span>
&nbsp;
	<span style="color: #0000ff;">ConsoleColor</span><span style="color: #000066;">&#40;</span><span style="color: #0000ff;">Random</span><span style="color: #000066;">&#40;</span><span style="color: #CC0000;">15</span><span style="color: #000066;">&#41;</span>, <span style="color: #0000ff;">Random</span><span style="color: #000066;">&#40;</span><span style="color: #CC0000;">15</span><span style="color: #000066;">&#41;</span><span style="color: #000066;">&#41;</span>
	<span style="color: #0000ff;">PrintN</span><span style="color: #000066;">&#40;</span><span style="color: #009900;">&quot; Hi from the callback! &quot;</span><span style="color: #000066;">&#41;</span>
&nbsp;
	<span style="color: #0000ff;">PrintN</span><span style="color: #000066;">&#40;</span> <span style="color: #009900;">&quot; The other timer is set to: &quot;</span> <span style="color: #000066;">+</span> <span style="color: #0000ff;">Str</span><span style="color: #000066;">&#40;</span> TimeLapseGet<span style="color: #000066;">&#40;</span> <span style="color: #000066;">*</span>this<span style="color: #000066;">\</span>userdata <span style="color: #000066;">&#41;</span> <span style="color: #000066;">&#41;</span> <span style="color: #000066;">+</span> <span style="color: #009900;">&quot;ms&quot;</span> <span style="color: #000066;">&#41;</span>
	<span style="color: #0000ff;">PrintN</span><span style="color: #000066;">&#40;</span> <span style="color: #009900;">&quot; ...Reducing the time interval down by 50 ms... &quot;</span> <span style="color: #000066;">&#41;</span>
&nbsp;
	TimeLapseSet<span style="color: #000066;">&#40;</span> <span style="color: #000066;">*</span>this<span style="color: #000066;">\</span>userdata, TimeLapseGet<span style="color: #000066;">&#40;</span> <span style="color: #000066;">*</span>this<span style="color: #000066;">\</span>userdata <span style="color: #000066;">&#41;</span> <span style="color: #000066;">-</span> <span style="color: #CC0000;">50</span> <span style="color: #000066;">&#41;</span>
	<span style="color: #0000ff;">ConsoleColor</span><span style="color: #000066;">&#40;</span><span style="color: #CC0000;">15</span>, <span style="color: #CC0000;">0</span><span style="color: #000066;">&#41;</span>
&nbsp;
	<span style="color: #000066; font-weight: bold;">ProcedureReturn</span> #True
&nbsp;
<span style="color: #000066; font-weight: bold;">EndProcedure</span>
&nbsp;
<span style="color: #000066; font-weight: bold;">Define</span>.TIMELAPSE  <span style="color: #000066;">*</span>timer_one 	<span style="color: #000066;">=</span> TimeLapseCreate<span style="color: #000066;">&#40;</span> <span style="color: #CC0000;">500</span> <span style="color: #000066;">&#41;</span>				<span style="color: #ff0000; font-style: italic;">; The first TimeLapse , nothing special.</span>
<span style="color: #000066; font-weight: bold;">Define</span>.TIMELAPSE  <span style="color: #000066;">*</span>timer_two 	<span style="color: #000066;">=</span> TimeLapseCreate<span style="color: #000066;">&#40;</span> <span style="color: #CC0000;">2000</span>, @MyCallback<span style="color: #000066;">&#40;</span><span style="color: #000066;">&#41;</span>, <span style="color: #000066;">*</span>timer_one <span style="color: #000066;">&#41;</span>	<span style="color: #ff0000; font-style: italic;">; The second TimeLapse , it manipulates the first one through a callback.</span>
<span style="color: #000066; font-weight: bold;">Define</span>.TIMELAPSE  <span style="color: #000066;">*</span>timer_three	<span style="color: #000066;">=</span> TimeLapseCreate<span style="color: #000066;">&#40;</span> <span style="color: #CC0000;">20</span><span style="color: #000066;">*</span><span style="color: #CC0000;">1000</span> <span style="color: #000066;">&#41;</span>				<span style="color: #ff0000; font-style: italic;">; This TimeLapse  will simply let us exit the example after the set time.</span>
&nbsp;
<span style="color: #000066; font-weight: bold;">If</span> <span style="color: #0000ff;">OpenConsole</span><span style="color: #000066;">&#40;</span><span style="color: #000066;">&#41;</span>
&nbsp;
	<span style="color: #0000ff;">EnableGraphicalConsole</span><span style="color: #000066;">&#40;</span><span style="color: #CC0000;">1</span><span style="color: #000066;">&#41;</span>
	<span style="color: #0000ff;">ConsoleColor</span><span style="color: #000066;">&#40;</span><span style="color: #CC0000;">15</span>, <span style="color: #CC0000;">0</span><span style="color: #000066;">&#41;</span>
&nbsp;
	<span style="color: #000066; font-weight: bold;">Define</span>.i quit <span style="color: #000066;">=</span> #False
&nbsp;
	<span style="color: #000066; font-weight: bold;">Repeat</span>
&nbsp;
		<span style="color: #000066; font-weight: bold;">If</span> TimeLapseUpdate<span style="color: #000066;">&#40;</span> <span style="color: #000066;">*</span>timer_three <span style="color: #000066;">&#41;</span>
			quit <span style="color: #000066;">=</span> #True
		<span style="color: #000066; font-weight: bold;">Else</span>
			<span style="color: #000066; font-weight: bold;">If</span> TimeLapseUpdate<span style="color: #000066;">&#40;</span> <span style="color: #000066;">*</span>timer_one <span style="color: #000066;">&#41;</span>
				<span style="color: #0000ff;">PrintN</span><span style="color: #000066;">&#40;</span><span style="color: #009900;">&quot;timer_one: &quot;</span> <span style="color: #000066;">+</span> <span style="color: #0000ff;">Str</span><span style="color: #000066;">&#40;</span><span style="color: #000066;">*</span>timer_one<span style="color: #000066;">\</span>time_out<span style="color: #000066;">&#41;</span> <span style="color: #000066;">+</span> <span style="color: #009900;">&quot;ms reached.&quot;</span><span style="color: #000066;">&#41;</span>
			<span style="color: #000066; font-weight: bold;">EndIf</span>
			<span style="color: #000066; font-weight: bold;">If</span> TimeLapseUpdate<span style="color: #000066;">&#40;</span> <span style="color: #000066;">*</span>timer_two <span style="color: #000066;">&#41;</span>
				<span style="color: #0000ff;">PrintN</span><span style="color: #000066;">&#40;</span><span style="color: #009900;">&quot;timer_two: &quot;</span> <span style="color: #000066;">+</span> <span style="color: #0000ff;">Str</span><span style="color: #000066;">&#40;</span><span style="color: #000066;">*</span>timer_two<span style="color: #000066;">\</span>time_out<span style="color: #000066;">&#41;</span> <span style="color: #000066;">+</span> <span style="color: #009900;">&quot;ms reached.&quot;</span><span style="color: #000066;">&#41;</span>
			<span style="color: #000066; font-weight: bold;">EndIf</span>
		<span style="color: #000066; font-weight: bold;">EndIf</span>
&nbsp;
		<span style="color: #0000ff;">Delay</span><span style="color: #000066;">&#40;</span><span style="color: #CC0000;">10</span><span style="color: #000066;">&#41;</span>
&nbsp;
	<span style="color: #000066; font-weight: bold;">Until</span> <span style="color: #0000ff;">Inkey</span><span style="color: #000066;">&#40;</span><span style="color: #000066;">&#41;</span> <span style="color: #000066;">=</span> <span style="color: #0000ff;">Chr</span><span style="color: #000066;">&#40;</span><span style="color: #CC0000;">27</span><span style="color: #000066;">&#41;</span> <span style="color: #000066; font-weight: bold;">Or</span> quit 
&nbsp;
	<span style="color: #0000ff;">PrintN</span><span style="color: #000066;">&#40;</span> <span style="color: #009900;">&quot;timer_three: The example finished.&quot;</span> <span style="color: #000066;">&#41;</span>
&nbsp;
	TimeLapseDestroy<span style="color: #000066;">&#40;</span><span style="color: #000066;">*</span>timer_one<span style="color: #000066;">&#41;</span>
	TimeLapseDestroy<span style="color: #000066;">&#40;</span><span style="color: #000066;">*</span>timer_two<span style="color: #000066;">&#41;</span>
	TimeLapseDestroy<span style="color: #000066;">&#40;</span><span style="color: #000066;">*</span>timer_three<span style="color: #000066;">&#41;</span>
&nbsp;
	<span style="color: #0000ff;">Input</span><span style="color: #000066;">&#40;</span><span style="color: #000066;">&#41;</span>
	<span style="color: #0000ff;">CloseConsole</span><span style="color: #000066;">&#40;</span><span style="color: #000066;">&#41;</span>
&nbsp;
<span style="color: #000066; font-weight: bold;">EndIf</span>
<span style="color: #000066; font-weight: bold;">End</span></pre></div></div>

<p>The examples are crude, but they show every function in the library.<br />
Should you have any questions, feel free to ask.</p>
<p>I&#8217;ll soon post the &#8220;Animation&#8221; lib that depends on &#8220;TimeLapse&#8221;.</p>
<p>Cheers.</p>
<div id="crp_related"><h3>Related Posts:</h3><ul><li><a href="http://gushh.net/blog/2009/08/06/animation-lib/" rel="bookmark" class="crp_title">Animation lib</a></li><li><a href="http://gushh.net/blog/2010/06/04/icmp-ping-routine/" rel="bookmark" class="crp_title">ICMP Ping Routine (Windows only)</a></li><li><a href="http://gushh.net/blog/2010/08/14/autocomplete-library/" rel="bookmark" class="crp_title">AutoComplete Library</a></li><li><a href="http://gushh.net/blog/2009/08/28/structuring-libraries-basic-design-tips/" rel="bookmark" class="crp_title">Structuring libraries, basic design tips.</a></li><li><a href="http://gushh.net/blog/2009/08/05/average-template/" rel="bookmark" class="crp_title">Average template</a></li></ul></div>]]></content:encoded>
			<wfw:commentRss>http://gushh.net/blog/2009/08/05/timelapse-lib/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
	</channel>
</rss>
