<?xml version="1.0" encoding="UTF-8"?>
<!-- generator="weebly" -->
<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/" >

<channel><title><![CDATA[PsyFlash Game Studios - A minds eye view of flash games - Home]]></title><link><![CDATA[http://www.psyflashproductions.com/index.html]]></link><description><![CDATA[Home]]></description><pubDate>Fri, 05 Feb 2010 19:34:01 +0700</pubDate><generator>Weebly</generator><item><title><![CDATA[Website downtime apology]]></title><link><![CDATA[http://www.psyflashproductions.com/3/post/2010/01/website-downtime-apology.html]]></link><comments><![CDATA[http://www.psyflashproductions.com/3/post/2010/01/website-downtime-apology.html#comments]]></comments><pubDate>Fri, 01 Jan 2010 16:27:38 +0700</pubDate><category><![CDATA[Uncategorized]]></category><guid isPermaLink="false">http://www.psyflashproductions.com/3/post/2010/01/website-downtime-apology.html</guid><description><![CDATA[The website has had a lot of downtime recently, and I apologize for it. I still haven't really fixed the problem, either; I just switched the site to my old site's URL. I haven't had much time to keep the site up and I wont for a long time (I'm very busy at the moment with work). I will make sure to fix the problem when I release my next game (which will be in about 10 months). I will have a 6 month leave from game development, and will take an [...] ]]></description><content:encoded><![CDATA[<div  class="paragraph" style=" text-align: left; ">The website has had a lot of downtime recently, and I apologize for it. I still haven't really fixed the problem, either; I just switched the site to my old site's URL. I haven't had much time to keep the site up and I wont for a long time (I'm very busy at the moment with work). I will make sure to fix the problem when I release my next game (which will be in about 10 months). I will have a 6 month leave from game development, and will take another 3 months to make the third and final [Visible] plus one more for sponsorship and release.<br /><br /><br />On a side note, I released Revert to Growth and Thief's Escape in the site's downtime, so go play them!</div>]]></content:encoded></item><item><title><![CDATA[Official Launch Date for Revert to Growth]]></title><link><![CDATA[http://www.psyflashproductions.com/3/post/2009/10/official-launch-date-for-revert-to-growth.html]]></link><comments><![CDATA[http://www.psyflashproductions.com/3/post/2009/10/official-launch-date-for-revert-to-growth.html#comments]]></comments><pubDate>Sun, 18 Oct 2009 16:10:23 +0700</pubDate><category><![CDATA[Uncategorized]]></category><guid isPermaLink="false">http://www.psyflashproductions.com/3/post/2009/10/official-launch-date-for-revert-to-growth.html</guid><description><![CDATA[Ok everyone, I now have an official launch date for Revert to Growth: It releases globally on Oct 29th (no its not a halloween game). Please vote it high (well vote what it deserves, which is high). I hope you all are as excited about its release as I am, its going to be epic.In other news, I have another game in the works. the code is all done, I'm just waiting for art and music. Sadly, in the world of selling flash games, it [...] ]]></description><content:encoded><![CDATA[<div  class="paragraph" style=" text-align: left; ">Ok everyone, I now have an official launch date for Revert to Growth: It releases globally on Oct 29th (no its not a halloween game). Please vote it high (well vote what it deserves, which is high). I hope you all are as excited about its release as I am, its going to be epic.<br /><br /><br />In other news, I have another game in the works. the code is all done, I'm just waiting for art and music. Sadly, in the world of selling flash games, it takes about 1 1/2 months after a game is finished to release, but I'll try to pump this one out fast. The game itself should be&nbsp;completely&nbsp;finished on Wednesday, so It'll likely be released in November sometime.<br /><br /><br />Thats all for now.</div>]]></content:encoded></item><item><title><![CDATA[My newest venture - Arenafox.com]]></title><link><![CDATA[http://www.psyflashproductions.com/3/post/2009/10/my-newest-venture-arenafoxcom.html]]></link><comments><![CDATA[http://www.psyflashproductions.com/3/post/2009/10/my-newest-venture-arenafoxcom.html#comments]]></comments><pubDate>Tue, 06 Oct 2009 17:55:36 +0700</pubDate><category><![CDATA[Uncategorized]]></category><guid isPermaLink="false">http://www.psyflashproductions.com/3/post/2009/10/my-newest-venture-arenafoxcom.html</guid><description><![CDATA[I have a new venture, an arcade website where you can play a bunch of games:http://www.arenafox.comIts a new site, and will likely be going through some changes in the coming weeks, and it will be getting a larger selection of games as well. [...] ]]></description><content:encoded><![CDATA[<div  class="paragraph" style=" text-align: left; ">I have a new venture, an arcade website where you can play a bunch of games:<br><br><br><a href="http://www.arenafox.com/" target="_blank">http://www.arenafox.com</a><br><br><br>Its a new site, and will likely be going through some changes in the coming weeks, and it will be getting a larger selection of games as well.</div>]]></content:encoded></item><item><title><![CDATA[Sorry about the time offline]]></title><link><![CDATA[http://www.psyflashproductions.com/3/post/2009/09/sorry-about-the-time-offline.html]]></link><comments><![CDATA[http://www.psyflashproductions.com/3/post/2009/09/sorry-about-the-time-offline.html#comments]]></comments><pubDate>Wed, 30 Sep 2009 10:32:06 +0700</pubDate><category><![CDATA[Uncategorized]]></category><guid isPermaLink="false">http://www.psyflashproductions.com/3/post/2009/09/sorry-about-the-time-offline.html</guid><description><![CDATA[Sorry about the time offlineMy host suffered a DDoS, and my site wasn't loading. Anyways, just a quick update:Revert to Growth should be online everywhere in about 3 weeks.Sadly, the sponsorship process is a long one, but I will be choosing my sponsor tomorrow, and it will take about three weeks to prepare it for its world launch. Awesome.The next in the collision series  [...] ]]></description><content:encoded><![CDATA[<h2  style=" text-align: left; ">Sorry about the time offline</h2><div  class="paragraph" style=" text-align: left; ">My host suffered a DDoS, and my site wasn't loading. Anyways, just a quick update:<br /><br /><br />Revert to Growth should be online everywhere in about 3 weeks.Sadly, the sponsorship process is a long one, but I will be choosing my sponsor tomorrow, and it will take about three weeks to prepare it for its world launch. Awesome.<br /><br /><br />The next in the collision series should be coming within the next week as well. Look out for it!</div>]]></content:encoded></item><item><title><![CDATA[Collision Series: AABB to AABB - Separation]]></title><link><![CDATA[http://www.psyflashproductions.com/3/post/2009/09/collision-series-aabb-to-aabb-separation.html]]></link><comments><![CDATA[http://www.psyflashproductions.com/3/post/2009/09/collision-series-aabb-to-aabb-separation.html#comments]]></comments><pubDate>Sun, 13 Sep 2009 20:19:19 +0700</pubDate><category><![CDATA[Uncategorized]]></category><guid isPermaLink="false">http://www.psyflashproductions.com/3/post/2009/09/collision-series-aabb-to-aabb-separation.html</guid><description><![CDATA[AABB to AABB - SeparationLast time we learned how to check for a collision between two axis aligned rectangles and that collision detection doesnt have to be scary.First, an optomization:Thanks to John Blackburne for poin [...] ]]></description><content:encoded><![CDATA[<h2  style=" text-align: left; ">AABB to AABB - Separation</h2><div  class="paragraph" style=" text-align: left; "><a href="http://www.psyflash.com/3/post/2009/09/aabb2aabbdetection.html" target="_blank">Last time</a> we learned how to check for a collision between two axis aligned rectangles and that collision detection doesnt have to be scary.</div><h2  style=" text-align: left; ">First, an optomization:</h2><div  class="paragraph" style=" text-align: left; ">Thanks to John Blackburne for pointing out a code optomization:<br /><br />In your code, change any division by 2 to multiplication by .5 (multiplication is faster than division).<br /><br /><br /><br /></div><h2  style=" text-align: left; ">Helpful, but...</h2><div  class="paragraph" style=" text-align: left; ">While having good collision detection is helpful, its not that useful. If you are making a game (especially a platformer), chances are that you need to do something after they collide. You know, something along the lines of separating them so that they DON'T overlap. A character going through the wall or ground isn't my idea of a good game. So lets do something about it!</div><div ><!--BLOG_SUMMARY_END--></div><h2  style=" text-align: left; ">How this is done:</h2><div  class="paragraph" style=" text-align: left; ">You may say: "Well thats all fine and dandy, but how do you get to that point?<br /><br /><br />The good news is that we already have all the information we need with the last code, so we just need to change it a little. Instead of making a function that returns a boolean, we'll just make a function that DOES something. No returns nessecary.<br /><br /><br />This is what we have right now:<br /><br /><br /><em>function checkAABB(r1:MovieClip, r2:MovieClip, custW1:Number = 0, custH1:Number = 0, custW2:Number = 0, custH2:Number = 0):Boolean{<br /><br />var fAbs:Function = Math.abs;<br />var overlap:Boolean;<br /><br />var xr1:Number = r1.x;<br />var yr1:Number = r1.y;<br />var xr2:Number = r2.x;<br />var yr2:Number = r2.y;<br /></em><em><br />(custW1 == 0) ? wr1 = r1.width*.5 : wr1 = custW1*.5;<br />(custH1 == 0) ? hr1 = r1.height*.5&nbsp;: hr1 = custH1*.5;<br />(custW2 == 0) ? wr2 = r2.width*.5&nbsp;: wr2 = custW2*.5;<br />(custH2 == 0) ? hr2 = r2.height*.5&nbsp;: hr2 = custH2*.5;<br /><br />var maxDistX:Number = wr1 + wr2;<br />var maxDistY:Number = hr1 + hr2;<br />var xDist:Number = xr1 - xr2;<br />var yDist:Number = yr1 - yr2;<br /><br />(fAbs(xDist) &lt;= maxDistX &amp;&amp; fAbs(yDist) &lt;= maxDistY) ? overlap = true : overlap = false;<br /><br />return overlap;<br /><br />}</em><br /><br />This is what we will need to change:<br /><br /><br /><span style="font-style: italic; ">function collide(r1:MovieClip, r2:MovieClip, custW1:Number = 0, custH1:Number = 0, custW2:Number = 0, custH2:Number = 0):void{</span><br /><br />First, we change the function name. We arent just checking anymore. We're colliding. then we change the return type from Boolean to void. We wont need to return anything.<br /><br /><br />With that in mind, we'll skip to the end and just erase this line:<br /><br /><span style="font-style: italic; ">return overlap;</span><br /><br />Now this is when the real change happens. This is the code that will separate the rectangles if they chould overlap. Change this:<br /><br /><span style="font-style: italic; ">(fAbs(xDist) &lt;= maxDistX &amp;&amp; fAbs(yDist) &lt;= maxDistY) ? overlap = true : overlap = false;</span><br /><br />To this:<br /><br /><em>if(r1 != r2){<br /><br />if(xDist &lt;=&nbsp;maxDistX&nbsp;&amp;&amp; yDist &lt;=&nbsp;maxDistY){<br /> &nbsp;<br />if(maxDistX - xDist &lt; maxDistY - yDist){<br /><br />(r1.x &lt; r2.x) ? r1.x -=&nbsp;maxDistX&nbsp;- xDist : r1.x +=&nbsp;maxDistX&nbsp;- xDist;<br /><br />}<br /><br />else if(maxDistY&nbsp;- yDist &lt;&nbsp;maxDistX&nbsp;- xDist){<br /><br />(r1.y &nbsp;&lt; r2.y) ? r1.y -=&nbsp;maxDistY&nbsp;- yDist : r1.y +=&nbsp;maxDistY&nbsp;- yDist;<br /><br />}<br /><br />}<br /><br />}</em></div><h2  style=" text-align: left; ">Explanation of changes</h2><div  class="paragraph" style=" text-align: left; "><span style="font-style: italic; ">if(r1 != r2){</span><br /><br />All this means is: If r1 is not the same object as r2. This prevents an object from trying to seperate from itself (it does nothing, so it wastes CPU).<br /><br /><em>if(xDist &lt;=&nbsp;maxDistX&nbsp;&amp;&amp; yDist &lt;=&nbsp;maxDistY){</em><br /><br />You already recognise this code, this just detects if they are overlapping.<br /><br /><em>if(maxDistX - xDist &lt; maxDistY - yDist){<br /><br />(r1.x &lt; r2.x) ? r1.x -=&nbsp;maxDistX&nbsp;- xDist : r1.x +=&nbsp;maxDistX&nbsp;- xDist;<br /><br />}</em><br /><br />This code checks to see if the distance the recatangles are overlapping is smaller on the x axis than the y axis. To seperate objects realisticlly, you need to use the smallest distance of overlap, and only seperate one axis at a time.<br /><br />After it checks to see if the x axis overlap is smaller than the y axis overlap, then it checks to see which side r1 is on comparitivly to r2. It then pushes it out the exact distance nessecary (determined by taking the maxDistX and subtracting it from the distX. This is the exact amount of overlap).<br /><br /><span style="font-style: italic; ">else if(maxDistY&nbsp;- yDist &lt;&nbsp;maxDistX&nbsp;- xDist){<br /><br />(r1.y &nbsp;&lt; r2.y) ? r1.y -=&nbsp;maxDistY&nbsp;- yDist : r1.y +=&nbsp;maxDistY&nbsp;- yDist;<br /><br />}</span><br /><br />This is the same thing, but it only activates if the y overlap is larger than the x overlap.</div><h2  style=" text-align: left; ">That was simple</h2><div  class="paragraph" style=" text-align: left; ">This is further proof that you dont need to stress over basic collision. It is simple stuff. what we have here is pixel perfect collision detection and seperation for simple axis alligned rectangles. Feel free to use this code as you see fit, of course.<br /><br /><br />Suprisingly, the collision seperation is faster than the checking itself. Strange? Yeah, pretty much.<br /><br /><br />Here is what you end up with:</div><div ><div style="padding-top: 20px; padding-bottom: 20px; text-align: left;"><object codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=9,0,0,0" classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" align="middle"	height="400px" width="400px" ><param name="movie" value="http://www.psyflashproductions.com/uploads/1/3/2/6/1326038/collisionfla.swf"> <param name="quality" value="high"> <param name="play" value="true"> <param name="loop" value="true"> <param name="wmode" value="transparent"> <param name="allowFullScreen" value="true"> <param name="flashvars" value=""> <embed src="http://www.psyflashproductions.com/uploads/1/3/2/6/1326038/collisionfla.swf" quality="high" pluginspage="http://www.macromedia.com/go/getflashplayer" play="true" loop="true" wmode="transparent" allowfullscreen="true" flashvars="" type="application/x-shockwave-flash" align="middle"  height="400px" width="400px"></embed></object></div></div>]]></content:encoded></item><item><title><![CDATA[Collision Series:AABB to AABB - Detection]]></title><link><![CDATA[http://www.psyflashproductions.com/3/post/2009/09/aabb2aabbdetection.html]]></link><comments><![CDATA[http://www.psyflashproductions.com/3/post/2009/09/aabb2aabbdetection.html#comments]]></comments><pubDate>Sat, 12 Sep 2009 03:06:00 +0700</pubDate><category><![CDATA[Uncategorized]]></category><guid isPermaLink="false">http://www.psyflashproductions.com/3/post/2009/09/aabb2aabbdetection.html</guid><description><![CDATA[AABB to AABB - DetectionHave you ever played a game with bad collision? It's not a very good experience. Bad collision in a game snowballs into other problems. It can interfere with the controls, interfere with the gameplay, and basically anything else that relies on objects overlapping (which is typically a lot). If you are just starting Actionscript, then you are probably using hitTestPoint() or hitTe [...] ]]></description><content:encoded><![CDATA[<h2  style=" text-align: left; ">AABB to AABB - Detection</h2><div  class="paragraph" style=" text-align: left; "><br>Have you ever played a game with bad collision? It's not a very good experience. Bad collision in a game snowballs into other problems. It can interfere with the controls, interfere with the gameplay, and basically anything else that relies on objects overlapping (which is typically a lot). If you are just starting Actionscript, then you are probably using hitTestPoint() or hitTestObject(), flash's built in collision detection. HitTestPoint() tests any given point pixel-perfectly against a graphical object. hitTestObject() uses two graphical objects' bounding boxes to collide.There are pro's and cons with both:<br><br><strong>Pros:</strong><br><br>hitTestPoint() - Easy to use, and it tests one point <span style="text-decoration: underline;"><em>pixel perfectly</em></span>&nbsp;against a graphical object. This can be extremely useful, as it is pixel perfect(meaning it returns true is it is touching any pixel that the object is comprised of).<br><br><br>hitTestObject() - Easy to use is honestly the only thing I can think of. It's pretty crappy otherwise.<br><br><br><strong>Cons:</strong><br><br><br>hitTestPoint - A point is a very small area (obviously). What if you need a bigger area? Using a lot of hitTestPoints will result in a slower program to get the same results as with other methods.<br><br>hitTestObject() - You dont get any flexibility with hitTestObject. The bounding boxes are being tested (the boxes who's dimensions are the objects width and height). That means if you dont need that entire area tested, or need more tested, you are out of luck. Not to mention that its a very slow method.<br><br><br>Though theres not really a suitable cure for hitTestPoint() that I can give you, I can give you the cure for hitTestObject!<br><br><br>Now after that very long intro, I can finally say: Welcome to the first of my collision series tutorials: AABB to AABB!</div><div ><!--BLOG_SUMMARY_END--></div><h2  style=" text-align: left; ">The Cure</h2><div  class="paragraph" style=" text-align: left; ">Essentially, what I'm going to give you is a hitTestObject with flexibility and speed. The collision series tutorials are based on math (everyones favorite subject), so if you have some kind of phobia, please leave (dont leave). This type of collision detection is called AABB to AABB (AABB is an axis aligned rectangle [no rotation]).<br /><br /><br />Example:</div><div ><div style="text-align: left;"><a><img src="http://www.psyflashproductions.com/uploads/1/3/2/6/1326038/4776216.jpg" style="margin-top: 10px; margin-bottom: 10px; margin-left: 0; margin-right: 10px; border: 1px solid black;" alt="Picture" /></a><div style="display: block; font-size: 90%; margin-top: -10px; margin-bottom: 10px;"></div></div></div><h2  style=" text-align: left; ">How it works</h2><div  class="paragraph" style=" text-align: left; ">It is actually quite simple. We just have to calculate the distance between 2 of its axes. Then you check to see if they are touching by comparing the distance to the maximum distance they could be while still touching. Confused? Dont be, I will show you.<br /><br /><br />In order to be overlapping another rectange, it has to be overlapping on both axes, like so:</div><div ><div style="text-align: center;"><a><img src="http://www.psyflashproductions.com/uploads/1/3/2/6/1326038/4411399.jpg?418x177" style="margin-top: 10px; margin-bottom: 10px; margin-left: 10px; margin-right: 10px; border: 1px solid black;" alt="Picture" /></a><div style="display: block; font-size: 90%; margin-top: -10px; margin-bottom: 10px;"></div></div></div><h2  style=" text-align: left; ">How we do that stuff</h2><div  class="paragraph" style=" text-align: left; ">Testing this in Actionscript is simpler even than it looks. We need a little bit of information first though. We need the width of both of the objects, the height of both of the objects, and the x,y positions of both of the objects. Luckily, flash makes this easily avaliable to us. We will work with two rectangles (lets call them r1 and r2):<br /><br /><br /><em>var wr1:Number = r1.width;</em><br /><em>var hr1:Number = r1.height;</em><br /><em>var wr2:Number = r2.width;</em><br /><em>var hr2:Number = r2.height;</em><br /><br /><em>var xr1:Number = r1.x;</em><br /><em>var yr1:Number = r1.y;</em><br /><em>var xr2:Number = r2.x;</em><br /><em>var yr2:Number = r2.y;</em><br /><br />That was easy. And thats all the raw information we need to solve this collision problem. From now on. We will simply be manipulating this information from now on.<br /><br />The next thing we will need to do is find the max distance between them before they stop overlapping. If you think about it, it is just half of their width added together. Then half of their height added together for the other axis. Since we wont be needing the full width or height data of the rectangles, lets go back and halve our variables:<br /><br /><em>var wr1:Number = r1.width/2;</em><br /><em>var hr1:Number = r1.height/2;</em><br /><em>var wr2:Number = r2.width/2;</em><br /><em>var hr2:Number = r2.height/2;</em><br /><br />Awesome. Let's calculate the max distances now:<br /><br /><br /><em>var maxDistX:Number = wr1 + wr2;</em><br /><em>var maxDistY:Number = hr1 + hr2;</em><br /><br />Now were getting somewhere. Of course, this is just the begginning. We havent even tested the overlap yet. So close, yet so far...<br /><br /><br />We can easily check the distance between the rectangles on both axes by subtracting the x and y distances of the 2 rectangles. Guess what that mean? More variables!!!<br /><br /><em>var xDist:Number = xr1 - xr2;</em><br /><em>var yDist:Number = yr1 - yr2;</em><br /><br />We are now finally ready to check the overlap!!! All this variable preparation has lead us up to this:<br /><br /><br /><em>var overlap:Boolean;</em><br /><br /><em>if(xDist &lt;= maxDistX &amp;&amp; yDist &lt;= maxDistY){</em><br /><em>overlap = true;</em><br /><em>} else {</em><br /><em>overlap = false;</em><br /><em>}</em><br /><br /><br />If you test the code ouy on a couple of rectangles, you may notice that it doesn't work. Why could that be?! Well, your xDist or YDist variables arent always positive. A negative reading will skew the equation, because there isn't negative distance. Flash gives us the Math class to handle such things, specifically Math.abs(). Lets make it into a variable for speeds sake (pulling a static class variable from a local position is kind of slow):<br /><br /><em>var fAbs:Function = Math.abs;</em><br /><br />Now we can redo that nasty code:<br /><br /><em>if(fAbs(xDist) &lt;= maxDistX &amp;&amp; fAbs(yDist) &lt;= maxDistY){</em><br /><em>overlap = true;</em><br /><em>} else {</em><br /><em>overlap = false;</em><br /><em>}</em><br /><br />Eh. That code is working perfectly fine, but if/else statements arent the fastest way to go. If only we had a really codey looking operator that could make the code faster and impress our friends out of confusion... Enter the conditional operator.<br /><br /><br />The conditional operator looks something like this:<br /><br /><em>(booleanValue) ? ifTrue : ifFalse;</em><br /><br />Thats not so bad right? Lets add our if/else statement in there:<br /><br /><span style="font-style: italic; ">(fAbs(xDist) &lt;= maxDistX &amp;&amp; fAbs(yDist) &lt;= maxDistY) ? overlap = true : overlap = false;</span><br /><br />Congratulations!!! You've just... well... replicated hitTestObject(). Dang!!!</div><h2  style=" text-align: left; ">We can improve it. We have the technology.</h2><div  class="paragraph" style=" text-align: left; ">That sounded a lot cooler in my head. Anyways, we now have a faster version of hitTestObject(), which still doesnt help us in the flexibility department. I do still have a cure though, so dont run away yet. The good thing about math based detection is that it's based on numbers. So why don't we just change the numbers! This would be a good use of a function with parameters. This is the anatomy of the function:<br /><br /><br /><em>function someFunction( param1:Type, param2:Type, etc:Type):ReturnType{&nbsp;<br />//do stuff here<br />&nbsp;};</em><br /><br /><br />The function can use the parameters you give it as variables inside the function. This is not only super cool, but amazingly useful. lets write our function and its parameters now:<br /><br /><br /><em>function checkAABB(r1:MovieClip, r2:MovieClip, custW1:Number = 0, custH1:Number = 0, </em><em>&nbsp;&nbsp; &nbsp;&nbsp;custW2:Number = 0, custH2:Number = 0):Boolean{</em><br /><br /><em>//function stuff here</em><br /><br /><em>}</em><br /><br /><br />we are shoving lots of info into our function here, so I will explain it all:<br /><br /><br />r1 &amp; r2 are our faithful rectangles<br /><br /><br />custW1 &amp; custH1 are the numbers we want to set as our 'width' and 'height' for r1<br /><br /><br />custW2 &amp; custH2 are the same thing, but for r2<br /><br /><br />You may notice that the custom widths and heights are set equivelant to something already. What this allows us to do is skip over those if we want, as they already have a pre-set value.<br /><br /><br />That means if we just type...<br /><br /><br /><em>checkAABB(rectangle1, rectangle1);</em><br /><br /><br />... it will set the testing widths and heights to 0. Wait... we dont want that. Lets make some conditionals to help set it straight and make it easy on ourselves. If we dont want to type in a custom test width or height, just set it to the real width or height:<br /><br /><br /><em>function checkAABB(r1:MovieClip, r2:MovieClip, custW1:Number = 0, custH1:Number = 0,&nbsp;</em><em>&nbsp;&nbsp; &nbsp;&nbsp;custW2:Number = 0, custH2:Number = 0):Boolean{</em><br /><br /><em><span style="font-style: normal; "><em>var wr1:Number;</em><br /><em>var hr1:Number;</em><br /><em>var wr2:Number;</em><br /><em>var hr2:Number;</em></span></em><br /><br /><em>(custW1 == 0) ? wr1 = r1.width/2 : wr1 = custW1/2;</em><br /><em>(custH1 == 0) ? hr1 = r1.height/2 : hr1 = custH1/2;</em><br /><em>(custW2 == 0) ? wr2 = r2.width/2 : wr2 = custW2/2;</em><br /><em>(custH2 == 0) ? hr2 = r2.height/2 : hr2 = custH2/2;<br /></em><br /><em>}</em><br /><br />Ok, all set. Now if we dont enter a custon value for them, they automatically become the true width or height. Now just add the rest of your code and return overlap (since the function requires you to return a value with the type Boolean). It'll look something like this:</div><h2  style=" text-align: left; ">Final Code</h2><div  class="paragraph" style=" text-align: left; "><em>function checkAABB(r1:MovieClip, r2:MovieClip, custW1:Number = 0, custH1:Number = 0,&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;custW2:Number = 0, custH2:Number = 0):Boolean{<br /><br />var fAbs:Function = Math.abs;<br />var overlap:Boolean;<br /><br />var xr1:Number = r1.x;<br />var yr1:Number = r1.y;<br />var xr2:Number = r2.x;<br />var yr2:Number = r2.y;<br /><br />var wr1:Number;<br />var hr1:Number;<br />var wr2:Number;<br />var hr2:Number;<br /><br />(custW1 == 0) ? wr1 = r1.width*.5 : wr1 = custW1*.5;<br />(custH1 == 0) ? hr1 = r1.height*.5&nbsp;: hr1 = custH1*.5;<br />(custW2 == 0) ? wr2 = r2.width*.5&nbsp;: wr2 = custW2*.5;<br />(custH2 == 0) ? hr2 = r2.height*.5&nbsp;: hr2 = custH2*.5;<br /><br />var maxDistX:Number = wr1 + wr2;<br />var maxDistY:Number = hr1 + hr2;<br />var xDist:Number = xr1 - xr2;<br />var yDist:Number = yr1 - yr2;<br /><br />(fAbs(xDist) &lt;= maxDistX &amp;&amp; fAbs(yDist) &lt;= maxDistY) ? overlap = true : overlap = false;<br /><br />return overlap;<br /><br />}</em></div><div ><div style="padding-top: 20px; padding-bottom: 20px; text-align: left;"><object codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=9,0,0,0" classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" align="middle"	height="400px" width="400px" ><param name="movie" value="http://www.psyflashproductions.com/uploads/1/3/2/6/1326038/collisionfla2.swf"> <param name="quality" value="high"> <param name="play" value="true"> <param name="loop" value="true"> <param name="wmode" value="transparent"> <param name="allowFullScreen" value="true"> <param name="flashvars" value=""> <embed src="http://www.psyflashproductions.com/uploads/1/3/2/6/1326038/collisionfla2.swf" quality="high" pluginspage="http://www.macromedia.com/go/getflashplayer" play="true" loop="true" wmode="transparent" allowfullscreen="true" flashvars="" type="application/x-shockwave-flash" align="middle"  height="400px" width="400px"></embed></object></div></div><h2  style=" text-align: left; ">Overview</h2><div  class="paragraph" style=" text-align: left; ">I really drug this tutorial on and on. Thats not very much code, but its flexible on rectangle size and faster than hitTestObject! Please look for the next tutorial, where I show you how to separate the rectangles when they overlap!<br /><br /><br />*Edit* Next tutorial is here: <a href="http://www.psyflash.com/3/post/2009/09/collision-series-aabb-to-aabb-separation.html">AABB to AABB - Separation</a></div>]]></content:encoded></item><item><title><![CDATA[New site up!!!]]></title><link><![CDATA[http://www.psyflashproductions.com/3/post/2009/09/new-site-up.html]]></link><comments><![CDATA[http://www.psyflashproductions.com/3/post/2009/09/new-site-up.html#comments]]></comments><pubDate>Wed, 09 Sep 2009 02:25:46 +0700</pubDate><category><![CDATA[Uncategorized]]></category><guid isPermaLink="false">http://www.psyflashproductions.com/3/post/2009/09/new-site-up.html</guid><description><![CDATA[New Site is Up!!!I have decided to completely overhaul my site. To my fellow flash developers, it is more developer centric now, and I will be coming out with tutorials, post-mortems, and other studies in the coming months. To my fans, and other people visiting this site, you can still view my games in the "games portfolio" page. You can also learn to make flash games like me by going to the developer resou [...] ]]></description><content:encoded><![CDATA[<h2  style=" text-align: left; ">New Site is Up!!!</h2><div  class="paragraph" style=" text-align: left; ">I have decided to completely overhaul my site. To my fellow flash developers, it is more developer centric now, and I will be coming out with tutorials, post-mortems, and other studies in the coming months. To my fans, and other people visiting this site, you can still view my games in the "games portfolio" page. You can also learn to make flash games like me by going to the developer resources page. I hope you enjoy the new look and new focus.<br /><br /><br />-Psyflash</div>]]></content:encoded></item></channel></rss>
