<?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:media="http://search.yahoo.com/mrss/"
	>

<channel>
	<title>Game Development Juice</title>
	<atom:link href="http://gamedevjuice.wordpress.com/feed/" rel="self" type="application/rss+xml" />
	<link>http://gamedevjuice.wordpress.com</link>
	<description>Just another Game Development weblog</description>
	<pubDate>Wed, 26 Mar 2008 02:01:53 +0000</pubDate>
	<generator>http://wordpress.org/?v=MU</generator>
	<language>en</language>
			<item>
		<title>This blog is moving</title>
		<link>http://gamedevjuice.wordpress.com/2008/03/25/this-blog-is-moving/</link>
		<comments>http://gamedevjuice.wordpress.com/2008/03/25/this-blog-is-moving/#comments</comments>
		<pubDate>Wed, 26 Mar 2008 02:01:53 +0000</pubDate>
		<dc:creator>gamedevjuice</dc:creator>
		
		<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://gamedevjuice.wordpress.com/?p=22</guid>
		<description><![CDATA[This blog will be discontinued here at wordpress and will be moved to blogger, so please update your feed to:
http://www.gamedevjuice.blogspot.com/
Cheers.
Martin.
       ]]></description>
			<content:encoded><![CDATA[<div class='snap_preview'><br /><p>This blog will be discontinued here at wordpress and will be moved to blogger, so please update your feed to:</p>
<p><a href="http://www.gamedevjuice.blogspot.com/">http://www.gamedevjuice.blogspot.com/</a></p>
<p>Cheers.</p>
<p>Martin.</p>
<img alt="" border="0" src="http://feeds.wordpress.com/1.0/categories/gamedevjuice.wordpress.com/22/" /> <img alt="" border="0" src="http://feeds.wordpress.com/1.0/tags/gamedevjuice.wordpress.com/22/" /> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/gamedevjuice.wordpress.com/22/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/gamedevjuice.wordpress.com/22/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/gamedevjuice.wordpress.com/22/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/gamedevjuice.wordpress.com/22/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/gamedevjuice.wordpress.com/22/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/gamedevjuice.wordpress.com/22/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/gamedevjuice.wordpress.com/22/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/gamedevjuice.wordpress.com/22/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/gamedevjuice.wordpress.com/22/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/gamedevjuice.wordpress.com/22/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=gamedevjuice.wordpress.com&blog=2875767&post=22&subd=gamedevjuice&ref=&feed=1" /></div>]]></content:encoded>
			<wfw:commentRss>http://gamedevjuice.wordpress.com/2008/03/25/this-blog-is-moving/feed/</wfw:commentRss>
	
		<media:content url="http://a.wordpress.com/avatar/gamedevjuice-128.jpg" medium="image">
			<media:title type="html">Martingo</media:title>
		</media:content>
	</item>
		<item>
		<title>GotAPI.com</title>
		<link>http://gamedevjuice.wordpress.com/2008/03/20/gotapicom/</link>
		<comments>http://gamedevjuice.wordpress.com/2008/03/20/gotapicom/#comments</comments>
		<pubDate>Thu, 20 Mar 2008 19:36:05 +0000</pubDate>
		<dc:creator>gamedevjuice</dc:creator>
		
		<category><![CDATA[Programming]]></category>

		<category><![CDATA[languages]]></category>

		<category><![CDATA[reference]]></category>

		<guid isPermaLink="false">http://gamedevjuice.wordpress.com/?p=20</guid>
		<description><![CDATA[www.gotapi.com
 I wanted to share this incredibly useful web site. No matter in what language you program this site is the equivalent to a Victorinox Swiss army pocket knife for a programmer. GotApi is a web language reference for a lot of languages and APIs. This is the supported stuff:



HTML / CSS / JavaScript
HTML at [...]]]></description>
			<content:encoded><![CDATA[<div class='snap_preview'><br /><p><a href="http://www.gotapi.com" title="GotAPI">www.gotapi.com</a></p>
<p><a href="http://gamedevjuice.files.wordpress.com/2008/03/gotapi.png" title="gotapi.png"><img src="http://gamedevjuice.files.wordpress.com/2008/03/gotapi.thumbnail.png" alt="gotapi.png" align="left" /></a> I wanted to share this incredibly useful web site. No matter in what language you program this site is the equivalent to a Victorinox Swiss army pocket knife for a programmer. GotApi is a web language reference for a lot of languages and APIs. This is the supported stuff:</p>
<table class="quickLinkTable" border="0" cellpadding="0" cellspacing="0">
<tr>
<td valign="top">
<h3>HTML / CSS / JavaScript</h3>
<p><span class="quickLink">HTML <span class="quickLinkSmall">at htmlhelp.com</span></span><br />
&lt;!&#8211; <span class="quickLink">HTML <span class="quickLinkSmall">at msdn.microsoft.com</span></span><br />
&#8211;&gt;                 <span class="quickLink">HTML <span class="quickLinkSmall">at w3.org</span></span><br />
<span class="quickLink">CSS <span class="quickLinkSmall">at htmlhelp.com</span></span><br />
<span class="quickLink">CSS <span class="quickLinkSmall">at msdn.microsoft.com</span></span><br />
<span class="quickLink">CSS2 <span class="quickLinkSmall">at w3schools.com</span></span><br />
<span class="quickLink">JavaScript/DOM <span class="quickLinkSmall">at w3schools.com</span></span><br />
<span class="quickLink">JavaScript/DOM on Firefox <span class="quickLinkSmall">at mozilla.org</span></span></p>
<h3>AJAX and Frameworks</h3>
<p><span class="quickLink">Google GWT</span><br />
<span class="quickLink">Prototype.js v1.5 <span class="quickLinkSmall">sergiopereira.com</span></span><br />
<span class="quickLink">Prototype.js v1.5 <span class="quickLinkSmall">prototypejs.org</span></span> -<span class="hblock">Dusan Maliarik</span> <span class="newMark"><sup>New</sup></span><br />
<span class="quickLink">jQuery 1.0.3</span> <span class="hblock">- Rich Manalang</span><br />
<span class="quickLink">Yahoo! UI</span> <span class="hblock"> - Misha Peric</span><br />
<span class="quickLink">MochiKit</span> <span class="hblock"> - Arnar Birgisson</span></p>
<h3>XML</h3>
<p><span class="quickLink">XSL <span class="quickLinkSmall">at w3schools.com</span></span><br />
<span class="quickLink">XPath <span class="quickLinkSmall">at w3schools.com</span></span><br />
<span class="quickLink">Schema (XSD) <span class="quickLinkSmall">at w3schools.com</span></span><br />
<span class="quickLink">XML DOM <span class="quickLinkSmall">at w3.org</span></span><br />
<span class="quickLink">DITA XML <span class="quickLinkSmall">at oasis-open.org</span></span><br />
<span class="quickLink">DocBook <span class="quickLinkSmall">at docbook.org</span></span></p>
<h3>C/C++</h3>
<p><span class="quickLink">C, C++, STL <span class="quickLinkSmall">at cppreference.com</span></span><br />
<span class="quickLink">RogueWave <span class="quickLinkSmall">at roguewave.com</span></span><br />
<span class="quickLink">Dinkumware C/C++/STL</span> <span class="hblock"> - Jason Petrone</span><br />
<span class="quickLink">Berkeley DB XML</span> <span class="hblock"> - Michael Driscoll<br />
<span class="quickLink">OpenGL 2.1</span> <span class="hblock"> - James Darpinian</span><br />
</span></td>
<td>&nbsp;</td>
<td valign="top">
<h3>PHP</h3>
<p><span class="quickLink">PHP <span class="quickLinkSmall">at php.net</span></span><br />
<span class="quickLink">PHP Tutorials <span class="quickLinkSmall">600 from misc. sources</span></span><br />
<span class="quickLink">CakePHP <span class="quickLinkSmall">at cakephp.org</span></span><br />
<span class="quickLink">Symfony <span class="quickLinkSmall">at symfony-project.com</span></span></p>
<h3>Ruby / Rails</h3>
<p><span class="quickLink">Ruby / Rails <span class="quickLinkSmall">at ruby-doc.org &amp; rubyonrails.com</span></span><br />
<span class="quickLink">Ruby Standard Packages <span class="quickLinkSmall">at ruby-doc.org</span></span><br />
<span class="quickLink">RMagic <span class="quickLinkSmall">simplesystems.org</span></span> <span class="hblock"> - K. Adam Christensen</span></p>
<h3>Python</h3>
<p><span class="quickLink">Python <span class="quickLinkSmall">at docs.python.org</span></span></p>
<h3>More Programming Languages</h3>
<p><span class="quickLink">Sicstus Prolog</span> <span class="hblock"><br />
<span class="quickLink">Perl <span class="quickLinkSmall">at activestate.com</span></span> - Rowan Nairn<br />
<span class="quickLink">Erlang</span> <span class="hblock"> -  Matthew Pflueger</span></span></p>
<h3>Adobe / Macromedia</h3>
<p><span class="quickLink">ActionScript</span><br />
<span class="quickLink">ActionScript (frames)</span><br />
<span class="quickLink">ColdFusion Tags/Functions</span><br />
<span class="quickLink">Flex 2</span></p>
<h3>Groovy</h3>
<p><span class="quickLink">Groovy 1.1 beta 1</span>                 <span class="hblock">- Marc Dexet</span> <span class="newMark"><sup>Updated</sup></span></p>
<h3>Drupal CMS</h3>
<p><span class="quickLink">Drupal 4.7/HEAD</span> 				<span class="hblock">- Z.Karman</span></p>
<h3>Flickr</h3>
<p><span class="quickLink">Flickr API</span> 				<span class="hblock">- parhuzamos</span></p>
<h3>Orb API</h3>
<p><span class="quickLink">Orb API</span> <span class="hblock"> - Orb Networks<br />
</span></td>
<td>&nbsp;</td>
<td valign="top">
<h3>Databases</h3>
<p><span class="quickLink">MySQL <span class="quickLinkSmall">at mysql.com</span></span><br />
<span class="quickLink">PostgreSQL <span class="quickLinkSmall">at postgresql.org</span></span><br />
<span class="quickLink">Oracle9i</span><br />
<span class="quickLink">Oracle10g</span></p>
<h3>Java</h3>
<p><span class="quickLink">J2SE v1.3.0</span><br />
<span class="quickLink">J2SE v1.4.2</span><br />
<span class="quickLink">J2SE v1.5.0</span><br />
<span class="quickLink">J2SE v1.5</span> 					<span style="font-size:9px;color:#a0a0a0;">faster without AWT/Swing</span><br />
<span class="quickLink">J2EE</span><br />
<span class="quickLink">Struts</span><br />
<span class="quickLink">Spring Framework</span><br />
<span class="quickLink">Hibernate</span><br />
<span class="quickLink">Castor</span><br />
<span class="quickLink">Log4J</span><br />
<span class="quickLink">Apache RegExp</span><br />
<span class="quickLink">Apache Commons Net</span></p>
<h3>Application Testing</h3>
<p><span class="quickLink">JUnit</span><br />
<span class="quickLink">HttpUnit</span><br />
<span class="quickLink">DbUnit</span><br />
<span class="quickLink">Selenium</span> <span class="hblock"> - Tom Smyth</span></p>
<h3>Java2ME</h3>
<p><span class="quickLink">expand&#8230;</span></p>
<div style="display:none;"> 				<a href="http://www.gotapi.com/intro/ccpp.html#" class="quickLink">CDC <span class="quickLinkSmall">Connected Device Conf v1.1.2</span></a><br />
<a href="http://www.gotapi.com/intro/ccpp.html#" class="quickLink">MIDP <span class="quickLinkSmall">Mobile Inf. Device Profile v2.0</span></a><br />
<a href="http://www.gotapi.com/intro/ccpp.html#" class="quickLink">CLDC <span class="quickLinkSmall">Connected Ltd Device Conf v1.1</span></a><br />
<a href="http://www.gotapi.com/intro/ccpp.html#" class="quickLink">FP <span class="quickLinkSmall">Foundation Profile v1.1.2</span></a><br />
<a href="http://www.gotapi.com/intro/ccpp.html#" class="quickLink">PBP <span class="quickLinkSmall">Personal Basis Profile v1.1.2</span></a><br />
<a href="http://www.gotapi.com/intro/ccpp.html#" class="quickLink">Bluetooth and OBEX <span class="quickLinkSmall">v1.1</span></a><br />
<a href="http://www.gotapi.com/intro/ccpp.html#" class="quickLink">Web Services <span class="quickLinkSmall">v1.0</span></a><br />
<a href="http://www.gotapi.com/intro/ccpp.html#" class="quickLink">Mobile Media <span class="quickLinkSmall">v1.2</span></a></div>
<h3>Apache Ant</h3>
<p><span class="quickLink">Ant <span class="quickLinkSmall">at ant.apache.com</span></span></td>
</tr>
</table>
<img alt="" border="0" src="http://feeds.wordpress.com/1.0/categories/gamedevjuice.wordpress.com/20/" /> <img alt="" border="0" src="http://feeds.wordpress.com/1.0/tags/gamedevjuice.wordpress.com/20/" /> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/gamedevjuice.wordpress.com/20/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/gamedevjuice.wordpress.com/20/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/gamedevjuice.wordpress.com/20/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/gamedevjuice.wordpress.com/20/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/gamedevjuice.wordpress.com/20/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/gamedevjuice.wordpress.com/20/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/gamedevjuice.wordpress.com/20/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/gamedevjuice.wordpress.com/20/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/gamedevjuice.wordpress.com/20/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/gamedevjuice.wordpress.com/20/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=gamedevjuice.wordpress.com&blog=2875767&post=20&subd=gamedevjuice&ref=&feed=1" /></div>]]></content:encoded>
			<wfw:commentRss>http://gamedevjuice.wordpress.com/2008/03/20/gotapicom/feed/</wfw:commentRss>
	
		<media:content url="http://a.wordpress.com/avatar/gamedevjuice-128.jpg" medium="image">
			<media:title type="html">Martingo</media:title>
		</media:content>

		<media:content url="http://gamedevjuice.files.wordpress.com/2008/03/gotapi.thumbnail.png" medium="image">
			<media:title type="html">gotapi.png</media:title>
		</media:content>
	</item>
		<item>
		<title>BitmapMovieClip</title>
		<link>http://gamedevjuice.wordpress.com/2008/03/07/bitmapmovieclip/</link>
		<comments>http://gamedevjuice.wordpress.com/2008/03/07/bitmapmovieclip/#comments</comments>
		<pubDate>Fri, 07 Mar 2008 06:32:57 +0000</pubDate>
		<dc:creator>gamedevjuice</dc:creator>
		
		<category><![CDATA[Actionscript]]></category>

		<category><![CDATA[flash]]></category>

		<category><![CDATA[animations]]></category>

		<category><![CDATA[as3]]></category>

		<category><![CDATA[bitmap]]></category>

		<category><![CDATA[BitmapMovieClip]]></category>

		<category><![CDATA[flex]]></category>

		<category><![CDATA[movieclip]]></category>

		<category><![CDATA[sprite]]></category>

		<category><![CDATA[sprites]]></category>

		<guid isPermaLink="false">http://gamedevjuice.wordpress.com/?p=16</guid>
		<description><![CDATA[In some cases in a project, we need to use striped sprites, it means an an animation of bitmaps which has their frames arranged in rows or columns like the examples below:




Sometimes the output of some graphic tools are this kind of sprite, for example this explosion generator: http://www.geocities.com/starlinesinc Actionscript do not brings anything built-in [...]]]></description>
			<content:encoded><![CDATA[<div class='snap_preview'><br /><p>In some cases in a project, we need to use striped sprites, it means an an animation of bitmaps which has their frames arranged in rows or columns like the examples below:</p>
<p><a href="http://gamedevjuice.files.wordpress.com/2008/03/explode_1.png" title="explode_1.png"></a></p>
<div style="text-align:center;"><a href="http://gamedevjuice.files.wordpress.com/2008/03/explode_1.png" title="explode_1.png"><img src="http://gamedevjuice.files.wordpress.com/2008/03/explode_1.png" alt="explode_1.png" /></a></div>
<p><a href="http://gamedevjuice.files.wordpress.com/2008/03/water_exp.png" title="water_exp.png"></a></p>
<div style="text-align:center;"><a href="http://gamedevjuice.files.wordpress.com/2008/03/water_exp.png" title="water_exp.png"><img src="http://gamedevjuice.files.wordpress.com/2008/03/water_exp.png" alt="water_exp.png" /></a></div>
<p>Sometimes the output of some graphic tools are this kind of sprite, for example this explosion generator: <a href="http://www.geocities.com/starlinesinc/">http://www.geocities.com/starlinesinc</a> Actionscript do not brings anything built-in to handle this kind of sprites what I called Bitmap MovieClip, so I created a handy class to handle this situations where we need want to create an animation from an array of frames on an image.<br />
The result is something like this:</p>
<p align="center"> <a href="http://gamedevjuice.wordpress.com/2008/03/07/bitmapmovieclip/19/" rel="attachment wp-att-19" title="bmpmovieclip.png"></a></p>
<div style="text-align:center;"><a href="http://www.webklan.com/martin/gdj/TestMClip.html" title="bmpmovieclip.png"><img src="http://gamedevjuice.files.wordpress.com/2008/03/bmpmovieclip.thumbnail.png" alt="bmpmovieclip.png" /></a></div>
<p><span id="more-16"></span><br />
The use of this class is very simple and is not too different from using a regular <a href="http://livedocs.adobe.com/flex/2/langref/flash/display/MovieClip.html">MovieClip,</a> in fact the class IS a <a href="http://livedocs.adobe.com/flex/2/langref/flash/display/MovieClip.html">MovieClip,</a> BitmapMovieClip inherits from the MovieClip class and can be treated like that.</p>
<pre name="code" class="jscript">

public function TestMClip()
{

         mBmpClip = new BitmapMovieClip( new explode(), 4,4);

         this.addChild( mBmpClip );
         mBmpClip.frameDelay = 40 ;
         mBmpClip.loopTimes = 0 ;
         mBmpClip.play();

         mBmpClipB = new BitmapMovieClip( new orb(), 1,5);
         mBmpClipB.y = 150 ;
         this.addChild( mBmpClipB );
         mBmpClipB.frameDelay = 100 ;
         mBmpClipB.loopTimes = 0 ;
         mBmpClipB.play();
}
</pre>
<p>The constructor receive three parameters. The first is the Bitmap with the frames of the animation, the second and third are rows and column respectively it means how many rows and columns the animation has, for example in our first example shown previously our explosion has four rows and four columns, while the second animations has only one row and five columns.<br />
The <i>frameDelay</i> property is a measure of time in miliseconds, is the time what the frame will be shown before to switch to the next animation frame.<br />
The <i>loopTimes</i> property is the number of times what the animation will be played, if this is zero the loop will be for ever.<br />
The play method must be called to start running the animation. And thats it.<br />
You can find the source of this sample and the BitmapMovieClip class <a href="http://www.webklan.com/martin/gdj/TestMClip.zip">here.</a></p>
<img alt="" border="0" src="http://feeds.wordpress.com/1.0/categories/gamedevjuice.wordpress.com/16/" /> <img alt="" border="0" src="http://feeds.wordpress.com/1.0/tags/gamedevjuice.wordpress.com/16/" /> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/gamedevjuice.wordpress.com/16/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/gamedevjuice.wordpress.com/16/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/gamedevjuice.wordpress.com/16/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/gamedevjuice.wordpress.com/16/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/gamedevjuice.wordpress.com/16/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/gamedevjuice.wordpress.com/16/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/gamedevjuice.wordpress.com/16/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/gamedevjuice.wordpress.com/16/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/gamedevjuice.wordpress.com/16/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/gamedevjuice.wordpress.com/16/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=gamedevjuice.wordpress.com&blog=2875767&post=16&subd=gamedevjuice&ref=&feed=1" /></div>]]></content:encoded>
			<wfw:commentRss>http://gamedevjuice.wordpress.com/2008/03/07/bitmapmovieclip/feed/</wfw:commentRss>
	
		<media:content url="http://a.wordpress.com/avatar/gamedevjuice-128.jpg" medium="image">
			<media:title type="html">Martingo</media:title>
		</media:content>

		<media:content url="http://gamedevjuice.files.wordpress.com/2008/03/explode_1.png" medium="image">
			<media:title type="html">explode_1.png</media:title>
		</media:content>

		<media:content url="http://gamedevjuice.files.wordpress.com/2008/03/water_exp.png" medium="image">
			<media:title type="html">water_exp.png</media:title>
		</media:content>

		<media:content url="http://gamedevjuice.files.wordpress.com/2008/03/bmpmovieclip.thumbnail.png" medium="image">
			<media:title type="html">bmpmovieclip.png</media:title>
		</media:content>
	</item>
		<item>
		<title>Got DS</title>
		<link>http://gamedevjuice.wordpress.com/2008/03/03/got-ds/</link>
		<comments>http://gamedevjuice.wordpress.com/2008/03/03/got-ds/#comments</comments>
		<pubDate>Mon, 03 Mar 2008 16:28:42 +0000</pubDate>
		<dc:creator>gamedevjuice</dc:creator>
		
		<category><![CDATA[DS]]></category>

		<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://gamedevjuice.wordpress.com/?p=15</guid>
		<description><![CDATA[Finally after a long wait  I got a Nintedo DS.

I also bought a R4, so after a long season of gaming I will start to diving into the nuts and bolts of DS game programming.
       ]]></description>
			<content:encoded><![CDATA[<div class='snap_preview'><br /><p>Finally after a long wait  I got a Nintedo DS.</p>
<div style="text-align:center;"><img src="http://jhernandez.gpltarragona.org/varios/Nintendo_DS_Lite.jpg" height="350" width="420" /></div>
<p>I also bought a R4, so after a long season of gaming I will start to diving into the nuts and bolts of DS game programming.</p>
<img alt="" border="0" src="http://feeds.wordpress.com/1.0/categories/gamedevjuice.wordpress.com/15/" /> <img alt="" border="0" src="http://feeds.wordpress.com/1.0/tags/gamedevjuice.wordpress.com/15/" /> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/gamedevjuice.wordpress.com/15/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/gamedevjuice.wordpress.com/15/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/gamedevjuice.wordpress.com/15/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/gamedevjuice.wordpress.com/15/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/gamedevjuice.wordpress.com/15/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/gamedevjuice.wordpress.com/15/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/gamedevjuice.wordpress.com/15/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/gamedevjuice.wordpress.com/15/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/gamedevjuice.wordpress.com/15/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/gamedevjuice.wordpress.com/15/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=gamedevjuice.wordpress.com&blog=2875767&post=15&subd=gamedevjuice&ref=&feed=1" /></div>]]></content:encoded>
			<wfw:commentRss>http://gamedevjuice.wordpress.com/2008/03/03/got-ds/feed/</wfw:commentRss>
	
		<media:content url="http://a.wordpress.com/avatar/gamedevjuice-128.jpg" medium="image">
			<media:title type="html">Martingo</media:title>
		</media:content>

		<media:content url="http://jhernandez.gpltarragona.org/varios/Nintendo_DS_Lite.jpg" medium="image" />
	</item>
		<item>
		<title>Considerations in Collision Detection with PV3D</title>
		<link>http://gamedevjuice.wordpress.com/2008/02/28/considerations-in-collision-detection-with-pv3d/</link>
		<comments>http://gamedevjuice.wordpress.com/2008/02/28/considerations-in-collision-detection-with-pv3d/#comments</comments>
		<pubDate>Thu, 28 Feb 2008 19:59:08 +0000</pubDate>
		<dc:creator>gamedevjuice</dc:creator>
		
		<category><![CDATA[Actionscript]]></category>

		<category><![CDATA[Papervision3D]]></category>

		<category><![CDATA[flash]]></category>

		<category><![CDATA[collision]]></category>

		<category><![CDATA[collision detection]]></category>

		<category><![CDATA[hitTest]]></category>

		<category><![CDATA[papervision]]></category>

		<category><![CDATA[pv3d]]></category>

		<guid isPermaLink="false">http://gamedevjuice.wordpress.com/?p=13</guid>
		<description><![CDATA[
 use left and right arrows.
The collision detection in Papervision3D is not a big deal. Is easy to detect collision between two DisplayObject3D for that task PV3D provide us with two methods

public function hitTestPoint( x:Number, y:Number, z:Number ):Boolean

public function hitTestObject( obj:DisplayObject3D,multiplier:Number=1 ):Boolean

The first method is to test if the current DisplayObject3D is hitting a point [...]]]></description>
			<content:encoded><![CDATA[<div class='snap_preview'><br /><div style="text-align:center;"><a href="http://www.webklan.com/martin/gdj/tempPVTestCollision.html" title="col.png"><img src="http://gamedevjuice.files.wordpress.com/2008/02/col.thumbnail.png" alt="col.png" /></a></div>
<div align="center"> use left and right arrows.</div>
<p>The collision detection in Papervision3D is not a big deal. Is easy to detect collision between two DisplayObject3D for that task PV3D provide us with two methods</p>
<pre name="code" class="jscript">
public function hitTestPoint( x:Number, y:Number, z:Number ):Boolean

public function hitTestObject( obj:DisplayObject3D,multiplier:Number=1 ):Boolean
</pre>
<p>The first method is to test if the current DisplayObject3D is hitting a point in the scene and the second one is to detect if the current object is hitting another DisplayObject3D in the scene.<br />
This is quite similar to the display architecture used by flash and its DisplayObject the difference is when we have a main DisplayObject3D with other objects 3D as childs.<br />
In that case we would be tempted to use hitTestObject assuming that the collision test will be tested using the parent DisplayObject3D and their childs but that is wrong.<br />
<span id="more-13"></span><br />
Lets suppose that we have a parent DisplayObject3D A on our Scene and inside that object we have a Collada mesh object which has been added to A at initialization time. Inside the main loop I&#8217;d like to test if my object A is hitting another DisplayObject3D called B which has and sphere object as child.<br />
To do this I use something like this:</p>
<pre name="code" class="jscript">

if( A.hitTestObject(B) )
{
	trace(&quot;hit&quot;);
}
</pre>
<p>This would never do what we expected to do. The hit test between A and B will never return true. Let&#8217;s see why. The main reason is that the hit test of a DisplayObject3D do not take in consideration their childs, it only use the geometry of current object and the geometry of the object received as parameter.<br />
When I say geometry I am referring to the &#8220;geometry&#8221; member of the class DisplayObject3D which its is GeometryObject3D.<br />
From the PV3D documentation:&#8221;When different objects share the same geometry, they become instances. They are the same object, displayed multiple times. Changing the shape of this object changes the shape of all of its instances.<br />
Instancing an object saves system memory, and is useful to display an object multiple times while maintaining its shape.<br />
For example, you could create armies and forests full of duplicate objects without needing the memory to handle that much actual geometry. Each instance has its own transform node so it can have its own position, rotation, and scaling.&#8221;When we create an empty DisplayObject3D in this way:</p>
<pre name="code" class="jscript">
private var mContA:DisplayObject3D = new DisplayObject3D();
</pre>
<p>The geometry of the mContA is set to null so when the hit test is made there is no geometry object to test if the two objects are colliding.<br />
One possible solution is assign to the geometry of the parent the geometry of the child what you want to be used when the hiTestObject is called.<br />
Other solution is evaluate your collision using dummy DisplayObject3D attached to the object what you want to test collision, so when you call hitTestObject you do it on the dummy object for example an sphere or a plane.<br />
A third possible solution is use the following function what I made using the PV3D code for hitTestObject but I just add two extra arguments, geometries. So you give the parents DisplayObject3D as parameter and the geometries of their childs what will be used in the hit test.<br />
You can find a sample source code of this case <a href="http://www.webklan.com/martin/gdj/PVTestCollision.zip">here.</a></p>
<img alt="" border="0" src="http://feeds.wordpress.com/1.0/categories/gamedevjuice.wordpress.com/13/" /> <img alt="" border="0" src="http://feeds.wordpress.com/1.0/tags/gamedevjuice.wordpress.com/13/" /> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/gamedevjuice.wordpress.com/13/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/gamedevjuice.wordpress.com/13/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/gamedevjuice.wordpress.com/13/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/gamedevjuice.wordpress.com/13/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/gamedevjuice.wordpress.com/13/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/gamedevjuice.wordpress.com/13/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/gamedevjuice.wordpress.com/13/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/gamedevjuice.wordpress.com/13/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/gamedevjuice.wordpress.com/13/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/gamedevjuice.wordpress.com/13/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=gamedevjuice.wordpress.com&blog=2875767&post=13&subd=gamedevjuice&ref=&feed=1" /></div>]]></content:encoded>
			<wfw:commentRss>http://gamedevjuice.wordpress.com/2008/02/28/considerations-in-collision-detection-with-pv3d/feed/</wfw:commentRss>
	
		<media:content url="http://a.wordpress.com/avatar/gamedevjuice-128.jpg" medium="image">
			<media:title type="html">Martingo</media:title>
		</media:content>

		<media:content url="http://gamedevjuice.files.wordpress.com/2008/02/col.thumbnail.png" medium="image">
			<media:title type="html">col.png</media:title>
		</media:content>
	</item>
		<item>
		<title>Particle System for Papervision3D</title>
		<link>http://gamedevjuice.wordpress.com/2008/02/22/particle-system-for-papervision3d/</link>
		<comments>http://gamedevjuice.wordpress.com/2008/02/22/particle-system-for-papervision3d/#comments</comments>
		<pubDate>Fri, 22 Feb 2008 18:26:57 +0000</pubDate>
		<dc:creator>gamedevjuice</dc:creator>
		
		<category><![CDATA[Actionscript]]></category>

		<category><![CDATA[Papervision3D]]></category>

		<category><![CDATA[flash]]></category>

		<category><![CDATA[papervision]]></category>

		<category><![CDATA[pv3d]]></category>

		<category><![CDATA[effects]]></category>

		<category><![CDATA[particles]]></category>

		<category><![CDATA[particle system]]></category>

		<guid isPermaLink="false">http://gamedevjuice.wordpress.com/?p=11</guid>
		<description><![CDATA[ 	 	 	 	 	A few weeks ago I made some modifications to the Zeus Lab particle system for Actionscript made by Josh Tynjala . The Josh&#8217;s particle system is neat, simple and if you combine the particle system with the use of filter you can obtain beautiful visual effects. I wanted to continue [...]]]></description>
			<content:encoded><![CDATA[<div class='snap_preview'><br /><p><title></title> 	 	 	 	<!-- 		@page { size: 21cm 29.7cm; margin: 2cm } 	--> 	A few weeks ago I made some modifications to the <a href="http://www.zeuslabs.us/2006/05/09/introduction-to-particle-systems-using-actionscript-3/">Zeus Lab particle system</a> for Actionscript made by <a href="http://www.zeuslabs.us/">Josh Tynjala</a> . The Josh&#8217;s particle system is neat, simple and if you combine the particle system with the use of filter you can obtain beautiful visual effects. I wanted to continue using it while experimenting with Papervision, the only problem is that it is 2D, so I made the port of the particle system to make it usable in a 3D environment, the result was some kind of distribution of the particle system because I didn&#8217;t touch the 2D code I only extended to be usable with the display architecture and classes in PV3D.</p>
<p>In the following example I will explain how to use it combined with the Effects branch to obtain something like this:</p>
<p><a href="http://gamedevjuice.files.wordpress.com/2008/02/particle.png" title="particle.png"></a></p>
<div style="text-align:center;"><a href="http://www.webklan.com/martin/gdj/ParticleTestv2.html" target="_blank" title="particle.png"><img src="http://gamedevjuice.files.wordpress.com/2008/02/particle.png" alt="particle.png" /></a></div>
<p><span id="more-11"></span><br />
Let&#8217;s see how this is done:</p>
<p><title></title> 	 	 	 	<!-- 		@page { size: 21cm 29.7cm; margin: 2cm } 	--></p>
<p>The first we need is a ParticleSystem3D:</p>
<pre name="code" class="jscript">

pSys = new ParticleSystem3D(this.stage);
pSys.spawnRate = 4;
pSys.particleClass = SimpleParticle3D ;
pSys.start();
</pre>
<p><title></title>                          	 	 	<!-- 		@page { size: 21cm 29.7cm; margin: 2cm } 	--> 	ParticleSystem3D receive the stage for parameter, which is used to add a listener to the ENTER_FRAME Event.<br />
The SpawnRate is the rate of spawn particles, this means that if this value is higher you obtain more particles spawned per second.<br />
The particleClass property is the class or data type used by the particle system there are two types of particles for this tutorial, I used SimpleParticle3D only, the other type of particle BillBoardParticle3D is a billboard but I can&#8217;t make it work with the Effect branch yet. With the particleClass property set, the ParticleSystem3D knows which particle should create when we start it.<br />
Finally we should start the particle system so we call its method start.</p>
<pre name="code" class="jscript">

mScene.addChild(this.pSys);
this.pSys.addEventListener( ParticleEvent.INITIALIZE_PARTICLE, initializeParticle);
this.pSys.addEventListener(ParticleEvent.UPDATE_PARTICLE, updateWaterParticle);
</pre>
<p>After initialize the particle system we must add it to the scene, ParticleSystem3D is a DisplayObject3D. We also add event listeners for the events INITIALIZE and UPDATE_PARTICLE. The INITIALIZE Event of a particle is dispatched once when the particle is created the first time and the UPDATE_PARTICLE event is dispatched every time what the particle is updated, it means in every frame. There is a third particle event that you can listen and is not used here it is DESTROY_PARTICLE, this event is dispatched when the life time of the particle ends.The following section of code do the effect tricks:</p>
<pre name="code" class="jscript">
// Create a bitmap effect layer
mBfx = new BitmapEffectLayer(400, 400);
// Add a blur effect to the layer.
mBfx.addEffect(new BitmapLayerEffect(new BlurFilter(5, 5, 4)));
// add the effect layer to the viewport
mViewport.addRenderLayer(mBfx);
// Create a draw command for the visual effect
mBfx.drawCommand = new BitmapDrawCommand(null, new ColorTransform(0.3, 0.8, 0.6, 1), BlendMode.ADD);
// Set the blend mode of the effect layer
mBfx.drawLayer.blendMode = BlendMode.OVERLAY;
// Set a little scroll in y for the effect layer.
mBfx.setScroll(0,-0.5);

RenderLayerManager.getInstance().sortMode = RenderLayerSortMode.Z_SORT;
</pre>
<p>I will not explain what is done here because is beyond the scope of this tutorial, if you want to understand what happens here see the Andy Zupko Tutorial <a href="http://blog.zupko.info/?p=76">here.</a><title></title>    	 	 	 	 	<!-- 		@page { size: 21cm 29.7cm; margin: 2cm } 		P { margin-bottom: 0.21cm } 	--></p>
<pre name="code" class="jscript">
private function initializeParticle(event:ParticleEvent):void
{
 var particle:SimpleParticle3D = event.particle as SimpleParticle3D;
 particle.renderLayer = mBfx ;

	particle.size = 1.5;
 particle.lifetime = 2000;

	particle.position = new Number3D(0, Math.random() * this.stage.stageHeight / 8,0);

	var width:Number = this.stage.stageWidth / 100;
 particle.velocity = new Number3D(Math.random() * width - width / 2, this.stage.stageHeight / 8,Math.random() * width - width / 2);
}
</pre>
<p>This is the method added as listener of the initialize event for a particle. In this function we set the initial values for the render layer, the size, life time, position and velocity of the particle.</p>
<pre name="code" class="jscript">
private function updateParticle(event:ParticleEvent):void
{
 var particle:SimpleParticle3D = event.particle as SimpleParticle3D;
 var age:Number = getTimer() - particle.spawnTime;

	particle.size = particle.size + 0.05;

	var vX:Number = particle.spawnVelocity.x;
 if(age / particle.lifetime &gt;= 0.25)
 {
 	vX = particle.spawnVelocity.x * 6;
 }

	var vZ:Number =  particle.velocity.z ;
 if(age / particle.lifetime &gt;= 0.25)
 {
 	vZ = particle.spawnVelocity.z * 8;
 }

	var vY:Number =  particle.velocity.y - 5;

	particle.velocity = new Number3D(vX, vY, vZ); 

}
</pre>
<p>And this is the Update function for every particle update, in this function we change the particle velocity to obtain some kind of fountain effect and thats it.You can find the source code of the <a href="http://www.webklan.com/martin/gdj/ParticleTestv2.zip">example here</a>. And you can download Zeus Particles 3D version <a href="http://www.webklan.com/martin/gdj/ZeusParticles3Dv2.zip">release here</a>.</p>
<p>Sources:<a href="http://blog.zupko.info/?p=76">http://blog.zupko.info/?p=76</a><a href="http://blog.zupko.info/?p=76"></a><a href="http://www.zeuslabs.us/2006/05/09/introduction-to-particle-systems-using-actionscript-3/">http://www.zeuslabs.us/2006/05/09/introduction-to-particle-systems-using-actionscript-3/</a></p>
<p>Update: You can find a release of the particle system for PV3D 1.7  <a href="http://www.webklan.com/martin/gdj/ZeusParticles3D.zip">here</a> .</p>
<img alt="" border="0" src="http://feeds.wordpress.com/1.0/categories/gamedevjuice.wordpress.com/11/" /> <img alt="" border="0" src="http://feeds.wordpress.com/1.0/tags/gamedevjuice.wordpress.com/11/" /> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/gamedevjuice.wordpress.com/11/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/gamedevjuice.wordpress.com/11/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/gamedevjuice.wordpress.com/11/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/gamedevjuice.wordpress.com/11/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/gamedevjuice.wordpress.com/11/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/gamedevjuice.wordpress.com/11/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/gamedevjuice.wordpress.com/11/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/gamedevjuice.wordpress.com/11/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/gamedevjuice.wordpress.com/11/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/gamedevjuice.wordpress.com/11/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=gamedevjuice.wordpress.com&blog=2875767&post=11&subd=gamedevjuice&ref=&feed=1" /></div>]]></content:encoded>
			<wfw:commentRss>http://gamedevjuice.wordpress.com/2008/02/22/particle-system-for-papervision3d/feed/</wfw:commentRss>
	
		<media:content url="http://a.wordpress.com/avatar/gamedevjuice-128.jpg" medium="image">
			<media:title type="html">Martingo</media:title>
		</media:content>

		<media:content url="http://gamedevjuice.files.wordpress.com/2008/02/particle.png" medium="image">
			<media:title type="html">particle.png</media:title>
		</media:content>
	</item>
		<item>
		<title>Bump mapping in flash</title>
		<link>http://gamedevjuice.wordpress.com/2008/02/18/bump-mapping-in-flash/</link>
		<comments>http://gamedevjuice.wordpress.com/2008/02/18/bump-mapping-in-flash/#comments</comments>
		<pubDate>Mon, 18 Feb 2008 18:53:37 +0000</pubDate>
		<dc:creator>gamedevjuice</dc:creator>
		
		<category><![CDATA[Actionscript]]></category>

		<category><![CDATA[Papervision3D]]></category>

		<guid isPermaLink="false">http://gamedevjuice.wordpress.com/?p=6</guid>
		<description><![CDATA[I&#8217;ve been playing around lately with Papervision3D 2.0 which still in alpha yet. But this new version has a lot of new cool features one of the new features are shaders. So make things look like this:


 
PV3D  has differents shaded materials to obtain different visual effects one of these shaded material can be [...]]]></description>
			<content:encoded><![CDATA[<div class='snap_preview'><br /><p>I&#8217;ve been playing around lately with <a href="http://www.papervision3d.org">Papervision3D 2.0</a> which still in alpha yet. But this new version has a lot of new cool features one of the new features are shaders. So make things look like this:</p>
<p><a href="http://www.webklan.com/martin/gdj/bumpmaptest.html" title="mars2.png"></p>
<div style="text-align:center;"><img src="http://gamedevjuice.files.wordpress.com/2008/02/mars2.png" alt="mars2.png" /></div>
<p></a> <span id="more-6"></span></p>
<p>PV3D  has differents shaded materials to obtain different visual effects one of these shaded material can be used to make Bump mapping.<br />
Bump mapping. From <a href="http://en.wikipedia.org/wiki/Bump_mapping">wikipedia</a>:</p>
<p>&#8220;<b>Bump mapping</b> is a <a href="http://en.wikipedia.org/wiki/Computer_graphics" title="Computer graphics">computer graphics</a> technique where at each <a href="http://en.wikipedia.org/wiki/Pixel" title="Pixel">pixel</a>, a perturbation to the <a href="http://en.wikipedia.org/wiki/Surface_normal" title="Surface normal">surface normal</a> of the object being <a href="http://en.wikipedia.org/wiki/Rendering_%28computer_graphics%29" title="Rendering (computer graphics)">rendered</a> is looked up in a <a href="http://en.wikipedia.org/wiki/Heightmap" title="Heightmap">heightmap</a> and applied before the illumination calculation is done (see, for instance, <a href="http://en.wikipedia.org/wiki/Phong_shading" title="Phong shading">Phong shading</a>). The result is a richer, more detailed surface representation that more closely resembles the details inherent in the natural world.&#8221;</p>
<p>For example the surface of an orange. For this  we need two textures one is the normal texture of the object and the second is the bumpmap, see the image below:<br />
<img src="http://upload.wikimedia.org/wikipedia/en/b/b3/Bump-map-demo-smooth.png" align="middle" height="160" width="160" /></p>
<p>Sphere without bump mapping.</p>
<p><img src="http://upload.wikimedia.org/wikipedia/en/thumb/0/0c/Orange-bumpmap.png/160px-Orange-bumpmap.png" height="160" width="160" /></p>
<p>The bump map that is applied to the image below.<br />
And the result is:<br />
<img src="http://upload.wikimedia.org/wikipedia/en/3/30/Bump-map-demo-bumpy.png" height="160" width="160" /></p>
<p>Enough introduction let&#8217;s do this on Papervision.<br />
To do this on PV3D I used a Mars example luckily I found a bump map of Mars in google image.<br />
<a href="http://gamedevjuice.files.wordpress.com/2008/02/marsmap.jpg" title="mars texture"></a></p>
<div style="text-align:center;"><a href="http://gamedevjuice.files.wordpress.com/2008/02/marsmap.jpg" title="mars texture"><img src="http://gamedevjuice.files.wordpress.com/2008/02/marsmap.thumbnail.jpg" alt="mars texture" /></a></div>
<p><a href="http://gamedevjuice.files.wordpress.com/2008/02/marsbumpmap.jpg" title="Mars bump map"></a></p>
<div style="text-align:center;"><a href="http://gamedevjuice.files.wordpress.com/2008/02/marsbumpmap.jpg" title="Mars bump map"><img src="http://gamedevjuice.files.wordpress.com/2008/02/marsbumpmap.thumbnail.jpg" alt="Mars bump map" /></a></div>
<pre name="code" class="jscript">

[SWF(width=&quot;600&quot;, height=&quot;400&quot;, backgroundColor=&quot;#000000&quot;)]
    public class bumpmaptest extends Sprite
    {
        private var mViewport:Viewport3D ;
        private var mRenderEngine:BasicRenderEngine ;
        private var mScene:Scene3D ;

        private var mCamera:WASDCamera ;
        private var mPlanet:Sphere ;

        [Embed (source=&quot;MarsMap.jpg&quot;)]
        private var mMapClass:Class ;
        private var mMapImage:Bitmap = new mMapClass();

        [Embed (source=&quot;MarsBumpMap.jpg&quot;)]
        private var mMarsBumpmapClass:Class
        private var mBumpMapImage:Bitmap = new mMarsBumpmapClass();

        public function bumpmaptest()
        {
            // Create the viewport for the scene
            mViewport = new Viewport3D();
            // We Add the viewport
            addChild( mViewport );
            // Create the render engine.
            mRenderEngine = new BasicRenderEngine();
            // Create scene.
            mScene = new Scene3D();
            //I create a wasd camera so we can navigate the scene
            // using WASD and mouse drag-and-drop
            mCamera = new WASDCamera(stage);
            // set the camera focus.
            mCamera.focus = 1000 ;
	    mCamera.z = -2000 ;

            // To create shadows we need lights.
            var pointLight:PointLight3D = new PointLight3D(true);
            // we place the light.
            pointLight.moveUp(50);
            pointLight.moveRight(50);

            var fMat:BitmapMaterial = new BitmapMaterial( mMapImage.bitmapData );
            var fMatBump:BitmapMaterial = new BitmapMaterial( mBumpMapImage.bitmapData );

            var marsShader:PhongShader = new PhongShader(pointLight, 0xFFFFFF,0&#215;303030,20, fMatBump.bitmap, fMat.bitmap);
            var fMatShaded:ShadedMaterial = new ShadedMaterial(fMat,marsShader);

            mPlanet = new Sphere(fMatShaded,250,16,16);

            mScene.addChild( mPlanet );

            stage.addEventListener(Event.ENTER_FRAME, Loop);

        }

        public function Loop( pEv:Event ):void
        {

            mPlanet.yaw( 0.25 ) ;

            mRenderEngine.renderScene( mScene, mCamera, mViewport );    

        }

    }
</pre>
<p>First we need to BitmapMaterial, one for the Mars Texture and other for the Mars bump map. The Bitmap material receive the bitmapData of the image.</p>
<pre name="code" class="jscript">

var fMat:BitmapMaterial = new BitmapMaterial( mMapImage.bitmapData );
var fMatBump:BitmapMaterial = new BitmapMaterial( mBumpMapImage.bitmapData );
</pre>
<p>After this we need a PhongShader, the PhongShader constructor receives:<br />
PhongShader( our previously created pointLight, the light color, the ambient color, the bumpMap bitmapData, the texture bitmapData or specularMap ) .</p>
<pre name="code" class="jscript">

var marsShader:PhongShader = new PhongShader(pointLight, 0xFFFFFF,0x303030,20, fMatBump.bitmap, fMat.bitmap);
</pre>
<p>Once we have the phong shader we simply need a shader material. We use the BitmapMaterial for mars and the PhongShader convined to create a ShadedMaterial.<br />
ShadedMaterial( Mars bitmapMaterial, and our marsShader a phong shader in this case).</p>
<pre name="code" class="jscript">

var fMatShaded:ShadedMaterial = new ShadedMaterial(fMat,marsShader);
</pre>
<p>After create the ShadedMaterial you can use it wherever you want, in this case I use it on a sphere, but this can be used on loaded models too.</p>
<pre name="code" class="jscript">

mPlanet = new Sphere(fMatShaded,250,16,16);
mScene.addChild( mPlanet );
</pre>
<p>You may find the source code of this example <a href="http://www.webklan.com/martin/gdj/bumpmaptest.zip">here</a>.</p>
<img alt="" border="0" src="http://feeds.wordpress.com/1.0/categories/gamedevjuice.wordpress.com/6/" /> <img alt="" border="0" src="http://feeds.wordpress.com/1.0/tags/gamedevjuice.wordpress.com/6/" /> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/gamedevjuice.wordpress.com/6/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/gamedevjuice.wordpress.com/6/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/gamedevjuice.wordpress.com/6/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/gamedevjuice.wordpress.com/6/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/gamedevjuice.wordpress.com/6/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/gamedevjuice.wordpress.com/6/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/gamedevjuice.wordpress.com/6/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/gamedevjuice.wordpress.com/6/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/gamedevjuice.wordpress.com/6/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/gamedevjuice.wordpress.com/6/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=gamedevjuice.wordpress.com&blog=2875767&post=6&subd=gamedevjuice&ref=&feed=1" /></div>]]></content:encoded>
			<wfw:commentRss>http://gamedevjuice.wordpress.com/2008/02/18/bump-mapping-in-flash/feed/</wfw:commentRss>
	
		<media:content url="http://a.wordpress.com/avatar/gamedevjuice-128.jpg" medium="image">
			<media:title type="html">Martingo</media:title>
		</media:content>

		<media:content url="http://gamedevjuice.files.wordpress.com/2008/02/mars2.png" medium="image">
			<media:title type="html">mars2.png</media:title>
		</media:content>

		<media:content url="http://upload.wikimedia.org/wikipedia/en/b/b3/Bump-map-demo-smooth.png" medium="image" />

		<media:content url="http://upload.wikimedia.org/wikipedia/en/thumb/0/0c/Orange-bumpmap.png/160px-Orange-bumpmap.png" medium="image" />

		<media:content url="http://upload.wikimedia.org/wikipedia/en/3/30/Bump-map-demo-bumpy.png" medium="image" />

		<media:content url="http://gamedevjuice.files.wordpress.com/2008/02/marsmap.thumbnail.jpg" medium="image">
			<media:title type="html">mars texture</media:title>
		</media:content>

		<media:content url="http://gamedevjuice.files.wordpress.com/2008/02/marsbumpmap.thumbnail.jpg" medium="image">
			<media:title type="html">Mars bump map</media:title>
		</media:content>
	</item>
		<item>
		<title>Seven tips about performance optimization in Actionscript 3</title>
		<link>http://gamedevjuice.wordpress.com/2008/02/15/seven-tips-about-performance-optimization-in-actionscript-3/</link>
		<comments>http://gamedevjuice.wordpress.com/2008/02/15/seven-tips-about-performance-optimization-in-actionscript-3/#comments</comments>
		<pubDate>Fri, 15 Feb 2008 18:21:10 +0000</pubDate>
		<dc:creator>gamedevjuice</dc:creator>
		
		<category><![CDATA[Actionscript]]></category>

		<category><![CDATA[flash]]></category>

		<category><![CDATA[optimization]]></category>

		<category><![CDATA[performance]]></category>

		<guid isPermaLink="false">http://gamedevjuice.wordpress.com/?p=5</guid>
		<description><![CDATA[﻿This post is a list of tips and tricks for tunning performance in Actionscript 3. Keep in mind the following quote while reading this:
“Premature Optimization is the root of all evil.” - Hoare and Knuth

1.- Type Everything.
Every variable declaration, every function return value, loop counter, every function parameter must be typed. Avoid things like this:


var [...]]]></description>
			<content:encoded><![CDATA[<div class='snap_preview'><br /><p>﻿This post is a list of tips and tricks for tunning performance in Actionscript 3. Keep in mind the following quote while reading this:</p>
<p>“Premature Optimization is the root of all evil.” - <a href="http://en.wikipedia.org/wiki/Optimization_(computer_science)">Hoare and Knuth</a><br />
<span id="more-5"></span><br />
<b>1.- Type Everything.</b><br />
Every variable declaration, every function return value, loop counter, every function parameter must be typed. Avoid things like this:</p>
<pre name="code" class="jscript">

var foo ;

var foo2:Object ;

var foo:* ;
</pre>
<p>Typing optimizes the bytecode.<b>2.- Avoid implicit types conversion of numeric types.</b> This means:</p>
<pre name="code" class="jscript">

var foo:int = 10 ;

Math.sqrt( foo );
</pre>
<p>That is an implicit conversion, square root function receive a Number for parameters. Sometimes just using Number is more efficient.<b>3.- If you are going to access a property, variable, or a function value more than a few times, store that value in a local var:</b></p>
<pre name="code" class="jscript">

var person:Person;

if (person.firstName == “Matt” || person.firstName == “Ted” ||

person.firstName == “Alex”)...

var fname:String = person.firstName;

if (fname == “Matt” || fname == “Ted” || fname == “Alex”)
</pre>
<p>Imagine if that query is in a loop, every dot represents a lookup<br />
Other example of the same, maybe less trivial:</p>
<pre name="code" class="jscript">

for(var k:int=0; k&lt;    testArray.length; k++)
{
	trace(testArray[i]);
}
</pre>
<p>Here we are calling the length of the array in every loop, we can change it for something like this:</p>
<pre name="code" class="jscript">

var l:int = testArray.length;

for(var i:int=0; i&lt;    l; i++)
{
	trace(testArray[i]);
}
</pre>
<p>In the second case we are calling testarray.length just once for all the iterations.<b>4.- Use int for index array instead of Number. The array indexing is faster with ints.</b><b>5.- Avoid variable declaration inside loops, if you have something like this:</b></p>
<pre name="code" class="jscript">

for(var j:int=0; j&lt;    1000000; j++)

{

var loopvar:Number = Math.random();

}
</pre>
<p>Change it for this:</p>
<pre name="code" class="jscript">

var loopvar:Number = Math.random();

for(var j:int=0; j&lt;    1000000; j++)

{

loopvar = Math.random() ;

}
</pre>
<p>Make your var declaration outside the loops.<b>6.- Cast instances, while reading from Array.</b><br />
The Actionscript array can store any type of data, so before you call a method or access a property of an instance inside the array, don&#8217;t do it directly from the array, first store the instance in a typed variable.<br />
Instead of this:</p>
<pre name="code" class="jscript">

testArray[i].x
</pre>
<p>Do this:</p>
<pre name="code" class="jscript">

var auxPoint:Point ;
auxPoint = testArray[i] as Point ;
</pre>
<p>This other option is valid, but I made a test and the previous way using the “as” operator is faster than this:</p>
<pre name="code" class="jscript">

var auxPoint:Point ;
auxPoint = Point( testArray[i] ) ;
</pre>
<p><b>7.- Bit operation are faster than normal operators.</b><br />
If you have intensive math operations like this:</p>
<pre name="code" class="jscript">

var val1:int = 4 * 2;
var val2:int = 4 * 4;
var val3:int = 4 / 2;
var val4:int = 4 / 4 ;
</pre>
<p>Can be changed for:</p>
<pre name="code" class="jscript">

var val1:int = 4 &lt;&lt; 1;
var val2:int = 4 &lt;&lt; 2;
var val3:int = 4 &gt;&gt; 1;
var val4:int = 4 &gt;&gt; 2;
</pre>
<p><b>7.- Watch your Listeners.</b><br />
“A game sprite subscribes to its own enterFrame event. In every frame it moves, the application performs some calculations to determine its proximity to other game elements. In ActionScript 3.0, even after you remove the sprite from the display list and null all references to it, the application continues to run that code in every frame until it is removed by garbage collection. You must remember to explicitly remove the enterFrame listener when the sprite is removed.”<br />
If you don&#8217;t remember to remove the listener of this sprite you will be leaking memory.<br />
You have to solutions available. The first one is remember to remove your listeners when you have done to use them, so reference to the object is eliminated and the garbage collector can take it in the next sweep.<br />
The second is use weak reference when you register your event listeners. A weak reference is one that is not counted by the Garbage Collector to decide if that object must be collected. This means that if the only reference remaining to an object are weak the object will be marked for collection anyway and that piece of memory will be freed.<br />
We can do this with the function addEventListener, the fifth parameter is a flag called useWeakReference by default is in false, you should set it to true:</p>
<pre name="code" class="jscript">

stage.addEventListener(Event.ENTER_FRAME, YourLoopFunction,false,0,true);
</pre>
<p>This is an example with all values set by default except the useWeakReference, the last parameter set to true.<b></b><b>Sources:</b><br />
Matt Chotin&#8217;s presentation at <a href="http://www.adobe.com/devnet/flex/articles/as3_tuning.html">http://www.adobe.com/devnet/flex/articles/as3_tuning.html</a></p>
<p>Rozengain&#8217;s blog : <a href="http://rozengain.com/?postid=35">http://rozengain.com/?postid=35</a></p>
<p>Andre Michelle&#8217;s blog: <a href="http://blog.andre-michelle.com/2005/as3-optimations-suggestions">http://blog.andre-michelle.com/2005/as3-optimations-suggestions</a></p>
<p>Daniel Hai&#8217;s Blog: <a href="http://www.danielhai.com/blog/?p=55">http://www.danielhai.com/blog/?p=55</a></p>
<p><a href="http://www.adobe.com/devnet/flashplayer/articles/resource_management.html">http://www.adobe.com/devnet/flashplayer/articles/resource_management.html</a></p>
<img alt="" border="0" src="http://feeds.wordpress.com/1.0/categories/gamedevjuice.wordpress.com/5/" /> <img alt="" border="0" src="http://feeds.wordpress.com/1.0/tags/gamedevjuice.wordpress.com/5/" /> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/gamedevjuice.wordpress.com/5/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/gamedevjuice.wordpress.com/5/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/gamedevjuice.wordpress.com/5/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/gamedevjuice.wordpress.com/5/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/gamedevjuice.wordpress.com/5/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/gamedevjuice.wordpress.com/5/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/gamedevjuice.wordpress.com/5/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/gamedevjuice.wordpress.com/5/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/gamedevjuice.wordpress.com/5/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/gamedevjuice.wordpress.com/5/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=gamedevjuice.wordpress.com&blog=2875767&post=5&subd=gamedevjuice&ref=&feed=1" /></div>]]></content:encoded>
			<wfw:commentRss>http://gamedevjuice.wordpress.com/2008/02/15/seven-tips-about-performance-optimization-in-actionscript-3/feed/</wfw:commentRss>
	
		<media:content url="http://a.wordpress.com/avatar/gamedevjuice-128.jpg" medium="image">
			<media:title type="html">Martingo</media:title>
		</media:content>
	</item>
	</channel>
</rss>