<?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>Predator Interactive</title>
	<atom:link href="http://www.predatorinteractive.com/feed" rel="self" type="application/rss+xml" />
	<link>http://www.predatorinteractive.com</link>
	<description>2D Game Programming Resources for Noobs</description>
	<lastBuildDate>Tue, 22 Dec 2009 08:48:11 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.8.5</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Tutorial Makeovers [10/21/09]</title>
		<link>http://www.predatorinteractive.com/news/tutorial-makeovers-102109</link>
		<comments>http://www.predatorinteractive.com/news/tutorial-makeovers-102109#comments</comments>
		<pubDate>Wed, 21 Oct 2009 19:54:43 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[News]]></category>
		<category><![CDATA[makeover]]></category>
		<category><![CDATA[tutorial]]></category>

		<guid isPermaLink="false">http://www.predatorinteractive.com/?p=360</guid>
		<description><![CDATA[As some of you may have seen, as of today some of the quality on our videos are below average and are extremely hard to read.  So in the coming days, we are going to be redoing most of the tutorial videos to make sure that you can easily read the code and follow along [...]<!-- Easy AdSense V2.80 -->
<!-- Post[count: 2] -->
<div class="ezAdsense adsense adsense-leadout" style="text-align:center;margin:12px; "><script type="text/javascript"><!--
google_ad_client = "pub-8758858260781245";
/* 468x60, created 6/19/09 */
google_ad_slot = "6950501204";
google_ad_width = 468;
google_ad_height = 60;
//-->
</script>
<script type="text/javascript"
src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
</script></div>]]></description>
			<content:encoded><![CDATA[<p>As some of you may have seen, as of today some of the quality on our videos are below average and are extremely hard to read.  So in the coming days, we are going to be redoing most of the tutorial videos to make sure that you can easily read the code and follow along with no problem.</p>
<p>Also, we are going to be adding text explanations under all of our tutorial videos so you don&#8217;t always have to sit through an entire video just to get a bit of information.  This makeover of all the tutorials will take a couple of weeks to complete and we will be continuing to add the rest of the videos soon after that.  So keep all that in mind as you surf around and learn to program, Instinct style!</p>
<!-- Easy AdSense V2.80 -->
<!-- Post[count: 3] -->
<div class="ezAdsense adsense adsense-leadout" style="text-align:center;margin:12px; "><script type="text/javascript"><!--
google_ad_client = "pub-8758858260781245";
/* 468x60, created 6/19/09 */
google_ad_slot = "6950501204";
google_ad_width = 468;
google_ad_height = 60;
//-->
</script>
<script type="text/javascript"
src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
</script></div>]]></content:encoded>
			<wfw:commentRss>http://www.predatorinteractive.com/news/tutorial-makeovers-102109/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Open Source Plans [10/19/09]</title>
		<link>http://www.predatorinteractive.com/news/open-source-plans-101909</link>
		<comments>http://www.predatorinteractive.com/news/open-source-plans-101909#comments</comments>
		<pubDate>Mon, 19 Oct 2009 23:27:30 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[News]]></category>
		<category><![CDATA[instinct]]></category>
		<category><![CDATA[open source]]></category>

		<guid isPermaLink="false">http://www.predatorinteractive.com/?p=302</guid>
		<description><![CDATA[In the next six months, we are planning to put both the Instinct Graphics Package and Instinct Engine up as open source projects.]]></description>
			<content:encoded><![CDATA[<p>In the next recent months, there is going to be a concerted effort to start pushing both the <a href="http://www.predatorinteractive.com/category/instinctengine">Instinct Engine</a> and the <a href="http://www.predatorinteractive.com/category/instinct-graphics-package">Instinct Graphics Package</a> to become open source.  We feel that to be able to create the best packages and get wide spread use, we need to get both of these APIs cleaned up and put up as open source projects.  With this we hope to get a great community of supporters helping to fix and add better features so we can provide the best packages for you all to use.</p>
<p>The timetable we are looking for to have both of these up as open source is six months.  So keep a look out for more news on this in the coming months.  In the mean time, we will keep updating and adding new video tutorials on here so you can keep on learning!  Keep on coding!</p>
]]></content:encoded>
			<wfw:commentRss>http://www.predatorinteractive.com/news/open-source-plans-101909/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Instinct Graphics Package</title>
		<link>http://www.predatorinteractive.com/introductions/instinct-graphics-package</link>
		<comments>http://www.predatorinteractive.com/introductions/instinct-graphics-package#comments</comments>
		<pubDate>Sat, 27 Jun 2009 07:14:53 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Introductions]]></category>
		<category><![CDATA[Instinct Graphics Package]]></category>
		<category><![CDATA[overview]]></category>

		<guid isPermaLink="false">http://www.predatorinteractive.com/?p=260</guid>
		<description><![CDATA[Everything you need to know about using the Instinct Graphics Package.  From installation to animation and more! Build 2d programs and games with ease.]]></description>
			<content:encoded><![CDATA[<div id="wp_zdytfp_container_260" style="width:100%; height:470px; text-align:center; margin:auto;">
<div id="v_wp_zdytfp_container_260" style="width:100%; height:100%;">ZD YouTube FLV Player</div>
</div>
<script type="text/javascript">
var flashvars = {
vurl: "http://www.predatorinteractive.com/wp-content/uploads/2009/06/instinctpackageintro.flv",
autoplay: "yes",
yturl: "http://www.predatorinteractive.com/wp-content/plugins/zd-youtube-flv-player/fl_youTubeProxy.php"
};
var params = {
wmode: "transparent",
allowFullScreen: "true"
};
var attributes = {
id: "my_wp_zdytfp_container_260",
name: "my_wp_zdytfp_container_260"
};
swfobject.embedSWF("http://www.predatorinteractive.com/wp-content/plugins/zd-youtube-flv-player/flash/zdytflv-player-dark.swf", "v_wp_zdytfp_container_260", "630", "470", "9.0.0", false, flashvars, params, attributes);
</script>

<h2><span style="text-decoration: underline;">The Instinct Graphics Package</span></h2>
<p>The Instinct Graphics Package is an easy to use and free 2D graphics programming framework for C++.  It can be used simply to output something to a screen or as a package for making 2D games.  It is completely free to use whether it is for personal use or for educational purposes. For educational use or for general questions, feel free to contact us ratadero@predatorinteractive.com</p>
<h3><span style="text-decoration: underline;">Tutorials and Videos</span></h3>
<p>For videos and tutorials on installing and using the Instinct Graphics package, click <strong><a href="../category/videos/instinct-graphics-package">here</a></strong>.</p>
<h3><span style="text-decoration: underline;">Instinct Graphics Package Resources</span></h3>
<p><a href="http://www.predatorinteractive.com/wp-content/uploads/2009/06/InstinctReference.pdf">Reference Sheet</a><br />
All the major objects and functions you can use in the Instinct Graphics Package.</p>
<p><a href="http://www.predatorinteractive.com/wp-content/uploads/2009/06/instinct.zip"> Instinct Graphics Package Project Folder</a><br />
Any new Instinct Graphics Package program should start with this.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.predatorinteractive.com/introductions/instinct-graphics-package/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Instinct Engine</title>
		<link>http://www.predatorinteractive.com/introductions/instinct-engine</link>
		<comments>http://www.predatorinteractive.com/introductions/instinct-engine#comments</comments>
		<pubDate>Fri, 26 Jun 2009 07:31:48 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Introductions]]></category>
		<category><![CDATA[2D]]></category>
		<category><![CDATA[games]]></category>
		<category><![CDATA[instinct engine]]></category>

		<guid isPermaLink="false">http://www.predatorinteractive.com/?p=262</guid>
		<description><![CDATA[More for advanced programmers, learn to create professional looking 2D games with ease. Coming Soon.]]></description>
			<content:encoded><![CDATA[<p>Coming Soon.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.predatorinteractive.com/introductions/instinct-engine/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Camera Control</title>
		<link>http://www.predatorinteractive.com/2d-game-programming-tricks/camera-control</link>
		<comments>http://www.predatorinteractive.com/2d-game-programming-tricks/camera-control#comments</comments>
		<pubDate>Thu, 25 Jun 2009 10:13:41 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[2D Game Programming Tricks]]></category>

		<guid isPermaLink="false">http://www.predatorinteractive.com/?p=281</guid>
		<description><![CDATA[Coming Soon!
]]></description>
			<content:encoded><![CDATA[<p>Coming Soon!</p>
]]></content:encoded>
			<wfw:commentRss>http://www.predatorinteractive.com/2d-game-programming-tricks/camera-control/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>2D Game Programing Tricks</title>
		<link>http://www.predatorinteractive.com/introductions/2d-game-programing-tricks</link>
		<comments>http://www.predatorinteractive.com/introductions/2d-game-programing-tricks#comments</comments>
		<pubDate>Thu, 25 Jun 2009 09:12:19 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Introductions]]></category>
		<category><![CDATA[2D]]></category>
		<category><![CDATA[game]]></category>
		<category><![CDATA[programming]]></category>
		<category><![CDATA[tricks]]></category>

		<guid isPermaLink="false">http://www.predatorinteractive.com/?p=267</guid>
		<description><![CDATA[Have a graphics package you know how to use?  Learn the tricks for 2d game programming from physics to side-scrollers and more!]]></description>
			<content:encoded><![CDATA[<p>From strategies for building certain types of games to visual tricks.  Tons of knowledge for 2d game programming.</p>
<p>Coming Soon!</p>
]]></content:encoded>
			<wfw:commentRss>http://www.predatorinteractive.com/introductions/2d-game-programing-tricks/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Welcome To Predator Interactive</title>
		<link>http://www.predatorinteractive.com/new/welcome-to-predator-interactive</link>
		<comments>http://www.predatorinteractive.com/new/welcome-to-predator-interactive#comments</comments>
		<pubDate>Thu, 25 Jun 2009 07:05:40 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[I'm New Here]]></category>
		<category><![CDATA[intro]]></category>
		<category><![CDATA[predator interactive]]></category>
		<category><![CDATA[welcome]]></category>

		<guid isPermaLink="false">http://www.predatorinteractive.com/?p=256</guid>
		<description><![CDATA[Know a little C++? Want to learn 2D game programming? Start here to learn more!]]></description>
			<content:encoded><![CDATA[<h2><span style="text-decoration: underline;">Welcome to Predator Interactive.</span></h2>
<p>Everything you need to know to learn 2D gaming programming in no time.  We offer free to use graphics packages that allow you to display shapes, color, images, as well as get real time input from the user.</p>
<h3><span style="text-decoration: underline;"><strong>What do I need to know?</strong></span></h3>
<p>All you need is at least a little bit of C++ knowledge to start using one of our amazing graphics packages.  No graphics programming knowledge is required.</p>
<h3><span style="text-decoration: underline;"><strong>So where should I start here?</strong></span></h3>
<p>There are three main places you can start at:</p>
<ul>
<li><strong>Instinct Graphics Package</strong> (Introductory)</li>
<li><strong>Instinct Engine</strong> (Intermediate)</li>
<li><strong>Game Programming Tricks</strong></li>
</ul>
<h3><strong><a title="Instinct Graphics Package" href="http://www.predatorinteractive.com/category/graphicspackages/instinct-graphics-package" target="_self">Instinct Graphics Package<br />
</a></strong></h3>
<p style="padding-left: 30px;"><strong>Suggested User: </strong>Beginning C++ Programmer or Beginning Game Programmer</p>
<p style="padding-left: 30px;">The first is the Instinct Graphics Package.  If you have limited to intermediate knowledge of C++, have had no experience with graphics programming, or would just like to try something easy to start off with, we definitely suggest this.  Don&#8217;t be fooled though, this is still a powerful package that can do lots of interesting programs.  For more info on the Instinct Graphics Package, check out our video tutorials on that <a href="http://www.predatorinteractive.com/category/graphicspackages/instinct-graphics-package"><strong>here</strong></a>.</p>
<h3><a title="Instinct Engine" href="http://www.predatorinteractive.com/category/graphicspackages/instinctengine" target="_self">Instinct Engine</a></h3>
<p style="padding-left: 30px;"><strong>Suggested User:</strong> Intermediate to Advanced C++ Programmer</p>
<p style="padding-left: 30px;">The second place you can start at is the Instinct Engine.  This requires a stronger knowledge of C++ including classes and pointers.  If you have this level of knowledge and possibly want a little more control over everything, then this can be the place to start for you. Has the ability to make commercial quality 2D games.  For more info on the Instinct Engine, check out our video tutorials on that <a href="http://www.predatorinteractive.com/category/graphicspackages/instinctengine"><strong>here</strong></a>.</p>
<h3><a title="Game Programming Tricks" href="http://www.predatorinteractive.com/category/game-programming-tricks" target="_blank">2D Game Programming Tricks</a></h3>
<p style="padding-left: 30px;"><strong>Suggested User:</strong> Have knowledge and experience with either of the above packages or some other game programming package.</p>
<p style="padding-left: 30px;">The last place to start is at our 2D game programming tricks.  If you already know one of these two APIs (Instinct Graphics Package or Instinct Engine) or you have a different graphics API you are already using, then here is where you would want to learn to put those skills to use.  For more info on our 2D game programming tricks, check out our video tutorials on that there <a href="http://www.predatorinteractive.com/category/game-programming-tricks"><strong>here</strong></a>.</p>
<p>We hope that you will find everything you need here to transcend from noob to 2D game programming master.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.predatorinteractive.com/new/welcome-to-predator-interactive/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>9. Playing Audio</title>
		<link>http://www.predatorinteractive.com/instinct-graphics-package/9-playing-audio</link>
		<comments>http://www.predatorinteractive.com/instinct-graphics-package/9-playing-audio#comments</comments>
		<pubDate>Tue, 23 Jun 2009 05:14:36 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Instinct Graphics Package]]></category>
		<category><![CDATA[audio]]></category>
		<category><![CDATA[mp3]]></category>
		<category><![CDATA[music]]></category>
		<category><![CDATA[ogg]]></category>
		<category><![CDATA[sound]]></category>
		<category><![CDATA[wav]]></category>

		<guid isPermaLink="false">http://www.predatorinteractive.com/?p=242</guid>
		<description><![CDATA[Coming Soon!]]></description>
			<content:encoded><![CDATA[<p>Learn how to play different types of music and sounds as well as converting different types of audio to more suitable file types.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.predatorinteractive.com/instinct-graphics-package/9-playing-audio/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>8. Real Time User Input</title>
		<link>http://www.predatorinteractive.com/instinct-graphics-package/8-real-time-user-input</link>
		<comments>http://www.predatorinteractive.com/instinct-graphics-package/8-real-time-user-input#comments</comments>
		<pubDate>Tue, 23 Jun 2009 05:09:12 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Instinct Graphics Package]]></category>
		<category><![CDATA[input]]></category>
		<category><![CDATA[key]]></category>
		<category><![CDATA[mouse]]></category>
		<category><![CDATA[real time]]></category>
		<category><![CDATA[user]]></category>

		<guid isPermaLink="false">http://www.predatorinteractive.com/?p=237</guid>
		<description><![CDATA[Coming Soon!]]></description>
			<content:encoded><![CDATA[<p>Be able to now get real time feedback from the user without halting your program.  You should know the basics of animations prior to trying this one out.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.predatorinteractive.com/instinct-graphics-package/8-real-time-user-input/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>7. Basic Animation and Timers</title>
		<link>http://www.predatorinteractive.com/instinct-graphics-package/7-basic-animation-and-timers</link>
		<comments>http://www.predatorinteractive.com/instinct-graphics-package/7-basic-animation-and-timers#comments</comments>
		<pubDate>Tue, 23 Jun 2009 05:06:28 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Instinct Graphics Package]]></category>
		<category><![CDATA[animation]]></category>
		<category><![CDATA[ball]]></category>
		<category><![CDATA[bouncing]]></category>
		<category><![CDATA[frame]]></category>
		<category><![CDATA[loop]]></category>
		<category><![CDATA[timer]]></category>

		<guid isPermaLink="false">http://www.predatorinteractive.com/?p=233</guid>
		<description><![CDATA[How to generally setup your program for doing animations and using Timers to ensure the program runs the same across different computers.]]></description>
			<content:encoded><![CDATA[<div id="wp_zdytfp_container_233" style="width:100%; height:470px; text-align:center; margin:auto;">
<div id="v_wp_zdytfp_container_233" style="width:100%; height:100%;">ZD YouTube FLV Player</div>
</div>
<script type="text/javascript">
var flashvars = {
vurl: "http://www.predatorinteractive.com/wp-content/uploads/2009/06/instinct_animation.mp4",
autoplay: "yes",
yturl: "http://www.predatorinteractive.com/wp-content/plugins/zd-youtube-flv-player/fl_youTubeProxy.php"
};
var params = {
wmode: "transparent",
allowFullScreen: "true"
};
var attributes = {
id: "my_wp_zdytfp_container_233",
name: "my_wp_zdytfp_container_233"
};
swfobject.embedSWF("http://www.predatorinteractive.com/wp-content/plugins/zd-youtube-flv-player/flash/zdytflv-player-dark.swf", "v_wp_zdytfp_container_233", "630", "470", "9.0.0", false, flashvars, params, attributes);
</script>

<h2><span style="text-decoration: underline;">Basic Animation and Timers</span></h2>
<p>Prior to actually getting into the animation code, let&#8217;s take a quick look at timers.</p>
<h3><span style="text-decoration: underline;">Timers</span></h3>
<p>To create a timer which has a time value of zero, simply type: <strong>&#8220;Timer name_of_timer<span style="color: #ff0000;">;</span><span style="color: #000000;">&#8220;</span></strong><br />
Example:</p>
<ul>
<li>Timer animation_timer<span style="color: #ff0000;">;</span></li>
<li>Timer stopwatch<span style="color: #ff0000;">;</span></li>
</ul>
<p><span style="color: #000000;">The basic functions of timers are as follow:</span></p>
<ul>
<li><span style="color: #000000;">timer<span style="color: #ff0000;">.</span>start<span style="color: #ff0000;">();</span> <span style="color: #808080;">//Makes the timer starting ticking.</span><br />
</span></li>
<li><span style="color: #000000;">timer<span style="color: #ff0000;">.</span>stop<span style="color: #ff0000;">(); </span><span style="color: #808080;">//Stops the timer from ticking.</span></span></li>
<li><span style="color: #000000;">timer<span style="color: #ff0000;">.</span>reset<span style="color: #ff0000;">();</span> <span style="color: #808080;">//Resets the time value of the timer to zero regardless if it is running or not.</span></span></li>
</ul>
<p><span style="color: #000000;">To get the number of <em><strong>milliseconds</strong></em> on the timer, use the member function: <strong>&#8220;timer<span style="color: #ff0000;">.</span>get_time<span style="color: #ff0000;">();<span style="color: #000000;">&#8220;</span><br />
</span></strong><span style="color: #ff0000;"><span style="color: #000000;">Example:</span></span></span></p>
<ul>
<li><span style="color: #000000;"><span style="color: #ff0000;"><span style="color: #000000;"><span style="color: #0000ff;">int</span> milliseconds <span style="color: #ff0000;">=</span> timer<span style="color: #ff0000;">.</span>get_time<span style="color: #ff0000;">();</span></span></span></span></li>
<li><span style="color: #000000;"><span style="color: #ff0000;"><span style="color: #000000;">win <span style="color: #ff0000;">&lt;&lt;</span> Message<span style="color: #ff0000;">(</span>Point<span style="color: #ff0000;">(</span><span style="color: #ff00ff;">5</span><span style="color: #ff0000;">,</span> <span style="color: #ff00ff;">5</span><span style="color: #ff0000;">),</span> timer<span style="color: #ff0000;">.</span>get_time<span style="color: #ff0000;">());</span></span></span></span></li>
<li><span style="color: #000000;"><span style="color: #ff0000;"><span style="color: #000000;"><span style="color: #0000ff;">if</span><span style="color: #ff0000;">(</span>timer.get_time<span style="color: #ff0000;">()</span> <span style="color: #ff0000;">&gt;</span> <span style="color: #ff00ff;">1000</span><span style="color: #ff0000;">)</span></span></span></span></li>
</ul>
<p>To add time to the timer use the <strong>&#8220;timer<span style="color: #ff0000;">.</span>add_time<span style="color: #ff0000;">(</span><span style="color: #0000ff;">double</span> milliseconds<span style="color: #ff0000;">);<span style="color: #000000;">&#8220;</span></span></strong><span style="color: #000000;"> </span>member function.<br />
Example:</p>
<ul>
<li>timer<span style="color: #ff0000;">.</span>add_time<span style="color: #ff0000;">(</span><span style="color: #ff00ff;">20000</span><span style="color: #ff0000;">);</span></li>
<li>timer<span style="color: #ff0000;">.</span>add_time<span style="color: #ff0000;">(</span>penalty_time<span style="color: #ff0000;">);</span></li>
</ul>
<p><span style="color: #000000;">To check if the time has passed some number of milliseconds use:<strong><span style="color: #000000;"> &#8220;</span><span style="color: #0000ff;">bool</span> timer<span style="color: #ff0000;">.</span>has_passed<span style="color: #ff0000;">(</span><span style="color: #0000ff;">double</span> milliseconds<span style="color: #ff0000;">);<span style="color: #000000;">&#8220;</span><br />
</span></strong><span style="color: #ff0000;"><span style="color: #000000;">Example:</span></span></span></p>
<ul>
<li><span style="color: #000000;"><span style="color: #ff0000;"><span style="color: #000000;"><span style="color: #0000ff;">if</span><span style="color: #ff0000;">(</span>timer<span style="color: #ff0000;">.</span>has_passed<span style="color: #ff0000;">(</span><span style="color: #ff00ff;">15000</span><span style="color: #ff0000;">));</span></span></span></span></li>
<li><span style="color: #000000;"><span style="color: #ff0000;"><span style="color: #000000;"><span style="color: #0000ff;">bool</span> passed <span style="color: #ff0000;">=</span> timer<span style="color: #ff0000;">.</span>has_passed<span style="color: #ff0000;">(</span><span style="color: #ff00ff;">10500</span><span style="color: #ff0000;">);</span></span></span></span></li>
</ul>
<h3><span style="text-decoration: underline;">Wait for</span></h3>
<p>You can also use the <strong>&#8220;wait_for<span style="color: #ff0000;">(</span><span style="color: #0000ff;">double</span> milliseconds<span style="color: #ff0000;">)<span style="color: #000000;">&#8220;</span></span></strong><span style="color: #ff0000;"> </span>function which makes the program wait for the passed in number of milliseconds.<br />
Example:</p>
<ul>
<li>wait_for<span style="color: #ff0000;">(</span><span style="color: #ff00ff;">10000</span><span style="color: #ff0000;">);</span> <span style="color: #808080;">//The program will wait here for 10 seconds.</span></li>
<li>wait_for<span style="color: #ff0000;">(</span>delay_time<span style="color: #ff0000;">);</span> <span style="color: #808080;">//The program will wait here for delay_time milliseconds.</span></li>
</ul>
<p>Remember, there are <span style="color: #ff00ff;">1000</span> milliseconds in <span style="color: #ff00ff;">1</span> second.</p>
<h2><span style="text-decoration: underline;">Animation</span></h2>
<p>To better understand animation, here is a general definition:<strong> Seeing a series of rapid pictures that gives the illusion of movement.</strong></p>
<h3><strong><span style="text-decoration: underline;">Frames</span><br />
</strong></h3>
<p>We are going to call these individual pictures that create this illusion of movement<em><strong> frames. </strong></em>So for example here are a series of four frames:</p>
<p style="text-align: center;"><a rel="attachment wp-att-489" href="http://www.predatorinteractive.com/instinct-graphics-package/7-basic-animation-and-timers/attachment/movingballframe_1"><img class="alignnone size-full wp-image-489" title="movingballframe_1" src="http://www.predatorinteractive.com/wp-content/uploads/2009/06/movingballframe_1.gif" alt="movingballframe_1" width="132" height="132" /></a> <a rel="attachment wp-att-490" href="http://www.predatorinteractive.com/instinct-graphics-package/7-basic-animation-and-timers/attachment/movingballframe_2"><img class="alignnone size-full wp-image-490" title="movingballframe_2" src="http://www.predatorinteractive.com/wp-content/uploads/2009/06/movingballframe_2.gif" alt="movingballframe_2" width="132" height="132" /></a> <a rel="attachment wp-att-491" href="http://www.predatorinteractive.com/instinct-graphics-package/7-basic-animation-and-timers/attachment/movingballframe_3"><img class="alignnone size-full wp-image-491" title="movingballframe_3" src="http://www.predatorinteractive.com/wp-content/uploads/2009/06/movingballframe_3.gif" alt="movingballframe_3" width="132" height="132" /></a> <a rel="attachment wp-att-492" href="http://www.predatorinteractive.com/instinct-graphics-package/7-basic-animation-and-timers/attachment/movingballframe_4"><img class="alignnone size-full wp-image-492" title="movingballframe_4" src="http://www.predatorinteractive.com/wp-content/uploads/2009/06/movingballframe_4.gif" alt="movingballframe_4" width="132" height="132" /></a></p>
<p>Now if we show each of these frames one after another with a small pause in between, we will see what <em>looks</em> like a ball moving. This illusion is the basis behind animation!</p>
<p style="text-align: center;"><a rel="attachment wp-att-498" href="http://www.predatorinteractive.com/instinct-graphics-package/7-basic-animation-and-timers/attachment/movingball"><img class="size-full wp-image-498 aligncenter" title="movingball" src="http://www.predatorinteractive.com/wp-content/uploads/2009/06/movingball.gif" alt="movingball" width="180" height="180" /></a></p>
<p style="text-align: left;">Now that we hopefully have a better understanding of how animation works, we can but it to use with the Instinct Graphics Package.</p>
<h3 style="text-align: left;"><span style="text-decoration: underline;">Coding Animation</span></h3>
<p>Well we could code the above example by simply drawing a ball, moving it and redrawing it.  If we did that four times in our code with a <strong>wait_for<span style="color: #ff0000;">(</span><span style="color: #ff00ff;">100</span><span style="color: #ff0000;">);</span></strong> in between each of those to cause a slight pause, we could reproduce the moving blue ball easily.<br />
Example:</p>
<pre style="padding-left: 30px;">Circle circ <span style="color: #ff0000;">=</span> Circle<span style="color: #ff0000;">(</span>Point<span style="color: #ff0000;">(</span><span style="color: #ff00ff;">1</span><span style="color: #ff0000;">,</span> <span style="color: #ff00ff;">5</span><span style="color: #ff0000;">),</span> <span style="color: #ff00ff;">1</span><span style="color: #ff0000;">,</span> BLUE<span style="color: #ff0000;">,</span> <span style="color: #0000ff;">true</span><span style="color: #ff0000;">);</span>

<span style="color: #808080;">//Frame 1</span>
win <span style="color: #ff0000;">&lt;&lt;</span> circ<span style="color: #ff0000;">;</span>
win<span style="color: #ff0000;">.</span>output_buffer<span style="color: #ff0000;">();</span>

<span style="color: #808080;">//Frame 2</span>
wait_for<span style="color: #ff0000;">(</span><span style="color: #ff00ff;">100</span><span style="color: #ff0000;">);</span>
circ<span style="color: #ff0000;">.</span>move<span style="color: #ff0000;">(</span><span style="color: #ff00ff;">1</span><span style="color: #ff0000;">,</span> <span style="color: #ff00ff;">0</span><span style="color: #ff0000;">);</span>
win.clear_buffer<span style="color: #ff0000;">();</span>
win <span style="color: #ff0000;">&lt;&lt;</span> circ<span style="color: #ff0000;">;</span>
win<span style="color: #ff0000;">.</span>output_buffer<span style="color: #ff0000;">();</span>

<span style="color: #808080;">//Frame 3</span>
wait_for<span style="color: #ff0000;">(</span><span style="color: #ff00ff;">100</span><span style="color: #ff0000;">);</span>
circ<span style="color: #ff0000;">.</span>move<span style="color: #ff0000;">(</span><span style="color: #ff00ff;">1</span><span style="color: #ff0000;">,</span> <span style="color: #ff00ff;">0</span><span style="color: #ff0000;">);</span>
win.clear_buffer<span style="color: #ff0000;">();</span>
win <span style="color: #ff0000;">&lt;&lt;</span> circ<span style="color: #ff0000;">;</span>
win<span style="color: #ff0000;">.</span>output_buffer<span style="color: #ff0000;">();</span>

<span style="color: #808080;">//Frame 4</span>
wait_for<span style="color: #ff0000;">(</span><span style="color: #ff00ff;">100</span><span style="color: #ff0000;">);</span>
circ<span style="color: #ff0000;">.</span>move<span style="color: #ff0000;">(</span><span style="color: #ff00ff;">1</span><span style="color: #ff0000;">,</span> <span style="color: #ff00ff;">0</span><span style="color: #ff0000;">);</span>
win.clear_buffer<span style="color: #ff0000;">();</span>
win <span style="color: #ff0000;">&lt;&lt;</span> circ<span style="color: #ff0000;">;</span>
win<span style="color: #ff0000;">.</span>output_buffer<span style="color: #ff0000;">();
</span></pre>
<p>As you can see above, the frames 2-4 become very much the same. If we wanted more frames we would have to continue copying and pasting the same code for each frame.</p>
<h3><span style="text-decoration: underline;">Using loops</span></h3>
<p>However, if we use a loop that moves everything and redraws it each time, we could have as many frames as we want without having to continuously add code for each frame.<br />
Example:</p>
<pre style="padding-left: 30px;">win <span style="color: #ff0000;">&lt;&lt;</span> circ<span style="color: #ff0000;">;</span>
win<span style="color: #ff0000;">.</span>output_buffer<span style="color: #ff0000;">();</span>

<span style="color: #808080;"><span style="color: #0000ff;">while</span><span style="color: #ff0000;">(</span><span style="color: #0000ff;">true</span><span style="color: #ff0000;">)</span>
<span style="color: #ff0000;">{</span></span>
    wait_for<span style="color: #ff0000;">(</span><span style="color: #ff00ff;">100</span><span style="color: #ff0000;">);</span>
    circ<span style="color: #ff0000;">.</span>move<span style="color: #ff0000;">(</span><span style="color: #ff00ff;">1</span><span style="color: #ff0000;">,</span> <span style="color: #ff00ff;">0</span><span style="color: #ff0000;">);</span>
    win.clear_buffer<span style="color: #ff0000;">();</span>
    win <span style="color: #ff0000;">&lt;&lt;</span> circ<span style="color: #ff0000;">;</span>
    win<span style="color: #ff0000;">.</span>output_buffer<span style="color: #ff0000;">();
}</span></pre>
<p>With the <strong><span style="color: #0000ff;">while</span><span style="color: #ff0000;">(</span><span style="color: #0000ff;">true</span><span style="color: #ff0000;">)</span></strong>, the program will continuously run that loop until we close the program.  So now the loop will continously do frame after frame of moving the ball and redrawing it.</p>
<h3><span style="text-decoration: underline;">Frame Rate<br />
</span></h3>
<p>As you can see above, we were using a value of <span style="color: #ff00ff;">100</span> as the number of milliseconds to wait in between each frame.  This is practice is not a nice number to use since that only allows us to have around <span style="color: #ff00ff;">10</span> frames per second (FPS), which is not a good number.  Generally speaking, a good frame rate for animated programs is usually in between <span style="color: #ff00ff;">60</span> and <span style="color: #ff00ff;">30</span> frames per second.  Because of that, I would suggest using a wait_for amount of <strong><span style="color: #ff00ff;">20</span></strong> milliseconds, which in turn creates a frame rate of around <span style="color: #ff00ff;">50</span> FPS.</p>
<ul>
<li>wait_for<span style="color: #ff0000;">(</span><span style="color: #ff00ff;">20</span><span style="color: #ff0000;">);</span></li>
</ul>
<p>Just keep in mind that this wait_for<span style="color: #ff0000;">(</span><span style="color: #ff00ff;">20</span><span style="color: #ff0000;">);</span> by itself is not the best way to do timing for animation, but it is the simplest.  Later we will go over better and more advanced forms of doing timing for animation loops.</p>
<h3><span style="text-decoration: underline;">Sectioning the Animation Loop</span></h3>
<p>The last bit of advice I would suggest is to always split up the animation loop into two sections to make sure it is done right:</p>
<pre style="padding-left: 30px;"><span style="color: #808080;"><span style="color: #0000ff;">while</span><span style="color: #ff0000;">(</span><span style="color: #0000ff;">true</span><span style="color: #ff0000;">)</span>
<span style="color: #ff0000;">{</span></span>
    wait_for<span style="color: #ff0000;">(</span><span style="color: #ff00ff;">20</span><span style="color: #ff0000;">);</span>

    <span style="color: #808080;">///////////////////
    // Handle Logic
    /////////////////</span><span style="color: #808080;">//</span>
    circ<span style="color: #ff0000;">.</span>move<span style="color: #ff0000;">(</span><span style="color: #ff00ff;">1</span><span style="color: #ff0000;">,</span> <span style="color: #ff00ff;">0</span><span style="color: #ff0000;">);

    <span style="color: #808080;">///////////////////
    // Draw Everything
    ///////////////////</span>
</span>    win.clear_buffer<span style="color: #ff0000;">();</span>
    win <span style="color: #ff0000;">&lt;&lt;</span> circ<span style="color: #ff0000;">;</span>
    win<span style="color: #ff0000;">.</span>output_buffer<span style="color: #ff0000;">();
}
</span></pre>
<p>There should be two distinct sections, the section that handles all the logic of the animation (moving objects, doing collision detection, changing colors of objects, etc), and a section that simply draws everything that needs to be drawn.  So what does this mean?  There should be NO drawing of objects in the <em><strong>Handle Logic</strong></em> section, and only code that deals with the drawing of objects in the <em><strong>Draw Everything</strong></em> section.  If you code is sectioned properly and done correctly, your animation should come out nice and smooth and work perfectly with no flickering.</p>
<h3><span style="text-decoration: underline;">What Now?</span></h3>
<p>Now the rest is up to you in terms of what you want to do in this animation loop.  You don&#8217;t have to have a ball that moves around solely in the X direction.  This was merely an example. You can use Rects, Circles, Images, etc. to make anything you can think of.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.predatorinteractive.com/instinct-graphics-package/7-basic-animation-and-timers/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
<enclosure url="http://www.predatorinteractive.com/wp-content/uploads/2009/06/instinct_animation.mp4" length="40893731" type="video/mp4" />
		</item>
	</channel>
</rss>
