<?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>Tile Isle</title>
	<atom:link href="http://www.tileisle.net/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.tileisle.net</link>
	<description>Games with Style</description>
	<lastBuildDate>Sat, 30 Oct 2010 21:26:42 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.2-bleeding</generator>
		<item>
		<title>HALOWEENIES!</title>
		<link>http://www.tileisle.net/haloweenies/</link>
		<comments>http://www.tileisle.net/haloweenies/#comments</comments>
		<pubDate>Sat, 30 Oct 2010 05:00:20 +0000</pubDate>
		<dc:creator>Tim</dc:creator>
				<category><![CDATA[Flixel Showcase]]></category>
		<category><![CDATA[as3]]></category>
		<category><![CDATA[fall]]></category>
		<category><![CDATA[halloween]]></category>
		<category><![CDATA[leaves]]></category>
		<category><![CDATA[special effects]]></category>

		<guid isPermaLink="false">http://www.tileisle.net/?p=236</guid>
		<description><![CDATA[Mwa ha ha! Cower in fear puny mortals! The realm of the dead has burst upon your world and nothing is safe!]]></description>
			<content:encoded><![CDATA[<p>Mwa ha ha! Cower in fear puny mortals! The realm of the dead has burst upon your world and nothing is safe!</p>
<p>
<object width="320" height="240">
<param name="movie" value="/Flixel/crazy_fall/falldemo.swf"></param>
<param name="quality" value="high"></param>
<param name="wmode" value="window"></param>
<param name="menu" value="true"></param>
<param name="bgcolor" value="#000000"></param>
<embed type="application/x-shockwave-flash" width="320" height="240" src="/Flixel/crazy_fall/falldemo.swf" quality="high" bgcolor="#000000" wmode="window" menu="true" ></embed>
</object>
</p>
<p> <img src='http://www.tileisle.net/wp-includes/images/smilies/icon_wink.gif' alt=';)' class='wp-smiley' /> </p>
]]></content:encoded>
			<wfw:commentRss>http://www.tileisle.net/haloweenies/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Flixel Showcase: Fall</title>
		<link>http://www.tileisle.net/flixel-showcase-fall/</link>
		<comments>http://www.tileisle.net/flixel-showcase-fall/#comments</comments>
		<pubDate>Tue, 26 Oct 2010 16:58:01 +0000</pubDate>
		<dc:creator>Tim</dc:creator>
				<category><![CDATA[Flixel Showcase]]></category>
		<category><![CDATA[actionscript]]></category>
		<category><![CDATA[actionscript 3]]></category>
		<category><![CDATA[as3]]></category>
		<category><![CDATA[chaos]]></category>
		<category><![CDATA[code]]></category>
		<category><![CDATA[cool]]></category>
		<category><![CDATA[demo]]></category>
		<category><![CDATA[demonstration]]></category>
		<category><![CDATA[effect]]></category>
		<category><![CDATA[effects]]></category>
		<category><![CDATA[flash]]></category>
		<category><![CDATA[Flixel]]></category>
		<category><![CDATA[fx]]></category>
		<category><![CDATA[neat]]></category>
		<category><![CDATA[random]]></category>
		<category><![CDATA[samples]]></category>
		<category><![CDATA[source code]]></category>
		<category><![CDATA[special effect]]></category>
		<category><![CDATA[special effects]]></category>
		<category><![CDATA[tricks]]></category>

		<guid isPermaLink="false">http://www.tileisle.net/?p=234</guid>
		<description><![CDATA[Another &#8216;seasonal&#8217; special effect! This one&#8217;s (obviously) about fall There&#8217;s several things going on here: First, the tree and it&#8217;s leaves are all randomly generated. The tree is comprised of &#8220;TreeBits&#8221;, which are 1&#215;1 black FlxSprites with a &#8216;weight&#8217; assigned to them. These are placed in the area around the top of the trunk randomly, [...]]]></description>
			<content:encoded><![CDATA[<p>Another &#8216;seasonal&#8217; special effect! This one&#8217;s (obviously) about fall <img src='http://www.tileisle.net/wp-includes/images/smilies/icon_razz.gif' alt=':P' class='wp-smiley' /> </p>
<p>
<object width="320" height="240">
<param name="movie" value="/Flixel/fall/falldemo.swf"></param>
<param name="quality" value="high"></param>
<param name="wmode" value="window"></param>
<param name="menu" value="true"></param>
<param name="bgcolor" value="#000000"></param>
<embed type="application/x-shockwave-flash" width="320" height="240" src="/Flixel/fall/falldemo.swf" quality="high" bgcolor="#000000" wmode="window" menu="true" ></embed>
</object>
</p>
<p>There&#8217;s several things going on here:</p>
<ul>
<li>First, the tree and it&#8217;s leaves are all randomly generated. The tree is comprised of &#8220;TreeBits&#8221;, which are 1&#215;1 black FlxSprites with a &#8216;weight&#8217; assigned to them. These are placed in the area around the top of the trunk randomly, but slightly denser towards the middle mass of the tree.</li>
<li>The leaves are placed on a layer on top of the branches. These are also 1&#215;1 FlxSprites with a random color assigned to them, and a random weight (but much lighter than the branches). These are scattered all over, and a little outside the area of the branches, and then several are randomly placed just above the ground.</li>
<li>Some of the other graphics are setup including the background, and the very, very subtle mist layer in front of everything else. These are the only 2 &#8216;external&#8217; images used &#8211; I didn&#8217;t feel like messing around with gradients in code.</li>
<li>The wind is set to be randomly blowing somewhere between -10 and 10, and it&#8217;s &#8216;goal&#8217; strength is randomly set within the same range.</li>
<li>Then it starts running: the wind will gradually increase or decrease until it hit&#8217;s it&#8217;s &#8216;goal&#8217; strength, and then it will be assigned a new random goal. So the wind will always be gusting and it might increase or decrease or reverse directions.</li>
<li>Each of the individual leaves in the tree will be sent a &#8216;push&#8217; command, with the current wind strength and direction. Based on the leaf&#8217;s weight, it will move a slightly random amount in the direction of the wind (it might not move at all). Fluctuations are built in so they&#8217;ll look more like they&#8217;re flailing back and forth. The same thing happens with the branches, but they weigh more and so move less with less fluctuation.</li>
<li>If a leaf is pushed to it&#8217;s limit, there&#8217;s a random chance it will break away from the tree and start falling. Falling leaves are simply pushed a slightly randomized amount based on their weight and the wind, with some up/down fluctuation, and a little side-to-side fluctuations. Branches won&#8217;t break off.</li>
<li>Falling leaves don&#8217;t collide with anything except the ground, or leaves that are on the ground. Once it collides, the leaf gets marked as &#8216;on the ground&#8217; so that it can collide with other leaves.</li>
<li>Leaves on the ground that do not have a leaf directly above them can be randomly picked up by the wind again. It takes a little more force from the wind to pull them off the ground than out of the tree, and it&#8217;s randomized.</li>
<li>Besides the leaves, there are also little wisps of dust or particles being pushed by the wind. These can randomly appear just off the screen if the wind is strong enough in either direction and fly quickly across the screen with some variant in their up/down movement and opacity. If the wind slows down enough, they&#8217;ll disappear.</li>
<li>To top it all off, random &#8216;ghosts&#8217; will appear from the ground, fade in and then fade out again with some randomness in their y velocity and some side-to-side movement. These ghosts are made up of individual blocks of FlxSprites that change their opacity separately depending on the Sprite above&#8217;s opacity.</li>
<li>Also, the leaves on the tree are finite. If you leave it run long enough, the tree will be bare. Leaves that enter from off the screen are infinite.</li>
</ul>
<p>And that&#8217;s it! I had fun playing with this, and I would like to make many more in the future <img src='http://www.tileisle.net/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' />  Let me know what you think!</p>
<p>You can take a look at my code to see how I&#8217;m doing things:<br />
<span id="more-234"></span></p>
<h3>PlayState</h3>
<div class="codecolorer-container actionscript3 default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;height:450px;"><div class="actionscript3 codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #9900cc; font-weight: bold;">package</span> &nbsp;<br />
<span style="color: #000000;">&#123;</span><br />
&nbsp; <span style="color: #0033ff; font-weight: bold;">import</span> org<span style="color: #000066; font-weight: bold;">.</span>flixel<span style="color: #000066; font-weight: bold;">.</span>FlxPoint<span style="color: #000066; font-weight: bold;">;</span><br />
&nbsp; <span style="color: #0033ff; font-weight: bold;">import</span> org<span style="color: #000066; font-weight: bold;">.</span>flixel<span style="color: #000066; font-weight: bold;">.</span>FlxSprite<span style="color: #000066; font-weight: bold;">;</span><br />
&nbsp; <span style="color: #0033ff; font-weight: bold;">import</span> org<span style="color: #000066; font-weight: bold;">.</span>flixel<span style="color: #000066; font-weight: bold;">.</span>FlxState<span style="color: #000066; font-weight: bold;">;</span><br />
&nbsp; <span style="color: #0033ff; font-weight: bold;">import</span> org<span style="color: #000066; font-weight: bold;">.</span>flixel<span style="color: #000066; font-weight: bold;">.</span>FlxGroup<span style="color: #000066; font-weight: bold;">;</span><br />
&nbsp; <span style="color: #0033ff; font-weight: bold;">import</span> org<span style="color: #000066; font-weight: bold;">.</span>flixel<span style="color: #000066; font-weight: bold;">.</span>FlxTileblock<span style="color: #000066; font-weight: bold;">;</span><br />
&nbsp; <span style="color: #0033ff; font-weight: bold;">import</span> org<span style="color: #000066; font-weight: bold;">.</span>flixel<span style="color: #000066; font-weight: bold;">.</span>FlxG<span style="color: #000066; font-weight: bold;">;</span><br />
&nbsp; <span style="color: #0033ff; font-weight: bold;">import</span> org<span style="color: #000066; font-weight: bold;">.</span>flixel<span style="color: #000066; font-weight: bold;">.</span>FlxU<span style="color: #000066; font-weight: bold;">;</span><br />
&nbsp; <span style="color: #0033ff; font-weight: bold;">import</span> com<span style="color: #000066; font-weight: bold;">.</span>gskinner<span style="color: #000066; font-weight: bold;">.</span>utils<span style="color: #000066; font-weight: bold;">.</span>Rnd<span style="color: #000066; font-weight: bold;">;</span><br />
&nbsp; &nbsp;<br />
&nbsp; <span style="color: #0033ff; font-weight: bold;">public</span> <span style="color: #9900cc; font-weight: bold;">class</span> PlayState <span style="color: #0033ff; font-weight: bold;">extends</span> FlxState<br />
&nbsp; <span style="color: #000000;">&#123;</span><br />
&nbsp; &nbsp; <span style="color: #000000;">&#91;</span>Embed<span style="color: #000000;">&#40;</span><span style="color: #004993;">source</span> = <span style="color: #990000;">'back.png'</span><span style="color: #000000;">&#41;</span><span style="color: #000000;">&#93;</span> <span style="color: #0033ff; font-weight: bold;">private</span> <span style="color: #6699cc; font-weight: bold;">var</span> ImgBack<span style="color: #000066; font-weight: bold;">:</span><span style="color: #004993;">Class</span><span style="color: #000066; font-weight: bold;">;</span><br />
&nbsp; &nbsp; <span style="color: #000000;">&#91;</span>Embed<span style="color: #000000;">&#40;</span><span style="color: #004993;">source</span> = <span style="color: #990000;">'mist.png'</span><span style="color: #000000;">&#41;</span><span style="color: #000000;">&#93;</span> <span style="color: #0033ff; font-weight: bold;">private</span> <span style="color: #6699cc; font-weight: bold;">var</span> ImgMist<span style="color: #000066; font-weight: bold;">:</span><span style="color: #004993;">Class</span><span style="color: #000066; font-weight: bold;">;</span><br />
&nbsp; &nbsp; <span style="color: #0033ff; font-weight: bold;">private</span> <span style="color: #6699cc; font-weight: bold;">var</span> sky<span style="color: #000066; font-weight: bold;">:</span>FlxSprite<span style="color: #000066; font-weight: bold;">;</span> <span style="color: #009900; font-style: italic;">// our background sky</span><br />
&nbsp; &nbsp; <span style="color: #0033ff; font-weight: bold;">private</span> <span style="color: #6699cc; font-weight: bold;">var</span> ground<span style="color: #000066; font-weight: bold;">:</span>FlxSprite<span style="color: #000066; font-weight: bold;">;</span> <span style="color: #009900; font-style: italic;">// our ground object</span><br />
&nbsp; &nbsp; <span style="color: #0033ff; font-weight: bold;">public</span> static <span style="color: #6699cc; font-weight: bold;">var</span> wind<span style="color: #000066; font-weight: bold;">:</span><span style="color: #004993;">Number</span> = <span style="color: #000000; font-weight:bold;">0.0</span><span style="color: #000066; font-weight: bold;">;</span> <span style="color: #009900; font-style: italic;">// direction and force of the wind</span><br />
&nbsp; &nbsp; <span style="color: #0033ff; font-weight: bold;">private</span> <span style="color: #6699cc; font-weight: bold;">var</span> mist<span style="color: #000066; font-weight: bold;">:</span>FlxSprite<span style="color: #000066; font-weight: bold;">;</span> <br />
&nbsp; &nbsp; <span style="color: #0033ff; font-weight: bold;">private</span> <span style="color: #6699cc; font-weight: bold;">var</span> treegrp<span style="color: #000066; font-weight: bold;">:</span>FlxGroup<span style="color: #000066; font-weight: bold;">;</span> <span style="color: #009900; font-style: italic;">// all of our tree pixels...</span><br />
&nbsp; &nbsp; <span style="color: #0033ff; font-weight: bold;">public</span> static <span style="color: #6699cc; font-weight: bold;">var</span> leafgrp<span style="color: #000066; font-weight: bold;">:</span>FlxGroup<span style="color: #000066; font-weight: bold;">;</span> <span style="color: #009900; font-style: italic;">// all of our leaves in a group</span><br />
&nbsp; &nbsp; <span style="color: #0033ff; font-weight: bold;">private</span> <span style="color: #6699cc; font-weight: bold;">var</span> <span style="color: #004993;">timer</span><span style="color: #000066; font-weight: bold;">:</span><span style="color: #004993;">Number</span> = <span style="color: #000000; font-weight:bold;">0</span><span style="color: #000066; font-weight: bold;">;</span><br />
&nbsp; &nbsp; <span style="color: #0033ff; font-weight: bold;">private</span> <span style="color: #6699cc; font-weight: bold;">var</span> goal<span style="color: #000066; font-weight: bold;">:</span><span style="color: #004993;">Number</span> = <span style="color: #000000; font-weight:bold;">0</span><span style="color: #000066; font-weight: bold;">;</span><br />
&nbsp; &nbsp; <span style="color: #0033ff; font-weight: bold;">private</span> <span style="color: #6699cc; font-weight: bold;">var</span> mistDir<span style="color: #000066; font-weight: bold;">:</span><span style="color: #004993;">int</span> = <span style="color: #000066; font-weight: bold;">-</span><span style="color: #000000; font-weight:bold;">1</span><span style="color: #000066; font-weight: bold;">;</span><br />
&nbsp; &nbsp; <span style="color: #0033ff; font-weight: bold;">private</span> <span style="color: #6699cc; font-weight: bold;">var</span> wispBackGrp<span style="color: #000066; font-weight: bold;">:</span>FlxGroup<span style="color: #000066; font-weight: bold;">;</span><br />
&nbsp; &nbsp; <span style="color: #0033ff; font-weight: bold;">private</span> <span style="color: #6699cc; font-weight: bold;">var</span> wispFrontGrp<span style="color: #000066; font-weight: bold;">:</span>FlxGroup<span style="color: #000066; font-weight: bold;">;</span><br />
&nbsp; &nbsp; <span style="color: #0033ff; font-weight: bold;">private</span> <span style="color: #6699cc; font-weight: bold;">var</span> ghostgrp<span style="color: #000066; font-weight: bold;">:</span>FlxGroup<span style="color: #000066; font-weight: bold;">;</span><br />
&nbsp; &nbsp; <br />
&nbsp; &nbsp; <span style="color: #0033ff; font-weight: bold;">public</span> <span style="color: #339966; font-weight: bold;">function</span> PlayState<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span> <br />
&nbsp; &nbsp; <span style="color: #000000;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; <span style="color: #009900; font-style: italic;">// the background graphic</span><br />
&nbsp; &nbsp; &nbsp; sky = <span style="color: #004993;">add</span><span style="color: #000000;">&#40;</span><span style="color: #0033ff; font-weight: bold;">new</span> FlxSprite<span style="color: #000000;">&#40;</span><span style="color: #000000; font-weight:bold;">0</span><span style="color: #000066; font-weight: bold;">,</span> <span style="color: #000000; font-weight:bold;">0</span><span style="color: #000066; font-weight: bold;">,</span> <span style="color: #0033ff; font-weight: bold;">null</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">.</span>loadGraphic<span style="color: #000000;">&#40;</span>ImgBack<span style="color: #000066; font-weight: bold;">,</span> <span style="color: #0033ff; font-weight: bold;">false</span><span style="color: #000066; font-weight: bold;">,</span> <span style="color: #0033ff; font-weight: bold;">false</span><span style="color: #000066; font-weight: bold;">,</span> FlxG<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">width</span><span style="color: #000066; font-weight: bold;">,</span> FlxG<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">height</span><span style="color: #000066; font-weight: bold;">,</span> <span style="color: #0033ff; font-weight: bold;">true</span><span style="color: #000000;">&#41;</span><span style="color: #000000;">&#41;</span> <span style="color: #0033ff; font-weight: bold;">as</span> FlxSprite<span style="color: #000066; font-weight: bold;">;</span><br />
&nbsp; &nbsp; &nbsp; <span style="color: #009900; font-style: italic;">// our different layers</span><br />
&nbsp; &nbsp; &nbsp; wispBackGrp = <span style="color: #004993;">add</span><span style="color: #000000;">&#40;</span><span style="color: #0033ff; font-weight: bold;">new</span> FlxGroup<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><span style="color: #000000;">&#41;</span> <span style="color: #0033ff; font-weight: bold;">as</span> FlxGroup<span style="color: #000066; font-weight: bold;">;</span><br />
&nbsp; &nbsp; &nbsp; ghostgrp = <span style="color: #004993;">add</span><span style="color: #000000;">&#40;</span><span style="color: #0033ff; font-weight: bold;">new</span> FlxGroup<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><span style="color: #000000;">&#41;</span> <span style="color: #0033ff; font-weight: bold;">as</span> FlxGroup<span style="color: #000066; font-weight: bold;">;</span><br />
&nbsp; &nbsp; &nbsp; treegrp = <span style="color: #004993;">add</span><span style="color: #000000;">&#40;</span><span style="color: #0033ff; font-weight: bold;">new</span> FlxGroup<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><span style="color: #000000;">&#41;</span> <span style="color: #0033ff; font-weight: bold;">as</span> FlxGroup<span style="color: #000066; font-weight: bold;">;</span><br />
&nbsp; &nbsp; &nbsp; leafgrp = <span style="color: #004993;">add</span><span style="color: #000000;">&#40;</span><span style="color: #0033ff; font-weight: bold;">new</span> FlxGroup<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><span style="color: #000000;">&#41;</span> <span style="color: #0033ff; font-weight: bold;">as</span> FlxGroup<span style="color: #000066; font-weight: bold;">;</span><br />
&nbsp; &nbsp; &nbsp; wispFrontGrp = <span style="color: #004993;">add</span><span style="color: #000000;">&#40;</span><span style="color: #0033ff; font-weight: bold;">new</span> FlxGroup<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><span style="color: #000000;">&#41;</span> <span style="color: #0033ff; font-weight: bold;">as</span> FlxGroup<span style="color: #000066; font-weight: bold;">;</span><br />
&nbsp; &nbsp; &nbsp; <span style="color: #009900; font-style: italic;">// build the tree!</span><br />
&nbsp; &nbsp; &nbsp; BuildTree<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span><br />
&nbsp; &nbsp; &nbsp; BuildLeaves<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span><br />
&nbsp; &nbsp; &nbsp; <span style="color: #009900; font-style: italic;">// this is the mist graphic that goes on top of everything else.</span><br />
&nbsp; &nbsp; &nbsp; mist = <span style="color: #004993;">add</span><span style="color: #000000;">&#40;</span><span style="color: #0033ff; font-weight: bold;">new</span> FlxSprite<span style="color: #000000;">&#40;</span> <span style="color: #000066; font-weight: bold;">-</span><span style="color: #000000; font-weight:bold;">250</span> <span style="color: #000066; font-weight: bold;">+</span> <span style="color: #000000;">&#40;</span>FlxG<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">width</span> <span style="color: #000066; font-weight: bold;">/</span> <span style="color: #000000; font-weight:bold;">2</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">,</span> FlxG<span style="color: #000066; font-weight: bold;">.</span>height<span style="color: #000066; font-weight: bold;">-</span><span style="color: #000000; font-weight:bold;">45</span><span style="color: #000066; font-weight: bold;">,</span> <span style="color: #0033ff; font-weight: bold;">null</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">.</span>loadGraphic<span style="color: #000000;">&#40;</span>ImgMist<span style="color: #000066; font-weight: bold;">,</span> <span style="color: #0033ff; font-weight: bold;">false</span><span style="color: #000066; font-weight: bold;">,</span> <span style="color: #0033ff; font-weight: bold;">false</span><span style="color: #000066; font-weight: bold;">,</span> <span style="color: #000000; font-weight:bold;">500</span><span style="color: #000066; font-weight: bold;">,</span> FlxG<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">height</span><span style="color: #000066; font-weight: bold;">,</span> <span style="color: #0033ff; font-weight: bold;">true</span><span style="color: #000000;">&#41;</span><span style="color: #000000;">&#41;</span> <span style="color: #0033ff; font-weight: bold;">as</span> FlxSprite<span style="color: #000066; font-weight: bold;">;</span><br />
&nbsp; &nbsp; &nbsp; mist<span style="color: #000066; font-weight: bold;">.</span>moves = <span style="color: #0033ff; font-weight: bold;">true</span><span style="color: #000066; font-weight: bold;">;</span><br />
&nbsp; &nbsp; &nbsp; mist<span style="color: #000066; font-weight: bold;">.</span>solid = <span style="color: #0033ff; font-weight: bold;">false</span><span style="color: #000066; font-weight: bold;">;</span><br />
&nbsp; &nbsp; &nbsp; mist<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">alpha</span> = <span style="color: #000000; font-weight:bold;">0.44</span><span style="color: #000066; font-weight: bold;">;</span><br />
&nbsp; &nbsp; &nbsp; <span style="color: #009900; font-style: italic;">// the ground sprite</span><br />
&nbsp; &nbsp; &nbsp; ground = <span style="color: #004993;">add</span><span style="color: #000000;">&#40;</span><span style="color: #0033ff; font-weight: bold;">new</span> FlxSprite<span style="color: #000000;">&#40;</span> <span style="color: #000066; font-weight: bold;">-</span><span style="color: #000000; font-weight:bold;">50</span><span style="color: #000066; font-weight: bold;">,</span> FlxG<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">height</span> <span style="color: #000066; font-weight: bold;">-</span> <span style="color: #000000; font-weight:bold;">5</span><span style="color: #000066; font-weight: bold;">,</span> <span style="color: #0033ff; font-weight: bold;">null</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">.</span>createGraphic<span style="color: #000000;">&#40;</span>FlxG<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">width</span> <span style="color: #000066; font-weight: bold;">+</span> <span style="color: #000000; font-weight:bold;">50</span><span style="color: #000066; font-weight: bold;">,</span> <span style="color: #000000; font-weight:bold;">20</span><span style="color: #000066; font-weight: bold;">,</span> 0xff000000<span style="color: #000066; font-weight: bold;">,</span> <span style="color: #0033ff; font-weight: bold;">true</span><span style="color: #000066; font-weight: bold;">,</span> <span style="color: #990000;">&quot;ground&quot;</span><span style="color: #000000;">&#41;</span><span style="color: #000000;">&#41;</span> <span style="color: #0033ff; font-weight: bold;">as</span> FlxSprite<span style="color: #000066; font-weight: bold;">;</span><br />
&nbsp; &nbsp; &nbsp; ground<span style="color: #000066; font-weight: bold;">.</span>fixed = <span style="color: #0033ff; font-weight: bold;">true</span><span style="color: #000066; font-weight: bold;">;</span> &nbsp;<span style="color: #009900; font-style: italic;">// set it to fixed, not moves, and solid for collision.</span><br />
&nbsp; &nbsp; &nbsp; ground<span style="color: #000066; font-weight: bold;">.</span>moves = <span style="color: #0033ff; font-weight: bold;">false</span><span style="color: #000066; font-weight: bold;">;</span><br />
&nbsp; &nbsp; &nbsp; ground<span style="color: #000066; font-weight: bold;">.</span>solid = <span style="color: #0033ff; font-weight: bold;">true</span><span style="color: #000066; font-weight: bold;">;</span><br />
&nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; <span style="color: #009900; font-style: italic;">//lets seed the ground with some leaves already:</span><br />
&nbsp; &nbsp; &nbsp; <span style="color: #6699cc; font-weight: bold;">var</span> tL<span style="color: #000066; font-weight: bold;">:</span>LeafBit<span style="color: #000066; font-weight: bold;">;</span><br />
&nbsp; &nbsp; &nbsp; <span style="color: #0033ff; font-weight: bold;">for</span> <span style="color: #000000;">&#40;</span><span style="color: #6699cc; font-weight: bold;">var</span> tY<span style="color: #000066; font-weight: bold;">:</span><span style="color: #004993;">int</span> = FlxG<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">height</span> <span style="color: #000066; font-weight: bold;">-</span><span style="color: #000000; font-weight:bold;">6</span><span style="color: #000066; font-weight: bold;">;</span> tY <span style="color: #000066; font-weight: bold;">&gt;</span> FlxG<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">height</span> <span style="color: #000066; font-weight: bold;">-</span> <span style="color: #000000; font-weight:bold;">8</span><span style="color: #000066; font-weight: bold;">;</span> tY<span style="color: #000066; font-weight: bold;">--</span><span style="color: #000000;">&#41;</span><br />
&nbsp; &nbsp; &nbsp; <span style="color: #000000;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0033ff; font-weight: bold;">for</span> <span style="color: #000000;">&#40;</span><span style="color: #6699cc; font-weight: bold;">var</span> tX<span style="color: #000066; font-weight: bold;">:</span><span style="color: #004993;">int</span> = <span style="color: #000066; font-weight: bold;">-</span><span style="color: #000000; font-weight:bold;">50</span><span style="color: #000066; font-weight: bold;">;</span> tX <span style="color: #000066; font-weight: bold;">&lt;</span>= FlxG<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">width</span><span style="color: #000066; font-weight: bold;">+</span><span style="color: #000000; font-weight:bold;">50</span><span style="color: #000066; font-weight: bold;">;</span> tX<span style="color: #000066; font-weight: bold;">++</span><span style="color: #000000;">&#41;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0033ff; font-weight: bold;">if</span> <span style="color: #000000;">&#40;</span>Rnd<span style="color: #000066; font-weight: bold;">.</span>boolean<span style="color: #000000;">&#40;</span><span style="color: #000000; font-weight:bold;">0.5</span><span style="color: #000000;">&#41;</span><span style="color: #000000;">&#41;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; tL = leafgrp<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">add</span><span style="color: #000000;">&#40;</span><span style="color: #0033ff; font-weight: bold;">new</span> LeafBit<span style="color: #000000;">&#40;</span>tX<span style="color: #000066; font-weight: bold;">,</span> tY<span style="color: #000066; font-weight: bold;">,</span> Rnd<span style="color: #000066; font-weight: bold;">.</span>integer<span style="color: #000000;">&#40;</span><span style="color: #000000; font-weight:bold;">1</span><span style="color: #000066; font-weight: bold;">,</span> <span style="color: #000000; font-weight:bold;">2</span><span style="color: #000000;">&#41;</span><span style="color: #000000;">&#41;</span> <span style="color: #0033ff; font-weight: bold;">as</span> LeafBit<span style="color: #000000;">&#41;</span> <span style="color: #0033ff; font-weight: bold;">as</span> LeafBit<span style="color: #000066; font-weight: bold;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; tL<span style="color: #000066; font-weight: bold;">.</span>solid = <span style="color: #0033ff; font-weight: bold;">true</span><span style="color: #000066; font-weight: bold;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; tL<span style="color: #000066; font-weight: bold;">.</span>falling = <span style="color: #0033ff; font-weight: bold;">true</span><span style="color: #000066; font-weight: bold;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; tL<span style="color: #000066; font-weight: bold;">.</span>landed = <span style="color: #0033ff; font-weight: bold;">false</span><span style="color: #000066; font-weight: bold;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000;">&#125;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000;">&#125;</span><br />
&nbsp; &nbsp; &nbsp; <span style="color: #000000;">&#125;</span><br />
&nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; <span style="color: #009900; font-style: italic;">// set the wind's speed and goal</span><br />
&nbsp; &nbsp; &nbsp; wind = Rnd<span style="color: #000066; font-weight: bold;">.</span>float<span style="color: #000000;">&#40;</span> <span style="color: #000066; font-weight: bold;">-</span><span style="color: #000000; font-weight:bold;">10</span><span style="color: #000066; font-weight: bold;">,</span> <span style="color: #000000; font-weight:bold;">10</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span><br />
&nbsp; &nbsp; &nbsp; goal = Rnd<span style="color: #000066; font-weight: bold;">.</span>float<span style="color: #000000;">&#40;</span> <span style="color: #000066; font-weight: bold;">-</span><span style="color: #000000; font-weight:bold;">10</span><span style="color: #000066; font-weight: bold;">,</span> <span style="color: #000000; font-weight:bold;">10</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span><br />
&nbsp; &nbsp; <span style="color: #000000;">&#125;</span><br />
&nbsp; &nbsp; <br />
&nbsp; &nbsp; <span style="color: #0033ff; font-weight: bold;">private</span> <span style="color: #339966; font-weight: bold;">function</span> BuildTree<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">:</span><span style="color: #0033ff; font-weight: bold;">void</span><br />
&nbsp; &nbsp; <span style="color: #000000;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; <span style="color: #009900; font-style: italic;">//build our tree - this gets a bit complicated...</span><br />
&nbsp; &nbsp; &nbsp; <span style="color: #009900; font-style: italic;">// start at the bottom</span><br />
&nbsp; &nbsp; &nbsp; <span style="color: #0033ff; font-weight: bold;">for</span> <span style="color: #000000;">&#40;</span><span style="color: #6699cc; font-weight: bold;">var</span> tY<span style="color: #000066; font-weight: bold;">:</span><span style="color: #004993;">int</span> = FlxG<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">height</span> <span style="color: #000066; font-weight: bold;">-</span> <span style="color: #000000; font-weight:bold;">6</span><span style="color: #000066; font-weight: bold;">;</span> tY <span style="color: #000066; font-weight: bold;">&gt;</span> FlxG<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">height</span> <span style="color: #000066; font-weight: bold;">-</span> <span style="color: #000000; font-weight:bold;">25</span><span style="color: #000066; font-weight: bold;">;</span> tY<span style="color: #000066; font-weight: bold;">--</span><span style="color: #000000;">&#41;</span><br />
&nbsp; &nbsp; &nbsp; <span style="color: #000000;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0033ff; font-weight: bold;">for</span> <span style="color: #000000;">&#40;</span><span style="color: #6699cc; font-weight: bold;">var</span> tX<span style="color: #000066; font-weight: bold;">:</span><span style="color: #004993;">int</span> = <span style="color: #000000;">&#40;</span>FlxG<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">width</span><span style="color: #000066; font-weight: bold;">/</span><span style="color: #000000; font-weight:bold;">2</span><span style="color: #000000;">&#41;</span> <span style="color: #000066; font-weight: bold;">-</span> <span style="color: #000000; font-weight:bold;">2</span><span style="color: #000066; font-weight: bold;">;</span> tX <span style="color: #000066; font-weight: bold;">&lt;</span>= <span style="color: #000000;">&#40;</span>FlxG<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">width</span><span style="color: #000066; font-weight: bold;">/</span><span style="color: #000000; font-weight:bold;">2</span><span style="color: #000000;">&#41;</span> <span style="color: #000066; font-weight: bold;">+</span> <span style="color: #000000; font-weight:bold;">2</span><span style="color: #000066; font-weight: bold;">;</span> tX<span style="color: #000066; font-weight: bold;">++</span><span style="color: #000000;">&#41;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; treegrp<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">add</span><span style="color: #000000;">&#40;</span><span style="color: #0033ff; font-weight: bold;">new</span> TreeBit<span style="color: #000000;">&#40;</span>tX<span style="color: #000066; font-weight: bold;">,</span> tY<span style="color: #000066; font-weight: bold;">,</span><span style="color: #000000; font-weight:bold;">50</span><span style="color: #000000;">&#41;</span> <span style="color: #0033ff; font-weight: bold;">as</span> TreeBit<span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000;">&#125;</span><br />
&nbsp; &nbsp; &nbsp; <span style="color: #000000;">&#125;</span><br />
&nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; <span style="color: #009900; font-style: italic;">// bottom block of branches</span><br />
&nbsp; &nbsp; &nbsp; <span style="color: #0033ff; font-weight: bold;">for</span> <span style="color: #000000;">&#40;</span>tY = FlxG<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">height</span> <span style="color: #000066; font-weight: bold;">-</span><span style="color: #000000; font-weight:bold;">20</span><span style="color: #000066; font-weight: bold;">;</span> tY <span style="color: #000066; font-weight: bold;">&gt;</span> FlxG<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">height</span> <span style="color: #000066; font-weight: bold;">-</span> <span style="color: #000000; font-weight:bold;">25</span><span style="color: #000066; font-weight: bold;">;</span> tY<span style="color: #000066; font-weight: bold;">--</span><span style="color: #000000;">&#41;</span><br />
&nbsp; &nbsp; &nbsp; <span style="color: #000000;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0033ff; font-weight: bold;">for</span> <span style="color: #000000;">&#40;</span>tX = <span style="color: #000000;">&#40;</span>FlxG<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">width</span> <span style="color: #000066; font-weight: bold;">/</span> <span style="color: #000000; font-weight:bold;">2</span><span style="color: #000000;">&#41;</span> <span style="color: #000066; font-weight: bold;">-</span><span style="color: #000000; font-weight:bold;">10</span><span style="color: #000066; font-weight: bold;">;</span> tX <span style="color: #000066; font-weight: bold;">&lt;</span>= <span style="color: #000000;">&#40;</span>FlxG<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">width</span> <span style="color: #000066; font-weight: bold;">/</span> <span style="color: #000000; font-weight:bold;">2</span><span style="color: #000000;">&#41;</span> <span style="color: #000066; font-weight: bold;">+</span> <span style="color: #000000; font-weight:bold;">10</span><span style="color: #000066; font-weight: bold;">;</span> tX<span style="color: #000066; font-weight: bold;">++</span><span style="color: #000000;">&#41;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0033ff; font-weight: bold;">if</span> <span style="color: #000000;">&#40;</span>Rnd<span style="color: #000066; font-weight: bold;">.</span>boolean<span style="color: #000000;">&#40;</span>Rnd<span style="color: #000066; font-weight: bold;">.</span>float<span style="color: #000000;">&#40;</span><span style="color: #000000; font-weight:bold;">0.2</span><span style="color: #000066; font-weight: bold;">,</span> <span style="color: #000000; font-weight:bold;">0.4</span><span style="color: #000000;">&#41;</span><span style="color: #000000;">&#41;</span><span style="color: #000000;">&#41;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; treegrp<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">add</span><span style="color: #000000;">&#40;</span><span style="color: #0033ff; font-weight: bold;">new</span> TreeBit<span style="color: #000000;">&#40;</span>tX<span style="color: #000066; font-weight: bold;">,</span> tY<span style="color: #000066; font-weight: bold;">,</span> Rnd<span style="color: #000066; font-weight: bold;">.</span>integer<span style="color: #000000;">&#40;</span><span style="color: #000000; font-weight:bold;">4</span><span style="color: #000066; font-weight: bold;">,</span><span style="color: #000000; font-weight:bold;">6</span><span style="color: #000000;">&#41;</span><span style="color: #000000;">&#41;</span> <span style="color: #0033ff; font-weight: bold;">as</span> TreeBit<span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000;">&#125;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000;">&#125;</span><br />
&nbsp; &nbsp; &nbsp; <span style="color: #000000;">&#125;</span><br />
&nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; <span style="color: #009900; font-style: italic;">//make the central mass of branches</span><br />
&nbsp; &nbsp; &nbsp; <span style="color: #0033ff; font-weight: bold;">for</span> <span style="color: #000000;">&#40;</span>tY = FlxG<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">height</span> <span style="color: #000066; font-weight: bold;">-</span> <span style="color: #000000; font-weight:bold;">25</span><span style="color: #000066; font-weight: bold;">;</span> tY <span style="color: #000066; font-weight: bold;">&gt;</span> FlxG<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">height</span> <span style="color: #000066; font-weight: bold;">-</span> <span style="color: #000000; font-weight:bold;">36</span><span style="color: #000066; font-weight: bold;">;</span> tY<span style="color: #000066; font-weight: bold;">--</span><span style="color: #000000;">&#41;</span><br />
&nbsp; &nbsp; &nbsp; <span style="color: #000000;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0033ff; font-weight: bold;">for</span> <span style="color: #000000;">&#40;</span>tX = <span style="color: #000000;">&#40;</span>FlxG<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">width</span> <span style="color: #000066; font-weight: bold;">/</span> <span style="color: #000000; font-weight:bold;">2</span><span style="color: #000000;">&#41;</span> <span style="color: #000066; font-weight: bold;">-</span> <span style="color: #000000; font-weight:bold;">6</span><span style="color: #000066; font-weight: bold;">;</span> tX <span style="color: #000066; font-weight: bold;">&lt;</span>= <span style="color: #000000;">&#40;</span>FlxG<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">width</span> <span style="color: #000066; font-weight: bold;">/</span> <span style="color: #000000; font-weight:bold;">2</span><span style="color: #000000;">&#41;</span> <span style="color: #000066; font-weight: bold;">+</span> <span style="color: #000000; font-weight:bold;">6</span><span style="color: #000066; font-weight: bold;">;</span> tX<span style="color: #000066; font-weight: bold;">++</span><span style="color: #000000;">&#41;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0033ff; font-weight: bold;">if</span> <span style="color: #000000;">&#40;</span>Rnd<span style="color: #000066; font-weight: bold;">.</span>boolean<span style="color: #000000;">&#40;</span>Rnd<span style="color: #000066; font-weight: bold;">.</span>float<span style="color: #000000;">&#40;</span><span style="color: #000000; font-weight:bold;">0.5</span><span style="color: #000066; font-weight: bold;">,</span> <span style="color: #000000; font-weight:bold;">0.7</span><span style="color: #000000;">&#41;</span><span style="color: #000000;">&#41;</span><span style="color: #000000;">&#41;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; treegrp<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">add</span><span style="color: #000000;">&#40;</span><span style="color: #0033ff; font-weight: bold;">new</span> TreeBit<span style="color: #000000;">&#40;</span>tX<span style="color: #000066; font-weight: bold;">,</span> tY<span style="color: #000066; font-weight: bold;">,</span> Rnd<span style="color: #000066; font-weight: bold;">.</span>integer<span style="color: #000000;">&#40;</span><span style="color: #000000; font-weight:bold;">6</span><span style="color: #000066; font-weight: bold;">,</span><span style="color: #000000; font-weight:bold;">8</span><span style="color: #000000;">&#41;</span><span style="color: #000000;">&#41;</span> <span style="color: #0033ff; font-weight: bold;">as</span> TreeBit<span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000;">&#125;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000;">&#125;</span><br />
&nbsp; &nbsp; &nbsp; <span style="color: #000000;">&#125;</span><br />
&nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; <span style="color: #009900; font-style: italic;">//make the left-side mass of branches</span><br />
&nbsp; &nbsp; &nbsp; <span style="color: #0033ff; font-weight: bold;">for</span> <span style="color: #000000;">&#40;</span>tY = FlxG<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">height</span> <span style="color: #000066; font-weight: bold;">-</span> <span style="color: #000000; font-weight:bold;">23</span><span style="color: #000066; font-weight: bold;">;</span> tY <span style="color: #000066; font-weight: bold;">&gt;</span> FlxG<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">height</span> <span style="color: #000066; font-weight: bold;">-</span> <span style="color: #000000; font-weight:bold;">36</span><span style="color: #000066; font-weight: bold;">;</span> tY<span style="color: #000066; font-weight: bold;">--</span><span style="color: #000000;">&#41;</span><br />
&nbsp; &nbsp; &nbsp; <span style="color: #000000;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0033ff; font-weight: bold;">for</span> <span style="color: #000000;">&#40;</span>tX = <span style="color: #000000;">&#40;</span>FlxG<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">width</span> <span style="color: #000066; font-weight: bold;">/</span> <span style="color: #000000; font-weight:bold;">2</span><span style="color: #000000;">&#41;</span> <span style="color: #000066; font-weight: bold;">-</span> <span style="color: #000000; font-weight:bold;">18</span><span style="color: #000066; font-weight: bold;">;</span> tX <span style="color: #000066; font-weight: bold;">&lt;</span>= <span style="color: #000000;">&#40;</span>FlxG<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">width</span> <span style="color: #000066; font-weight: bold;">/</span> <span style="color: #000000; font-weight:bold;">2</span><span style="color: #000000;">&#41;</span> <span style="color: #000066; font-weight: bold;">-</span> <span style="color: #000000; font-weight:bold;">6</span><span style="color: #000066; font-weight: bold;">;</span> tX<span style="color: #000066; font-weight: bold;">++</span><span style="color: #000000;">&#41;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0033ff; font-weight: bold;">if</span> <span style="color: #000000;">&#40;</span>Rnd<span style="color: #000066; font-weight: bold;">.</span>boolean<span style="color: #000000;">&#40;</span>Rnd<span style="color: #000066; font-weight: bold;">.</span>float<span style="color: #000000;">&#40;</span><span style="color: #000000; font-weight:bold;">0.1</span><span style="color: #000066; font-weight: bold;">,</span> <span style="color: #000000; font-weight:bold;">0.4</span><span style="color: #000000;">&#41;</span><span style="color: #000000;">&#41;</span><span style="color: #000000;">&#41;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; treegrp<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">add</span><span style="color: #000000;">&#40;</span><span style="color: #0033ff; font-weight: bold;">new</span> TreeBit<span style="color: #000000;">&#40;</span>tX<span style="color: #000066; font-weight: bold;">,</span> tY<span style="color: #000066; font-weight: bold;">,</span> Rnd<span style="color: #000066; font-weight: bold;">.</span>integer<span style="color: #000000;">&#40;</span><span style="color: #000000; font-weight:bold;">4</span><span style="color: #000066; font-weight: bold;">,</span><span style="color: #000000; font-weight:bold;">6</span><span style="color: #000000;">&#41;</span><span style="color: #000000;">&#41;</span> <span style="color: #0033ff; font-weight: bold;">as</span> TreeBit<span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000;">&#125;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000;">&#125;</span><br />
&nbsp; &nbsp; &nbsp; <span style="color: #000000;">&#125;</span><br />
&nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; <span style="color: #009900; font-style: italic;">//make the right-side mass of branches</span><br />
&nbsp; &nbsp; &nbsp; <span style="color: #0033ff; font-weight: bold;">for</span> <span style="color: #000000;">&#40;</span>tY = FlxG<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">height</span> <span style="color: #000066; font-weight: bold;">-</span> <span style="color: #000000; font-weight:bold;">23</span><span style="color: #000066; font-weight: bold;">;</span> tY <span style="color: #000066; font-weight: bold;">&gt;</span> FlxG<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">height</span> <span style="color: #000066; font-weight: bold;">-</span> <span style="color: #000000; font-weight:bold;">36</span><span style="color: #000066; font-weight: bold;">;</span> tY<span style="color: #000066; font-weight: bold;">--</span><span style="color: #000000;">&#41;</span><br />
&nbsp; &nbsp; &nbsp; <span style="color: #000000;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0033ff; font-weight: bold;">for</span> <span style="color: #000000;">&#40;</span>tX = <span style="color: #000000;">&#40;</span>FlxG<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">width</span> <span style="color: #000066; font-weight: bold;">/</span> <span style="color: #000000; font-weight:bold;">2</span><span style="color: #000000;">&#41;</span> <span style="color: #000066; font-weight: bold;">+</span> <span style="color: #000000; font-weight:bold;">6</span><span style="color: #000066; font-weight: bold;">;</span> tX <span style="color: #000066; font-weight: bold;">&lt;</span>= <span style="color: #000000;">&#40;</span>FlxG<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">width</span> <span style="color: #000066; font-weight: bold;">/</span> <span style="color: #000000; font-weight:bold;">2</span><span style="color: #000000;">&#41;</span> <span style="color: #000066; font-weight: bold;">+</span> <span style="color: #000000; font-weight:bold;">18</span><span style="color: #000066; font-weight: bold;">;</span> tX<span style="color: #000066; font-weight: bold;">++</span><span style="color: #000000;">&#41;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0033ff; font-weight: bold;">if</span> <span style="color: #000000;">&#40;</span>Rnd<span style="color: #000066; font-weight: bold;">.</span>boolean<span style="color: #000000;">&#40;</span>Rnd<span style="color: #000066; font-weight: bold;">.</span>float<span style="color: #000000;">&#40;</span><span style="color: #000000; font-weight:bold;">0.1</span><span style="color: #000066; font-weight: bold;">,</span> <span style="color: #000000; font-weight:bold;">0.4</span><span style="color: #000000;">&#41;</span><span style="color: #000000;">&#41;</span><span style="color: #000000;">&#41;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; treegrp<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">add</span><span style="color: #000000;">&#40;</span><span style="color: #0033ff; font-weight: bold;">new</span> TreeBit<span style="color: #000000;">&#40;</span>tX<span style="color: #000066; font-weight: bold;">,</span> tY<span style="color: #000066; font-weight: bold;">,</span> Rnd<span style="color: #000066; font-weight: bold;">.</span>integer<span style="color: #000000;">&#40;</span><span style="color: #000000; font-weight:bold;">4</span><span style="color: #000066; font-weight: bold;">,</span><span style="color: #000000; font-weight:bold;">6</span><span style="color: #000000;">&#41;</span><span style="color: #000000;">&#41;</span> <span style="color: #0033ff; font-weight: bold;">as</span> TreeBit<span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000;">&#125;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000;">&#125;</span><br />
&nbsp; &nbsp; &nbsp; <span style="color: #000000;">&#125;</span><br />
&nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; <span style="color: #009900; font-style: italic;">//make the upper middle mass of branches</span><br />
&nbsp; &nbsp; &nbsp; <span style="color: #0033ff; font-weight: bold;">for</span> <span style="color: #000000;">&#40;</span>tY = FlxG<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">height</span> <span style="color: #000066; font-weight: bold;">-</span> <span style="color: #000000; font-weight:bold;">36</span><span style="color: #000066; font-weight: bold;">;</span> tY <span style="color: #000066; font-weight: bold;">&gt;</span> FlxG<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">height</span> <span style="color: #000066; font-weight: bold;">-</span> <span style="color: #000000; font-weight:bold;">47</span><span style="color: #000066; font-weight: bold;">;</span> tY<span style="color: #000066; font-weight: bold;">--</span><span style="color: #000000;">&#41;</span><br />
&nbsp; &nbsp; &nbsp; <span style="color: #000000;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0033ff; font-weight: bold;">for</span> <span style="color: #000000;">&#40;</span>tX = <span style="color: #000000;">&#40;</span>FlxG<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">width</span> <span style="color: #000066; font-weight: bold;">/</span> <span style="color: #000000; font-weight:bold;">2</span><span style="color: #000000;">&#41;</span> <span style="color: #000066; font-weight: bold;">-</span> <span style="color: #000000; font-weight:bold;">14</span><span style="color: #000066; font-weight: bold;">;</span> tX <span style="color: #000066; font-weight: bold;">&lt;</span>= <span style="color: #000000;">&#40;</span>FlxG<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">width</span> <span style="color: #000066; font-weight: bold;">/</span> <span style="color: #000000; font-weight:bold;">2</span><span style="color: #000000;">&#41;</span> <span style="color: #000066; font-weight: bold;">+</span> <span style="color: #000000; font-weight:bold;">14</span><span style="color: #000066; font-weight: bold;">;</span> tX<span style="color: #000066; font-weight: bold;">++</span><span style="color: #000000;">&#41;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0033ff; font-weight: bold;">if</span> <span style="color: #000000;">&#40;</span>Rnd<span style="color: #000066; font-weight: bold;">.</span>boolean<span style="color: #000000;">&#40;</span>Rnd<span style="color: #000066; font-weight: bold;">.</span>float<span style="color: #000000;">&#40;</span><span style="color: #000000; font-weight:bold;">0.2</span><span style="color: #000066; font-weight: bold;">,</span> <span style="color: #000000; font-weight:bold;">0.6</span><span style="color: #000000;">&#41;</span><span style="color: #000000;">&#41;</span><span style="color: #000000;">&#41;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; treegrp<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">add</span><span style="color: #000000;">&#40;</span><span style="color: #0033ff; font-weight: bold;">new</span> TreeBit<span style="color: #000000;">&#40;</span>tX<span style="color: #000066; font-weight: bold;">,</span> tY<span style="color: #000066; font-weight: bold;">,</span> Rnd<span style="color: #000066; font-weight: bold;">.</span>integer<span style="color: #000000;">&#40;</span><span style="color: #000000; font-weight:bold;">3</span><span style="color: #000066; font-weight: bold;">,</span><span style="color: #000000; font-weight:bold;">5</span><span style="color: #000000;">&#41;</span><span style="color: #000000;">&#41;</span> <span style="color: #0033ff; font-weight: bold;">as</span> TreeBit<span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000;">&#125;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000;">&#125;</span><br />
&nbsp; &nbsp; &nbsp; <span style="color: #000000;">&#125;</span><br />
&nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; <span style="color: #009900; font-style: italic;">// make the top branches</span><br />
&nbsp; &nbsp; &nbsp; <span style="color: #0033ff; font-weight: bold;">for</span> <span style="color: #000000;">&#40;</span>tY = FlxG<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">height</span> <span style="color: #000066; font-weight: bold;">-</span> <span style="color: #000000; font-weight:bold;">47</span><span style="color: #000066; font-weight: bold;">;</span> tY <span style="color: #000066; font-weight: bold;">&gt;</span> FlxG<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">height</span> <span style="color: #000066; font-weight: bold;">-</span> <span style="color: #000000; font-weight:bold;">52</span><span style="color: #000066; font-weight: bold;">;</span> tY<span style="color: #000066; font-weight: bold;">--</span><span style="color: #000000;">&#41;</span><br />
&nbsp; &nbsp; &nbsp; <span style="color: #000000;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0033ff; font-weight: bold;">for</span> <span style="color: #000000;">&#40;</span>tX = <span style="color: #000000;">&#40;</span>FlxG<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">width</span> <span style="color: #000066; font-weight: bold;">/</span> <span style="color: #000000; font-weight:bold;">2</span><span style="color: #000000;">&#41;</span> <span style="color: #000066; font-weight: bold;">-</span> <span style="color: #000000; font-weight:bold;">8</span><span style="color: #000066; font-weight: bold;">;</span> tX <span style="color: #000066; font-weight: bold;">&lt;</span>= <span style="color: #000000;">&#40;</span>FlxG<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">width</span> <span style="color: #000066; font-weight: bold;">/</span> <span style="color: #000000; font-weight:bold;">2</span><span style="color: #000000;">&#41;</span> <span style="color: #000066; font-weight: bold;">+</span> <span style="color: #000000; font-weight:bold;">8</span><span style="color: #000066; font-weight: bold;">;</span> tX<span style="color: #000066; font-weight: bold;">++</span><span style="color: #000000;">&#41;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0033ff; font-weight: bold;">if</span> <span style="color: #000000;">&#40;</span>Rnd<span style="color: #000066; font-weight: bold;">.</span>boolean<span style="color: #000000;">&#40;</span>Rnd<span style="color: #000066; font-weight: bold;">.</span>float<span style="color: #000000;">&#40;</span><span style="color: #000000; font-weight:bold;">0.1</span><span style="color: #000066; font-weight: bold;">,</span> <span style="color: #000000; font-weight:bold;">0.3</span><span style="color: #000000;">&#41;</span><span style="color: #000000;">&#41;</span><span style="color: #000000;">&#41;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; treegrp<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">add</span><span style="color: #000000;">&#40;</span><span style="color: #0033ff; font-weight: bold;">new</span> TreeBit<span style="color: #000000;">&#40;</span>tX<span style="color: #000066; font-weight: bold;">,</span> tY<span style="color: #000066; font-weight: bold;">,</span> Rnd<span style="color: #000066; font-weight: bold;">.</span>integer<span style="color: #000000;">&#40;</span><span style="color: #000000; font-weight:bold;">2</span><span style="color: #000066; font-weight: bold;">,</span><span style="color: #000000; font-weight:bold;">4</span><span style="color: #000000;">&#41;</span><span style="color: #000000;">&#41;</span> <span style="color: #0033ff; font-weight: bold;">as</span> TreeBit<span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000;">&#125;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000;">&#125;</span><br />
&nbsp; &nbsp; &nbsp; <span style="color: #000000;">&#125;</span><br />
&nbsp; &nbsp; <span style="color: #000000;">&#125;</span><br />
&nbsp; &nbsp; <br />
&nbsp; &nbsp; <span style="color: #0033ff; font-weight: bold;">private</span> <span style="color: #339966; font-weight: bold;">function</span> BuildLeaves<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">:</span><span style="color: #0033ff; font-weight: bold;">void</span><br />
&nbsp; &nbsp; <span style="color: #000000;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; <span style="color: #009900; font-style: italic;">// bottom block of branches</span><br />
&nbsp; &nbsp; &nbsp; <span style="color: #0033ff; font-weight: bold;">for</span> <span style="color: #000000;">&#40;</span><span style="color: #6699cc; font-weight: bold;">var</span> tY<span style="color: #000066; font-weight: bold;">:</span><span style="color: #004993;">int</span> = FlxG<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">height</span> <span style="color: #000066; font-weight: bold;">-</span><span style="color: #000000; font-weight:bold;">18</span><span style="color: #000066; font-weight: bold;">;</span> tY <span style="color: #000066; font-weight: bold;">&gt;</span> FlxG<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">height</span> <span style="color: #000066; font-weight: bold;">-</span> <span style="color: #000000; font-weight:bold;">25</span><span style="color: #000066; font-weight: bold;">;</span> tY<span style="color: #000066; font-weight: bold;">--</span><span style="color: #000000;">&#41;</span><br />
&nbsp; &nbsp; &nbsp; <span style="color: #000000;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0033ff; font-weight: bold;">for</span> <span style="color: #000000;">&#40;</span><span style="color: #6699cc; font-weight: bold;">var</span> tX<span style="color: #000066; font-weight: bold;">:</span><span style="color: #004993;">int</span> = <span style="color: #000000;">&#40;</span>FlxG<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">width</span> <span style="color: #000066; font-weight: bold;">/</span> <span style="color: #000000; font-weight:bold;">2</span><span style="color: #000000;">&#41;</span> <span style="color: #000066; font-weight: bold;">-</span> <span style="color: #000000; font-weight:bold;">12</span><span style="color: #000066; font-weight: bold;">;</span> tX <span style="color: #000066; font-weight: bold;">&lt;</span>= <span style="color: #000000;">&#40;</span>FlxG<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">width</span> <span style="color: #000066; font-weight: bold;">/</span> <span style="color: #000000; font-weight:bold;">2</span><span style="color: #000000;">&#41;</span> <span style="color: #000066; font-weight: bold;">+</span> <span style="color: #000000; font-weight:bold;">12</span><span style="color: #000066; font-weight: bold;">;</span> tX<span style="color: #000066; font-weight: bold;">++</span><span style="color: #000000;">&#41;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0033ff; font-weight: bold;">if</span> <span style="color: #000000;">&#40;</span>Rnd<span style="color: #000066; font-weight: bold;">.</span>boolean<span style="color: #000000;">&#40;</span>Rnd<span style="color: #000066; font-weight: bold;">.</span>float<span style="color: #000000;">&#40;</span><span style="color: #000000; font-weight:bold;">0.3</span><span style="color: #000066; font-weight: bold;">,</span> <span style="color: #000000; font-weight:bold;">0.5</span><span style="color: #000000;">&#41;</span><span style="color: #000000;">&#41;</span><span style="color: #000000;">&#41;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; leafgrp<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">add</span><span style="color: #000000;">&#40;</span><span style="color: #0033ff; font-weight: bold;">new</span> LeafBit<span style="color: #000000;">&#40;</span>tX<span style="color: #000066; font-weight: bold;">,</span> tY<span style="color: #000066; font-weight: bold;">,</span> Rnd<span style="color: #000066; font-weight: bold;">.</span>integer<span style="color: #000000;">&#40;</span><span style="color: #000000; font-weight:bold;">1</span><span style="color: #000066; font-weight: bold;">,</span><span style="color: #000000; font-weight:bold;">2</span><span style="color: #000000;">&#41;</span><span style="color: #000000;">&#41;</span> <span style="color: #0033ff; font-weight: bold;">as</span> LeafBit<span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000;">&#125;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000;">&#125;</span><br />
&nbsp; &nbsp; &nbsp; <span style="color: #000000;">&#125;</span><br />
&nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; <span style="color: #009900; font-style: italic;">//make the central mass of branches</span><br />
&nbsp; &nbsp; &nbsp; <span style="color: #0033ff; font-weight: bold;">for</span> <span style="color: #000000;">&#40;</span>tY = FlxG<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">height</span> <span style="color: #000066; font-weight: bold;">-</span> <span style="color: #000000; font-weight:bold;">25</span><span style="color: #000066; font-weight: bold;">;</span> tY <span style="color: #000066; font-weight: bold;">&gt;</span> FlxG<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">height</span> <span style="color: #000066; font-weight: bold;">-</span> <span style="color: #000000; font-weight:bold;">36</span><span style="color: #000066; font-weight: bold;">;</span> tY<span style="color: #000066; font-weight: bold;">--</span><span style="color: #000000;">&#41;</span><br />
&nbsp; &nbsp; &nbsp; <span style="color: #000000;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0033ff; font-weight: bold;">for</span> <span style="color: #000000;">&#40;</span>tX = <span style="color: #000000;">&#40;</span>FlxG<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">width</span> <span style="color: #000066; font-weight: bold;">/</span> <span style="color: #000000; font-weight:bold;">2</span><span style="color: #000000;">&#41;</span> <span style="color: #000066; font-weight: bold;">-</span> <span style="color: #000000; font-weight:bold;">6</span><span style="color: #000066; font-weight: bold;">;</span> tX <span style="color: #000066; font-weight: bold;">&lt;</span>= <span style="color: #000000;">&#40;</span>FlxG<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">width</span> <span style="color: #000066; font-weight: bold;">/</span> <span style="color: #000000; font-weight:bold;">2</span><span style="color: #000000;">&#41;</span> <span style="color: #000066; font-weight: bold;">+</span> <span style="color: #000000; font-weight:bold;">6</span><span style="color: #000066; font-weight: bold;">;</span> tX<span style="color: #000066; font-weight: bold;">++</span><span style="color: #000000;">&#41;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0033ff; font-weight: bold;">if</span> <span style="color: #000000;">&#40;</span>Rnd<span style="color: #000066; font-weight: bold;">.</span>boolean<span style="color: #000000;">&#40;</span>Rnd<span style="color: #000066; font-weight: bold;">.</span>float<span style="color: #000000;">&#40;</span><span style="color: #000000; font-weight:bold;">0.6</span><span style="color: #000066; font-weight: bold;">,</span> <span style="color: #000000; font-weight:bold;">0.8</span><span style="color: #000000;">&#41;</span><span style="color: #000000;">&#41;</span><span style="color: #000000;">&#41;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; leafgrp<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">add</span><span style="color: #000000;">&#40;</span><span style="color: #0033ff; font-weight: bold;">new</span> LeafBit<span style="color: #000000;">&#40;</span>tX<span style="color: #000066; font-weight: bold;">,</span> tY<span style="color: #000066; font-weight: bold;">,</span> Rnd<span style="color: #000066; font-weight: bold;">.</span>integer<span style="color: #000000;">&#40;</span><span style="color: #000000; font-weight:bold;">1</span><span style="color: #000066; font-weight: bold;">,</span><span style="color: #000000; font-weight:bold;">2</span><span style="color: #000000;">&#41;</span><span style="color: #000000;">&#41;</span> <span style="color: #0033ff; font-weight: bold;">as</span> LeafBit<span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000;">&#125;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000;">&#125;</span><br />
&nbsp; &nbsp; &nbsp; <span style="color: #000000;">&#125;</span><br />
&nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; <span style="color: #009900; font-style: italic;">//make the left-side mass of branches</span><br />
&nbsp; &nbsp; &nbsp; <span style="color: #0033ff; font-weight: bold;">for</span> <span style="color: #000000;">&#40;</span>tY = FlxG<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">height</span> <span style="color: #000066; font-weight: bold;">-</span> <span style="color: #000000; font-weight:bold;">21</span><span style="color: #000066; font-weight: bold;">;</span> tY <span style="color: #000066; font-weight: bold;">&gt;</span> FlxG<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">height</span> <span style="color: #000066; font-weight: bold;">-</span> <span style="color: #000000; font-weight:bold;">38</span><span style="color: #000066; font-weight: bold;">;</span> tY<span style="color: #000066; font-weight: bold;">--</span><span style="color: #000000;">&#41;</span><br />
&nbsp; &nbsp; &nbsp; <span style="color: #000000;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0033ff; font-weight: bold;">for</span> <span style="color: #000000;">&#40;</span>tX = <span style="color: #000000;">&#40;</span>FlxG<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">width</span> <span style="color: #000066; font-weight: bold;">/</span> <span style="color: #000000; font-weight:bold;">2</span><span style="color: #000000;">&#41;</span> <span style="color: #000066; font-weight: bold;">-</span> <span style="color: #000000; font-weight:bold;">20</span><span style="color: #000066; font-weight: bold;">;</span> tX <span style="color: #000066; font-weight: bold;">&lt;</span>= <span style="color: #000000;">&#40;</span>FlxG<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">width</span> <span style="color: #000066; font-weight: bold;">/</span> <span style="color: #000000; font-weight:bold;">2</span><span style="color: #000000;">&#41;</span> <span style="color: #000066; font-weight: bold;">-</span> <span style="color: #000000; font-weight:bold;">6</span><span style="color: #000066; font-weight: bold;">;</span> tX<span style="color: #000066; font-weight: bold;">++</span><span style="color: #000000;">&#41;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0033ff; font-weight: bold;">if</span> <span style="color: #000000;">&#40;</span>Rnd<span style="color: #000066; font-weight: bold;">.</span>boolean<span style="color: #000000;">&#40;</span>Rnd<span style="color: #000066; font-weight: bold;">.</span>float<span style="color: #000000;">&#40;</span><span style="color: #000000; font-weight:bold;">0.2</span><span style="color: #000066; font-weight: bold;">,</span> <span style="color: #000000; font-weight:bold;">0.5</span><span style="color: #000000;">&#41;</span><span style="color: #000000;">&#41;</span><span style="color: #000000;">&#41;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; leafgrp<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">add</span><span style="color: #000000;">&#40;</span><span style="color: #0033ff; font-weight: bold;">new</span> LeafBit<span style="color: #000000;">&#40;</span>tX<span style="color: #000066; font-weight: bold;">,</span> tY<span style="color: #000066; font-weight: bold;">,</span> Rnd<span style="color: #000066; font-weight: bold;">.</span>integer<span style="color: #000000;">&#40;</span><span style="color: #000000; font-weight:bold;">1</span><span style="color: #000066; font-weight: bold;">,</span><span style="color: #000000; font-weight:bold;">2</span><span style="color: #000000;">&#41;</span><span style="color: #000000;">&#41;</span> <span style="color: #0033ff; font-weight: bold;">as</span> LeafBit<span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000;">&#125;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000;">&#125;</span><br />
&nbsp; &nbsp; &nbsp; <span style="color: #000000;">&#125;</span><br />
&nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; <span style="color: #009900; font-style: italic;">//make the right-side mass of branches</span><br />
&nbsp; &nbsp; &nbsp; <span style="color: #0033ff; font-weight: bold;">for</span> <span style="color: #000000;">&#40;</span>tY = FlxG<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">height</span> <span style="color: #000066; font-weight: bold;">-</span> <span style="color: #000000; font-weight:bold;">21</span><span style="color: #000066; font-weight: bold;">;</span> tY <span style="color: #000066; font-weight: bold;">&gt;</span> FlxG<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">height</span> <span style="color: #000066; font-weight: bold;">-</span> <span style="color: #000000; font-weight:bold;">38</span><span style="color: #000066; font-weight: bold;">;</span> tY<span style="color: #000066; font-weight: bold;">--</span><span style="color: #000000;">&#41;</span><br />
&nbsp; &nbsp; &nbsp; <span style="color: #000000;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0033ff; font-weight: bold;">for</span> <span style="color: #000000;">&#40;</span>tX = <span style="color: #000000;">&#40;</span>FlxG<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">width</span> <span style="color: #000066; font-weight: bold;">/</span> <span style="color: #000000; font-weight:bold;">2</span><span style="color: #000000;">&#41;</span> <span style="color: #000066; font-weight: bold;">+</span> <span style="color: #000000; font-weight:bold;">6</span><span style="color: #000066; font-weight: bold;">;</span> tX <span style="color: #000066; font-weight: bold;">&lt;</span>= <span style="color: #000000;">&#40;</span>FlxG<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">width</span> <span style="color: #000066; font-weight: bold;">/</span> <span style="color: #000000; font-weight:bold;">2</span><span style="color: #000000;">&#41;</span> <span style="color: #000066; font-weight: bold;">+</span> <span style="color: #000000; font-weight:bold;">20</span><span style="color: #000066; font-weight: bold;">;</span> tX<span style="color: #000066; font-weight: bold;">++</span><span style="color: #000000;">&#41;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0033ff; font-weight: bold;">if</span> <span style="color: #000000;">&#40;</span>Rnd<span style="color: #000066; font-weight: bold;">.</span>boolean<span style="color: #000000;">&#40;</span>Rnd<span style="color: #000066; font-weight: bold;">.</span>float<span style="color: #000000;">&#40;</span><span style="color: #000000; font-weight:bold;">0.2</span><span style="color: #000066; font-weight: bold;">,</span> <span style="color: #000000; font-weight:bold;">0.5</span><span style="color: #000000;">&#41;</span><span style="color: #000000;">&#41;</span><span style="color: #000000;">&#41;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; leafgrp<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">add</span><span style="color: #000000;">&#40;</span><span style="color: #0033ff; font-weight: bold;">new</span> LeafBit<span style="color: #000000;">&#40;</span>tX<span style="color: #000066; font-weight: bold;">,</span> tY<span style="color: #000066; font-weight: bold;">,</span> Rnd<span style="color: #000066; font-weight: bold;">.</span>integer<span style="color: #000000;">&#40;</span><span style="color: #000000; font-weight:bold;">1</span><span style="color: #000066; font-weight: bold;">,</span><span style="color: #000000; font-weight:bold;">2</span><span style="color: #000000;">&#41;</span><span style="color: #000000;">&#41;</span> <span style="color: #0033ff; font-weight: bold;">as</span> LeafBit<span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000;">&#125;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000;">&#125;</span><br />
&nbsp; &nbsp; &nbsp; <span style="color: #000000;">&#125;</span><br />
&nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; <span style="color: #009900; font-style: italic;">//make the upper middle mass of branches</span><br />
&nbsp; &nbsp; &nbsp; <span style="color: #0033ff; font-weight: bold;">for</span> <span style="color: #000000;">&#40;</span>tY = FlxG<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">height</span> <span style="color: #000066; font-weight: bold;">-</span> <span style="color: #000000; font-weight:bold;">36</span><span style="color: #000066; font-weight: bold;">;</span> tY <span style="color: #000066; font-weight: bold;">&gt;</span> FlxG<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">height</span> <span style="color: #000066; font-weight: bold;">-</span> <span style="color: #000000; font-weight:bold;">47</span><span style="color: #000066; font-weight: bold;">;</span> tY<span style="color: #000066; font-weight: bold;">--</span><span style="color: #000000;">&#41;</span><br />
&nbsp; &nbsp; &nbsp; <span style="color: #000000;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0033ff; font-weight: bold;">for</span> <span style="color: #000000;">&#40;</span>tX = <span style="color: #000000;">&#40;</span>FlxG<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">width</span> <span style="color: #000066; font-weight: bold;">/</span> <span style="color: #000000; font-weight:bold;">2</span><span style="color: #000000;">&#41;</span> <span style="color: #000066; font-weight: bold;">-</span> <span style="color: #000000; font-weight:bold;">16</span><span style="color: #000066; font-weight: bold;">;</span> tX <span style="color: #000066; font-weight: bold;">&lt;</span>= <span style="color: #000000;">&#40;</span>FlxG<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">width</span> <span style="color: #000066; font-weight: bold;">/</span> <span style="color: #000000; font-weight:bold;">2</span><span style="color: #000000;">&#41;</span> <span style="color: #000066; font-weight: bold;">+</span> <span style="color: #000000; font-weight:bold;">16</span><span style="color: #000066; font-weight: bold;">;</span> tX<span style="color: #000066; font-weight: bold;">++</span><span style="color: #000000;">&#41;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0033ff; font-weight: bold;">if</span> <span style="color: #000000;">&#40;</span>Rnd<span style="color: #000066; font-weight: bold;">.</span>boolean<span style="color: #000000;">&#40;</span>Rnd<span style="color: #000066; font-weight: bold;">.</span>float<span style="color: #000000;">&#40;</span><span style="color: #000000; font-weight:bold;">0.3</span><span style="color: #000066; font-weight: bold;">,</span> <span style="color: #000000; font-weight:bold;">0.7</span><span style="color: #000000;">&#41;</span><span style="color: #000000;">&#41;</span><span style="color: #000000;">&#41;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; leafgrp<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">add</span><span style="color: #000000;">&#40;</span><span style="color: #0033ff; font-weight: bold;">new</span> LeafBit<span style="color: #000000;">&#40;</span>tX<span style="color: #000066; font-weight: bold;">,</span> tY<span style="color: #000066; font-weight: bold;">,</span> Rnd<span style="color: #000066; font-weight: bold;">.</span>integer<span style="color: #000000;">&#40;</span><span style="color: #000000; font-weight:bold;">1</span><span style="color: #000066; font-weight: bold;">,</span><span style="color: #000000; font-weight:bold;">2</span><span style="color: #000000;">&#41;</span><span style="color: #000000;">&#41;</span> <span style="color: #0033ff; font-weight: bold;">as</span> LeafBit<span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000;">&#125;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000;">&#125;</span><br />
&nbsp; &nbsp; &nbsp; <span style="color: #000000;">&#125;</span><br />
&nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; <span style="color: #009900; font-style: italic;">// make the top branches</span><br />
&nbsp; &nbsp; &nbsp; <span style="color: #0033ff; font-weight: bold;">for</span> <span style="color: #000000;">&#40;</span>tY = FlxG<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">height</span> <span style="color: #000066; font-weight: bold;">-</span> <span style="color: #000000; font-weight:bold;">47</span><span style="color: #000066; font-weight: bold;">;</span> tY <span style="color: #000066; font-weight: bold;">&gt;</span> FlxG<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">height</span> <span style="color: #000066; font-weight: bold;">-</span> <span style="color: #000000; font-weight:bold;">54</span><span style="color: #000066; font-weight: bold;">;</span> tY<span style="color: #000066; font-weight: bold;">--</span><span style="color: #000000;">&#41;</span><br />
&nbsp; &nbsp; &nbsp; <span style="color: #000000;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0033ff; font-weight: bold;">for</span> <span style="color: #000000;">&#40;</span>tX = <span style="color: #000000;">&#40;</span>FlxG<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">width</span> <span style="color: #000066; font-weight: bold;">/</span> <span style="color: #000000; font-weight:bold;">2</span><span style="color: #000000;">&#41;</span> <span style="color: #000066; font-weight: bold;">-</span> <span style="color: #000000; font-weight:bold;">10</span><span style="color: #000066; font-weight: bold;">;</span> tX <span style="color: #000066; font-weight: bold;">&lt;</span>= <span style="color: #000000;">&#40;</span>FlxG<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">width</span> <span style="color: #000066; font-weight: bold;">/</span> <span style="color: #000000; font-weight:bold;">2</span><span style="color: #000000;">&#41;</span> <span style="color: #000066; font-weight: bold;">+</span> <span style="color: #000000; font-weight:bold;">10</span><span style="color: #000066; font-weight: bold;">;</span> tX<span style="color: #000066; font-weight: bold;">++</span><span style="color: #000000;">&#41;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0033ff; font-weight: bold;">if</span> <span style="color: #000000;">&#40;</span>Rnd<span style="color: #000066; font-weight: bold;">.</span>boolean<span style="color: #000000;">&#40;</span>Rnd<span style="color: #000066; font-weight: bold;">.</span>float<span style="color: #000000;">&#40;</span><span style="color: #000000; font-weight:bold;">0.2</span><span style="color: #000066; font-weight: bold;">,</span> <span style="color: #000000; font-weight:bold;">0.4</span><span style="color: #000000;">&#41;</span><span style="color: #000000;">&#41;</span><span style="color: #000000;">&#41;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; leafgrp<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">add</span><span style="color: #000000;">&#40;</span><span style="color: #0033ff; font-weight: bold;">new</span> LeafBit<span style="color: #000000;">&#40;</span>tX<span style="color: #000066; font-weight: bold;">,</span> tY<span style="color: #000066; font-weight: bold;">,</span> Rnd<span style="color: #000066; font-weight: bold;">.</span>integer<span style="color: #000000;">&#40;</span><span style="color: #000000; font-weight:bold;">1</span><span style="color: #000066; font-weight: bold;">,</span><span style="color: #000000; font-weight:bold;">2</span><span style="color: #000000;">&#41;</span><span style="color: #000000;">&#41;</span> <span style="color: #0033ff; font-weight: bold;">as</span> LeafBit<span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000;">&#125;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000;">&#125;</span><br />
&nbsp; &nbsp; &nbsp; <span style="color: #000000;">&#125;</span><br />
&nbsp; &nbsp; <span style="color: #000000;">&#125;</span><br />
&nbsp; &nbsp; <br />
&nbsp; &nbsp; override <span style="color: #0033ff; font-weight: bold;">public</span> <span style="color: #339966; font-weight: bold;">function</span> update<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">:</span><span style="color: #0033ff; font-weight: bold;">void</span><br />
&nbsp; &nbsp; <span style="color: #000000;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; <span style="color: #0033ff; font-weight: bold;">if</span> <span style="color: #000000;">&#40;</span><span style="color: #004993;">timer</span> <span style="color: #000066; font-weight: bold;">&lt;</span>= <span style="color: #000000; font-weight:bold;">0</span><span style="color: #000000;">&#41;</span><br />
&nbsp; &nbsp; &nbsp; <span style="color: #000000;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900; font-style: italic;">// move the wind's strength</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; wind <span style="color: #000066; font-weight: bold;">+</span>= Rnd<span style="color: #000066; font-weight: bold;">.</span>float<span style="color: #000000;">&#40;</span><span style="color: #000000; font-weight:bold;">0.1</span><span style="color: #000066; font-weight: bold;">,</span> <span style="color: #000000; font-weight:bold;">0.3</span><span style="color: #000000;">&#41;</span> <span style="color: #000066; font-weight: bold;">*</span> <span style="color: #000000;">&#40;</span>goal<span style="color: #000066; font-weight: bold;">/</span><span style="color: #004993;">Math</span><span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">abs</span><span style="color: #000000;">&#40;</span>goal<span style="color: #000000;">&#41;</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #004993;">timer</span> = <span style="color: #000000; font-weight:bold;">0.2</span><span style="color: #000066; font-weight: bold;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900; font-style: italic;">// push each branch</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #6699cc; font-weight: bold;">var</span> t<span style="color: #000066; font-weight: bold;">:</span>TreeBit<span style="color: #000066; font-weight: bold;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0033ff; font-weight: bold;">for</span> <span style="color: #0033ff; font-weight: bold;">each</span> <span style="color: #000000;">&#40;</span>t <span style="color: #0033ff; font-weight: bold;">in</span> treegrp<span style="color: #000066; font-weight: bold;">.</span>members<span style="color: #000000;">&#41;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; t<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">push</span><span style="color: #000000;">&#40;</span>wind<span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900; font-style: italic;">//push each leaf</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #6699cc; font-weight: bold;">var</span> l<span style="color: #000066; font-weight: bold;">:</span>LeafBit<span style="color: #000066; font-weight: bold;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0033ff; font-weight: bold;">for</span> <span style="color: #0033ff; font-weight: bold;">each</span> <span style="color: #000000;">&#40;</span>l <span style="color: #0033ff; font-weight: bold;">in</span> leafgrp<span style="color: #000066; font-weight: bold;">.</span>members<span style="color: #000000;">&#41;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; l<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">push</span><span style="color: #000000;">&#40;</span>wind<span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span><br />
&nbsp; &nbsp; &nbsp; <span style="color: #000000;">&#125;</span><br />
&nbsp; &nbsp; &nbsp; <span style="color: #0033ff; font-weight: bold;">else</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #004993;">timer</span> <span style="color: #000066; font-weight: bold;">-</span>= FlxG<span style="color: #000066; font-weight: bold;">.</span>elapsed<span style="color: #000066; font-weight: bold;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; <span style="color: #009900; font-style: italic;">// here's some logic to get the mist moving and to stay in the bounds.</span><br />
&nbsp; &nbsp; &nbsp; <span style="color: #0033ff; font-weight: bold;">if</span> <span style="color: #000000;">&#40;</span><span style="color: #004993;">Math</span><span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">abs</span><span style="color: #000000;">&#40;</span>wind<span style="color: #000000;">&#41;</span> <span style="color: #000066; font-weight: bold;">&gt;</span>= <span style="color: #004993;">Math</span><span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">abs</span><span style="color: #000000;">&#40;</span>goal<span style="color: #000000;">&#41;</span><span style="color: #000000;">&#41;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; goal = Rnd<span style="color: #000066; font-weight: bold;">.</span>float<span style="color: #000000;">&#40;</span> <span style="color: #000066; font-weight: bold;">-</span><span style="color: #000000; font-weight:bold;">10</span><span style="color: #000066; font-weight: bold;">,</span> <span style="color: #000000; font-weight:bold;">10</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span><br />
&nbsp; &nbsp; &nbsp; mist<span style="color: #000066; font-weight: bold;">.</span>velocity<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">x</span> = wind<span style="color: #000066; font-weight: bold;">;</span><br />
&nbsp; &nbsp; &nbsp; <span style="color: #0033ff; font-weight: bold;">if</span> <span style="color: #000000;">&#40;</span>mist<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">x</span> <span style="color: #000066; font-weight: bold;">&lt;</span> <span style="color: #000066; font-weight: bold;">-</span><span style="color: #000000; font-weight:bold;">500</span> <span style="color: #000066; font-weight: bold;">+</span> FlxG<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">width</span><span style="color: #000000;">&#41;</span> mist<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">x</span> = <span style="color: #000066; font-weight: bold;">-</span><span style="color: #000000; font-weight:bold;">500</span> <span style="color: #000066; font-weight: bold;">+</span> FlxG<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">width</span><span style="color: #000066; font-weight: bold;">;</span><br />
&nbsp; &nbsp; &nbsp; <span style="color: #0033ff; font-weight: bold;">else</span> <span style="color: #0033ff; font-weight: bold;">if</span> <span style="color: #000000;">&#40;</span>mist<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">x</span> <span style="color: #000066; font-weight: bold;">&gt;</span> <span style="color: #000000; font-weight:bold;">0</span><span style="color: #000000;">&#41;</span> mist<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">x</span> = <span style="color: #000000; font-weight:bold;">0</span><span style="color: #000066; font-weight: bold;">;</span><br />
&nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; <span style="color: #009900; font-style: italic;">// collide leaves with other leaves and the ground</span><br />
&nbsp; &nbsp; &nbsp; leafgrp<span style="color: #000066; font-weight: bold;">.</span>collide<span style="color: #000000;">&#40;</span>leafgrp<span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span><br />
&nbsp; &nbsp; &nbsp; ground<span style="color: #000066; font-weight: bold;">.</span>collide<span style="color: #000000;">&#40;</span>leafgrp<span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span><br />
&nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; <span style="color: #009900; font-style: italic;">//randomly add new leaves from off the screen...</span><br />
&nbsp; &nbsp; &nbsp; <span style="color: #0033ff; font-weight: bold;">if</span> <span style="color: #000000;">&#40;</span>Rnd<span style="color: #000066; font-weight: bold;">.</span>boolean<span style="color: #000000;">&#40;</span><span style="color: #000000; font-weight:bold;">0.01</span><span style="color: #000000;">&#41;</span><span style="color: #000000;">&#41;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; SpawnLeaf<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span><br />
&nbsp; &nbsp; &nbsp; <span style="color: #009900; font-style: italic;">// random wisps</span><br />
&nbsp; &nbsp; &nbsp; <span style="color: #0033ff; font-weight: bold;">if</span> <span style="color: #000000;">&#40;</span>Rnd<span style="color: #000066; font-weight: bold;">.</span>boolean<span style="color: #000000;">&#40;</span><span style="color: #000000; font-weight:bold;">0.01</span><span style="color: #000000;">&#41;</span><span style="color: #000000;">&#41;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; SpawnBackWisp<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span><br />
&nbsp; &nbsp; &nbsp; <span style="color: #0033ff; font-weight: bold;">if</span> <span style="color: #000000;">&#40;</span>Rnd<span style="color: #000066; font-weight: bold;">.</span>boolean<span style="color: #000000;">&#40;</span><span style="color: #000000; font-weight:bold;">0.005</span><span style="color: #000000;">&#41;</span><span style="color: #000000;">&#41;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; SpawnFrontWisp<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span><br />
&nbsp; &nbsp; &nbsp; <span style="color: #009900; font-style: italic;">// random ghosts</span><br />
&nbsp; &nbsp; &nbsp; <span style="color: #0033ff; font-weight: bold;">if</span> <span style="color: #000000;">&#40;</span>Rnd<span style="color: #000066; font-weight: bold;">.</span>boolean<span style="color: #000000;">&#40;</span><span style="color: #000000; font-weight:bold;">0.001</span><span style="color: #000000;">&#41;</span><span style="color: #000000;">&#41;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; SpawnGhost<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span><br />
&nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; <span style="color: #0033ff; font-weight: bold;">super</span><span style="color: #000066; font-weight: bold;">.</span>update<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span><br />
&nbsp; &nbsp; <span style="color: #000000;">&#125;</span><br />
&nbsp; &nbsp; <br />
&nbsp; &nbsp; <span style="color: #0033ff; font-weight: bold;">private</span> <span style="color: #339966; font-weight: bold;">function</span> SpawnBackWisp<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">:</span><span style="color: #0033ff; font-weight: bold;">void</span><br />
&nbsp; &nbsp; <span style="color: #000000;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; <span style="color: #009900; font-style: italic;">// spawn a random wisp off the screen.</span><br />
&nbsp; &nbsp; &nbsp; <span style="color: #6699cc; font-weight: bold;">var</span> tW<span style="color: #000066; font-weight: bold;">:</span>WispBit<span style="color: #000066; font-weight: bold;">;</span><br />
&nbsp; &nbsp; &nbsp; tW = wispBackGrp<span style="color: #000066; font-weight: bold;">.</span>getFirstAvail<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span> <span style="color: #0033ff; font-weight: bold;">as</span> WispBit<span style="color: #000066; font-weight: bold;">;</span><br />
&nbsp; &nbsp; &nbsp; <span style="color: #0033ff; font-weight: bold;">if</span> <span style="color: #000000;">&#40;</span>tW == <span style="color: #0033ff; font-weight: bold;">null</span><span style="color: #000000;">&#41;</span><br />
&nbsp; &nbsp; &nbsp; <span style="color: #000000;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0033ff; font-weight: bold;">if</span> <span style="color: #000000;">&#40;</span>wind <span style="color: #000066; font-weight: bold;">&lt;</span> <span style="color: #000000; font-weight:bold;">0</span><span style="color: #000000;">&#41;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; tW = wispBackGrp<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">add</span><span style="color: #000000;">&#40;</span><span style="color: #0033ff; font-weight: bold;">new</span> WispBit<span style="color: #000000;">&#40;</span>FlxG<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">width</span> <span style="color: #000066; font-weight: bold;">+</span> <span style="color: #000000; font-weight:bold;">1</span><span style="color: #000066; font-weight: bold;">,</span> Rnd<span style="color: #000066; font-weight: bold;">.</span>integer<span style="color: #000000;">&#40;</span> <span style="color: #000066; font-weight: bold;">-</span><span style="color: #000000; font-weight:bold;">1</span><span style="color: #000066; font-weight: bold;">,</span> FlxG<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">height</span> <span style="color: #000066; font-weight: bold;">-</span> <span style="color: #000000; font-weight:bold;">4</span><span style="color: #000000;">&#41;</span><span style="color: #000000;">&#41;</span><span style="color: #000000;">&#41;</span> <span style="color: #0033ff; font-weight: bold;">as</span> WispBit<span style="color: #000066; font-weight: bold;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0033ff; font-weight: bold;">else</span> <span style="color: #0033ff; font-weight: bold;">if</span> <span style="color: #000000;">&#40;</span>wind <span style="color: #000066; font-weight: bold;">&gt;</span> <span style="color: #000000; font-weight:bold;">0</span><span style="color: #000000;">&#41;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; tW = wispBackGrp<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">add</span><span style="color: #000000;">&#40;</span><span style="color: #0033ff; font-weight: bold;">new</span> WispBit<span style="color: #000000;">&#40;</span><span style="color: #000066; font-weight: bold;">-</span><span style="color: #000000; font-weight:bold;">1</span><span style="color: #000066; font-weight: bold;">,</span> Rnd<span style="color: #000066; font-weight: bold;">.</span>integer<span style="color: #000000;">&#40;</span> <span style="color: #000066; font-weight: bold;">-</span><span style="color: #000000; font-weight:bold;">1</span><span style="color: #000066; font-weight: bold;">,</span> FlxG<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">height</span> <span style="color: #000066; font-weight: bold;">-</span> <span style="color: #000000; font-weight:bold;">4</span><span style="color: #000000;">&#41;</span><span style="color: #000000;">&#41;</span><span style="color: #000000;">&#41;</span> <span style="color: #0033ff; font-weight: bold;">as</span> WispBit<span style="color: #000066; font-weight: bold;">;</span><br />
&nbsp; &nbsp; &nbsp; <span style="color: #000000;">&#125;</span><br />
&nbsp; &nbsp; &nbsp; <span style="color: #0033ff; font-weight: bold;">else</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; tW<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">reset</span><span style="color: #000000;">&#40;</span>FlxG<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">width</span> <span style="color: #000066; font-weight: bold;">+</span> <span style="color: #000000; font-weight:bold;">1</span><span style="color: #000066; font-weight: bold;">,</span> Rnd<span style="color: #000066; font-weight: bold;">.</span>integer<span style="color: #000000;">&#40;</span> <span style="color: #000066; font-weight: bold;">-</span><span style="color: #000000; font-weight:bold;">1</span><span style="color: #000066; font-weight: bold;">,</span> FlxG<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">height</span> <span style="color: #000066; font-weight: bold;">-</span> <span style="color: #000000; font-weight:bold;">4</span><span style="color: #000000;">&#41;</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span><br />
&nbsp; &nbsp; <span style="color: #000000;">&#125;</span><br />
&nbsp; &nbsp; <span style="color: #0033ff; font-weight: bold;">private</span> <span style="color: #339966; font-weight: bold;">function</span> SpawnFrontWisp<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">:</span><span style="color: #0033ff; font-weight: bold;">void</span><br />
&nbsp; &nbsp; <span style="color: #000000;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; <span style="color: #009900; font-style: italic;">// spawn a random wisp off the screen in the foreground.</span><br />
&nbsp; &nbsp; &nbsp; <span style="color: #6699cc; font-weight: bold;">var</span> tW<span style="color: #000066; font-weight: bold;">:</span>WispBit<span style="color: #000066; font-weight: bold;">;</span><br />
&nbsp; &nbsp; &nbsp; tW = wispFrontGrp<span style="color: #000066; font-weight: bold;">.</span>getFirstAvail<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span> <span style="color: #0033ff; font-weight: bold;">as</span> WispBit<span style="color: #000066; font-weight: bold;">;</span><br />
&nbsp; &nbsp; &nbsp; <span style="color: #0033ff; font-weight: bold;">if</span> <span style="color: #000000;">&#40;</span>tW == <span style="color: #0033ff; font-weight: bold;">null</span><span style="color: #000000;">&#41;</span><br />
&nbsp; &nbsp; &nbsp; <span style="color: #000000;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0033ff; font-weight: bold;">if</span> <span style="color: #000000;">&#40;</span>wind <span style="color: #000066; font-weight: bold;">&lt;</span> <span style="color: #000000; font-weight:bold;">0</span><span style="color: #000000;">&#41;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; tW = wispFrontGrp<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">add</span><span style="color: #000000;">&#40;</span><span style="color: #0033ff; font-weight: bold;">new</span> WispBit<span style="color: #000000;">&#40;</span>FlxG<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">width</span> <span style="color: #000066; font-weight: bold;">+</span> <span style="color: #000000; font-weight:bold;">1</span><span style="color: #000066; font-weight: bold;">,</span> Rnd<span style="color: #000066; font-weight: bold;">.</span>integer<span style="color: #000000;">&#40;</span> <span style="color: #000066; font-weight: bold;">-</span><span style="color: #000000; font-weight:bold;">1</span><span style="color: #000066; font-weight: bold;">,</span> FlxG<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">height</span> <span style="color: #000066; font-weight: bold;">-</span> <span style="color: #000000; font-weight:bold;">4</span><span style="color: #000000;">&#41;</span><span style="color: #000000;">&#41;</span><span style="color: #000000;">&#41;</span> <span style="color: #0033ff; font-weight: bold;">as</span> WispBit<span style="color: #000066; font-weight: bold;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0033ff; font-weight: bold;">else</span> <span style="color: #0033ff; font-weight: bold;">if</span> <span style="color: #000000;">&#40;</span>wind <span style="color: #000066; font-weight: bold;">&gt;</span> <span style="color: #000000; font-weight:bold;">0</span><span style="color: #000000;">&#41;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; tW = wispFrontGrp<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">add</span><span style="color: #000000;">&#40;</span><span style="color: #0033ff; font-weight: bold;">new</span> WispBit<span style="color: #000000;">&#40;</span><span style="color: #000066; font-weight: bold;">-</span><span style="color: #000000; font-weight:bold;">1</span><span style="color: #000066; font-weight: bold;">,</span> Rnd<span style="color: #000066; font-weight: bold;">.</span>integer<span style="color: #000000;">&#40;</span> <span style="color: #000066; font-weight: bold;">-</span><span style="color: #000000; font-weight:bold;">1</span><span style="color: #000066; font-weight: bold;">,</span> FlxG<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">height</span> <span style="color: #000066; font-weight: bold;">-</span> <span style="color: #000000; font-weight:bold;">4</span><span style="color: #000000;">&#41;</span><span style="color: #000000;">&#41;</span><span style="color: #000000;">&#41;</span> <span style="color: #0033ff; font-weight: bold;">as</span> WispBit<span style="color: #000066; font-weight: bold;">;</span><br />
&nbsp; &nbsp; &nbsp; <span style="color: #000000;">&#125;</span><br />
&nbsp; &nbsp; &nbsp; <span style="color: #0033ff; font-weight: bold;">else</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; tW<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">reset</span><span style="color: #000000;">&#40;</span>FlxG<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">width</span> <span style="color: #000066; font-weight: bold;">+</span> <span style="color: #000000; font-weight:bold;">1</span><span style="color: #000066; font-weight: bold;">,</span> Rnd<span style="color: #000066; font-weight: bold;">.</span>integer<span style="color: #000000;">&#40;</span> <span style="color: #000066; font-weight: bold;">-</span><span style="color: #000000; font-weight:bold;">1</span><span style="color: #000066; font-weight: bold;">,</span> FlxG<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">height</span> <span style="color: #000066; font-weight: bold;">-</span> <span style="color: #000000; font-weight:bold;">4</span><span style="color: #000000;">&#41;</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span><br />
&nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; <span style="color: #000000;">&#125;</span><br />
&nbsp; &nbsp; <br />
&nbsp; &nbsp; <span style="color: #0033ff; font-weight: bold;">private</span> <span style="color: #339966; font-weight: bold;">function</span> SpawnGhost<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">:</span><span style="color: #0033ff; font-weight: bold;">void</span><br />
&nbsp; &nbsp; <span style="color: #000000;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; <span style="color: #009900; font-style: italic;">// spawn a random ghost</span><br />
&nbsp; &nbsp; &nbsp; <span style="color: #6699cc; font-weight: bold;">var</span> g<span style="color: #000066; font-weight: bold;">:</span>Ghost<span style="color: #000066; font-weight: bold;">;</span><br />
&nbsp; &nbsp; &nbsp; g = ghostgrp<span style="color: #000066; font-weight: bold;">.</span>getFirstAvail<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span> <span style="color: #0033ff; font-weight: bold;">as</span> Ghost<span style="color: #000066; font-weight: bold;">;</span><br />
&nbsp; &nbsp; &nbsp; <span style="color: #0033ff; font-weight: bold;">if</span> <span style="color: #000000;">&#40;</span>g == <span style="color: #0033ff; font-weight: bold;">null</span><span style="color: #000000;">&#41;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; ghostgrp<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">add</span><span style="color: #000000;">&#40;</span><span style="color: #0033ff; font-weight: bold;">new</span> Ghost<span style="color: #000000;">&#40;</span>Rnd<span style="color: #000066; font-weight: bold;">.</span>integer<span style="color: #000000;">&#40;</span><span style="color: #000000; font-weight:bold;">2</span><span style="color: #000066; font-weight: bold;">,</span> FlxG<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">width</span> <span style="color: #000066; font-weight: bold;">-</span> <span style="color: #000000; font-weight:bold;">7</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">,</span> Rnd<span style="color: #000066; font-weight: bold;">.</span>integer<span style="color: #000000;">&#40;</span>FlxG<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">height</span> <span style="color: #000066; font-weight: bold;">+</span> <span style="color: #000000; font-weight:bold;">2</span><span style="color: #000066; font-weight: bold;">,</span> FlxG<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">height</span> <span style="color: #000066; font-weight: bold;">-</span> <span style="color: #000000; font-weight:bold;">4</span><span style="color: #000000;">&#41;</span><span style="color: #000000;">&#41;</span><span style="color: #000000;">&#41;</span> <span style="color: #0033ff; font-weight: bold;">as</span> Ghost<span style="color: #000066; font-weight: bold;">;</span><br />
&nbsp; &nbsp; &nbsp; <span style="color: #0033ff; font-weight: bold;">else</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; g<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">reset</span><span style="color: #000000;">&#40;</span>Rnd<span style="color: #000066; font-weight: bold;">.</span>integer<span style="color: #000000;">&#40;</span><span style="color: #000000; font-weight:bold;">2</span><span style="color: #000066; font-weight: bold;">,</span> FlxG<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">width</span> <span style="color: #000066; font-weight: bold;">-</span> <span style="color: #000000; font-weight:bold;">7</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">,</span> Rnd<span style="color: #000066; font-weight: bold;">.</span>integer<span style="color: #000000;">&#40;</span>FlxG<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">height</span> <span style="color: #000066; font-weight: bold;">+</span> <span style="color: #000000; font-weight:bold;">2</span><span style="color: #000066; font-weight: bold;">,</span> FlxG<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">height</span> <span style="color: #000066; font-weight: bold;">-</span> <span style="color: #000000; font-weight:bold;">4</span><span style="color: #000000;">&#41;</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span><br />
&nbsp; &nbsp; <span style="color: #000000;">&#125;</span><br />
&nbsp; &nbsp; <br />
&nbsp; &nbsp; <span style="color: #0033ff; font-weight: bold;">private</span> <span style="color: #339966; font-weight: bold;">function</span> SpawnLeaf<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">:</span><span style="color: #0033ff; font-weight: bold;">void</span><br />
&nbsp; &nbsp; <span style="color: #000000;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; <span style="color: #009900; font-style: italic;">// spawn a random leaf off the screen.</span><br />
&nbsp; &nbsp; &nbsp; <span style="color: #6699cc; font-weight: bold;">var</span> tL<span style="color: #000066; font-weight: bold;">:</span>LeafBit<span style="color: #000066; font-weight: bold;">;</span><br />
&nbsp; &nbsp; &nbsp; tL = leafgrp<span style="color: #000066; font-weight: bold;">.</span>getFirstAvail<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span> <span style="color: #0033ff; font-weight: bold;">as</span> LeafBit<span style="color: #000066; font-weight: bold;">;</span><br />
&nbsp; &nbsp; &nbsp; <span style="color: #6699cc; font-weight: bold;">var</span> pos<span style="color: #000066; font-weight: bold;">:</span>FlxPoint = <span style="color: #0033ff; font-weight: bold;">new</span> FlxPoint<span style="color: #000000;">&#40;</span><span style="color: #000000; font-weight:bold;">0</span><span style="color: #000066; font-weight: bold;">,</span><span style="color: #000000; font-weight:bold;">0</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span><br />
&nbsp; &nbsp; &nbsp; <span style="color: #0033ff; font-weight: bold;">if</span> <span style="color: #000000;">&#40;</span>wind <span style="color: #000066; font-weight: bold;">&gt;</span> <span style="color: #000000; font-weight:bold;">0</span><span style="color: #000000;">&#41;</span><br />
&nbsp; &nbsp; &nbsp; <span style="color: #000000;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; pos<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">x</span> = <span style="color: #000066; font-weight: bold;">-</span><span style="color: #000000; font-weight:bold;">1</span><span style="color: #000066; font-weight: bold;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; pos<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">y</span> = Rnd<span style="color: #000066; font-weight: bold;">.</span>integer<span style="color: #000000;">&#40;</span> <span style="color: #000066; font-weight: bold;">-</span>FlxG<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">width</span><span style="color: #000066; font-weight: bold;">,</span> FlxG<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">width</span> <span style="color: #000066; font-weight: bold;">-</span> <span style="color: #000000; font-weight:bold;">6</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span><br />
&nbsp; &nbsp; &nbsp; <span style="color: #000000;">&#125;</span><br />
&nbsp; &nbsp; &nbsp; <span style="color: #0033ff; font-weight: bold;">else</span> <span style="color: #0033ff; font-weight: bold;">if</span> <span style="color: #000000;">&#40;</span>wind <span style="color: #000066; font-weight: bold;">&lt;</span> <span style="color: #000000; font-weight:bold;">0</span><span style="color: #000000;">&#41;</span><br />
&nbsp; &nbsp; &nbsp; <span style="color: #000000;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; pos<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">x</span> = FlxG<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">width</span> <span style="color: #000066; font-weight: bold;">+</span> <span style="color: #000000; font-weight:bold;">1</span><span style="color: #000066; font-weight: bold;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; pos<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">y</span> = Rnd<span style="color: #000066; font-weight: bold;">.</span>integer<span style="color: #000000;">&#40;</span> <span style="color: #000066; font-weight: bold;">-</span>FlxG<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">width</span><span style="color: #000066; font-weight: bold;">,</span> FlxG<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">width</span> <span style="color: #000066; font-weight: bold;">-</span> <span style="color: #000000; font-weight:bold;">6</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span><br />
&nbsp; &nbsp; &nbsp; <span style="color: #000000;">&#125;</span><br />
&nbsp; &nbsp; &nbsp; <span style="color: #0033ff; font-weight: bold;">else</span><br />
&nbsp; &nbsp; &nbsp; <span style="color: #000000;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0033ff; font-weight: bold;">if</span> <span style="color: #000000;">&#40;</span>Rnd<span style="color: #000066; font-weight: bold;">.</span>boolean<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><span style="color: #000000;">&#41;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; pos<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">x</span> = <span style="color: #000066; font-weight: bold;">-</span><span style="color: #000000; font-weight:bold;">1</span><span style="color: #000066; font-weight: bold;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; pos<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">y</span> = Rnd<span style="color: #000066; font-weight: bold;">.</span>integer<span style="color: #000000;">&#40;</span> <span style="color: #000066; font-weight: bold;">-</span>FlxG<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">width</span><span style="color: #000066; font-weight: bold;">,</span> FlxG<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">width</span> <span style="color: #000066; font-weight: bold;">-</span> <span style="color: #000000; font-weight:bold;">6</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000;">&#125;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0033ff; font-weight: bold;">else</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; pos<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">x</span> = FlxG<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">width</span> <span style="color: #000066; font-weight: bold;">+</span> <span style="color: #000000; font-weight:bold;">1</span><span style="color: #000066; font-weight: bold;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; pos<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">y</span> = Rnd<span style="color: #000066; font-weight: bold;">.</span>integer<span style="color: #000000;">&#40;</span> <span style="color: #000066; font-weight: bold;">-</span>FlxG<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">width</span><span style="color: #000066; font-weight: bold;">,</span> FlxG<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">width</span> <span style="color: #000066; font-weight: bold;">-</span> <span style="color: #000000; font-weight:bold;">6</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000;">&#125;</span><br />
&nbsp; &nbsp; &nbsp; <span style="color: #000000;">&#125;</span><br />
&nbsp; &nbsp; &nbsp; <span style="color: #0033ff; font-weight: bold;">if</span> <span style="color: #000000;">&#40;</span>tL <span style="color: #000066; font-weight: bold;">!</span>= <span style="color: #0033ff; font-weight: bold;">null</span><span style="color: #000000;">&#41;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; tL<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">reset</span><span style="color: #000000;">&#40;</span>pos<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">x</span><span style="color: #000066; font-weight: bold;">,</span>pos<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">y</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span><br />
&nbsp; &nbsp; &nbsp; <span style="color: #0033ff; font-weight: bold;">else</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; tL = leafgrp<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">add</span><span style="color: #000000;">&#40;</span><span style="color: #0033ff; font-weight: bold;">new</span> LeafBit<span style="color: #000000;">&#40;</span>pos<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">x</span><span style="color: #000066; font-weight: bold;">,</span> pos<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">y</span><span style="color: #000066; font-weight: bold;">,</span> Rnd<span style="color: #000066; font-weight: bold;">.</span>integer<span style="color: #000000;">&#40;</span><span style="color: #000000; font-weight:bold;">1</span><span style="color: #000066; font-weight: bold;">,</span> <span style="color: #000000; font-weight:bold;">2</span><span style="color: #000000;">&#41;</span><span style="color: #000000;">&#41;</span><span style="color: #000000;">&#41;</span> <span style="color: #0033ff; font-weight: bold;">as</span> LeafBit<span style="color: #000066; font-weight: bold;">;</span><br />
&nbsp; &nbsp; &nbsp; tL<span style="color: #000066; font-weight: bold;">.</span>solid = <span style="color: #0033ff; font-weight: bold;">true</span><span style="color: #000066; font-weight: bold;">;</span><br />
&nbsp; &nbsp; &nbsp; tL<span style="color: #000066; font-weight: bold;">.</span>falling = <span style="color: #0033ff; font-weight: bold;">true</span><span style="color: #000066; font-weight: bold;">;</span><br />
&nbsp; &nbsp; &nbsp; tL<span style="color: #000066; font-weight: bold;">.</span>landed = <span style="color: #0033ff; font-weight: bold;">false</span><span style="color: #000066; font-weight: bold;">;</span><br />
&nbsp; &nbsp; <span style="color: #000000;">&#125;</span><br />
&nbsp; <span style="color: #000000;">&#125;</span><br />
<br />
<span style="color: #000000;">&#125;</span></div></div>
<h3>TreeBit.as</h3>
<div class="codecolorer-container actionscript3 default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;height:450px;"><div class="actionscript3 codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #9900cc; font-weight: bold;">package</span> &nbsp;<br />
<span style="color: #000000;">&#123;</span><br />
&nbsp; <span style="color: #0033ff; font-weight: bold;">import</span> org<span style="color: #000066; font-weight: bold;">.</span>flixel<span style="color: #000066; font-weight: bold;">.</span>FlxPoint<span style="color: #000066; font-weight: bold;">;</span><br />
&nbsp; <span style="color: #0033ff; font-weight: bold;">import</span> org<span style="color: #000066; font-weight: bold;">.</span>flixel<span style="color: #000066; font-weight: bold;">.</span>FlxSprite<span style="color: #000066; font-weight: bold;">;</span><br />
&nbsp; <span style="color: #0033ff; font-weight: bold;">import</span> org<span style="color: #000066; font-weight: bold;">.</span>flixel<span style="color: #000066; font-weight: bold;">.</span>FlxObject<span style="color: #000066; font-weight: bold;">;</span><br />
&nbsp; <span style="color: #0033ff; font-weight: bold;">import</span> org<span style="color: #000066; font-weight: bold;">.</span>flixel<span style="color: #000066; font-weight: bold;">.</span>FlxG<span style="color: #000066; font-weight: bold;">;</span><br />
&nbsp; <span style="color: #0033ff; font-weight: bold;">import</span> com<span style="color: #000066; font-weight: bold;">.</span>gskinner<span style="color: #000066; font-weight: bold;">.</span>utils<span style="color: #000066; font-weight: bold;">.</span>Rnd<span style="color: #000066; font-weight: bold;">;</span><br />
&nbsp; <br />
&nbsp; <span style="color: #0033ff; font-weight: bold;">public</span> <span style="color: #9900cc; font-weight: bold;">class</span> TreeBit <span style="color: #0033ff; font-weight: bold;">extends</span> FlxSprite<br />
&nbsp; <span style="color: #000000;">&#123;</span><br />
&nbsp; &nbsp; <span style="color: #0033ff; font-weight: bold;">public</span> <span style="color: #6699cc; font-weight: bold;">var</span> weight<span style="color: #000066; font-weight: bold;">:</span><span style="color: #004993;">Number</span> = <span style="color: #000000; font-weight:bold;">0</span><span style="color: #000066; font-weight: bold;">;</span> <span style="color: #009900; font-style: italic;">// this is how much this part of the tree 'weighs'. The heavier it is, the more wind force it takes before it should move...</span><br />
&nbsp; &nbsp; <span style="color: #0033ff; font-weight: bold;">private</span> <span style="color: #6699cc; font-weight: bold;">var</span> <span style="color: #004993;">init</span><span style="color: #000066; font-weight: bold;">:</span>FlxPoint<span style="color: #000066; font-weight: bold;">;</span><br />
&nbsp; &nbsp; <span style="color: #0033ff; font-weight: bold;">public</span> <span style="color: #339966; font-weight: bold;">function</span> TreeBit<span style="color: #000000;">&#40;</span>X<span style="color: #000066; font-weight: bold;">:</span><span style="color: #004993;">Number</span><span style="color: #000066; font-weight: bold;">,</span> Y<span style="color: #000066; font-weight: bold;">:</span><span style="color: #004993;">Number</span><span style="color: #000066; font-weight: bold;">,</span> w<span style="color: #000066; font-weight: bold;">:</span><span style="color: #004993;">int</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">:</span><span style="color: #0033ff; font-weight: bold;">void</span> <br />
&nbsp; &nbsp; <span style="color: #000000;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; <span style="color: #0033ff; font-weight: bold;">super</span><span style="color: #000000;">&#40;</span>X<span style="color: #000066; font-weight: bold;">,</span> Y<span style="color: #000066; font-weight: bold;">,</span> <span style="color: #0033ff; font-weight: bold;">null</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span><br />
&nbsp; &nbsp; &nbsp; createGraphic<span style="color: #000000;">&#40;</span><span style="color: #000000; font-weight:bold;">1</span><span style="color: #000066; font-weight: bold;">,</span> <span style="color: #000000; font-weight:bold;">1</span><span style="color: #000066; font-weight: bold;">,</span>0xff000000<span style="color: #000066; font-weight: bold;">,</span> <span style="color: #0033ff; font-weight: bold;">false</span><span style="color: #000066; font-weight: bold;">,</span> <span style="color: #0033ff; font-weight: bold;">null</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span><br />
&nbsp; &nbsp; &nbsp; <span style="color: #004993;">width</span> = <span style="color: #000000; font-weight:bold;">1</span><span style="color: #000066; font-weight: bold;">;</span><br />
&nbsp; &nbsp; &nbsp; <span style="color: #004993;">height</span> = <span style="color: #000000; font-weight:bold;">1</span><span style="color: #000066; font-weight: bold;">;</span><br />
&nbsp; &nbsp; &nbsp; weight = w<span style="color: #000066; font-weight: bold;">;</span><br />
&nbsp; &nbsp; &nbsp; <span style="color: #004993;">reset</span><span style="color: #000000;">&#40;</span>X<span style="color: #000066; font-weight: bold;">,</span> Y<span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span><br />
&nbsp; &nbsp; <span style="color: #000000;">&#125;</span><br />
&nbsp; &nbsp; <br />
&nbsp; &nbsp; <span style="color: #0033ff; font-weight: bold;">public</span> <span style="color: #339966; font-weight: bold;">function</span> <span style="color: #004993;">push</span><span style="color: #000000;">&#40;</span>Force<span style="color: #000066; font-weight: bold;">:</span><span style="color: #004993;">Number</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">:</span><span style="color: #0033ff; font-weight: bold;">void</span><br />
&nbsp; &nbsp; <span style="color: #000000;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; <span style="color: #009900; font-style: italic;">// take the amount of force being applied, subtact the weight of this bit (+/- a random amount), the remainder is how much it moves.</span><br />
&nbsp; &nbsp; &nbsp; <span style="color: #6699cc; font-weight: bold;">var</span> m<span style="color: #000066; font-weight: bold;">:</span><span style="color: #004993;">Number</span> = <span style="color: #004993;">Math</span><span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">abs</span><span style="color: #000000;">&#40;</span>Force<span style="color: #000000;">&#41;</span> <span style="color: #000066; font-weight: bold;">-</span> weight<span style="color: #000066; font-weight: bold;">;</span><br />
&nbsp; &nbsp; &nbsp; <span style="color: #6699cc; font-weight: bold;">var</span> dir<span style="color: #000066; font-weight: bold;">:</span><span style="color: #004993;">int</span> = Force <span style="color: #000066; font-weight: bold;">/</span> <span style="color: #004993;">Math</span><span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">abs</span><span style="color: #000000;">&#40;</span>Force<span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span><br />
&nbsp; &nbsp; &nbsp; <span style="color: #009900; font-style: italic;">// theres a change the branch will move, and if it doesn't it goes back to where it started</span><br />
&nbsp; &nbsp; &nbsp; <span style="color: #0033ff; font-weight: bold;">if</span> <span style="color: #000000;">&#40;</span>Rnd<span style="color: #000066; font-weight: bold;">.</span>boolean<span style="color: #000000;">&#40;</span>Rnd<span style="color: #000066; font-weight: bold;">.</span>float<span style="color: #000000;">&#40;</span><span style="color: #000000; font-weight:bold;">0.1</span><span style="color: #000066; font-weight: bold;">,</span> <span style="color: #000000; font-weight:bold;">0.3</span><span style="color: #000000;">&#41;</span><span style="color: #000000;">&#41;</span> <span style="color: #000066; font-weight: bold;">&amp;&amp;</span> m <span style="color: #000066; font-weight: bold;">&gt;</span> <span style="color: #000000; font-weight:bold;">0</span><span style="color: #000000;">&#41;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #004993;">x</span> = <span style="color: #004993;">init</span><span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">x</span> <span style="color: #000066; font-weight: bold;">+</span><span style="color: #000000;">&#40;</span>dir <span style="color: #000066; font-weight: bold;">*</span> <span style="color: #004993;">Math</span><span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">ceil</span><span style="color: #000000;">&#40;</span>m<span style="color: #000066; font-weight: bold;">/</span><span style="color: #000000; font-weight:bold;">2</span><span style="color: #000000;">&#41;</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span><br />
&nbsp; &nbsp; &nbsp; <span style="color: #0033ff; font-weight: bold;">else</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; snapback<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span><br />
&nbsp; &nbsp; <span style="color: #000000;">&#125;</span><br />
&nbsp; &nbsp; <br />
&nbsp; &nbsp; override <span style="color: #0033ff; font-weight: bold;">public</span> <span style="color: #339966; font-weight: bold;">function</span> <span style="color: #004993;">reset</span><span style="color: #000000;">&#40;</span>X<span style="color: #000066; font-weight: bold;">:</span><span style="color: #004993;">Number</span><span style="color: #000066; font-weight: bold;">,</span> Y<span style="color: #000066; font-weight: bold;">:</span><span style="color: #004993;">Number</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">:</span><span style="color: #0033ff; font-weight: bold;">void</span><br />
&nbsp; &nbsp; <span style="color: #000000;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; <span style="color: #0033ff; font-weight: bold;">super</span><span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">reset</span><span style="color: #000000;">&#40;</span>X<span style="color: #000066; font-weight: bold;">,</span> Y<span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span><br />
&nbsp; &nbsp; &nbsp; <span style="color: #004993;">init</span> = <span style="color: #0033ff; font-weight: bold;">new</span> FlxPoint<span style="color: #000000;">&#40;</span>X<span style="color: #000066; font-weight: bold;">,</span> Y<span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span><br />
&nbsp; &nbsp; &nbsp; fixed = <span style="color: #0033ff; font-weight: bold;">false</span><span style="color: #000066; font-weight: bold;">;</span><br />
&nbsp; &nbsp; &nbsp; moves = <span style="color: #0033ff; font-weight: bold;">true</span><span style="color: #000066; font-weight: bold;">;</span><br />
&nbsp; &nbsp; &nbsp; solid &nbsp;= <span style="color: #0033ff; font-weight: bold;">true</span><span style="color: #000066; font-weight: bold;">;</span><br />
&nbsp; &nbsp; &nbsp; <span style="color: #004993;">alpha</span> = <span style="color: #000000; font-weight:bold;">1</span><span style="color: #000066; font-weight: bold;">;</span><br />
&nbsp; &nbsp; <span style="color: #000000;">&#125;</span><br />
&nbsp; &nbsp; <br />
&nbsp; &nbsp; <span style="color: #0033ff; font-weight: bold;">public</span> <span style="color: #339966; font-weight: bold;">function</span> snapback<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">:</span><span style="color: #0033ff; font-weight: bold;">void</span><br />
&nbsp; &nbsp; <span style="color: #000000;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; <span style="color: #004993;">x</span> = <span style="color: #004993;">init</span><span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">x</span><span style="color: #000066; font-weight: bold;">;</span><br />
&nbsp; &nbsp; &nbsp; <span style="color: #004993;">y</span> = <span style="color: #004993;">init</span><span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">y</span><span style="color: #000066; font-weight: bold;">;</span><br />
&nbsp; &nbsp; <span style="color: #000000;">&#125;</span><br />
&nbsp; &nbsp; <br />
&nbsp; &nbsp; override <span style="color: #0033ff; font-weight: bold;">public</span> <span style="color: #339966; font-weight: bold;">function</span> update<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">:</span><span style="color: #0033ff; font-weight: bold;">void</span><br />
&nbsp; &nbsp; <span style="color: #000000;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; <span style="color: #0033ff; font-weight: bold;">super</span><span style="color: #000066; font-weight: bold;">.</span>update<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span><br />
&nbsp; &nbsp; <span style="color: #000000;">&#125;</span><br />
&nbsp; <span style="color: #000000;">&#125;</span><br />
<br />
<span style="color: #000000;">&#125;</span></div></div>
<h3>LeafBit.as</h3>
<div class="codecolorer-container actionscript3 default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;height:450px;"><div class="actionscript3 codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #9900cc; font-weight: bold;">package</span> <br />
<span style="color: #000000;">&#123;</span><br />
&nbsp; <span style="color: #0033ff; font-weight: bold;">import</span> org<span style="color: #000066; font-weight: bold;">.</span>flixel<span style="color: #000066; font-weight: bold;">.</span>FlxPoint<span style="color: #000066; font-weight: bold;">;</span><br />
&nbsp; <span style="color: #0033ff; font-weight: bold;">import</span> org<span style="color: #000066; font-weight: bold;">.</span>flixel<span style="color: #000066; font-weight: bold;">.</span>FlxSprite<span style="color: #000066; font-weight: bold;">;</span><br />
&nbsp; <span style="color: #0033ff; font-weight: bold;">import</span> org<span style="color: #000066; font-weight: bold;">.</span>flixel<span style="color: #000066; font-weight: bold;">.</span>FlxObject<span style="color: #000066; font-weight: bold;">;</span><br />
&nbsp; <span style="color: #0033ff; font-weight: bold;">import</span> org<span style="color: #000066; font-weight: bold;">.</span>flixel<span style="color: #000066; font-weight: bold;">.</span>FlxG<span style="color: #000066; font-weight: bold;">;</span><br />
&nbsp; <span style="color: #0033ff; font-weight: bold;">import</span> com<span style="color: #000066; font-weight: bold;">.</span>gskinner<span style="color: #000066; font-weight: bold;">.</span>utils<span style="color: #000066; font-weight: bold;">.</span>Rnd<span style="color: #000066; font-weight: bold;">;</span><br />
&nbsp; <br />
&nbsp; <span style="color: #0033ff; font-weight: bold;">public</span> <span style="color: #9900cc; font-weight: bold;">class</span> LeafBit <span style="color: #0033ff; font-weight: bold;">extends</span> FlxSprite<br />
&nbsp; <span style="color: #000000;">&#123;</span><br />
&nbsp; &nbsp; <span style="color: #0033ff; font-weight: bold;">public</span> <span style="color: #6699cc; font-weight: bold;">var</span> weight<span style="color: #000066; font-weight: bold;">:</span><span style="color: #004993;">Number</span> = <span style="color: #000000; font-weight:bold;">0</span><span style="color: #000066; font-weight: bold;">;</span> <span style="color: #009900; font-style: italic;">// affects how much the wind moves this leaf</span><br />
&nbsp; &nbsp; <span style="color: #0033ff; font-weight: bold;">private</span> <span style="color: #6699cc; font-weight: bold;">var</span> <span style="color: #004993;">init</span><span style="color: #000066; font-weight: bold;">:</span>FlxPoint<span style="color: #000066; font-weight: bold;">;</span> <span style="color: #009900; font-style: italic;">// the 'starting' point of the leaf to snap back to</span><br />
&nbsp; &nbsp; <span style="color: #0033ff; font-weight: bold;">private</span> <span style="color: #6699cc; font-weight: bold;">var</span> <span style="color: #004993;">colors</span><span style="color: #000066; font-weight: bold;">:</span><span style="color: #004993;">Array</span><span style="color: #000066; font-weight: bold;">;</span> <span style="color: #009900; font-style: italic;">// array of colors</span><br />
&nbsp; &nbsp; <span style="color: #0033ff; font-weight: bold;">public</span> <span style="color: #6699cc; font-weight: bold;">var</span> falling<span style="color: #000066; font-weight: bold;">:</span><span style="color: #004993;">Boolean</span> = <span style="color: #0033ff; font-weight: bold;">false</span><span style="color: #000066; font-weight: bold;">;</span> <span style="color: #009900; font-style: italic;">// if the leaf is falling or not</span><br />
&nbsp; &nbsp; <span style="color: #0033ff; font-weight: bold;">public</span> <span style="color: #6699cc; font-weight: bold;">var</span> landed<span style="color: #000066; font-weight: bold;">:</span><span style="color: #004993;">Boolean</span> = <span style="color: #0033ff; font-weight: bold;">false</span><span style="color: #000066; font-weight: bold;">;</span> <span style="color: #009900; font-style: italic;">// if the leaf is on the ground or not</span><br />
&nbsp; &nbsp; <br />
&nbsp; &nbsp; <span style="color: #0033ff; font-weight: bold;">public</span> <span style="color: #339966; font-weight: bold;">function</span> LeafBit<span style="color: #000000;">&#40;</span>X<span style="color: #000066; font-weight: bold;">:</span><span style="color: #004993;">int</span><span style="color: #000066; font-weight: bold;">,</span> Y<span style="color: #000066; font-weight: bold;">:</span><span style="color: #004993;">int</span><span style="color: #000066; font-weight: bold;">,</span> w<span style="color: #000066; font-weight: bold;">:</span><span style="color: #004993;">int</span><span style="color: #000000;">&#41;</span> <br />
&nbsp; &nbsp; <span style="color: #000000;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; <span style="color: #0033ff; font-weight: bold;">super</span><span style="color: #000000;">&#40;</span>X<span style="color: #000066; font-weight: bold;">,</span> Y<span style="color: #000066; font-weight: bold;">,</span> <span style="color: #0033ff; font-weight: bold;">null</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span><br />
&nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; <span style="color: #004993;">colors</span> = <span style="color: #0033ff; font-weight: bold;">new</span> <span style="color: #004993;">Array</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span><br />
&nbsp; &nbsp; &nbsp; <span style="color: #009900; font-style: italic;">// this is an array of possibly 'fall' colors for our leaves.</span><br />
&nbsp; &nbsp; &nbsp; <span style="color: #004993;">colors</span><span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">push</span><span style="color: #000000;">&#40;</span>0xffb14211<span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span><br />
&nbsp; &nbsp; &nbsp; <span style="color: #004993;">colors</span><span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">push</span><span style="color: #000000;">&#40;</span>0xffd9541a<span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span><br />
&nbsp; &nbsp; &nbsp; <span style="color: #004993;">colors</span><span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">push</span><span style="color: #000000;">&#40;</span>0xff663408<span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span><br />
&nbsp; &nbsp; &nbsp; <span style="color: #004993;">colors</span><span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">push</span><span style="color: #000000;">&#40;</span>0xffbc5815<span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span><br />
&nbsp; &nbsp; &nbsp; <span style="color: #004993;">colors</span><span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">push</span><span style="color: #000000;">&#40;</span>0xffecb338<span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span><br />
&nbsp; &nbsp; &nbsp; <span style="color: #004993;">colors</span><span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">push</span><span style="color: #000000;">&#40;</span>0xffbf1313<span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span><br />
&nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; createGraphic<span style="color: #000000;">&#40;</span><span style="color: #000000; font-weight:bold;">1</span><span style="color: #000066; font-weight: bold;">,</span> <span style="color: #000000; font-weight:bold;">1</span><span style="color: #000066; font-weight: bold;">,</span> <span style="color: #004993;">colors</span><span style="color: #000000;">&#91;</span>Rnd<span style="color: #000066; font-weight: bold;">.</span>integer<span style="color: #000000;">&#40;</span><span style="color: #000000; font-weight:bold;">0</span><span style="color: #000066; font-weight: bold;">,</span> <span style="color: #000000; font-weight:bold;">5</span><span style="color: #000000;">&#41;</span><span style="color: #000000;">&#93;</span><span style="color: #000066; font-weight: bold;">,</span> <span style="color: #0033ff; font-weight: bold;">false</span><span style="color: #000066; font-weight: bold;">,</span> <span style="color: #0033ff; font-weight: bold;">null</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span><br />
&nbsp; &nbsp; &nbsp; <span style="color: #004993;">width</span> = <span style="color: #000000; font-weight:bold;">1</span><span style="color: #000066; font-weight: bold;">;</span><br />
&nbsp; &nbsp; &nbsp; <span style="color: #004993;">height</span> = <span style="color: #000000; font-weight:bold;">1</span><span style="color: #000066; font-weight: bold;">;</span><br />
&nbsp; &nbsp; &nbsp; weight = w<span style="color: #000066; font-weight: bold;">;</span><br />
&nbsp; &nbsp; &nbsp; <span style="color: #004993;">reset</span><span style="color: #000000;">&#40;</span>X<span style="color: #000066; font-weight: bold;">,</span> Y<span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span><br />
&nbsp; &nbsp; <span style="color: #000000;">&#125;</span><br />
&nbsp; &nbsp; <br />
&nbsp; &nbsp; <span style="color: #0033ff; font-weight: bold;">public</span> <span style="color: #339966; font-weight: bold;">function</span> <span style="color: #004993;">push</span><span style="color: #000000;">&#40;</span>Force<span style="color: #000066; font-weight: bold;">:</span><span style="color: #004993;">Number</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">:</span><span style="color: #0033ff; font-weight: bold;">void</span><br />
&nbsp; &nbsp; <span style="color: #000000;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; <span style="color: #009900; font-style: italic;">// take the amount of force being applied, subtact the weight of this bit (+/- a random amount), the remainder is how much it moves.</span><br />
&nbsp; &nbsp; &nbsp; <span style="color: #6699cc; font-weight: bold;">var</span> m<span style="color: #000066; font-weight: bold;">:</span><span style="color: #004993;">Number</span> = <span style="color: #004993;">Math</span><span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">ceil</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#40;</span><span style="color: #004993;">Math</span><span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">abs</span><span style="color: #000000;">&#40;</span>Force<span style="color: #000000;">&#41;</span> <span style="color: #000066; font-weight: bold;">-</span> weight<span style="color: #000000;">&#41;</span> <span style="color: #000066; font-weight: bold;">/</span> <span style="color: #000000; font-weight:bold;">2</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span><br />
&nbsp; &nbsp; &nbsp; <span style="color: #6699cc; font-weight: bold;">var</span> dir<span style="color: #000066; font-weight: bold;">:</span><span style="color: #004993;">int</span> = Force <span style="color: #000066; font-weight: bold;">/</span> <span style="color: #004993;">Math</span><span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">abs</span><span style="color: #000000;">&#40;</span>Force<span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span><br />
&nbsp; &nbsp; &nbsp; <span style="color: #0033ff; font-weight: bold;">if</span> <span style="color: #000000;">&#40;</span>landed<span style="color: #000000;">&#41;</span><br />
&nbsp; &nbsp; &nbsp; <span style="color: #000000;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900; font-style: italic;">//if we landed, then we can only move if the wind is strong, and if we're not under another leaf</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0033ff; font-weight: bold;">if</span> <span style="color: #000000;">&#40;</span>m <span style="color: #000066; font-weight: bold;">&gt;</span> <span style="color: #000000; font-weight:bold;">2</span><span style="color: #000000;">&#41;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0033ff; font-weight: bold;">if</span> <span style="color: #000000;">&#40;</span>Rnd<span style="color: #000066; font-weight: bold;">.</span>boolean<span style="color: #000000;">&#40;</span><span style="color: #000000; font-weight:bold;">0.3</span><span style="color: #000000;">&#41;</span><span style="color: #000000;">&#41;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #6699cc; font-weight: bold;">var</span> tP<span style="color: #000066; font-weight: bold;">:</span>FlxSprite = <span style="color: #0033ff; font-weight: bold;">new</span> FlxSprite<span style="color: #000000;">&#40;</span><span style="color: #004993;">x</span><span style="color: #000066; font-weight: bold;">,</span> <span style="color: #004993;">y</span> <span style="color: #000066; font-weight: bold;">-</span> <span style="color: #000000; font-weight:bold;">1</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; tP<span style="color: #000066; font-weight: bold;">.</span>createGraphic<span style="color: #000000;">&#40;</span><span style="color: #000000; font-weight:bold;">1</span><span style="color: #000066; font-weight: bold;">,</span> <span style="color: #000000; font-weight:bold;">1</span><span style="color: #000066; font-weight: bold;">,</span> 0x00000000<span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0033ff; font-weight: bold;">if</span> <span style="color: #000000;">&#40;</span><span style="color: #000066; font-weight: bold;">!</span>tP<span style="color: #000066; font-weight: bold;">.</span>collide<span style="color: #000000;">&#40;</span>PlayState<span style="color: #000066; font-weight: bold;">.</span>leafgrp<span style="color: #000000;">&#41;</span><span style="color: #000000;">&#41;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; velocity<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">y</span> = <span style="color: #000066; font-weight: bold;">-</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#40;</span>dir <span style="color: #000066; font-weight: bold;">*</span> m<span style="color: #000000;">&#41;</span> <span style="color: #000066; font-weight: bold;">*</span> Rnd<span style="color: #000066; font-weight: bold;">.</span>float<span style="color: #000000;">&#40;</span> <span style="color: #000066; font-weight: bold;">-</span><span style="color: #000000; font-weight:bold;">0.15</span><span style="color: #000066; font-weight: bold;">,</span> <span style="color: #000000; font-weight:bold;">0.15</span><span style="color: #000000;">&#41;</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; falling = <span style="color: #0033ff; font-weight: bold;">true</span><span style="color: #000066; font-weight: bold;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; landed = <span style="color: #0033ff; font-weight: bold;">false</span><span style="color: #000066; font-weight: bold;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000;">&#125;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000;">&#125;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000;">&#125;</span><br />
&nbsp; &nbsp; &nbsp; <span style="color: #000000;">&#125;</span><br />
&nbsp; &nbsp; &nbsp; <span style="color: #0033ff; font-weight: bold;">else</span> <span style="color: #0033ff; font-weight: bold;">if</span> <span style="color: #000000;">&#40;</span><span style="color: #000066; font-weight: bold;">!</span>falling<span style="color: #000000;">&#41;</span><br />
&nbsp; &nbsp; &nbsp; <span style="color: #000000;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900; font-style: italic;">//if we're not falling, the wind might push us a little bit (or not) if it pushes too hard, we might start falling.</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0033ff; font-weight: bold;">if</span> <span style="color: #000000;">&#40;</span>Rnd<span style="color: #000066; font-weight: bold;">.</span>boolean<span style="color: #000000;">&#40;</span>Rnd<span style="color: #000066; font-weight: bold;">.</span>float<span style="color: #000000;">&#40;</span><span style="color: #000000; font-weight:bold;">0.1</span><span style="color: #000066; font-weight: bold;">,</span> <span style="color: #000000; font-weight:bold;">0.3</span><span style="color: #000000;">&#41;</span><span style="color: #000000;">&#41;</span> <span style="color: #000066; font-weight: bold;">&amp;&amp;</span> m <span style="color: #000066; font-weight: bold;">&gt;</span> <span style="color: #000000; font-weight:bold;">0</span><span style="color: #000000;">&#41;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0033ff; font-weight: bold;">if</span> <span style="color: #000000;">&#40;</span>m <span style="color: #000066; font-weight: bold;">&gt;</span> <span style="color: #000000; font-weight:bold;">2</span><span style="color: #000000;">&#41;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0033ff; font-weight: bold;">if</span> <span style="color: #000000;">&#40;</span>Rnd<span style="color: #000066; font-weight: bold;">.</span>boolean<span style="color: #000000;">&#40;</span><span style="color: #000000; font-weight:bold;">0.01</span><span style="color: #000000;">&#41;</span><span style="color: #000000;">&#41;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; falling = <span style="color: #0033ff; font-weight: bold;">true</span><span style="color: #000066; font-weight: bold;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; acceleration<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">y</span> = weight<span style="color: #000066; font-weight: bold;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; solid = <span style="color: #0033ff; font-weight: bold;">true</span><span style="color: #000066; font-weight: bold;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000;">&#125;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0033ff; font-weight: bold;">else</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #004993;">x</span> = <span style="color: #004993;">init</span><span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">x</span> <span style="color: #000066; font-weight: bold;">+</span> <span style="color: #000000;">&#40;</span>dir <span style="color: #000066; font-weight: bold;">*</span> <span style="color: #000000; font-weight:bold;">2</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0033ff; font-weight: bold;">else</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #004993;">x</span> = <span style="color: #004993;">init</span><span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">x</span> <span style="color: #000066; font-weight: bold;">+</span> <span style="color: #000000;">&#40;</span>dir <span style="color: #000066; font-weight: bold;">*</span> m<span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000;">&#125;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0033ff; font-weight: bold;">else</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; snapback<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span><br />
&nbsp; &nbsp; &nbsp; <span style="color: #000000;">&#125;</span><br />
&nbsp; &nbsp; &nbsp; <span style="color: #0033ff; font-weight: bold;">else</span><br />
&nbsp; &nbsp; &nbsp; <span style="color: #000000;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900; font-style: italic;">// if we're falling, the velocity can randomly change, but it's based on the wind.</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; velocity<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">x</span> = <span style="color: #000000;">&#40;</span><span style="color: #000000;">&#40;</span>dir <span style="color: #000066; font-weight: bold;">*</span> m<span style="color: #000000;">&#41;</span> <span style="color: #000066; font-weight: bold;">*</span> Rnd<span style="color: #000066; font-weight: bold;">.</span>float<span style="color: #000000;">&#40;</span><span style="color: #000000; font-weight:bold;">0.85</span><span style="color: #000066; font-weight: bold;">,</span> <span style="color: #000000; font-weight:bold;">1.15</span><span style="color: #000000;">&#41;</span><span style="color: #000000;">&#41;</span> <span style="color: #000066; font-weight: bold;">+</span> Rnd<span style="color: #000066; font-weight: bold;">.</span>integer<span style="color: #000000;">&#40;</span> <span style="color: #000066; font-weight: bold;">-</span><span style="color: #000000; font-weight:bold;">2</span><span style="color: #000066; font-weight: bold;">,</span> <span style="color: #000000; font-weight:bold;">2</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; velocity<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">y</span> <span style="color: #000066; font-weight: bold;">+</span>= <span style="color: #000000;">&#40;</span><span style="color: #000000;">&#40;</span>m <span style="color: #000066; font-weight: bold;">*</span> <span style="color: #000000; font-weight:bold;">0.5</span><span style="color: #000000;">&#41;</span> <span style="color: #000066; font-weight: bold;">*</span> Rnd<span style="color: #000066; font-weight: bold;">.</span>float<span style="color: #000000;">&#40;</span><span style="color: #000066; font-weight: bold;">-</span><span style="color: #000000; font-weight:bold;">0.15</span><span style="color: #000066; font-weight: bold;">,</span> <span style="color: #000000; font-weight:bold;">0.15</span><span style="color: #000000;">&#41;</span><span style="color: #000000;">&#41;</span> <span style="color: #000066; font-weight: bold;">*</span> Rnd<span style="color: #000066; font-weight: bold;">.</span>sign<span style="color: #000000;">&#40;</span><span style="color: #000000; font-weight:bold;">0.3</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span><br />
&nbsp; &nbsp; &nbsp; <span style="color: #000000;">&#125;</span><br />
&nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; <span style="color: #000000;">&#125;</span><br />
&nbsp; &nbsp; <br />
&nbsp; &nbsp; override <span style="color: #0033ff; font-weight: bold;">public</span> <span style="color: #339966; font-weight: bold;">function</span> <span style="color: #004993;">reset</span><span style="color: #000000;">&#40;</span>X<span style="color: #000066; font-weight: bold;">:</span><span style="color: #004993;">Number</span><span style="color: #000066; font-weight: bold;">,</span> Y<span style="color: #000066; font-weight: bold;">:</span><span style="color: #004993;">Number</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">:</span><span style="color: #0033ff; font-weight: bold;">void</span><br />
&nbsp; &nbsp; <span style="color: #000000;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; <span style="color: #0033ff; font-weight: bold;">super</span><span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">reset</span><span style="color: #000000;">&#40;</span>X<span style="color: #000066; font-weight: bold;">,</span> Y<span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span><br />
&nbsp; &nbsp; &nbsp; <span style="color: #004993;">init</span> = <span style="color: #0033ff; font-weight: bold;">new</span> FlxPoint<span style="color: #000000;">&#40;</span>X<span style="color: #000066; font-weight: bold;">,</span> Y<span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span><br />
&nbsp; &nbsp; &nbsp; fixed = <span style="color: #0033ff; font-weight: bold;">false</span><span style="color: #000066; font-weight: bold;">;</span><br />
&nbsp; &nbsp; &nbsp; moves = <span style="color: #0033ff; font-weight: bold;">true</span><span style="color: #000066; font-weight: bold;">;</span><br />
&nbsp; &nbsp; &nbsp; solid &nbsp;= <span style="color: #0033ff; font-weight: bold;">false</span><span style="color: #000066; font-weight: bold;">;</span><br />
&nbsp; &nbsp; &nbsp; <span style="color: #004993;">alpha</span> = <span style="color: #000000; font-weight:bold;">1</span><span style="color: #000066; font-weight: bold;">;</span><br />
&nbsp; &nbsp; <span style="color: #000000;">&#125;</span><br />
&nbsp; &nbsp; <br />
&nbsp; &nbsp; <span style="color: #0033ff; font-weight: bold;">public</span> <span style="color: #339966; font-weight: bold;">function</span> snapback<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">:</span><span style="color: #0033ff; font-weight: bold;">void</span><br />
&nbsp; &nbsp; <span style="color: #000000;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; <span style="color: #009900; font-style: italic;">// put the leaf back where it started</span><br />
&nbsp; &nbsp; &nbsp; <span style="color: #004993;">x</span> = <span style="color: #004993;">init</span><span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">x</span><span style="color: #000066; font-weight: bold;">;</span><br />
&nbsp; &nbsp; &nbsp; <span style="color: #004993;">y</span> = <span style="color: #004993;">init</span><span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">y</span><span style="color: #000066; font-weight: bold;">;</span><br />
&nbsp; &nbsp; <span style="color: #000000;">&#125;</span><br />
&nbsp; &nbsp; <br />
&nbsp; &nbsp; override <span style="color: #0033ff; font-weight: bold;">public</span> <span style="color: #339966; font-weight: bold;">function</span> update<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">:</span><span style="color: #0033ff; font-weight: bold;">void</span><br />
&nbsp; &nbsp; <span style="color: #000000;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; <span style="color: #009900; font-style: italic;">// if the leaf falls too far off the screen, we'll kill it</span><br />
&nbsp; &nbsp; &nbsp; <span style="color: #0033ff; font-weight: bold;">if</span> <span style="color: #000000;">&#40;</span><span style="color: #004993;">y</span> <span style="color: #000066; font-weight: bold;">&gt;</span> FlxG<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">height</span><span style="color: #000000;">&#41;</span> kill<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span><br />
&nbsp; &nbsp; &nbsp; <span style="color: #0033ff; font-weight: bold;">super</span><span style="color: #000066; font-weight: bold;">.</span>update<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span><br />
&nbsp; &nbsp; <span style="color: #000000;">&#125;</span><br />
&nbsp; &nbsp; <br />
&nbsp; &nbsp; override <span style="color: #0033ff; font-weight: bold;">public</span> <span style="color: #339966; font-weight: bold;">function</span> hitBottom<span style="color: #000000;">&#40;</span>Contact<span style="color: #000066; font-weight: bold;">:</span>FlxObject<span style="color: #000066; font-weight: bold;">,</span> Velocity<span style="color: #000066; font-weight: bold;">:</span><span style="color: #004993;">Number</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">:</span><span style="color: #0033ff; font-weight: bold;">void</span><br />
&nbsp; &nbsp; <span style="color: #000000;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; <span style="color: #009900; font-style: italic;">// we only want to land on top of the ground or other leaves that have landed.</span><br />
&nbsp; &nbsp; &nbsp; <span style="color: #6699cc; font-weight: bold;">var</span> hit<span style="color: #000066; font-weight: bold;">:</span><span style="color: #004993;">Boolean</span> = <span style="color: #0033ff; font-weight: bold;">false</span><span style="color: #000066; font-weight: bold;">;</span><br />
&nbsp; &nbsp; &nbsp; <span style="color: #0033ff; font-weight: bold;">if</span> <span style="color: #000000;">&#40;</span>Contact <span style="color: #0033ff; font-weight: bold;">is</span> LeafBit<span style="color: #000000;">&#41;</span><br />
&nbsp; &nbsp; &nbsp; <span style="color: #000000;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #6699cc; font-weight: bold;">var</span> f<span style="color: #000066; font-weight: bold;">:</span>LeafBit = Contact <span style="color: #0033ff; font-weight: bold;">as</span> LeafBit<span style="color: #000066; font-weight: bold;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0033ff; font-weight: bold;">if</span> <span style="color: #000000;">&#40;</span><span style="color: #000066; font-weight: bold;">!</span>f<span style="color: #000066; font-weight: bold;">.</span>landed<span style="color: #000000;">&#41;</span> hit = <span style="color: #0033ff; font-weight: bold;">true</span><span style="color: #000066; font-weight: bold;">;</span><br />
&nbsp; &nbsp; &nbsp; <span style="color: #000000;">&#125;</span><br />
&nbsp; &nbsp; &nbsp; <span style="color: #0033ff; font-weight: bold;">else</span> hit = <span style="color: #0033ff; font-weight: bold;">true</span><span style="color: #000066; font-weight: bold;">;</span><br />
&nbsp; &nbsp; &nbsp; <span style="color: #0033ff; font-weight: bold;">if</span> <span style="color: #000000;">&#40;</span>hit<span style="color: #000000;">&#41;</span><br />
&nbsp; &nbsp; &nbsp; <span style="color: #000000;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0033ff; font-weight: bold;">super</span><span style="color: #000066; font-weight: bold;">.</span>hitBottom<span style="color: #000000;">&#40;</span>Contact<span style="color: #000066; font-weight: bold;">,</span> <span style="color: #000000; font-weight:bold;">0</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900; font-style: italic;">// when we do land on something, we stop our movement and set falling to false</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; velocity<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">x</span> = <span style="color: #000000; font-weight:bold;">0</span><span style="color: #000066; font-weight: bold;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; falling = <span style="color: #0033ff; font-weight: bold;">false</span><span style="color: #000066; font-weight: bold;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; landed = <span style="color: #0033ff; font-weight: bold;">true</span><span style="color: #000066; font-weight: bold;">;</span><br />
&nbsp; &nbsp; &nbsp; <span style="color: #000000;">&#125;</span><br />
&nbsp; &nbsp; <span style="color: #000000;">&#125;</span><br />
&nbsp; &nbsp; <br />
&nbsp; <span style="color: #000000;">&#125;</span><br />
<br />
<span style="color: #000000;">&#125;</span></div></div>
<h3>WispBit.as</h3>
<div class="codecolorer-container actionscript3 default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;height:450px;"><div class="actionscript3 codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #9900cc; font-weight: bold;">package</span> <br />
<span style="color: #000000;">&#123;</span><br />
&nbsp; <span style="color: #0033ff; font-weight: bold;">import</span> org<span style="color: #000066; font-weight: bold;">.</span>flixel<span style="color: #000066; font-weight: bold;">.</span>FlxPoint<span style="color: #000066; font-weight: bold;">;</span><br />
&nbsp; <span style="color: #0033ff; font-weight: bold;">import</span> org<span style="color: #000066; font-weight: bold;">.</span>flixel<span style="color: #000066; font-weight: bold;">.</span>FlxSprite<span style="color: #000066; font-weight: bold;">;</span><br />
&nbsp; <span style="color: #0033ff; font-weight: bold;">import</span> org<span style="color: #000066; font-weight: bold;">.</span>flixel<span style="color: #000066; font-weight: bold;">.</span>FlxObject<span style="color: #000066; font-weight: bold;">;</span><br />
&nbsp; <span style="color: #0033ff; font-weight: bold;">import</span> org<span style="color: #000066; font-weight: bold;">.</span>flixel<span style="color: #000066; font-weight: bold;">.</span>FlxG<span style="color: #000066; font-weight: bold;">;</span><br />
&nbsp; <span style="color: #0033ff; font-weight: bold;">import</span> com<span style="color: #000066; font-weight: bold;">.</span>gskinner<span style="color: #000066; font-weight: bold;">.</span>utils<span style="color: #000066; font-weight: bold;">.</span>Rnd<span style="color: #000066; font-weight: bold;">;</span><br />
&nbsp; <br />
&nbsp; <span style="color: #0033ff; font-weight: bold;">public</span> <span style="color: #9900cc; font-weight: bold;">class</span> WispBit <span style="color: #0033ff; font-weight: bold;">extends</span> FlxSprite<br />
&nbsp; <span style="color: #000000;">&#123;</span><br />
&nbsp; &nbsp; <br />
&nbsp; &nbsp; <span style="color: #0033ff; font-weight: bold;">private</span> <span style="color: #6699cc; font-weight: bold;">var</span> lastdir<span style="color: #000066; font-weight: bold;">:</span><span style="color: #004993;">Number</span> = <span style="color: #000000; font-weight:bold;">0</span><span style="color: #000066; font-weight: bold;">;</span> <span style="color: #009900; font-style: italic;">// this is to rememer which way we were blowing. If the wind changes too much, we'll die.</span><br />
&nbsp; &nbsp; <span style="color: #0033ff; font-weight: bold;">private</span> <span style="color: #6699cc; font-weight: bold;">var</span> fading<span style="color: #000066; font-weight: bold;">:</span><span style="color: #004993;">Boolean</span> = <span style="color: #0033ff; font-weight: bold;">false</span><span style="color: #000066; font-weight: bold;">;</span><br />
&nbsp; &nbsp; <br />
&nbsp; &nbsp; <span style="color: #0033ff; font-weight: bold;">public</span> <span style="color: #339966; font-weight: bold;">function</span> WispBit<span style="color: #000000;">&#40;</span>X<span style="color: #000066; font-weight: bold;">:</span><span style="color: #004993;">int</span><span style="color: #000066; font-weight: bold;">,</span> Y<span style="color: #000066; font-weight: bold;">:</span><span style="color: #004993;">int</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">:</span><span style="color: #0033ff; font-weight: bold;">void</span><br />
&nbsp; &nbsp; <span style="color: #000000;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; <span style="color: #0033ff; font-weight: bold;">super</span><span style="color: #000000;">&#40;</span>X<span style="color: #000066; font-weight: bold;">,</span> Y<span style="color: #000066; font-weight: bold;">,</span> <span style="color: #0033ff; font-weight: bold;">null</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span><br />
&nbsp; &nbsp; &nbsp; createGraphic<span style="color: #000000;">&#40;</span><span style="color: #000000; font-weight:bold;">1</span><span style="color: #000066; font-weight: bold;">,</span> <span style="color: #000000; font-weight:bold;">1</span><span style="color: #000066; font-weight: bold;">,</span> 0xffffffff<span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span><br />
&nbsp; &nbsp; &nbsp; <span style="color: #004993;">width</span> = <span style="color: #000000; font-weight:bold;">1</span><span style="color: #000066; font-weight: bold;">;</span><br />
&nbsp; &nbsp; &nbsp; <span style="color: #004993;">height</span> = <span style="color: #000000; font-weight:bold;">1</span><span style="color: #000066; font-weight: bold;">;</span><br />
&nbsp; &nbsp; &nbsp; <span style="color: #004993;">reset</span><span style="color: #000000;">&#40;</span>X<span style="color: #000066; font-weight: bold;">,</span> Y<span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span><br />
&nbsp; &nbsp; <span style="color: #000000;">&#125;</span><br />
&nbsp; &nbsp; <br />
&nbsp; &nbsp; override <span style="color: #0033ff; font-weight: bold;">public</span> <span style="color: #339966; font-weight: bold;">function</span> <span style="color: #004993;">reset</span><span style="color: #000000;">&#40;</span>X<span style="color: #000066; font-weight: bold;">:</span><span style="color: #004993;">Number</span><span style="color: #000066; font-weight: bold;">,</span> Y<span style="color: #000066; font-weight: bold;">:</span><span style="color: #004993;">Number</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">:</span><span style="color: #0033ff; font-weight: bold;">void</span><br />
&nbsp; &nbsp; <span style="color: #000000;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; <span style="color: #0033ff; font-weight: bold;">super</span><span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">reset</span><span style="color: #000000;">&#40;</span>X<span style="color: #000066; font-weight: bold;">,</span> Y<span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span><br />
&nbsp; &nbsp; &nbsp; <span style="color: #004993;">alpha</span> = Rnd<span style="color: #000066; font-weight: bold;">.</span>float<span style="color: #000000;">&#40;</span><span style="color: #000000; font-weight:bold;">0.1</span><span style="color: #000066; font-weight: bold;">,</span> <span style="color: #000000; font-weight:bold;">0.6</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span><br />
&nbsp; &nbsp; &nbsp; lastdir = PlayState<span style="color: #000066; font-weight: bold;">.</span>wind<span style="color: #000066; font-weight: bold;">;</span><br />
&nbsp; &nbsp; &nbsp; fading = <span style="color: #0033ff; font-weight: bold;">false</span><span style="color: #000066; font-weight: bold;">;</span><br />
&nbsp; &nbsp; <span style="color: #000000;">&#125;</span><br />
&nbsp; &nbsp; <br />
&nbsp; &nbsp; override <span style="color: #0033ff; font-weight: bold;">public</span> <span style="color: #339966; font-weight: bold;">function</span> update<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">:</span><span style="color: #0033ff; font-weight: bold;">void</span><br />
&nbsp; &nbsp; <span style="color: #000000;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; <span style="color: #0033ff; font-weight: bold;">if</span> <span style="color: #000000;">&#40;</span>dead <span style="color: #000066; font-weight: bold;">||</span> <span style="color: #000066; font-weight: bold;">!</span>exists<span style="color: #000000;">&#41;</span> <span style="color: #0033ff; font-weight: bold;">return</span><span style="color: #000066; font-weight: bold;">;</span><br />
&nbsp; &nbsp; &nbsp; <span style="color: #0033ff; font-weight: bold;">if</span> <span style="color: #000000;">&#40;</span>fading<span style="color: #000000;">&#41;</span><br />
&nbsp; &nbsp; &nbsp; <span style="color: #000000;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900; font-style: italic;">// if we're fading out, decrease our opacity each tick and then kill us for real when it's 0.</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0033ff; font-weight: bold;">if</span> <span style="color: #000000;">&#40;</span><span style="color: #004993;">alpha</span> <span style="color: #000066; font-weight: bold;">&lt;</span>= <span style="color: #000000; font-weight:bold;">0</span><span style="color: #000000;">&#41;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; dead = <span style="color: #0033ff; font-weight: bold;">true</span><span style="color: #000066; font-weight: bold;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; exists = <span style="color: #0033ff; font-weight: bold;">false</span><span style="color: #000066; font-weight: bold;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000;">&#125;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0033ff; font-weight: bold;">else</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #004993;">alpha</span> <span style="color: #000066; font-weight: bold;">-</span>= <span style="color: #000000; font-weight:bold;">0.2</span><span style="color: #000066; font-weight: bold;">;</span><br />
&nbsp; &nbsp; &nbsp; <span style="color: #000000;">&#125;</span><br />
&nbsp; &nbsp; &nbsp; <span style="color: #0033ff; font-weight: bold;">else</span> <span style="color: #0033ff; font-weight: bold;">if</span> <span style="color: #000000;">&#40;</span><span style="color: #004993;">Math</span><span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">abs</span><span style="color: #000000;">&#40;</span>PlayState<span style="color: #000066; font-weight: bold;">.</span>wind<span style="color: #000000;">&#41;</span> <span style="color: #000066; font-weight: bold;">&lt;</span> <span style="color: #000000; font-weight:bold;">3</span><span style="color: #000000;">&#41;</span> kill<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span> <span style="color: #009900; font-style: italic;">// if the wind stops or slows down too much, we just die right away.</span><br />
&nbsp; &nbsp; &nbsp; <span style="color: #0033ff; font-weight: bold;">else</span> <span style="color: #0033ff; font-weight: bold;">if</span> <span style="color: #000000;">&#40;</span>lastdir <span style="color: #000066; font-weight: bold;">&lt;</span> <span style="color: #000000; font-weight:bold;">0</span><span style="color: #000000;">&#41;</span> <span style="color: #009900; font-style: italic;">// if we were going one way and then the wind suddenly reversed on us, we die.</span><br />
&nbsp; &nbsp; &nbsp; <span style="color: #000000;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0033ff; font-weight: bold;">if</span> <span style="color: #000000;">&#40;</span><span style="color: #004993;">x</span> <span style="color: #000066; font-weight: bold;">&lt;</span> <span style="color: #000000; font-weight:bold;">0</span><span style="color: #000000;">&#41;</span> kill<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0033ff; font-weight: bold;">if</span> <span style="color: #000000;">&#40;</span>PlayState<span style="color: #000066; font-weight: bold;">.</span>wind <span style="color: #000066; font-weight: bold;">&gt;</span>= <span style="color: #000000; font-weight:bold;">0</span><span style="color: #000000;">&#41;</span> kill<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span><br />
&nbsp; &nbsp; &nbsp; <span style="color: #000000;">&#125;</span><br />
&nbsp; &nbsp; &nbsp; <span style="color: #0033ff; font-weight: bold;">else</span> <span style="color: #0033ff; font-weight: bold;">if</span> <span style="color: #000000;">&#40;</span>lastdir <span style="color: #000066; font-weight: bold;">&gt;</span> <span style="color: #000000; font-weight:bold;">0</span><span style="color: #000000;">&#41;</span><br />
&nbsp; &nbsp; &nbsp; <span style="color: #000000;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0033ff; font-weight: bold;">if</span> <span style="color: #000000;">&#40;</span><span style="color: #004993;">x</span> <span style="color: #000066; font-weight: bold;">&gt;</span> FlxG<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">width</span><span style="color: #000000;">&#41;</span> kill<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0033ff; font-weight: bold;">if</span> <span style="color: #000000;">&#40;</span>PlayState<span style="color: #000066; font-weight: bold;">.</span>wind <span style="color: #000066; font-weight: bold;">&lt;</span>= <span style="color: #000000; font-weight:bold;">0</span><span style="color: #000000;">&#41;</span> kill<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span><br />
&nbsp; &nbsp; &nbsp; <span style="color: #000000;">&#125;</span><br />
&nbsp; &nbsp; &nbsp; <span style="color: #009900; font-style: italic;">// our speed and direction is randomly based on the wind.</span><br />
&nbsp; &nbsp; &nbsp; velocity<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">x</span> = <span style="color: #000000;">&#40;</span>PlayState<span style="color: #000066; font-weight: bold;">.</span>wind <span style="color: #000066; font-weight: bold;">*</span> <span style="color: #000000; font-weight:bold;">20</span><span style="color: #000000;">&#41;</span> <span style="color: #000066; font-weight: bold;">*</span> Rnd<span style="color: #000066; font-weight: bold;">.</span>float<span style="color: #000000;">&#40;</span><span style="color: #000000; font-weight:bold;">0.75</span><span style="color: #000066; font-weight: bold;">,</span> <span style="color: #000000; font-weight:bold;">1.25</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span><br />
&nbsp; &nbsp; &nbsp; velocity<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">y</span> <span style="color: #000066; font-weight: bold;">+</span>= <span style="color: #000000;">&#40;</span>PlayState<span style="color: #000066; font-weight: bold;">.</span>wind <span style="color: #000066; font-weight: bold;">*</span> <span style="color: #000000; font-weight:bold;">0.05</span><span style="color: #000000;">&#41;</span> <span style="color: #000066; font-weight: bold;">*</span> Rnd<span style="color: #000066; font-weight: bold;">.</span>float<span style="color: #000000;">&#40;</span><span style="color: #000066; font-weight: bold;">-</span><span style="color: #000000; font-weight:bold;">0.25</span><span style="color: #000066; font-weight: bold;">,</span> <span style="color: #000000; font-weight:bold;">0.25</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span><br />
&nbsp; &nbsp; &nbsp; lastdir = PlayState<span style="color: #000066; font-weight: bold;">.</span>wind<span style="color: #000066; font-weight: bold;">;</span><br />
&nbsp; &nbsp; &nbsp; <span style="color: #0033ff; font-weight: bold;">super</span><span style="color: #000066; font-weight: bold;">.</span>update<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span><br />
&nbsp; &nbsp; <span style="color: #000000;">&#125;</span><br />
&nbsp; &nbsp; <br />
&nbsp; &nbsp; override <span style="color: #0033ff; font-weight: bold;">public</span> <span style="color: #339966; font-weight: bold;">function</span> kill<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">:</span><span style="color: #0033ff; font-weight: bold;">void</span><br />
&nbsp; &nbsp; <span style="color: #000000;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; <span style="color: #009900; font-style: italic;">// if we get killed, we really just want to fade out.</span><br />
&nbsp; &nbsp; &nbsp; fading = <span style="color: #0033ff; font-weight: bold;">true</span><span style="color: #000066; font-weight: bold;">;</span><br />
&nbsp; &nbsp; <span style="color: #000000;">&#125;</span><br />
&nbsp; <span style="color: #000000;">&#125;</span><br />
<br />
<span style="color: #000000;">&#125;</span></div></div>
<h3>Ghost.as</h3>
<div class="codecolorer-container actionscript3 default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;height:450px;"><div class="actionscript3 codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #9900cc; font-weight: bold;">package</span> <br />
<span style="color: #000000;">&#123;</span><br />
&nbsp; <span style="color: #0033ff; font-weight: bold;">import</span> org<span style="color: #000066; font-weight: bold;">.</span>flixel<span style="color: #000066; font-weight: bold;">.</span>FlxPoint<span style="color: #000066; font-weight: bold;">;</span><br />
&nbsp; <span style="color: #0033ff; font-weight: bold;">import</span> org<span style="color: #000066; font-weight: bold;">.</span>flixel<span style="color: #000066; font-weight: bold;">.</span>FlxSprite<span style="color: #000066; font-weight: bold;">;</span><br />
&nbsp; <span style="color: #0033ff; font-weight: bold;">import</span> org<span style="color: #000066; font-weight: bold;">.</span>flixel<span style="color: #000066; font-weight: bold;">.</span>FlxObject<span style="color: #000066; font-weight: bold;">;</span><br />
&nbsp; <span style="color: #0033ff; font-weight: bold;">import</span> org<span style="color: #000066; font-weight: bold;">.</span>flixel<span style="color: #000066; font-weight: bold;">.</span>FlxG<span style="color: #000066; font-weight: bold;">;</span><br />
&nbsp; <span style="color: #0033ff; font-weight: bold;">import</span> org<span style="color: #000066; font-weight: bold;">.</span>flixel<span style="color: #000066; font-weight: bold;">.</span>FlxGroup<span style="color: #000066; font-weight: bold;">;</span><br />
&nbsp; <span style="color: #0033ff; font-weight: bold;">import</span> com<span style="color: #000066; font-weight: bold;">.</span>gskinner<span style="color: #000066; font-weight: bold;">.</span>utils<span style="color: #000066; font-weight: bold;">.</span>Rnd<span style="color: #000066; font-weight: bold;">;</span><br />
&nbsp; <br />
&nbsp; <span style="color: #0033ff; font-weight: bold;">public</span> <span style="color: #9900cc; font-weight: bold;">class</span> Ghost <span style="color: #0033ff; font-weight: bold;">extends</span> FlxGroup<br />
&nbsp; <span style="color: #000000;">&#123;</span><br />
&nbsp; &nbsp; <br />
&nbsp; &nbsp; <span style="color: #0033ff; font-weight: bold;">private</span> <span style="color: #6699cc; font-weight: bold;">var</span> ghostParts<span style="color: #000066; font-weight: bold;">:</span><span style="color: #004993;">Array</span><span style="color: #000066; font-weight: bold;">;</span> <span style="color: #009900; font-style: italic;">// this array will hold all of our ghost's parts</span><br />
&nbsp; &nbsp; <span style="color: #0033ff; font-weight: bold;">private</span> <span style="color: #6699cc; font-weight: bold;">var</span> fading<span style="color: #000066; font-weight: bold;">:</span><span style="color: #004993;">Boolean</span> = <span style="color: #0033ff; font-weight: bold;">false</span><span style="color: #000066; font-weight: bold;">;</span> <span style="color: #009900; font-style: italic;">// track if we're fading in or not</span><br />
&nbsp; &nbsp; <span style="color: #0033ff; font-weight: bold;">private</span> <span style="color: #6699cc; font-weight: bold;">var</span> <span style="color: #004993;">timer</span><span style="color: #000066; font-weight: bold;">:</span><span style="color: #004993;">Number</span> = <span style="color: #000000; font-weight:bold;">0</span><span style="color: #000066; font-weight: bold;">;</span><br />
&nbsp; &nbsp; <br />
&nbsp; &nbsp; <span style="color: #0033ff; font-weight: bold;">public</span> <span style="color: #339966; font-weight: bold;">function</span> Ghost<span style="color: #000000;">&#40;</span>X<span style="color: #000066; font-weight: bold;">:</span><span style="color: #004993;">Number</span><span style="color: #000066; font-weight: bold;">,</span> Y<span style="color: #000066; font-weight: bold;">:</span><span style="color: #004993;">Number</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">:</span><span style="color: #0033ff; font-weight: bold;">void</span> <br />
&nbsp; &nbsp; <span style="color: #000000;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; <span style="color: #0033ff; font-weight: bold;">super</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span><br />
&nbsp; &nbsp; &nbsp; <span style="color: #004993;">x</span> = X<span style="color: #000066; font-weight: bold;">;</span><br />
&nbsp; &nbsp; &nbsp; <span style="color: #004993;">y</span> = Y<span style="color: #000066; font-weight: bold;">;</span><br />
&nbsp; &nbsp; &nbsp; ghostParts = <span style="color: #0033ff; font-weight: bold;">new</span> <span style="color: #004993;">Array</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span><br />
&nbsp; &nbsp; &nbsp; <span style="color: #009900; font-style: italic;">// our ghost is made up of smaller FlxSprites so that we have more control over alpha.</span><br />
&nbsp; &nbsp; &nbsp; ghostParts<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">push</span><span style="color: #000000;">&#40;</span><span style="color: #004993;">add</span><span style="color: #000000;">&#40;</span><span style="color: #0033ff; font-weight: bold;">new</span> FlxSprite<span style="color: #000000;">&#40;</span><span style="color: #000000; font-weight:bold;">0</span><span style="color: #000066; font-weight: bold;">,</span> <span style="color: #000000; font-weight:bold;">0</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">.</span>createGraphic<span style="color: #000000;">&#40;</span><span style="color: #000000; font-weight:bold;">5</span><span style="color: #000066; font-weight: bold;">,</span> <span style="color: #000000; font-weight:bold;">1</span><span style="color: #000066; font-weight: bold;">,</span> 0xffffffff<span style="color: #000000;">&#41;</span><span style="color: #000000;">&#41;</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span><br />
&nbsp; &nbsp; &nbsp; ghostParts<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">push</span><span style="color: #000000;">&#40;</span><span style="color: #004993;">add</span><span style="color: #000000;">&#40;</span><span style="color: #0033ff; font-weight: bold;">new</span> FlxSprite<span style="color: #000000;">&#40;</span><span style="color: #000000; font-weight:bold;">0</span><span style="color: #000066; font-weight: bold;">,</span> <span style="color: #000000; font-weight:bold;">1</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">.</span>createGraphic<span style="color: #000000;">&#40;</span><span style="color: #000000; font-weight:bold;">1</span><span style="color: #000066; font-weight: bold;">,</span> <span style="color: #000000; font-weight:bold;">1</span><span style="color: #000066; font-weight: bold;">,</span> 0xffffffff<span style="color: #000000;">&#41;</span><span style="color: #000000;">&#41;</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span><br />
&nbsp; &nbsp; &nbsp; ghostParts<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">push</span><span style="color: #000000;">&#40;</span><span style="color: #004993;">add</span><span style="color: #000000;">&#40;</span><span style="color: #0033ff; font-weight: bold;">new</span> FlxSprite<span style="color: #000000;">&#40;</span><span style="color: #000000; font-weight:bold;">2</span><span style="color: #000066; font-weight: bold;">,</span> <span style="color: #000000; font-weight:bold;">1</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">.</span>createGraphic<span style="color: #000000;">&#40;</span><span style="color: #000000; font-weight:bold;">1</span><span style="color: #000066; font-weight: bold;">,</span> <span style="color: #000000; font-weight:bold;">1</span><span style="color: #000066; font-weight: bold;">,</span> 0xffffffff<span style="color: #000000;">&#41;</span><span style="color: #000000;">&#41;</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span><br />
&nbsp; &nbsp; &nbsp; ghostParts<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">push</span><span style="color: #000000;">&#40;</span><span style="color: #004993;">add</span><span style="color: #000000;">&#40;</span><span style="color: #0033ff; font-weight: bold;">new</span> FlxSprite<span style="color: #000000;">&#40;</span><span style="color: #000000; font-weight:bold;">4</span><span style="color: #000066; font-weight: bold;">,</span> <span style="color: #000000; font-weight:bold;">1</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">.</span>createGraphic<span style="color: #000000;">&#40;</span><span style="color: #000000; font-weight:bold;">1</span><span style="color: #000066; font-weight: bold;">,</span> <span style="color: #000000; font-weight:bold;">1</span><span style="color: #000066; font-weight: bold;">,</span> 0xffffffff<span style="color: #000000;">&#41;</span><span style="color: #000000;">&#41;</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span><br />
&nbsp; &nbsp; &nbsp; ghostParts<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">push</span><span style="color: #000000;">&#40;</span><span style="color: #004993;">add</span><span style="color: #000000;">&#40;</span><span style="color: #0033ff; font-weight: bold;">new</span> FlxSprite<span style="color: #000000;">&#40;</span><span style="color: #000000; font-weight:bold;">0</span><span style="color: #000066; font-weight: bold;">,</span> <span style="color: #000000; font-weight:bold;">2</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">.</span>createGraphic<span style="color: #000000;">&#40;</span><span style="color: #000000; font-weight:bold;">5</span><span style="color: #000066; font-weight: bold;">,</span> <span style="color: #000000; font-weight:bold;">1</span><span style="color: #000066; font-weight: bold;">,</span> 0xffffffff<span style="color: #000000;">&#41;</span><span style="color: #000000;">&#41;</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span><br />
&nbsp; &nbsp; &nbsp; ghostParts<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">push</span><span style="color: #000000;">&#40;</span><span style="color: #004993;">add</span><span style="color: #000000;">&#40;</span><span style="color: #0033ff; font-weight: bold;">new</span> FlxSprite<span style="color: #000000;">&#40;</span><span style="color: #000000; font-weight:bold;">0</span><span style="color: #000066; font-weight: bold;">,</span> <span style="color: #000000; font-weight:bold;">3</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">.</span>createGraphic<span style="color: #000000;">&#40;</span><span style="color: #000000; font-weight:bold;">2</span><span style="color: #000066; font-weight: bold;">,</span> <span style="color: #000000; font-weight:bold;">1</span><span style="color: #000066; font-weight: bold;">,</span> 0xffffffff<span style="color: #000000;">&#41;</span><span style="color: #000000;">&#41;</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span><br />
&nbsp; &nbsp; &nbsp; ghostParts<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">push</span><span style="color: #000000;">&#40;</span><span style="color: #004993;">add</span><span style="color: #000000;">&#40;</span><span style="color: #0033ff; font-weight: bold;">new</span> FlxSprite<span style="color: #000000;">&#40;</span><span style="color: #000000; font-weight:bold;">3</span><span style="color: #000066; font-weight: bold;">,</span> <span style="color: #000000; font-weight:bold;">3</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">.</span>createGraphic<span style="color: #000000;">&#40;</span><span style="color: #000000; font-weight:bold;">2</span><span style="color: #000066; font-weight: bold;">,</span> <span style="color: #000000; font-weight:bold;">1</span><span style="color: #000066; font-weight: bold;">,</span> 0xffffffff<span style="color: #000000;">&#41;</span><span style="color: #000000;">&#41;</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span><br />
&nbsp; &nbsp; &nbsp; ghostParts<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">push</span><span style="color: #000000;">&#40;</span><span style="color: #004993;">add</span><span style="color: #000000;">&#40;</span><span style="color: #0033ff; font-weight: bold;">new</span> FlxSprite<span style="color: #000000;">&#40;</span><span style="color: #000000; font-weight:bold;">0</span><span style="color: #000066; font-weight: bold;">,</span> <span style="color: #000000; font-weight:bold;">4</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">.</span>createGraphic<span style="color: #000000;">&#40;</span><span style="color: #000000; font-weight:bold;">2</span><span style="color: #000066; font-weight: bold;">,</span> <span style="color: #000000; font-weight:bold;">1</span><span style="color: #000066; font-weight: bold;">,</span> 0xffffffff<span style="color: #000000;">&#41;</span><span style="color: #000000;">&#41;</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span><br />
&nbsp; &nbsp; &nbsp; ghostParts<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">push</span><span style="color: #000000;">&#40;</span><span style="color: #004993;">add</span><span style="color: #000000;">&#40;</span><span style="color: #0033ff; font-weight: bold;">new</span> FlxSprite<span style="color: #000000;">&#40;</span><span style="color: #000000; font-weight:bold;">3</span><span style="color: #000066; font-weight: bold;">,</span> <span style="color: #000000; font-weight:bold;">4</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">.</span>createGraphic<span style="color: #000000;">&#40;</span><span style="color: #000000; font-weight:bold;">2</span><span style="color: #000066; font-weight: bold;">,</span> <span style="color: #000000; font-weight:bold;">1</span><span style="color: #000066; font-weight: bold;">,</span> 0xffffffff<span style="color: #000000;">&#41;</span><span style="color: #000000;">&#41;</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span><br />
&nbsp; &nbsp; &nbsp; ghostParts<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">push</span><span style="color: #000000;">&#40;</span><span style="color: #004993;">add</span><span style="color: #000000;">&#40;</span><span style="color: #0033ff; font-weight: bold;">new</span> FlxSprite<span style="color: #000000;">&#40;</span><span style="color: #000000; font-weight:bold;">0</span><span style="color: #000066; font-weight: bold;">,</span> <span style="color: #000000; font-weight:bold;">5</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">.</span>createGraphic<span style="color: #000000;">&#40;</span><span style="color: #000000; font-weight:bold;">5</span><span style="color: #000066; font-weight: bold;">,</span> <span style="color: #000000; font-weight:bold;">1</span><span style="color: #000066; font-weight: bold;">,</span> 0xffffffff<span style="color: #000000;">&#41;</span><span style="color: #000000;">&#41;</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span><br />
&nbsp; &nbsp; &nbsp; ghostParts<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">push</span><span style="color: #000000;">&#40;</span><span style="color: #004993;">add</span><span style="color: #000000;">&#40;</span><span style="color: #0033ff; font-weight: bold;">new</span> FlxSprite<span style="color: #000000;">&#40;</span><span style="color: #000000; font-weight:bold;">0</span><span style="color: #000066; font-weight: bold;">,</span> <span style="color: #000000; font-weight:bold;">6</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">.</span>createGraphic<span style="color: #000000;">&#40;</span><span style="color: #000000; font-weight:bold;">5</span><span style="color: #000066; font-weight: bold;">,</span> <span style="color: #000000; font-weight:bold;">1</span><span style="color: #000066; font-weight: bold;">,</span> 0xffffffff<span style="color: #000000;">&#41;</span><span style="color: #000000;">&#41;</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span><br />
&nbsp; &nbsp; &nbsp; ghostParts<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">push</span><span style="color: #000000;">&#40;</span><span style="color: #004993;">add</span><span style="color: #000000;">&#40;</span><span style="color: #0033ff; font-weight: bold;">new</span> FlxSprite<span style="color: #000000;">&#40;</span><span style="color: #000000; font-weight:bold;">0</span><span style="color: #000066; font-weight: bold;">,</span> <span style="color: #000000; font-weight:bold;">7</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">.</span>createGraphic<span style="color: #000000;">&#40;</span><span style="color: #000000; font-weight:bold;">1</span><span style="color: #000066; font-weight: bold;">,</span> <span style="color: #000000; font-weight:bold;">1</span><span style="color: #000066; font-weight: bold;">,</span> 0xffffffff<span style="color: #000000;">&#41;</span><span style="color: #000000;">&#41;</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span><br />
&nbsp; &nbsp; &nbsp; ghostParts<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">push</span><span style="color: #000000;">&#40;</span><span style="color: #004993;">add</span><span style="color: #000000;">&#40;</span><span style="color: #0033ff; font-weight: bold;">new</span> FlxSprite<span style="color: #000000;">&#40;</span><span style="color: #000000; font-weight:bold;">2</span><span style="color: #000066; font-weight: bold;">,</span> <span style="color: #000000; font-weight:bold;">7</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">.</span>createGraphic<span style="color: #000000;">&#40;</span><span style="color: #000000; font-weight:bold;">1</span><span style="color: #000066; font-weight: bold;">,</span> <span style="color: #000000; font-weight:bold;">1</span><span style="color: #000066; font-weight: bold;">,</span> 0xffffffff<span style="color: #000000;">&#41;</span><span style="color: #000000;">&#41;</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span><br />
&nbsp; &nbsp; &nbsp; ghostParts<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">push</span><span style="color: #000000;">&#40;</span><span style="color: #004993;">add</span><span style="color: #000000;">&#40;</span><span style="color: #0033ff; font-weight: bold;">new</span> FlxSprite<span style="color: #000000;">&#40;</span><span style="color: #000000; font-weight:bold;">4</span><span style="color: #000066; font-weight: bold;">,</span> <span style="color: #000000; font-weight:bold;">7</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">.</span>createGraphic<span style="color: #000000;">&#40;</span><span style="color: #000000; font-weight:bold;">1</span><span style="color: #000066; font-weight: bold;">,</span> <span style="color: #000000; font-weight:bold;">1</span><span style="color: #000066; font-weight: bold;">,</span> 0xffffffff<span style="color: #000000;">&#41;</span><span style="color: #000000;">&#41;</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span><br />
&nbsp; &nbsp; &nbsp; ghostParts<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">push</span><span style="color: #000000;">&#40;</span><span style="color: #004993;">add</span><span style="color: #000000;">&#40;</span><span style="color: #0033ff; font-weight: bold;">new</span> FlxSprite<span style="color: #000000;">&#40;</span><span style="color: #000000; font-weight:bold;">0</span><span style="color: #000066; font-weight: bold;">,</span> <span style="color: #000000; font-weight:bold;">8</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">.</span>createGraphic<span style="color: #000000;">&#40;</span><span style="color: #000000; font-weight:bold;">1</span><span style="color: #000066; font-weight: bold;">,</span> <span style="color: #000000; font-weight:bold;">1</span><span style="color: #000066; font-weight: bold;">,</span> 0xffffffff<span style="color: #000000;">&#41;</span><span style="color: #000000;">&#41;</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span><br />
&nbsp; &nbsp; &nbsp; ghostParts<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">push</span><span style="color: #000000;">&#40;</span><span style="color: #004993;">add</span><span style="color: #000000;">&#40;</span><span style="color: #0033ff; font-weight: bold;">new</span> FlxSprite<span style="color: #000000;">&#40;</span><span style="color: #000000; font-weight:bold;">2</span><span style="color: #000066; font-weight: bold;">,</span> <span style="color: #000000; font-weight:bold;">8</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">.</span>createGraphic<span style="color: #000000;">&#40;</span><span style="color: #000000; font-weight:bold;">1</span><span style="color: #000066; font-weight: bold;">,</span> <span style="color: #000000; font-weight:bold;">1</span><span style="color: #000066; font-weight: bold;">,</span> 0xffffffff<span style="color: #000000;">&#41;</span><span style="color: #000000;">&#41;</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span><br />
&nbsp; &nbsp; &nbsp; ghostParts<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">push</span><span style="color: #000000;">&#40;</span><span style="color: #004993;">add</span><span style="color: #000000;">&#40;</span><span style="color: #0033ff; font-weight: bold;">new</span> FlxSprite<span style="color: #000000;">&#40;</span><span style="color: #000000; font-weight:bold;">4</span><span style="color: #000066; font-weight: bold;">,</span> <span style="color: #000000; font-weight:bold;">8</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">.</span>createGraphic<span style="color: #000000;">&#40;</span><span style="color: #000000; font-weight:bold;">1</span><span style="color: #000066; font-weight: bold;">,</span> <span style="color: #000000; font-weight:bold;">1</span><span style="color: #000066; font-weight: bold;">,</span> 0xffffffff<span style="color: #000000;">&#41;</span><span style="color: #000000;">&#41;</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span><br />
&nbsp; &nbsp; &nbsp; <span style="color: #004993;">reset</span><span style="color: #000000;">&#40;</span>X<span style="color: #000066; font-weight: bold;">,</span> Y<span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span><br />
&nbsp; &nbsp; <span style="color: #000000;">&#125;</span><br />
&nbsp; &nbsp; <br />
&nbsp; &nbsp; override <span style="color: #0033ff; font-weight: bold;">public</span> <span style="color: #339966; font-weight: bold;">function</span> <span style="color: #004993;">reset</span><span style="color: #000000;">&#40;</span>X<span style="color: #000066; font-weight: bold;">:</span><span style="color: #004993;">Number</span><span style="color: #000066; font-weight: bold;">,</span> Y<span style="color: #000066; font-weight: bold;">:</span><span style="color: #004993;">Number</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">:</span><span style="color: #0033ff; font-weight: bold;">void</span><br />
&nbsp; &nbsp; <span style="color: #000000;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; <span style="color: #0033ff; font-weight: bold;">super</span><span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">reset</span><span style="color: #000000;">&#40;</span>X<span style="color: #000066; font-weight: bold;">,</span> Y<span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span><br />
&nbsp; &nbsp; &nbsp; <span style="color: #004993;">x</span> = X<span style="color: #000066; font-weight: bold;">;</span><br />
&nbsp; &nbsp; &nbsp; <span style="color: #004993;">y</span> = Y<span style="color: #000066; font-weight: bold;">;</span><br />
&nbsp; &nbsp; &nbsp; <span style="color: #6699cc; font-weight: bold;">var</span> gP<span style="color: #000066; font-weight: bold;">:</span>FlxSprite<span style="color: #000066; font-weight: bold;">;</span><br />
&nbsp; &nbsp; &nbsp; <span style="color: #009900; font-style: italic;">// set each ghost part to be almost invisible.</span><br />
&nbsp; &nbsp; &nbsp; <span style="color: #0033ff; font-weight: bold;">for</span> <span style="color: #0033ff; font-weight: bold;">each</span> <span style="color: #000000;">&#40;</span>gP <span style="color: #0033ff; font-weight: bold;">in</span> ghostParts<span style="color: #000000;">&#41;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; gP<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">alpha</span> = <span style="color: #000000; font-weight:bold;">0.1</span><span style="color: #000066; font-weight: bold;">;</span><br />
&nbsp; &nbsp; &nbsp; fading = <span style="color: #0033ff; font-weight: bold;">false</span><span style="color: #000066; font-weight: bold;">;</span><br />
&nbsp; &nbsp; &nbsp; <span style="color: #004993;">timer</span> = <span style="color: #000000; font-weight:bold;">0</span><span style="color: #000066; font-weight: bold;">;</span><br />
&nbsp; &nbsp; &nbsp; velocity<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">y</span> <span style="color: #000066; font-weight: bold;">-</span>= Rnd<span style="color: #000066; font-weight: bold;">.</span>float<span style="color: #000000;">&#40;</span><span style="color: #000000; font-weight:bold;">16</span><span style="color: #000066; font-weight: bold;">,</span><span style="color: #000000; font-weight:bold;">24</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span> <span style="color: #009900; font-style: italic;">// set random starting y velocity</span><br />
&nbsp; &nbsp; <span style="color: #000000;">&#125;</span><br />
&nbsp; &nbsp; <br />
&nbsp; &nbsp; override <span style="color: #0033ff; font-weight: bold;">public</span> <span style="color: #339966; font-weight: bold;">function</span> update<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">:</span><span style="color: #0033ff; font-weight: bold;">void</span><br />
&nbsp; &nbsp; <span style="color: #000000;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; <span style="color: #009900; font-style: italic;">//basically, we go through each ghost part, starting with the top, and if we're fading in make it more opaque until it's full,</span><br />
&nbsp; &nbsp; &nbsp; <span style="color: #009900; font-style: italic;">// each piece after the first's alpha is based on the level right above it so we get a gradual effect of most opaque-&gt;least opaque</span><br />
&nbsp; &nbsp; &nbsp; <span style="color: #009900; font-style: italic;">// when ghost is faded in all the way, turn on 'fading' and then we reverse the process.</span><br />
&nbsp; &nbsp; &nbsp; <span style="color: #0033ff; font-weight: bold;">if</span> <span style="color: #000000;">&#40;</span>dead <span style="color: #000066; font-weight: bold;">||</span> <span style="color: #000066; font-weight: bold;">!</span>exists<span style="color: #000000;">&#41;</span> <span style="color: #0033ff; font-weight: bold;">return</span><span style="color: #000066; font-weight: bold;">;</span><br />
&nbsp; &nbsp; &nbsp; <span style="color: #0033ff; font-weight: bold;">if</span> <span style="color: #000000;">&#40;</span><span style="color: #004993;">timer</span> <span style="color: #000066; font-weight: bold;">&lt;</span>= <span style="color: #000000; font-weight:bold;">0</span><span style="color: #000000;">&#41;</span><br />
&nbsp; &nbsp; &nbsp; <span style="color: #000000;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #6699cc; font-weight: bold;">var</span> gP<span style="color: #000066; font-weight: bold;">:</span>FlxSprite<span style="color: #000066; font-weight: bold;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #6699cc; font-weight: bold;">var</span> i<span style="color: #000066; font-weight: bold;">:</span><span style="color: #004993;">int</span><span style="color: #000066; font-weight: bold;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0033ff; font-weight: bold;">if</span> <span style="color: #000000;">&#40;</span>fading<span style="color: #000000;">&#41;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0033ff; font-weight: bold;">if</span> <span style="color: #000000;">&#40;</span>ghostParts<span style="color: #000000;">&#91;</span><span style="color: #000000; font-weight:bold;">0</span><span style="color: #000000;">&#93;</span><span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">alpha</span> <span style="color: #000066; font-weight: bold;">&lt;</span>= <span style="color: #000000; font-weight:bold;">0</span><span style="color: #000000;">&#41;</span> kill<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0033ff; font-weight: bold;">else</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0033ff; font-weight: bold;">for</span> <span style="color: #000000;">&#40;</span>i = <span style="color: #000000; font-weight:bold;">0</span><span style="color: #000066; font-weight: bold;">;</span> i <span style="color: #000066; font-weight: bold;">&lt;</span> ghostParts<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">length</span><span style="color: #000066; font-weight: bold;">;</span> i<span style="color: #000066; font-weight: bold;">++</span><span style="color: #000000;">&#41;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0033ff; font-weight: bold;">switch</span><span style="color: #000000;">&#40;</span>i<span style="color: #000000;">&#41;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0033ff; font-weight: bold;">case</span> <span style="color: #000000; font-weight:bold;">0</span><span style="color: #000066; font-weight: bold;">:</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; ghostParts<span style="color: #000000;">&#91;</span>i<span style="color: #000000;">&#93;</span><span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">alpha</span> <span style="color: #000066; font-weight: bold;">-</span>= <span style="color: #000000; font-weight:bold;">0.15</span><span style="color: #000066; font-weight: bold;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0033ff; font-weight: bold;">break</span><span style="color: #000066; font-weight: bold;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0033ff; font-weight: bold;">case</span> <span style="color: #000000; font-weight:bold;">1</span><span style="color: #000066; font-weight: bold;">:</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0033ff; font-weight: bold;">case</span> <span style="color: #000000; font-weight:bold;">2</span><span style="color: #000066; font-weight: bold;">:</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0033ff; font-weight: bold;">case</span> <span style="color: #000000; font-weight:bold;">3</span><span style="color: #000066; font-weight: bold;">:</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; ghostParts<span style="color: #000000;">&#91;</span>i<span style="color: #000000;">&#93;</span><span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">alpha</span> = ghostParts<span style="color: #000000;">&#91;</span><span style="color: #000000; font-weight:bold;">0</span><span style="color: #000000;">&#93;</span><span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">alpha</span> <span style="color: #000066; font-weight: bold;">-</span><span style="color: #000000; font-weight:bold;">0.1</span><span style="color: #000066; font-weight: bold;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0033ff; font-weight: bold;">break</span><span style="color: #000066; font-weight: bold;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0033ff; font-weight: bold;">case</span> <span style="color: #000000; font-weight:bold;">4</span><span style="color: #000066; font-weight: bold;">:</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; ghostParts<span style="color: #000000;">&#91;</span>i<span style="color: #000000;">&#93;</span><span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">alpha</span> = ghostParts<span style="color: #000000;">&#91;</span><span style="color: #000000; font-weight:bold;">2</span><span style="color: #000000;">&#93;</span><span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">alpha</span> <span style="color: #000066; font-weight: bold;">-</span><span style="color: #000000; font-weight:bold;">0.1</span><span style="color: #000066; font-weight: bold;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0033ff; font-weight: bold;">break</span><span style="color: #000066; font-weight: bold;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0033ff; font-weight: bold;">case</span> <span style="color: #000000; font-weight:bold;">5</span><span style="color: #000066; font-weight: bold;">:</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0033ff; font-weight: bold;">case</span> <span style="color: #000000; font-weight:bold;">6</span><span style="color: #000066; font-weight: bold;">:</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; ghostParts<span style="color: #000000;">&#91;</span>i<span style="color: #000000;">&#93;</span><span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">alpha</span> = ghostParts<span style="color: #000000;">&#91;</span><span style="color: #000000; font-weight:bold;">4</span><span style="color: #000000;">&#93;</span><span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">alpha</span> <span style="color: #000066; font-weight: bold;">-</span><span style="color: #000000; font-weight:bold;">0.1</span><span style="color: #000066; font-weight: bold;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0033ff; font-weight: bold;">break</span><span style="color: #000066; font-weight: bold;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0033ff; font-weight: bold;">case</span> <span style="color: #000000; font-weight:bold;">7</span><span style="color: #000066; font-weight: bold;">:</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0033ff; font-weight: bold;">case</span> <span style="color: #000000; font-weight:bold;">8</span><span style="color: #000066; font-weight: bold;">:</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; ghostParts<span style="color: #000000;">&#91;</span>i<span style="color: #000000;">&#93;</span><span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">alpha</span> = ghostParts<span style="color: #000000;">&#91;</span><span style="color: #000000; font-weight:bold;">5</span><span style="color: #000000;">&#93;</span><span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">alpha</span> <span style="color: #000066; font-weight: bold;">-</span><span style="color: #000000; font-weight:bold;">0.1</span><span style="color: #000066; font-weight: bold;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0033ff; font-weight: bold;">break</span><span style="color: #000066; font-weight: bold;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0033ff; font-weight: bold;">case</span> <span style="color: #000000; font-weight:bold;">9</span><span style="color: #000066; font-weight: bold;">:</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; ghostParts<span style="color: #000000;">&#91;</span>i<span style="color: #000000;">&#93;</span><span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">alpha</span> = ghostParts<span style="color: #000000;">&#91;</span><span style="color: #000000; font-weight:bold;">7</span><span style="color: #000000;">&#93;</span><span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">alpha</span> <span style="color: #000066; font-weight: bold;">-</span><span style="color: #000000; font-weight:bold;">0.1</span><span style="color: #000066; font-weight: bold;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0033ff; font-weight: bold;">break</span><span style="color: #000066; font-weight: bold;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0033ff; font-weight: bold;">case</span> <span style="color: #000000; font-weight:bold;">10</span><span style="color: #000066; font-weight: bold;">:</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; ghostParts<span style="color: #000000;">&#91;</span>i<span style="color: #000000;">&#93;</span><span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">alpha</span> = ghostParts<span style="color: #000000;">&#91;</span><span style="color: #000000; font-weight:bold;">9</span><span style="color: #000000;">&#93;</span><span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">alpha</span> <span style="color: #000066; font-weight: bold;">-</span><span style="color: #000000; font-weight:bold;">0.1</span><span style="color: #000066; font-weight: bold;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0033ff; font-weight: bold;">break</span><span style="color: #000066; font-weight: bold;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0033ff; font-weight: bold;">case</span> <span style="color: #000000; font-weight:bold;">11</span><span style="color: #000066; font-weight: bold;">:</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0033ff; font-weight: bold;">case</span> <span style="color: #000000; font-weight:bold;">12</span><span style="color: #000066; font-weight: bold;">:</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0033ff; font-weight: bold;">case</span> <span style="color: #000000; font-weight:bold;">13</span><span style="color: #000066; font-weight: bold;">:</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; ghostParts<span style="color: #000000;">&#91;</span>i<span style="color: #000000;">&#93;</span><span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">alpha</span> = ghostParts<span style="color: #000000;">&#91;</span><span style="color: #000000; font-weight:bold;">10</span><span style="color: #000000;">&#93;</span><span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">alpha</span> <span style="color: #000066; font-weight: bold;">-</span><span style="color: #000000; font-weight:bold;">0.1</span><span style="color: #000066; font-weight: bold;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0033ff; font-weight: bold;">break</span><span style="color: #000066; font-weight: bold;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0033ff; font-weight: bold;">case</span> <span style="color: #000000; font-weight:bold;">14</span><span style="color: #000066; font-weight: bold;">:</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0033ff; font-weight: bold;">case</span> <span style="color: #000000; font-weight:bold;">15</span><span style="color: #000066; font-weight: bold;">:</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0033ff; font-weight: bold;">case</span> <span style="color: #000000; font-weight:bold;">16</span><span style="color: #000066; font-weight: bold;">:</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; ghostParts<span style="color: #000000;">&#91;</span>i<span style="color: #000000;">&#93;</span><span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">alpha</span> = ghostParts<span style="color: #000000;">&#91;</span><span style="color: #000000; font-weight:bold;">11</span><span style="color: #000000;">&#93;</span><span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">alpha</span> <span style="color: #000066; font-weight: bold;">-</span><span style="color: #000000; font-weight:bold;">0.1</span><span style="color: #000066; font-weight: bold;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0033ff; font-weight: bold;">break</span><span style="color: #000066; font-weight: bold;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000;">&#125;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000;">&#125;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000;">&#125;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000;">&#125;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0033ff; font-weight: bold;">else</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0033ff; font-weight: bold;">if</span> <span style="color: #000000;">&#40;</span>ghostParts<span style="color: #000000;">&#91;</span><span style="color: #000000; font-weight:bold;">0</span><span style="color: #000000;">&#93;</span><span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">alpha</span> <span style="color: #000066; font-weight: bold;">&gt;</span>= <span style="color: #000000; font-weight:bold;">1</span><span style="color: #000000;">&#41;</span> fading = <span style="color: #0033ff; font-weight: bold;">true</span><span style="color: #000066; font-weight: bold;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0033ff; font-weight: bold;">else</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0033ff; font-weight: bold;">for</span> <span style="color: #000000;">&#40;</span>i = <span style="color: #000000; font-weight:bold;">0</span><span style="color: #000066; font-weight: bold;">;</span> i <span style="color: #000066; font-weight: bold;">&lt;</span> ghostParts<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">length</span><span style="color: #000066; font-weight: bold;">;</span> i<span style="color: #000066; font-weight: bold;">++</span><span style="color: #000000;">&#41;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0033ff; font-weight: bold;">switch</span><span style="color: #000000;">&#40;</span>i<span style="color: #000000;">&#41;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0033ff; font-weight: bold;">case</span> <span style="color: #000000; font-weight:bold;">0</span><span style="color: #000066; font-weight: bold;">:</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; ghostParts<span style="color: #000000;">&#91;</span>i<span style="color: #000000;">&#93;</span><span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">alpha</span> <span style="color: #000066; font-weight: bold;">+</span>= <span style="color: #000000; font-weight:bold;">0.15</span><span style="color: #000066; font-weight: bold;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0033ff; font-weight: bold;">break</span><span style="color: #000066; font-weight: bold;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0033ff; font-weight: bold;">case</span> <span style="color: #000000; font-weight:bold;">1</span><span style="color: #000066; font-weight: bold;">:</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0033ff; font-weight: bold;">case</span> <span style="color: #000000; font-weight:bold;">2</span><span style="color: #000066; font-weight: bold;">:</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0033ff; font-weight: bold;">case</span> <span style="color: #000000; font-weight:bold;">3</span><span style="color: #000066; font-weight: bold;">:</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; ghostParts<span style="color: #000000;">&#91;</span>i<span style="color: #000000;">&#93;</span><span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">alpha</span> = ghostParts<span style="color: #000000;">&#91;</span><span style="color: #000000; font-weight:bold;">0</span><span style="color: #000000;">&#93;</span><span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">alpha</span> <span style="color: #000066; font-weight: bold;">-</span><span style="color: #000000; font-weight:bold;">0.1</span><span style="color: #000066; font-weight: bold;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0033ff; font-weight: bold;">break</span><span style="color: #000066; font-weight: bold;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0033ff; font-weight: bold;">case</span> <span style="color: #000000; font-weight:bold;">4</span><span style="color: #000066; font-weight: bold;">:</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; ghostParts<span style="color: #000000;">&#91;</span>i<span style="color: #000000;">&#93;</span><span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">alpha</span> = ghostParts<span style="color: #000000;">&#91;</span><span style="color: #000000; font-weight:bold;">2</span><span style="color: #000000;">&#93;</span><span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">alpha</span> <span style="color: #000066; font-weight: bold;">-</span><span style="color: #000000; font-weight:bold;">0.1</span><span style="color: #000066; font-weight: bold;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0033ff; font-weight: bold;">break</span><span style="color: #000066; font-weight: bold;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0033ff; font-weight: bold;">case</span> <span style="color: #000000; font-weight:bold;">5</span><span style="color: #000066; font-weight: bold;">:</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0033ff; font-weight: bold;">case</span> <span style="color: #000000; font-weight:bold;">6</span><span style="color: #000066; font-weight: bold;">:</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; ghostParts<span style="color: #000000;">&#91;</span>i<span style="color: #000000;">&#93;</span><span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">alpha</span> = ghostParts<span style="color: #000000;">&#91;</span><span style="color: #000000; font-weight:bold;">4</span><span style="color: #000000;">&#93;</span><span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">alpha</span> <span style="color: #000066; font-weight: bold;">-</span><span style="color: #000000; font-weight:bold;">0.1</span><span style="color: #000066; font-weight: bold;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0033ff; font-weight: bold;">break</span><span style="color: #000066; font-weight: bold;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0033ff; font-weight: bold;">case</span> <span style="color: #000000; font-weight:bold;">7</span><span style="color: #000066; font-weight: bold;">:</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0033ff; font-weight: bold;">case</span> <span style="color: #000000; font-weight:bold;">8</span><span style="color: #000066; font-weight: bold;">:</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; ghostParts<span style="color: #000000;">&#91;</span>i<span style="color: #000000;">&#93;</span><span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">alpha</span> = ghostParts<span style="color: #000000;">&#91;</span><span style="color: #000000; font-weight:bold;">5</span><span style="color: #000000;">&#93;</span><span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">alpha</span> <span style="color: #000066; font-weight: bold;">-</span><span style="color: #000000; font-weight:bold;">0.1</span><span style="color: #000066; font-weight: bold;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0033ff; font-weight: bold;">break</span><span style="color: #000066; font-weight: bold;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0033ff; font-weight: bold;">case</span> <span style="color: #000000; font-weight:bold;">9</span><span style="color: #000066; font-weight: bold;">:</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; ghostParts<span style="color: #000000;">&#91;</span>i<span style="color: #000000;">&#93;</span><span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">alpha</span> = ghostParts<span style="color: #000000;">&#91;</span><span style="color: #000000; font-weight:bold;">7</span><span style="color: #000000;">&#93;</span><span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">alpha</span> <span style="color: #000066; font-weight: bold;">-</span><span style="color: #000000; font-weight:bold;">0.1</span><span style="color: #000066; font-weight: bold;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0033ff; font-weight: bold;">break</span><span style="color: #000066; font-weight: bold;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0033ff; font-weight: bold;">case</span> <span style="color: #000000; font-weight:bold;">10</span><span style="color: #000066; font-weight: bold;">:</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; ghostParts<span style="color: #000000;">&#91;</span>i<span style="color: #000000;">&#93;</span><span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">alpha</span> = ghostParts<span style="color: #000000;">&#91;</span><span style="color: #000000; font-weight:bold;">9</span><span style="color: #000000;">&#93;</span><span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">alpha</span> <span style="color: #000066; font-weight: bold;">-</span><span style="color: #000000; font-weight:bold;">0.1</span><span style="color: #000066; font-weight: bold;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0033ff; font-weight: bold;">break</span><span style="color: #000066; font-weight: bold;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0033ff; font-weight: bold;">case</span> <span style="color: #000000; font-weight:bold;">11</span><span style="color: #000066; font-weight: bold;">:</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0033ff; font-weight: bold;">case</span> <span style="color: #000000; font-weight:bold;">12</span><span style="color: #000066; font-weight: bold;">:</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0033ff; font-weight: bold;">case</span> <span style="color: #000000; font-weight:bold;">13</span><span style="color: #000066; font-weight: bold;">:</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; ghostParts<span style="color: #000000;">&#91;</span>i<span style="color: #000000;">&#93;</span><span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">alpha</span> = ghostParts<span style="color: #000000;">&#91;</span><span style="color: #000000; font-weight:bold;">10</span><span style="color: #000000;">&#93;</span><span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">alpha</span> <span style="color: #000066; font-weight: bold;">-</span><span style="color: #000000; font-weight:bold;">0.1</span><span style="color: #000066; font-weight: bold;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0033ff; font-weight: bold;">break</span><span style="color: #000066; font-weight: bold;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0033ff; font-weight: bold;">case</span> <span style="color: #000000; font-weight:bold;">14</span><span style="color: #000066; font-weight: bold;">:</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0033ff; font-weight: bold;">case</span> <span style="color: #000000; font-weight:bold;">15</span><span style="color: #000066; font-weight: bold;">:</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0033ff; font-weight: bold;">case</span> <span style="color: #000000; font-weight:bold;">16</span><span style="color: #000066; font-weight: bold;">:</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; ghostParts<span style="color: #000000;">&#91;</span>i<span style="color: #000000;">&#93;</span><span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">alpha</span> = ghostParts<span style="color: #000000;">&#91;</span><span style="color: #000000; font-weight:bold;">11</span><span style="color: #000000;">&#93;</span><span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">alpha</span> <span style="color: #000066; font-weight: bold;">-</span><span style="color: #000000; font-weight:bold;">0.1</span><span style="color: #000066; font-weight: bold;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0033ff; font-weight: bold;">break</span><span style="color: #000066; font-weight: bold;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000;">&#125;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000;">&#125;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000;">&#125;</span> &nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000;">&#125;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; velocity<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">x</span> = Rnd<span style="color: #000066; font-weight: bold;">.</span>float<span style="color: #000000;">&#40;</span><span style="color: #000066; font-weight: bold;">-</span><span style="color: #000000; font-weight:bold;">2</span><span style="color: #000066; font-weight: bold;">,</span><span style="color: #000000; font-weight:bold;">2</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">/</span><span style="color: #000000; font-weight:bold;">4</span><span style="color: #000066; font-weight: bold;">;</span> <span style="color: #009900; font-style: italic;">// we change x velocity randomly</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #004993;">timer</span> = FlxG<span style="color: #000066; font-weight: bold;">.</span>elapsed<span style="color: #000066; font-weight: bold;">*</span><span style="color: #000000; font-weight:bold;">3.5</span><span style="color: #000066; font-weight: bold;">;</span><br />
&nbsp; &nbsp; &nbsp; <span style="color: #000000;">&#125;</span><br />
&nbsp; &nbsp; &nbsp; <span style="color: #0033ff; font-weight: bold;">else</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #004993;">timer</span> <span style="color: #000066; font-weight: bold;">-</span>= FlxG<span style="color: #000066; font-weight: bold;">.</span>elapsed<span style="color: #000066; font-weight: bold;">;</span><br />
&nbsp; &nbsp; &nbsp; <span style="color: #0033ff; font-weight: bold;">super</span><span style="color: #000066; font-weight: bold;">.</span>update<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span><br />
&nbsp; &nbsp; <span style="color: #000000;">&#125;</span><br />
&nbsp; &nbsp; <br />
&nbsp; <span style="color: #000000;">&#125;</span><br />
<br />
<span style="color: #000000;">&#125;</span></div></div>
<p>You can find the complete source <a href="http://github.com/SeiferTim/Flixel-Showcase--Fall">here on GitHub</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.tileisle.net/flixel-showcase-fall/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Flixel SNOWcase: Snow</title>
		<link>http://www.tileisle.net/flixel-showcase-snow/</link>
		<comments>http://www.tileisle.net/flixel-showcase-snow/#comments</comments>
		<pubDate>Wed, 22 Sep 2010 16:37:26 +0000</pubDate>
		<dc:creator>Tim</dc:creator>
				<category><![CDATA[Flixel Showcase]]></category>
		<category><![CDATA[actionscript]]></category>
		<category><![CDATA[actionscript 3]]></category>
		<category><![CDATA[as3]]></category>
		<category><![CDATA[chaos]]></category>
		<category><![CDATA[code]]></category>
		<category><![CDATA[cool]]></category>
		<category><![CDATA[demo]]></category>
		<category><![CDATA[demonstration]]></category>
		<category><![CDATA[example]]></category>
		<category><![CDATA[flash]]></category>
		<category><![CDATA[Flixel]]></category>
		<category><![CDATA[fx]]></category>
		<category><![CDATA[melt]]></category>
		<category><![CDATA[neat]]></category>
		<category><![CDATA[random]]></category>
		<category><![CDATA[snow]]></category>
		<category><![CDATA[source code]]></category>
		<category><![CDATA[special effect]]></category>

		<guid isPermaLink="false">http://www.tileisle.net/?p=225</guid>
		<description><![CDATA[In an effort to retain at least some of my sanity, I spent some time just goofing around with Flixel and came up with something that I think is really neat. Not sure why I always seem to like playing with snow There are several different subtle things going on all at once: First, it [...]]]></description>
			<content:encoded><![CDATA[<p>In an effort to retain at least some of my sanity, I spent some time just goofing around with Flixel and came up with something that I think is really neat.</p>
<p>
<object width="320" height="240">
<param name="movie" value="/Flixel/snow/snowdemo.swf"></param>
<param name="quality" value="high"></param>
<param name="wmode" value="window"></param>
<param name="menu" value="true"></param>
<param name="bgcolor" value="#000000"></param>
<embed type="application/x-shockwave-flash" width="320" height="240" src="/Flixel/snow/snowdemo.swf" quality="high" bgcolor="#000000" wmode="window" menu="true" ></embed>
</object>
</p>
<p>Not sure why I always seem to like playing with snow <img src='http://www.tileisle.net/wp-includes/images/smilies/icon_razz.gif' alt=':P' class='wp-smiley' /> </p>
<p>There are several different subtle things going on all at once: </p>
<ul>
<li>First, it only snows at night, and it starts out with a few fewer flakes and then builds up until the night is almost over before slowing down a bit. </li>
<li>The snow flakes are all affected by the wind, which randomly, gradually changes speed and direction throughout the night. </li>
<li>Flakes can land on the ground or land on other flakes on the ground and build up over time. </li>
<li>When the sun comes up, it starts to melt the snow that is at the top of the drifts, randomly melting more and more snow the higher the sun gets in the sky. </li>
<li>The snow will start to melt, and then turn to water, and no longer collide.</li>
<li>Any water that has not completely run away will refreeze at nightfall, becoming solid again.</li>
</ul>
<p>If you&#8217;d like to know a little more about the technical side of things, or would like to see the source code:</p>
<p><span id="more-225"></span></p>
<p>I really only used two classes in this experiment: I made a Flake class (extends FlxSprite) and then the PlayState. I probably could have used a FlxEmitter for the snow, but I kind of liked having the control to spawn them myself. The logic I have in place to determine if a given snowflake is covered or not went through several iterations &#8211; most of them extremely slow and intensive. Apparently it&#8217;s harder than it looks to check to see if the spot right above or next to a given object contains another object&#8230; I was originally only melting flakes that had 2 or more exposed edges, but had to scrap that for the simpler &#8220;check if something&#8217;s above me&#8221; routine.</p>
<p>Take a look at my code to see how I&#8217;m doing things:</p>
<h3>Flake.as</h3>
<div class="codecolorer-container actionscript3 default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;height:450px;"><div class="actionscript3 codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #9900cc; font-weight: bold;">package</span> &nbsp;<br />
<span style="color: #000000;">&#123;</span><br />
&nbsp; <span style="color: #0033ff; font-weight: bold;">import</span> org<span style="color: #000066; font-weight: bold;">.</span>flixel<span style="color: #000066; font-weight: bold;">.</span>FlxSprite<span style="color: #000066; font-weight: bold;">;</span><br />
&nbsp; <span style="color: #0033ff; font-weight: bold;">import</span> org<span style="color: #000066; font-weight: bold;">.</span>flixel<span style="color: #000066; font-weight: bold;">.</span>FlxObject<span style="color: #000066; font-weight: bold;">;</span><br />
&nbsp; <span style="color: #0033ff; font-weight: bold;">import</span> org<span style="color: #000066; font-weight: bold;">.</span>flixel<span style="color: #000066; font-weight: bold;">.</span>FlxG<span style="color: #000066; font-weight: bold;">;</span><br />
&nbsp; <span style="color: #0033ff; font-weight: bold;">import</span> com<span style="color: #000066; font-weight: bold;">.</span>gskinner<span style="color: #000066; font-weight: bold;">.</span>utils<span style="color: #000066; font-weight: bold;">.</span>Rnd<span style="color: #000066; font-weight: bold;">;</span><br />
&nbsp; <br />
&nbsp; <span style="color: #0033ff; font-weight: bold;">public</span> <span style="color: #9900cc; font-weight: bold;">class</span> Flake <span style="color: #0033ff; font-weight: bold;">extends</span> FlxSprite<br />
&nbsp; <span style="color: #000000;">&#123;</span><br />
&nbsp; &nbsp; <span style="color: #0033ff; font-weight: bold;">public</span> <span style="color: #6699cc; font-weight: bold;">var</span> _melting<span style="color: #000066; font-weight: bold;">:</span><span style="color: #004993;">Boolean</span> = <span style="color: #0033ff; font-weight: bold;">false</span><span style="color: #000066; font-weight: bold;">;</span> <span style="color: #009900; font-style: italic;">// this flag is set when the flake starts melting.</span><br />
&nbsp; &nbsp; <span style="color: #0033ff; font-weight: bold;">public</span> <span style="color: #6699cc; font-weight: bold;">var</span> _falling<span style="color: #000066; font-weight: bold;">:</span><span style="color: #004993;">Boolean</span> = <span style="color: #0033ff; font-weight: bold;">false</span><span style="color: #000066; font-weight: bold;">;</span> <span style="color: #009900; font-style: italic;">// this flag is set while the flake is falling</span><br />
&nbsp; &nbsp; <br />
&nbsp; &nbsp; <span style="color: #0033ff; font-weight: bold;">private</span> <span style="color: #6699cc; font-weight: bold;">var</span> _melt_timer<span style="color: #000066; font-weight: bold;">:</span><span style="color: #004993;">Number</span> = <span style="color: #000000; font-weight:bold;">3</span><span style="color: #000066; font-weight: bold;">;</span> <span style="color: #009900; font-style: italic;">// we don't start melting for a few ticks after melting is set, after it starts to melt, this is a timer.</span><br />
&nbsp; &nbsp; <br />
&nbsp; &nbsp; <span style="color: #0033ff; font-weight: bold;">public</span> <span style="color: #339966; font-weight: bold;">function</span> Flake<span style="color: #000000;">&#40;</span>X<span style="color: #000066; font-weight: bold;">:</span><span style="color: #004993;">Number</span><span style="color: #000066; font-weight: bold;">,</span> Y<span style="color: #000066; font-weight: bold;">:</span><span style="color: #004993;">Number</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">:</span><span style="color: #0033ff; font-weight: bold;">void</span><br />
&nbsp; &nbsp; <span style="color: #000000;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; <span style="color: #009900; font-style: italic;">// create our flake - just a 1x1 white sprite.</span><br />
&nbsp; &nbsp; &nbsp; <span style="color: #0033ff; font-weight: bold;">super</span><span style="color: #000000;">&#40;</span>X<span style="color: #000066; font-weight: bold;">,</span> Y<span style="color: #000066; font-weight: bold;">,</span> <span style="color: #0033ff; font-weight: bold;">null</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span><br />
&nbsp; &nbsp; &nbsp; createGraphic<span style="color: #000000;">&#40;</span><span style="color: #000000; font-weight:bold;">1</span><span style="color: #000066; font-weight: bold;">,</span> <span style="color: #000000; font-weight:bold;">1</span><span style="color: #000066; font-weight: bold;">,</span> 0xffffffff<span style="color: #000066; font-weight: bold;">,</span> <span style="color: #0033ff; font-weight: bold;">false</span><span style="color: #000066; font-weight: bold;">,</span> <span style="color: #0033ff; font-weight: bold;">null</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span><br />
&nbsp; &nbsp; &nbsp; <span style="color: #009900; font-style: italic;">// we set our max velocities to make sure they don't go too fast</span><br />
&nbsp; &nbsp; &nbsp; maxVelocity<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">y</span> = <span style="color: #000000; font-weight:bold;">8</span><span style="color: #000066; font-weight: bold;">;</span><br />
&nbsp; &nbsp; &nbsp; maxVelocity<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">x</span> = <span style="color: #000000; font-weight:bold;">8</span><span style="color: #000066; font-weight: bold;">;</span><br />
&nbsp; &nbsp; &nbsp; <span style="color: #009900; font-style: italic;">// we set the width and offset to something a bit smaller than 1 pixel so that they don't get stuck to each other's corner as often.</span><br />
&nbsp; &nbsp; &nbsp; <span style="color: #004993;">width</span> = <span style="color: #000000; font-weight:bold;">0.6</span><span style="color: #000066; font-weight: bold;">;</span><br />
&nbsp; &nbsp; &nbsp; <span style="color: #004993;">offset</span><span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">x</span> = <span style="color: #000000; font-weight:bold;">0.2</span><span style="color: #000066; font-weight: bold;">;</span><br />
&nbsp; &nbsp; &nbsp; <span style="color: #009900; font-style: italic;">// we call reset so that we can set our other properties.</span><br />
&nbsp; &nbsp; &nbsp; <span style="color: #004993;">reset</span><span style="color: #000000;">&#40;</span>X<span style="color: #000066; font-weight: bold;">,</span> Y<span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span><br />
&nbsp; &nbsp; <span style="color: #000000;">&#125;</span><br />
&nbsp; &nbsp; <br />
&nbsp; &nbsp; override <span style="color: #0033ff; font-weight: bold;">public</span> <span style="color: #339966; font-weight: bold;">function</span> <span style="color: #004993;">reset</span><span style="color: #000000;">&#40;</span>X<span style="color: #000066; font-weight: bold;">:</span><span style="color: #004993;">Number</span><span style="color: #000066; font-weight: bold;">,</span> Y<span style="color: #000066; font-weight: bold;">:</span><span style="color: #004993;">Number</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">:</span><span style="color: #0033ff; font-weight: bold;">void</span><br />
&nbsp; &nbsp; <span style="color: #000000;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; <span style="color: #0033ff; font-weight: bold;">super</span><span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">reset</span><span style="color: #000000;">&#40;</span>X<span style="color: #000066; font-weight: bold;">,</span> Y<span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span><br />
&nbsp; &nbsp; &nbsp; <span style="color: #009900; font-style: italic;">// we reset our flake's properties so it's ready to start falling</span><br />
&nbsp; &nbsp; &nbsp; _falling = <span style="color: #0033ff; font-weight: bold;">true</span><span style="color: #000066; font-weight: bold;">;</span> <span style="color: #009900; font-style: italic;">// flakes won't collide with other falling flakes.</span><br />
&nbsp; &nbsp; &nbsp; fixed = <span style="color: #0033ff; font-weight: bold;">false</span><span style="color: #000066; font-weight: bold;">;</span> <span style="color: #009900; font-style: italic;">// falling flakes aren't fixed. when they land, they become fixed</span><br />
&nbsp; &nbsp; &nbsp; moves = <span style="color: #0033ff; font-weight: bold;">true</span><span style="color: #000066; font-weight: bold;">;</span> <span style="color: #009900; font-style: italic;">// and moves is set to false so other flakes that land on them won't push them around</span><br />
&nbsp; &nbsp; &nbsp; solid = <span style="color: #0033ff; font-weight: bold;">true</span><span style="color: #000066; font-weight: bold;">;</span> <span style="color: #009900; font-style: italic;">// new flakes are solid</span><br />
&nbsp; &nbsp; &nbsp; _melting = <span style="color: #0033ff; font-weight: bold;">false</span><span style="color: #000066; font-weight: bold;">;</span> <span style="color: #009900; font-style: italic;">// new flakes aren't melting</span><br />
&nbsp; &nbsp; &nbsp; <span style="color: #004993;">alpha</span> = <span style="color: #000000; font-weight:bold;">1</span><span style="color: #000066; font-weight: bold;">;</span> <span style="color: #009900; font-style: italic;">// and are 100% visible</span><br />
&nbsp; &nbsp; &nbsp; acceleration<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">x</span> = <span style="color: #000000; font-weight:bold;">0</span><span style="color: #000066; font-weight: bold;">;</span> <span style="color: #009900; font-style: italic;">// new flakes aren't yet affected by the wind</span><br />
&nbsp; &nbsp; &nbsp; acceleration<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">y</span> = <span style="color: #000000; font-weight:bold;">4</span><span style="color: #000066; font-weight: bold;">;</span> <span style="color: #009900; font-style: italic;">// but they are affected by gravity</span><br />
&nbsp; &nbsp; <span style="color: #000000;">&#125;</span><br />
&nbsp; &nbsp; <br />
&nbsp; &nbsp; <span style="color: #3f5fbf;">/**<br />
&nbsp; &nbsp; &nbsp;* &lt;code&gt;melt&lt;/code&gt; is called when we want this flake to start melting.<br />
&nbsp; &nbsp; &nbsp;*/</span><br />
&nbsp; &nbsp; <span style="color: #0033ff; font-weight: bold;">public</span> <span style="color: #339966; font-weight: bold;">function</span> melt<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">:</span><span style="color: #0033ff; font-weight: bold;">void</span><br />
&nbsp; &nbsp; <span style="color: #000000;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; <span style="color: #0033ff; font-weight: bold;">if</span> <span style="color: #000000;">&#40;</span><span style="color: #000066; font-weight: bold;">!</span>_melting<span style="color: #000000;">&#41;</span><br />
&nbsp; &nbsp; &nbsp; <span style="color: #000000;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; _melting = <span style="color: #0033ff; font-weight: bold;">true</span><span style="color: #000066; font-weight: bold;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; _melt_timer = <span style="color: #000000; font-weight:bold;">2</span><span style="color: #000066; font-weight: bold;">;</span><br />
&nbsp; &nbsp; &nbsp; <span style="color: #000000;">&#125;</span><br />
&nbsp; &nbsp; <span style="color: #000000;">&#125;</span><br />
&nbsp; &nbsp; <br />
&nbsp; &nbsp; <span style="color: #3f5fbf;">/**<br />
&nbsp; &nbsp; &nbsp;* &lt;code&gt;refreeze&lt;/code&gt; stops the flake from melting and makes it solid again (for collision).<br />
&nbsp; &nbsp; &nbsp;*/</span><br />
&nbsp; &nbsp; <span style="color: #0033ff; font-weight: bold;">public</span> <span style="color: #339966; font-weight: bold;">function</span> refreeze<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">:</span><span style="color: #0033ff; font-weight: bold;">void</span><br />
&nbsp; &nbsp; <span style="color: #000000;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; <span style="color: #0033ff; font-weight: bold;">if</span> <span style="color: #000000;">&#40;</span>_melting<span style="color: #000000;">&#41;</span><br />
&nbsp; &nbsp; &nbsp; <span style="color: #000000;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; _melting = <span style="color: #0033ff; font-weight: bold;">false</span><span style="color: #000066; font-weight: bold;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; solid = <span style="color: #0033ff; font-weight: bold;">true</span><span style="color: #000066; font-weight: bold;">;</span><br />
&nbsp; &nbsp; &nbsp; <span style="color: #000000;">&#125;</span><br />
&nbsp; &nbsp; <span style="color: #000000;">&#125;</span><br />
&nbsp; &nbsp; <br />
&nbsp; &nbsp; override <span style="color: #0033ff; font-weight: bold;">public</span> <span style="color: #339966; font-weight: bold;">function</span> update<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">:</span><span style="color: #0033ff; font-weight: bold;">void</span><br />
&nbsp; &nbsp; <span style="color: #000000;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; <span style="color: #009900; font-style: italic;">// if the flake is currently melting, we wait until the melt timer is &lt;= 0 and then we start fading out the flake.</span><br />
&nbsp; &nbsp; &nbsp; <span style="color: #009900; font-style: italic;">// when the flake is halfway faded out, we make it not solid so that it starts to fall away.</span><br />
&nbsp; &nbsp; &nbsp; <span style="color: #009900; font-style: italic;">// once it's alpha =0 , we kill it.</span><br />
&nbsp; &nbsp; &nbsp; <span style="color: #0033ff; font-weight: bold;">if</span> <span style="color: #000000;">&#40;</span>_melting<span style="color: #000000;">&#41;</span><br />
&nbsp; &nbsp; &nbsp; <span style="color: #000000;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0033ff; font-weight: bold;">if</span> <span style="color: #000000;">&#40;</span>_melt_timer <span style="color: #000066; font-weight: bold;">&lt;</span>= <span style="color: #000000; font-weight:bold;">0</span><span style="color: #000000;">&#41;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; _melt_timer = <span style="color: #000000; font-weight:bold;">1</span><span style="color: #000066; font-weight: bold;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #004993;">alpha</span> <span style="color: #000066; font-weight: bold;">-</span>= <span style="color: #000000; font-weight:bold;">0.2</span><span style="color: #000066; font-weight: bold;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000;">&#125;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0033ff; font-weight: bold;">else</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; _melt_timer <span style="color: #000066; font-weight: bold;">-</span>= FlxG<span style="color: #000066; font-weight: bold;">.</span>elapsed<span style="color: #000066; font-weight: bold;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0033ff; font-weight: bold;">if</span> <span style="color: #000000;">&#40;</span><span style="color: #004993;">alpha</span> <span style="color: #000066; font-weight: bold;">&lt;</span> <span style="color: #000000; font-weight:bold;">0.5</span><span style="color: #000000;">&#41;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; solid = <span style="color: #0033ff; font-weight: bold;">false</span><span style="color: #000066; font-weight: bold;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0033ff; font-weight: bold;">else</span> <span style="color: #0033ff; font-weight: bold;">if</span> <span style="color: #000000;">&#40;</span><span style="color: #004993;">alpha</span> <span style="color: #000066; font-weight: bold;">&lt;</span>= <span style="color: #000000; font-weight:bold;">0</span><span style="color: #000000;">&#41;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; kill<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span><br />
&nbsp; &nbsp; &nbsp; <span style="color: #000000;">&#125;</span><br />
&nbsp; &nbsp; &nbsp; <span style="color: #0033ff; font-weight: bold;">if</span> <span style="color: #000000;">&#40;</span>_falling<span style="color: #000000;">&#41;</span> acceleration<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">x</span> = PlayState<span style="color: #000066; font-weight: bold;">.</span>wind <span style="color: #000066; font-weight: bold;">*</span> &nbsp;Rnd<span style="color: #000066; font-weight: bold;">.</span>float<span style="color: #000000;">&#40;</span><span style="color: #000000; font-weight:bold;">0.8</span><span style="color: #000066; font-weight: bold;">,</span> <span style="color: #000000; font-weight:bold;">1.2</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span> <span style="color: #009900; font-style: italic;">// if the flake is falling, it's affected by the wind (with some randomness)</span><br />
&nbsp; &nbsp; &nbsp; <span style="color: #0033ff; font-weight: bold;">if</span> <span style="color: #000000;">&#40;</span><span style="color: #004993;">y</span> <span style="color: #000066; font-weight: bold;">&gt;</span> FlxG<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">height</span><span style="color: #000000;">&#41;</span> kill<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span> <span style="color: #009900; font-style: italic;">// if the flake ever ends up below the bottom of the screen, we'll kill it.</span><br />
&nbsp; &nbsp; &nbsp; <span style="color: #0033ff; font-weight: bold;">super</span><span style="color: #000066; font-weight: bold;">.</span>update<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span><br />
&nbsp; &nbsp; <span style="color: #000000;">&#125;</span><br />
&nbsp; &nbsp; <br />
&nbsp; &nbsp; override <span style="color: #0033ff; font-weight: bold;">public</span> <span style="color: #339966; font-weight: bold;">function</span> hitBottom<span style="color: #000000;">&#40;</span>Contact<span style="color: #000066; font-weight: bold;">:</span>FlxObject<span style="color: #000066; font-weight: bold;">,</span> Velocity<span style="color: #000066; font-weight: bold;">:</span><span style="color: #004993;">Number</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">:</span><span style="color: #0033ff; font-weight: bold;">void</span><br />
&nbsp; &nbsp; <span style="color: #000000;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; <span style="color: #009900; font-style: italic;">// if this flake lands on something, we want to first check to see what it landed on.</span><br />
&nbsp; &nbsp; &nbsp; <span style="color: #009900; font-style: italic;">// if it lands on another flake, then we only want to collide if that flake is not also falling.</span><br />
&nbsp; &nbsp; &nbsp; <span style="color: #009900; font-style: italic;">// otherwise, we'll land on anything else there is (the ground).</span><br />
&nbsp; &nbsp; &nbsp; <span style="color: #6699cc; font-weight: bold;">var</span> hit<span style="color: #000066; font-weight: bold;">:</span><span style="color: #004993;">Boolean</span> = <span style="color: #0033ff; font-weight: bold;">false</span><span style="color: #000066; font-weight: bold;">;</span><br />
&nbsp; &nbsp; &nbsp; <span style="color: #0033ff; font-weight: bold;">if</span> <span style="color: #000000;">&#40;</span>Contact <span style="color: #0033ff; font-weight: bold;">is</span> Flake<span style="color: #000000;">&#41;</span><br />
&nbsp; &nbsp; &nbsp; <span style="color: #000000;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #6699cc; font-weight: bold;">var</span> f<span style="color: #000066; font-weight: bold;">:</span>Flake = Contact <span style="color: #0033ff; font-weight: bold;">as</span> Flake<span style="color: #000066; font-weight: bold;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0033ff; font-weight: bold;">if</span> <span style="color: #000000;">&#40;</span><span style="color: #000066; font-weight: bold;">!</span>f<span style="color: #000066; font-weight: bold;">.</span>_falling<span style="color: #000000;">&#41;</span> hit = <span style="color: #0033ff; font-weight: bold;">true</span><span style="color: #000066; font-weight: bold;">;</span><br />
&nbsp; &nbsp; &nbsp; <span style="color: #000000;">&#125;</span><br />
&nbsp; &nbsp; &nbsp; <span style="color: #0033ff; font-weight: bold;">else</span> hit = <span style="color: #0033ff; font-weight: bold;">true</span><span style="color: #000066; font-weight: bold;">;</span><br />
&nbsp; &nbsp; &nbsp; <span style="color: #0033ff; font-weight: bold;">if</span> <span style="color: #000000;">&#40;</span>hit<span style="color: #000000;">&#41;</span><br />
&nbsp; &nbsp; &nbsp; <span style="color: #000000;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0033ff; font-weight: bold;">super</span><span style="color: #000066; font-weight: bold;">.</span>hitBottom<span style="color: #000000;">&#40;</span>Contact<span style="color: #000066; font-weight: bold;">,</span> <span style="color: #000000; font-weight:bold;">0</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900; font-style: italic;">// when we do land on something, we stop our movement and set falling to false so other flakes can land on us.</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; velocity<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">x</span> = <span style="color: #000000; font-weight:bold;">0</span><span style="color: #000066; font-weight: bold;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; _falling = <span style="color: #0033ff; font-weight: bold;">false</span><span style="color: #000066; font-weight: bold;">;</span><br />
&nbsp; &nbsp; &nbsp; <span style="color: #000000;">&#125;</span><br />
&nbsp; &nbsp; <span style="color: #000000;">&#125;</span><br />
&nbsp; <span style="color: #000000;">&#125;</span><br />
<span style="color: #000000;">&#125;</span></div></div>
<h3>PlayState.as</h3>
<div class="codecolorer-container actionscript3 default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;height:450px;"><div class="actionscript3 codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #9900cc; font-weight: bold;">package</span><br />
<span style="color: #000000;">&#123;</span><br />
&nbsp; <span style="color: #0033ff; font-weight: bold;">import</span> org<span style="color: #000066; font-weight: bold;">.</span>flixel<span style="color: #000066; font-weight: bold;">.</span>FlxSprite<span style="color: #000066; font-weight: bold;">;</span><br />
&nbsp; <span style="color: #0033ff; font-weight: bold;">import</span> org<span style="color: #000066; font-weight: bold;">.</span>flixel<span style="color: #000066; font-weight: bold;">.</span>FlxState<span style="color: #000066; font-weight: bold;">;</span><br />
&nbsp; <span style="color: #0033ff; font-weight: bold;">import</span> org<span style="color: #000066; font-weight: bold;">.</span>flixel<span style="color: #000066; font-weight: bold;">.</span>FlxGroup<span style="color: #000066; font-weight: bold;">;</span><br />
&nbsp; <span style="color: #0033ff; font-weight: bold;">import</span> org<span style="color: #000066; font-weight: bold;">.</span>flixel<span style="color: #000066; font-weight: bold;">.</span>FlxTileblock<span style="color: #000066; font-weight: bold;">;</span><br />
&nbsp; <span style="color: #0033ff; font-weight: bold;">import</span> org<span style="color: #000066; font-weight: bold;">.</span>flixel<span style="color: #000066; font-weight: bold;">.</span>FlxG<span style="color: #000066; font-weight: bold;">;</span><br />
&nbsp; <span style="color: #0033ff; font-weight: bold;">import</span> org<span style="color: #000066; font-weight: bold;">.</span>flixel<span style="color: #000066; font-weight: bold;">.</span>FlxU<span style="color: #000066; font-weight: bold;">;</span><br />
&nbsp; <br />
&nbsp; <span style="color: #0033ff; font-weight: bold;">import</span> com<span style="color: #000066; font-weight: bold;">.</span>gskinner<span style="color: #000066; font-weight: bold;">.</span>utils<span style="color: #000066; font-weight: bold;">.</span>Rnd<span style="color: #000066; font-weight: bold;">;</span><br />
&nbsp; <span style="color: #0033ff; font-weight: bold;">public</span> <span style="color: #9900cc; font-weight: bold;">class</span> PlayState <span style="color: #0033ff; font-weight: bold;">extends</span> FlxState<br />
&nbsp; <span style="color: #000000;">&#123;</span><br />
&nbsp; &nbsp; <span style="color: #000000;">&#91;</span>Embed<span style="color: #000000;">&#40;</span><span style="color: #004993;">source</span> = <span style="color: #990000;">'tiles.png'</span><span style="color: #000000;">&#41;</span><span style="color: #000000;">&#93;</span><span style="color: #0033ff; font-weight: bold;">private</span> <span style="color: #6699cc; font-weight: bold;">var</span> ImgTile<span style="color: #000066; font-weight: bold;">:</span><span style="color: #004993;">Class</span><span style="color: #000066; font-weight: bold;">;</span> <span style="color: #009900; font-style: italic;">// our ground tileblock's image which is a 50x1 image, mostly white with a few gray colors for variety</span><br />
&nbsp; &nbsp; <br />
&nbsp; &nbsp; <span style="color: #0033ff; font-weight: bold;">public</span> static <span style="color: #6699cc; font-weight: bold;">var</span> wind<span style="color: #000066; font-weight: bold;">:</span><span style="color: #004993;">Number</span> = <span style="color: #000000; font-weight:bold;">0.0</span><span style="color: #000066; font-weight: bold;">;</span> <span style="color: #009900; font-style: italic;">// our current wind speed.</span><br />
&nbsp; &nbsp; <br />
&nbsp; &nbsp; <span style="color: #0033ff; font-weight: bold;">private</span> <span style="color: #6699cc; font-weight: bold;">var</span> sky<span style="color: #000066; font-weight: bold;">:</span>FlxSprite<span style="color: #000066; font-weight: bold;">;</span> <span style="color: #009900; font-style: italic;">// the blue sky sprite</span><br />
&nbsp; &nbsp; <span style="color: #0033ff; font-weight: bold;">private</span> <span style="color: #6699cc; font-weight: bold;">var</span> sun<span style="color: #000066; font-weight: bold;">:</span>FlxSprite<span style="color: #000066; font-weight: bold;">;</span> <span style="color: #009900; font-style: italic;">// the yellow sun sprite</span><br />
&nbsp; &nbsp; <span style="color: #0033ff; font-weight: bold;">private</span> <span style="color: #6699cc; font-weight: bold;">var</span> ground<span style="color: #000066; font-weight: bold;">:</span>FlxTileblock<span style="color: #000066; font-weight: bold;">;</span> <span style="color: #009900; font-style: italic;">// the ground</span><br />
&nbsp; &nbsp; <span style="color: #0033ff; font-weight: bold;">private</span> <span style="color: #6699cc; font-weight: bold;">var</span> flakeGrp<span style="color: #000066; font-weight: bold;">:</span>FlxGroup<span style="color: #000066; font-weight: bold;">;</span> <span style="color: #009900; font-style: italic;">// group for our flakes</span><br />
&nbsp; &nbsp; <span style="color: #0033ff; font-weight: bold;">private</span> <span style="color: #6699cc; font-weight: bold;">var</span> _wind_change<span style="color: #000066; font-weight: bold;">:</span><span style="color: #004993;">Number</span> = <span style="color: #000000; font-weight:bold;">0</span><span style="color: #000066; font-weight: bold;">;</span> <span style="color: #009900; font-style: italic;">// a timer for changing our wind speed</span><br />
&nbsp; &nbsp; <span style="color: #0033ff; font-weight: bold;">private</span> <span style="color: #6699cc; font-weight: bold;">var</span> _night_timer<span style="color: #000066; font-weight: bold;">:</span><span style="color: #004993;">Number</span> = <span style="color: #000000; font-weight:bold;">20</span><span style="color: #000066; font-weight: bold;">;</span> <span style="color: #009900; font-style: italic;">// timer for our night's duration</span><br />
&nbsp; &nbsp; <span style="color: #0033ff; font-weight: bold;">private</span> <span style="color: #6699cc; font-weight: bold;">var</span> dayMode<span style="color: #000066; font-weight: bold;">:</span><span style="color: #004993;">int</span> = <span style="color: #000000; font-weight:bold;">0</span><span style="color: #000066; font-weight: bold;">;</span> <span style="color: #009900; font-style: italic;">// which 'mode' of day it it</span><br />
&nbsp; &nbsp; <span style="color: #0033ff; font-weight: bold;">private</span> <span style="color: #6699cc; font-weight: bold;">var</span> _throttle<span style="color: #000066; font-weight: bold;">:</span><span style="color: #004993;">Number</span> = <span style="color: #000000; font-weight:bold;">1</span><span style="color: #000066; font-weight: bold;">;</span> <span style="color: #009900; font-style: italic;">// throttle to slow things down a little bit</span><br />
&nbsp; &nbsp; <br />
&nbsp; &nbsp; override <span style="color: #0033ff; font-weight: bold;">public</span> <span style="color: #339966; font-weight: bold;">function</span> create<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">:</span><span style="color: #0033ff; font-weight: bold;">void</span><br />
&nbsp; &nbsp; <span style="color: #000000;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; sky = <span style="color: #004993;">add</span><span style="color: #000000;">&#40;</span><span style="color: #0033ff; font-weight: bold;">new</span> FlxSprite<span style="color: #000000;">&#40;</span><span style="color: #000000; font-weight:bold;">0</span><span style="color: #000066; font-weight: bold;">,</span> <span style="color: #000000; font-weight:bold;">0</span><span style="color: #000066; font-weight: bold;">,</span> <span style="color: #0033ff; font-weight: bold;">null</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">.</span>createGraphic<span style="color: #000000;">&#40;</span>FlxG<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">width</span><span style="color: #000066; font-weight: bold;">,</span> FlxG<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">height</span><span style="color: #000066; font-weight: bold;">,</span> 0xff75E8FF<span style="color: #000066; font-weight: bold;">,</span> <span style="color: #0033ff; font-weight: bold;">true</span><span style="color: #000066; font-weight: bold;">,</span> <span style="color: #990000;">&quot;sky&quot;</span><span style="color: #000000;">&#41;</span><span style="color: #000000;">&#41;</span> <span style="color: #0033ff; font-weight: bold;">as</span> FlxSprite<span style="color: #000066; font-weight: bold;">;</span> <span style="color: #009900; font-style: italic;">// create and add our sky</span><br />
&nbsp; &nbsp; &nbsp; sky<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">alpha</span> = <span style="color: #000000; font-weight:bold;">0</span><span style="color: #000066; font-weight: bold;">;</span> <span style="color: #009900; font-style: italic;">// make it invisible for now</span><br />
&nbsp; &nbsp; &nbsp; sun = <span style="color: #004993;">add</span><span style="color: #000000;">&#40;</span><span style="color: #0033ff; font-weight: bold;">new</span> FlxSprite<span style="color: #000000;">&#40;</span>Rnd<span style="color: #000066; font-weight: bold;">.</span>integer<span style="color: #000000;">&#40;</span> <span style="color: #000066; font-weight: bold;">-</span><span style="color: #000000; font-weight:bold;">4</span><span style="color: #000066; font-weight: bold;">,</span> FlxG<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">width</span> <span style="color: #000066; font-weight: bold;">-</span> <span style="color: #000000; font-weight:bold;">6</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">,</span> FlxG<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">height</span><span style="color: #000066; font-weight: bold;">,</span> <span style="color: #0033ff; font-weight: bold;">null</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">.</span>createGraphic<span style="color: #000000;">&#40;</span><span style="color: #000000; font-weight:bold;">10</span><span style="color: #000066; font-weight: bold;">,</span> <span style="color: #000000; font-weight:bold;">10</span><span style="color: #000066; font-weight: bold;">,</span> 0xffFFFF00<span style="color: #000066; font-weight: bold;">,</span> <span style="color: #0033ff; font-weight: bold;">true</span><span style="color: #000066; font-weight: bold;">,</span> <span style="color: #990000;">&quot;sun&quot;</span><span style="color: #000000;">&#41;</span><span style="color: #000000;">&#41;</span> <span style="color: #0033ff; font-weight: bold;">as</span> FlxSprite<span style="color: #000066; font-weight: bold;">;</span> <span style="color: #009900; font-style: italic;">// create and add our sun. Put it below the horizon.</span><br />
&nbsp; &nbsp; &nbsp; wind = Rnd<span style="color: #000066; font-weight: bold;">.</span>integer<span style="color: #000000;">&#40;</span> <span style="color: #000066; font-weight: bold;">-</span><span style="color: #000000; font-weight:bold;">50</span><span style="color: #000066; font-weight: bold;">,</span> <span style="color: #000000; font-weight:bold;">50</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">/</span><span style="color: #000000; font-weight:bold;">10</span><span style="color: #000066; font-weight: bold;">;</span> <span style="color: #009900; font-style: italic;">// define our starting wind speed.</span><br />
&nbsp; &nbsp; &nbsp; _wind_change = Rnd<span style="color: #000066; font-weight: bold;">.</span>integer<span style="color: #000000;">&#40;</span><span style="color: #000000; font-weight:bold;">0</span><span style="color: #000066; font-weight: bold;">,</span> <span style="color: #000000; font-weight:bold;">5</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span> <span style="color: #009900; font-style: italic;">// randomly choose how long before our wind changes</span><br />
&nbsp; &nbsp; &nbsp; ground = <span style="color: #004993;">add</span><span style="color: #000000;">&#40;</span><span style="color: #0033ff; font-weight: bold;">new</span> FlxTileblock<span style="color: #000000;">&#40;</span> <span style="color: #000066; font-weight: bold;">-</span><span style="color: #000000; font-weight:bold;">50</span><span style="color: #000066; font-weight: bold;">,</span> FlxG<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">height</span> <span style="color: #000066; font-weight: bold;">-</span> <span style="color: #000000; font-weight:bold;">5</span><span style="color: #000066; font-weight: bold;">,</span> FlxG<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">width</span> <span style="color: #000066; font-weight: bold;">+</span> <span style="color: #000000; font-weight:bold;">50</span><span style="color: #000066; font-weight: bold;">,</span> <span style="color: #000000; font-weight:bold;">20</span><span style="color: #000000;">&#41;</span><span style="color: #000000;">&#41;</span> <span style="color: #0033ff; font-weight: bold;">as</span> FlxTileblock<span style="color: #000066; font-weight: bold;">;</span> <span style="color: #009900; font-style: italic;">// create the ground</span><br />
&nbsp; &nbsp; &nbsp; ground<span style="color: #000066; font-weight: bold;">.</span>loadGraphic<span style="color: #000000;">&#40;</span>ImgTile<span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span> <span style="color: #009900; font-style: italic;">// load ground images</span><br />
&nbsp; &nbsp; &nbsp; ground<span style="color: #000066; font-weight: bold;">.</span>fixed = <span style="color: #0033ff; font-weight: bold;">true</span><span style="color: #000066; font-weight: bold;">;</span> <span style="color: #009900; font-style: italic;">// set it to fixed, not moves, and solid for collision.</span><br />
&nbsp; &nbsp; &nbsp; ground<span style="color: #000066; font-weight: bold;">.</span>moves = <span style="color: #0033ff; font-weight: bold;">false</span><span style="color: #000066; font-weight: bold;">;</span><br />
&nbsp; &nbsp; &nbsp; ground<span style="color: #000066; font-weight: bold;">.</span>solid = <span style="color: #0033ff; font-weight: bold;">true</span><span style="color: #000066; font-weight: bold;">;</span><br />
&nbsp; &nbsp; &nbsp; flakeGrp = <span style="color: #004993;">add</span><span style="color: #000000;">&#40;</span><span style="color: #0033ff; font-weight: bold;">new</span> FlxGroup<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><span style="color: #000000;">&#41;</span> <span style="color: #0033ff; font-weight: bold;">as</span> FlxGroup<span style="color: #000066; font-weight: bold;">;</span> <span style="color: #009900; font-style: italic;">// create our flakeGroup and add a random number of flakes to start with</span><br />
&nbsp; &nbsp; &nbsp; <span style="color: #0033ff; font-weight: bold;">for</span> <span style="color: #000000;">&#40;</span><span style="color: #6699cc; font-weight: bold;">var</span> i<span style="color: #000066; font-weight: bold;">:</span><span style="color: #004993;">int</span> = <span style="color: #000000; font-weight:bold;">0</span><span style="color: #000066; font-weight: bold;">;</span> i <span style="color: #000066; font-weight: bold;">&lt;</span> Rnd<span style="color: #000066; font-weight: bold;">.</span>integer<span style="color: #000000;">&#40;</span><span style="color: #000000; font-weight:bold;">100</span><span style="color: #000066; font-weight: bold;">,</span><span style="color: #000000; font-weight:bold;">200</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span> i<span style="color: #000066; font-weight: bold;">++</span><span style="color: #000000;">&#41;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; flakeGrp<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">add</span><span style="color: #000000;">&#40;</span><span style="color: #0033ff; font-weight: bold;">new</span> Flake<span style="color: #000000;">&#40;</span>Rnd<span style="color: #000066; font-weight: bold;">.</span>integer<span style="color: #000000;">&#40;</span> <span style="color: #000066; font-weight: bold;">-</span><span style="color: #000000; font-weight:bold;">50</span><span style="color: #000066; font-weight: bold;">,</span> FlxG<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">width</span> <span style="color: #000066; font-weight: bold;">+</span> <span style="color: #000000; font-weight:bold;">50</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">,</span> Rnd<span style="color: #000066; font-weight: bold;">.</span>integer<span style="color: #000000;">&#40;</span> <span style="color: #000066; font-weight: bold;">-</span><span style="color: #000000; font-weight:bold;">50</span><span style="color: #000066; font-weight: bold;">,</span> <span style="color: #000066; font-weight: bold;">-</span><span style="color: #000000; font-weight:bold;">5</span><span style="color: #000000;">&#41;</span><span style="color: #000000;">&#41;</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span><br />
&nbsp; &nbsp; &nbsp; _throttle = <span style="color: #000000; font-weight:bold;">1</span><span style="color: #000066; font-weight: bold;">;</span> <span style="color: #009900; font-style: italic;">// initialize our throttle</span><br />
&nbsp; &nbsp; <span style="color: #000000;">&#125;</span><br />
&nbsp; &nbsp; <br />
&nbsp; &nbsp; override <span style="color: #0033ff; font-weight: bold;">public</span> <span style="color: #339966; font-weight: bold;">function</span> update<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">:</span><span style="color: #0033ff; font-weight: bold;">void</span><br />
&nbsp; &nbsp; <span style="color: #000000;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; <span style="color: #6699cc; font-weight: bold;">var</span> f<span style="color: #000066; font-weight: bold;">:</span>Flake<span style="color: #000066; font-weight: bold;">;</span><br />
&nbsp; &nbsp; &nbsp; <span style="color: #6699cc; font-weight: bold;">var</span> f2<span style="color: #000066; font-weight: bold;">:</span>Flake<span style="color: #000066; font-weight: bold;">;</span><br />
&nbsp; &nbsp; &nbsp; flakeGrp<span style="color: #000066; font-weight: bold;">.</span>collide<span style="color: #000000;">&#40;</span>flakeGrp<span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span> <span style="color: #009900; font-style: italic;">// collision for the flakes against each other, and the ground</span><br />
&nbsp; &nbsp; &nbsp; ground<span style="color: #000066; font-weight: bold;">.</span>collide<span style="color: #000000;">&#40;</span>flakeGrp<span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span><br />
&nbsp; &nbsp; &nbsp; <span style="color: #0033ff; font-weight: bold;">if</span> <span style="color: #000000;">&#40;</span>_night_timer <span style="color: #000066; font-weight: bold;">&lt;</span>= <span style="color: #000000; font-weight:bold;">0</span><span style="color: #000000;">&#41;</span><br />
&nbsp; &nbsp; &nbsp; <span style="color: #000000;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900; font-style: italic;">// this is our 'day time' logic.</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900; font-style: italic;">// find out which mode we're in</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0033ff; font-weight: bold;">switch</span><span style="color: #000000;">&#40;</span>dayMode<span style="color: #000000;">&#41;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0033ff; font-weight: bold;">case</span> <span style="color: #000000; font-weight:bold;">0</span><span style="color: #000066; font-weight: bold;">:</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900; font-style: italic;">// day just started, brighten the sky until it's 1/2 bright and then start the sun rising, and set mode to 1.</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0033ff; font-weight: bold;">if</span> <span style="color: #000000;">&#40;</span>sky<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">alpha</span> <span style="color: #000066; font-weight: bold;">&lt;</span> <span style="color: #000000; font-weight:bold;">0.5</span><span style="color: #000000;">&#41;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; sky<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">alpha</span> <span style="color: #000066; font-weight: bold;">+</span>= <span style="color: #000000; font-weight:bold;">0.1</span><span style="color: #000066; font-weight: bold;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0033ff; font-weight: bold;">else</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; sun<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">x</span> = Rnd<span style="color: #000066; font-weight: bold;">.</span>integer<span style="color: #000000;">&#40;</span> <span style="color: #000066; font-weight: bold;">-</span><span style="color: #000000; font-weight:bold;">4</span><span style="color: #000066; font-weight: bold;">,</span> FlxG<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">width</span> <span style="color: #000066; font-weight: bold;">-</span> <span style="color: #000000; font-weight:bold;">6</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; sun<span style="color: #000066; font-weight: bold;">.</span>velocity<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">y</span> = <span style="color: #000066; font-weight: bold;">-</span><span style="color: #000000; font-weight:bold;">12</span><span style="color: #000066; font-weight: bold;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; dayMode = <span style="color: #000000; font-weight:bold;">1</span><span style="color: #000066; font-weight: bold;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000;">&#125;</span> <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0033ff; font-weight: bold;">break</span><span style="color: #000066; font-weight: bold;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0033ff; font-weight: bold;">case</span> <span style="color: #000000; font-weight:bold;">1</span><span style="color: #000066; font-weight: bold;">:</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900; font-style: italic;">// continue brightening the sky and check to see if the sun has reached it's apex - if it has, send it back down, set mode to 2</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0033ff; font-weight: bold;">if</span> <span style="color: #000000;">&#40;</span>sky<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">alpha</span> <span style="color: #000066; font-weight: bold;">&lt;</span> <span style="color: #000000; font-weight:bold;">1</span><span style="color: #000000;">&#41;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; sky<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">alpha</span> <span style="color: #000066; font-weight: bold;">+</span>= <span style="color: #000000; font-weight:bold;">0.1</span><span style="color: #000066; font-weight: bold;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #0033ff; font-weight: bold;">if</span> <span style="color: #000000;">&#40;</span>sun<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">y</span> <span style="color: #000066; font-weight: bold;">&lt;</span>= <span style="color: #000066; font-weight: bold;">-</span><span style="color: #000000; font-weight:bold;">3</span><span style="color: #000000;">&#41;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #000000;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;sun<span style="color: #000066; font-weight: bold;">.</span>velocity<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">y</span> = <span style="color: #000000; font-weight:bold;">12</span><span style="color: #000066; font-weight: bold;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;dayMode = <span style="color: #000000; font-weight:bold;">2</span><span style="color: #000066; font-weight: bold;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #000000;">&#125;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #0033ff; font-weight: bold;">break</span><span style="color: #000066; font-weight: bold;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0033ff; font-weight: bold;">case</span> <span style="color: #000000; font-weight:bold;">2</span><span style="color: #000066; font-weight: bold;">:</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900; font-style: italic;">// check if the sun has gone down and stop it from moving if it has. start fading out the sky.</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0033ff; font-weight: bold;">if</span> <span style="color: #000000;">&#40;</span>sun<span style="color: #000066; font-weight: bold;">.</span>velocity<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">y</span> <span style="color: #000066; font-weight: bold;">!</span>= <span style="color: #000000; font-weight:bold;">0</span><span style="color: #000000;">&#41;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0033ff; font-weight: bold;">if</span> <span style="color: #000000;">&#40;</span>sun<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">y</span> <span style="color: #000066; font-weight: bold;">&gt;</span>= FlxG<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">height</span><span style="color: #000000;">&#41;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; sun<span style="color: #000066; font-weight: bold;">.</span>velocity<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">y</span> = <span style="color: #000000; font-weight:bold;">0</span><span style="color: #000066; font-weight: bold;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000;">&#125;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0033ff; font-weight: bold;">else</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0033ff; font-weight: bold;">if</span> <span style="color: #000000;">&#40;</span>sky<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">alpha</span> <span style="color: #000066; font-weight: bold;">&gt;</span> <span style="color: #000000; font-weight:bold;">0</span><span style="color: #000000;">&#41;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; sky<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">alpha</span> <span style="color: #000066; font-weight: bold;">-</span>= <span style="color: #000000; font-weight:bold;">0.1</span><span style="color: #000066; font-weight: bold;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0033ff; font-weight: bold;">else</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900; font-style: italic;">// when the sky is dark, set the mode to 0 (for tomorrow)</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; dayMode = <span style="color: #000000; font-weight:bold;">0</span><span style="color: #000066; font-weight: bold;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; _night_timer = <span style="color: #000000; font-weight:bold;">20</span><span style="color: #000066; font-weight: bold;">;</span> <span style="color: #009900; font-style: italic;">// reset the night_timer</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; _throttle = <span style="color: #000000; font-weight:bold;">1</span><span style="color: #000066; font-weight: bold;">;</span> <span style="color: #009900; font-style: italic;">// and the throttle</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900; font-style: italic;">// go through all the flakes that exist. If they are melting, refreeze them.</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0033ff; font-weight: bold;">for</span> <span style="color: #000000;">&#40;</span><span style="color: #6699cc; font-weight: bold;">var</span> l<span style="color: #000066; font-weight: bold;">:</span><span style="color: #004993;">int</span> = <span style="color: #000000; font-weight:bold;">0</span><span style="color: #000066; font-weight: bold;">;</span> l <span style="color: #000066; font-weight: bold;">&lt;</span> flakeGrp<span style="color: #000066; font-weight: bold;">.</span>members<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">length</span><span style="color: #000066; font-weight: bold;">;</span> l<span style="color: #000066; font-weight: bold;">++</span><span style="color: #000000;">&#41;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; f = flakeGrp<span style="color: #000066; font-weight: bold;">.</span>members<span style="color: #000000;">&#91;</span>l<span style="color: #000000;">&#93;</span><span style="color: #000066; font-weight: bold;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0033ff; font-weight: bold;">if</span> <span style="color: #000000;">&#40;</span>f <span style="color: #000066; font-weight: bold;">!</span>= <span style="color: #0033ff; font-weight: bold;">null</span> <span style="color: #000066; font-weight: bold;">&amp;&amp;</span> <span style="color: #000066; font-weight: bold;">!</span>f<span style="color: #000066; font-weight: bold;">.</span>dead <span style="color: #000066; font-weight: bold;">&amp;&amp;</span> f<span style="color: #000066; font-weight: bold;">.</span>exists <span style="color: #000066; font-weight: bold;">&amp;&amp;</span> f<span style="color: #000066; font-weight: bold;">.</span>_melting<span style="color: #000000;">&#41;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; f<span style="color: #000066; font-weight: bold;">.</span>refreeze<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000;">&#125;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000;">&#125;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000;">&#125;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0033ff; font-weight: bold;">break</span><span style="color: #000066; font-weight: bold;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000;">&#125;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #6699cc; font-weight: bold;">var</span> covered<span style="color: #000066; font-weight: bold;">:</span><span style="color: #004993;">Boolean</span> = <span style="color: #0033ff; font-weight: bold;">false</span><span style="color: #000066; font-weight: bold;">;</span> <span style="color: #009900; font-style: italic;">// this is for seeing if the flake should melt or not.</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0033ff; font-weight: bold;">if</span> <span style="color: #000000;">&#40;</span>sky<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">alpha</span> == <span style="color: #000000; font-weight:bold;">1</span><span style="color: #000000;">&#41;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900; font-style: italic;">// if the sky is fully brightened, then we're going to start checking for melting flakes.</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0033ff; font-weight: bold;">if</span> <span style="color: #000000;">&#40;</span>_throttle <span style="color: #000066; font-weight: bold;">&lt;</span>= <span style="color: #000000; font-weight:bold;">0</span><span style="color: #000000;">&#41;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; _throttle = <span style="color: #000000; font-weight:bold;">1</span><span style="color: #000066; font-weight: bold;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900; font-style: italic;">// we don't want to do this too often, so we use the throttle.</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0033ff; font-weight: bold;">for</span> <span style="color: #000000;">&#40;</span><span style="color: #6699cc; font-weight: bold;">var</span> j<span style="color: #000066; font-weight: bold;">:</span><span style="color: #004993;">int</span> = <span style="color: #000000; font-weight:bold;">0</span><span style="color: #000066; font-weight: bold;">;</span> j <span style="color: #000066; font-weight: bold;">&lt;</span> flakeGrp<span style="color: #000066; font-weight: bold;">.</span>members<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">length</span><span style="color: #000066; font-weight: bold;">;</span>j<span style="color: #000066; font-weight: bold;">++</span><span style="color: #000000;">&#41;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; f = flakeGrp<span style="color: #000066; font-weight: bold;">.</span>members<span style="color: #000000;">&#91;</span>j<span style="color: #000000;">&#93;</span> <span style="color: #0033ff; font-weight: bold;">as</span> Flake<span style="color: #000066; font-weight: bold;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900; font-style: italic;">// we're going to look at all the flakes in the group. If we see one that's not dead, and not already melting, then we'll check it.</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0033ff; font-weight: bold;">if</span> <span style="color: #000000;">&#40;</span>f<span style="color: #000066; font-weight: bold;">!</span>=<span style="color: #0033ff; font-weight: bold;">null</span> <span style="color: #000066; font-weight: bold;">&amp;&amp;</span> <span style="color: #000066; font-weight: bold;">!</span>f<span style="color: #000066; font-weight: bold;">.</span>dead <span style="color: #000066; font-weight: bold;">&amp;&amp;</span> f<span style="color: #000066; font-weight: bold;">.</span>exists <span style="color: #000066; font-weight: bold;">&amp;&amp;</span> <span style="color: #000066; font-weight: bold;">!</span>f<span style="color: #000066; font-weight: bold;">.</span>_melting<span style="color: #000000;">&#41;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900; font-style: italic;">// this is to add a bit of chaos to the code. There will be a chance that this eligible flake will not even be checked</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900; font-style: italic;">// the higher the sun is in the sky, the higher the chance is that it will be checked.</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0033ff; font-weight: bold;">if</span> <span style="color: #000000;">&#40;</span>Rnd<span style="color: #000066; font-weight: bold;">.</span>boolean<span style="color: #000000;">&#40;</span><span style="color: #000000; font-weight:bold;">1</span> <span style="color: #000066; font-weight: bold;">-</span> <span style="color: #000000;">&#40;</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#40;</span>sun<span style="color: #000066; font-weight: bold;">.</span>y<span style="color: #000066; font-weight: bold;">-</span><span style="color: #000000; font-weight:bold;">3</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">/</span><span style="color: #000000;">&#40;</span>FlxG<span style="color: #000066; font-weight: bold;">.</span>height<span style="color: #000066; font-weight: bold;">-</span><span style="color: #000000; font-weight:bold;">5</span><span style="color: #000000;">&#41;</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">*</span><span style="color: #000000; font-weight:bold;">0.25</span><span style="color: #000000;">&#41;</span><span style="color: #000000;">&#41;</span><span style="color: #000000;">&#41;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; covered = <span style="color: #0033ff; font-weight: bold;">false</span><span style="color: #000066; font-weight: bold;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900; font-style: italic;">// so now we know we are going to check this flake, we look at all the OTHER flakes in the group.</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0033ff; font-weight: bold;">for</span> <span style="color: #000000;">&#40;</span><span style="color: #6699cc; font-weight: bold;">var</span> k<span style="color: #000066; font-weight: bold;">:</span><span style="color: #004993;">int</span> = <span style="color: #000000; font-weight:bold;">0</span><span style="color: #000066; font-weight: bold;">;</span> k <span style="color: #000066; font-weight: bold;">&lt;</span> flakeGrp<span style="color: #000066; font-weight: bold;">.</span>members<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">length</span><span style="color: #000066; font-weight: bold;">;</span> k<span style="color: #000066; font-weight: bold;">++</span><span style="color: #000000;">&#41;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0033ff; font-weight: bold;">if</span> <span style="color: #000000;">&#40;</span>k <span style="color: #000066; font-weight: bold;">!</span>= j<span style="color: #000000;">&#41;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; f2 = flakeGrp<span style="color: #000066; font-weight: bold;">.</span>members<span style="color: #000000;">&#91;</span>k<span style="color: #000000;">&#93;</span> <span style="color: #0033ff; font-weight: bold;">as</span> Flake<span style="color: #000066; font-weight: bold;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900; font-style: italic;">// if we find a flake that's not dead, and is solid, etc, and it is directly above our current flake, then </span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900; font-style: italic;">// the current flake is 'covered' and saved from melting.</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0033ff; font-weight: bold;">if</span> <span style="color: #000000;">&#40;</span>f2 <span style="color: #000066; font-weight: bold;">!</span>= <span style="color: #0033ff; font-weight: bold;">null</span> <span style="color: #000066; font-weight: bold;">&amp;&amp;</span> <span style="color: #000066; font-weight: bold;">!</span>f2<span style="color: #000066; font-weight: bold;">.</span>dead <span style="color: #000066; font-weight: bold;">&amp;&amp;</span> f2<span style="color: #000066; font-weight: bold;">.</span>exists <span style="color: #000066; font-weight: bold;">&amp;&amp;</span> f2<span style="color: #000066; font-weight: bold;">.</span>solid<span style="color: #000000;">&#41;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0033ff; font-weight: bold;">if</span> <span style="color: #000000;">&#40;</span><span style="color: #000000;">&#40;</span><span style="color: #004993;">int</span><span style="color: #000000;">&#40;</span>f2<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">x</span><span style="color: #000000;">&#41;</span> == <span style="color: #004993;">int</span><span style="color: #000000;">&#40;</span>f<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">x</span><span style="color: #000000;">&#41;</span> &nbsp;<span style="color: #000066; font-weight: bold;">&amp;&amp;</span> <span style="color: #004993;">int</span><span style="color: #000000;">&#40;</span>f2<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">y</span><span style="color: #000000;">&#41;</span> == <span style="color: #004993;">int</span><span style="color: #000000;">&#40;</span>f<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">y</span><span style="color: #000000;">&#41;</span> <span style="color: #000066; font-weight: bold;">-</span> <span style="color: #000000; font-weight:bold;">1</span><span style="color: #000000;">&#41;</span><span style="color: #000000;">&#41;</span> covered = <span style="color: #0033ff; font-weight: bold;">true</span><span style="color: #000066; font-weight: bold;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0033ff; font-weight: bold;">if</span> <span style="color: #000000;">&#40;</span>covered<span style="color: #000000;">&#41;</span> <span style="color: #0033ff; font-weight: bold;">break</span><span style="color: #000066; font-weight: bold;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000;">&#125;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000;">&#125;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900; font-style: italic;">// if the current flake is not covered, then it melts</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0033ff; font-weight: bold;">if</span> <span style="color: #000000;">&#40;</span><span style="color: #000066; font-weight: bold;">!</span>covered<span style="color: #000000;">&#41;</span> f<span style="color: #000066; font-weight: bold;">.</span>melt<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000;">&#125;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000;">&#125;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000;">&#125;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000;">&#125;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0033ff; font-weight: bold;">else</span> _throttle<span style="color: #000066; font-weight: bold;">-</span>= FlxG<span style="color: #000066; font-weight: bold;">.</span>elapsed<span style="color: #000066; font-weight: bold;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000;">&#125;</span><br />
&nbsp; &nbsp; &nbsp; <span style="color: #000000;">&#125;</span><br />
&nbsp; &nbsp; &nbsp; <span style="color: #0033ff; font-weight: bold;">else</span><br />
&nbsp; &nbsp; &nbsp; <span style="color: #000000;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900; font-style: italic;">// this is the night logic. we use the night timer to see how long before the sun comes up</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; _night_timer <span style="color: #000066; font-weight: bold;">-</span>= FlxG<span style="color: #000066; font-weight: bold;">.</span>elapsed<span style="color: #000066; font-weight: bold;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900; font-style: italic;">// if it's time to change the wind, we do some random stuff to either add or subtract from the amount of wind there is.</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900; font-style: italic;">// we check to make sure the wind speed isn't too high or low.</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0033ff; font-weight: bold;">if</span> <span style="color: #000000;">&#40;</span>_wind_change <span style="color: #000066; font-weight: bold;">&lt;</span>= <span style="color: #000000; font-weight:bold;">0</span><span style="color: #000000;">&#41;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; _wind_change = Rnd<span style="color: #000066; font-weight: bold;">.</span>integer<span style="color: #000000;">&#40;</span><span style="color: #000000; font-weight:bold;">0</span><span style="color: #000066; font-weight: bold;">,</span> <span style="color: #000000; font-weight:bold;">5</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #6699cc; font-weight: bold;">var</span> sign<span style="color: #000066; font-weight: bold;">:</span><span style="color: #004993;">int</span><span style="color: #000066; font-weight: bold;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0033ff; font-weight: bold;">if</span> <span style="color: #000000;">&#40;</span>wind == <span style="color: #000000; font-weight:bold;">10</span><span style="color: #000000;">&#41;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; sign = <span style="color: #000066; font-weight: bold;">-</span><span style="color: #000000; font-weight:bold;">1</span><span style="color: #000066; font-weight: bold;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0033ff; font-weight: bold;">else</span> <span style="color: #0033ff; font-weight: bold;">if</span> <span style="color: #000000;">&#40;</span>wind == <span style="color: #000066; font-weight: bold;">-</span><span style="color: #000000; font-weight:bold;">10</span><span style="color: #000000;">&#41;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; sign = <span style="color: #000000; font-weight:bold;">1</span><span style="color: #000066; font-weight: bold;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0033ff; font-weight: bold;">else</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; sign = Rnd<span style="color: #000066; font-weight: bold;">.</span>sign<span style="color: #000000;">&#40;</span><span style="color: #000000; font-weight:bold;">0.5</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; wind <span style="color: #000066; font-weight: bold;">+</span>= <span style="color: #000000;">&#40;</span><span style="color: #000000;">&#40;</span>Rnd<span style="color: #000066; font-weight: bold;">.</span>integer<span style="color: #000000;">&#40;</span><span style="color: #000000; font-weight:bold;">5</span><span style="color: #000066; font-weight: bold;">,</span> <span style="color: #000000; font-weight:bold;">20</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">/</span><span style="color: #000000; font-weight:bold;">10</span><span style="color: #000000;">&#41;</span> <span style="color: #000066; font-weight: bold;">*</span> sign<span style="color: #000000;">&#41;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0033ff; font-weight: bold;">if</span> <span style="color: #000000;">&#40;</span>wind <span style="color: #000066; font-weight: bold;">&gt;</span> <span style="color: #000000; font-weight:bold;">10</span><span style="color: #000000;">&#41;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; wind = <span style="color: #000000; font-weight:bold;">10</span><span style="color: #000066; font-weight: bold;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0033ff; font-weight: bold;">else</span> <span style="color: #0033ff; font-weight: bold;">if</span> <span style="color: #000000;">&#40;</span>wind <span style="color: #000066; font-weight: bold;">&lt;</span> <span style="color: #000066; font-weight: bold;">-</span><span style="color: #000000; font-weight:bold;">10</span><span style="color: #000000;">&#41;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; wind = <span style="color: #000066; font-weight: bold;">-</span><span style="color: #000000; font-weight:bold;">10</span><span style="color: #000066; font-weight: bold;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000;">&#125;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0033ff; font-weight: bold;">else</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; _wind_change<span style="color: #000066; font-weight: bold;">-</span>= FlxG<span style="color: #000066; font-weight: bold;">.</span>elapsed<span style="color: #000066; font-weight: bold;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900; font-style: italic;">// if the night is not almost over, we'll continue and spawn new flakes.</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0033ff; font-weight: bold;">if</span> <span style="color: #000000;">&#40;</span>_night_timer <span style="color: #000066; font-weight: bold;">&gt;</span>= <span style="color: #000000; font-weight:bold;">4</span><span style="color: #000000;">&#41;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900; font-style: italic;">// using the throttle to keep from overloading things</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0033ff; font-weight: bold;">if</span> <span style="color: #000000;">&#40;</span>_throttle <span style="color: #000066; font-weight: bold;">&lt;</span>= <span style="color: #000000; font-weight:bold;">0</span><span style="color: #000000;">&#41;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; _throttle = <span style="color: #000000; font-weight:bold;">1</span><span style="color: #000066; font-weight: bold;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900; font-style: italic;">// we're going to create a random number of new flakes, with less flakes being created at the start of the night and near the end.</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900; font-style: italic;">// this is a pretty subtle effect</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0033ff; font-weight: bold;">for</span> <span style="color: #000000;">&#40;</span><span style="color: #6699cc; font-weight: bold;">var</span> i<span style="color: #000066; font-weight: bold;">:</span><span style="color: #004993;">int</span> = <span style="color: #000000; font-weight:bold;">0</span><span style="color: #000066; font-weight: bold;">;</span> i <span style="color: #000066; font-weight: bold;">&lt;</span> <span style="color: #000000;">&#40;</span>Rnd<span style="color: #000066; font-weight: bold;">.</span>integer<span style="color: #000000;">&#40;</span><span style="color: #000000; font-weight:bold;">170</span><span style="color: #000066; font-weight: bold;">,</span> <span style="color: #000000; font-weight:bold;">230</span><span style="color: #000000;">&#41;</span> <span style="color: #000066; font-weight: bold;">-</span> <span style="color: #000000;">&#40;</span><span style="color: #000000; font-weight:bold;">4</span> <span style="color: #000066; font-weight: bold;">*</span> <span style="color: #004993;">Math</span><span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">abs</span><span style="color: #000000;">&#40;</span>_night_timer <span style="color: #000066; font-weight: bold;">-</span> <span style="color: #000000;">&#40;</span><span style="color: #000000; font-weight:bold;">24</span><span style="color: #000000;">&#41;</span><span style="color: #000000;">&#41;</span><span style="color: #000000;">&#41;</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span> i<span style="color: #000066; font-weight: bold;">++</span><span style="color: #000000;">&#41;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; f = flakeGrp<span style="color: #000066; font-weight: bold;">.</span>getFirstAvail<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span> <span style="color: #0033ff; font-weight: bold;">as</span> Flake<span style="color: #000066; font-weight: bold;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900; font-style: italic;">// we try to reuse flakes that are available in the group if we can. </span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900; font-style: italic;">// we place our flakes randomly in a box that's much wider than the screen (because the wind can blow it on from the side)</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900; font-style: italic;">// and above the top of the screen.</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0033ff; font-weight: bold;">if</span> <span style="color: #000000;">&#40;</span>f <span style="color: #000066; font-weight: bold;">!</span>= <span style="color: #0033ff; font-weight: bold;">null</span><span style="color: #000000;">&#41;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; f<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">reset</span><span style="color: #000000;">&#40;</span>Rnd<span style="color: #000066; font-weight: bold;">.</span>integer<span style="color: #000000;">&#40;</span> <span style="color: #000066; font-weight: bold;">-</span><span style="color: #000000; font-weight:bold;">50</span><span style="color: #000066; font-weight: bold;">,</span> FlxG<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">width</span> <span style="color: #000066; font-weight: bold;">+</span> <span style="color: #000000; font-weight:bold;">50</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">,</span> Rnd<span style="color: #000066; font-weight: bold;">.</span>integer<span style="color: #000000;">&#40;</span> <span style="color: #000066; font-weight: bold;">-</span><span style="color: #000000; font-weight:bold;">15</span><span style="color: #000066; font-weight: bold;">,</span> <span style="color: #000066; font-weight: bold;">-</span><span style="color: #000000; font-weight:bold;">1</span><span style="color: #000000;">&#41;</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0033ff; font-weight: bold;">else</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; flakeGrp<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">add</span><span style="color: #000000;">&#40;</span><span style="color: #0033ff; font-weight: bold;">new</span> Flake<span style="color: #000000;">&#40;</span>Rnd<span style="color: #000066; font-weight: bold;">.</span>integer<span style="color: #000000;">&#40;</span> <span style="color: #000066; font-weight: bold;">-</span><span style="color: #000000; font-weight:bold;">50</span><span style="color: #000066; font-weight: bold;">,</span> FlxG<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">width</span> <span style="color: #000066; font-weight: bold;">+</span> <span style="color: #000000; font-weight:bold;">50</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">,</span> Rnd<span style="color: #000066; font-weight: bold;">.</span>integer<span style="color: #000000;">&#40;</span> <span style="color: #000066; font-weight: bold;">-</span><span style="color: #000000; font-weight:bold;">15</span><span style="color: #000066; font-weight: bold;">,</span> <span style="color: #000066; font-weight: bold;">-</span><span style="color: #000000; font-weight:bold;">1</span><span style="color: #000000;">&#41;</span><span style="color: #000000;">&#41;</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; f = <span style="color: #0033ff; font-weight: bold;">null</span><span style="color: #000066; font-weight: bold;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000;">&#125;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000;">&#125;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0033ff; font-weight: bold;">else</span> _throttle<span style="color: #000066; font-weight: bold;">-</span>= FlxG<span style="color: #000066; font-weight: bold;">.</span>elapsed<span style="color: #000066; font-weight: bold;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000;">&#125;</span><br />
&nbsp; &nbsp; &nbsp; <span style="color: #000000;">&#125;</span><br />
&nbsp; &nbsp; &nbsp; <span style="color: #0033ff; font-weight: bold;">super</span><span style="color: #000066; font-weight: bold;">.</span>update<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span><br />
&nbsp; &nbsp; <span style="color: #000000;">&#125;</span><br />
&nbsp; <span style="color: #000000;">&#125;</span><br />
<span style="color: #000000;">&#125;</span></div></div>
]]></content:encoded>
			<wfw:commentRss>http://www.tileisle.net/flixel-showcase-snow/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>Flixel Showcase: Displacement Effects</title>
		<link>http://www.tileisle.net/flixel-showcase-displacement-effects/</link>
		<comments>http://www.tileisle.net/flixel-showcase-displacement-effects/#comments</comments>
		<pubDate>Tue, 20 Jul 2010 16:23:14 +0000</pubDate>
		<dc:creator>Tim</dc:creator>
				<category><![CDATA[Flixel Showcase]]></category>
		<category><![CDATA[actionscript]]></category>
		<category><![CDATA[as3]]></category>
		<category><![CDATA[classes]]></category>
		<category><![CDATA[code]]></category>
		<category><![CDATA[displacement]]></category>
		<category><![CDATA[download]]></category>
		<category><![CDATA[effect]]></category>
		<category><![CDATA[Flixel]]></category>
		<category><![CDATA[free]]></category>
		<category><![CDATA[fx]]></category>
		<category><![CDATA[special effects]]></category>
		<category><![CDATA[tricks]]></category>

		<guid isPermaLink="false">http://www.tileisle.net/?p=182</guid>
		<description><![CDATA[In our upcoming project, we&#8217;ve been playing with some effects using BitmapData.copyPixels and came up with a neat displacement effect. Here&#8217;s what it looks like: Update: &#8220;Shockwave&#8221; effect added. Click the mouse to see it in action! Description We created a couple of classes you can use to achieve this effect: First off, you&#8217;ll need [...]]]></description>
			<content:encoded><![CDATA[<p>In our upcoming project, we&#8217;ve been playing with some effects using <code class="codecolorer actionscript3 default"><span class="actionscript3"><span style="color: #004993;">BitmapData</span><span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">copyPixels</span></span></code> and came up with a neat displacement effect.  Here&#8217;s what it looks like:</p>
<p><strong>Update:</strong> &#8220;Shockwave&#8221; effect added. Click the mouse to see it in action!</p>
<p>
<object width="480" height="320">
<param name="movie" value="/ProtoPlatformer.swf"></param>
<param name="quality" value="high"></param>
<param name="wmode" value="window"></param>
<param name="menu" value="true"></param>
<param name="bgcolor" value="#000000"></param>
<embed type="application/x-shockwave-flash" width="480" height="320" src="/ProtoPlatformer.swf" quality="high" bgcolor="#000000" wmode="window" menu="true" ></embed>
</object>
</p>
<p><span id="more-182"></span></p>
<h3>Description</h3>
<p>We created a couple of classes you can use to achieve this effect: First off, you&#8217;ll need the <code class="codecolorer actionscript3 default"><span class="actionscript3">FXGroup</span></code> class which will handle all of the special rendering for your displacements. The <code class="codecolorer actionscript3 default"><span class="actionscript3">DisplaceBlob</span></code> Class is the simple displacement object itself. You can add it to the stage directly, give it velocity, or whatever you want to do with it, and it will create a displacement wherever you put it. The <code class="codecolorer actionscript3 default"><span class="actionscript3">Displacement</span></code> Class is a simplified emitter which only spits out DisplaceBlobs. You can create the Displacement and put it on the stage and it will keep spitting out Blobs which will do their thing. You can setup how long the Blobs last, and how they behave. Using the Displacement you can achieve the &#8220;heat wave&#8221; kind of effects. The effect ends up being much faster, and less system intensive than a standard displacement map.</p>
<h3>Usage</h3>
<p>In order to use these classes, you&#8217;ll need to setup your state with a FXGroup. You add the FXGroup to your state like normal, and then you&#8217;ll need to override the state&#8217;s <code class="codecolorer text default"><span class="text">render</span></code> function. When you go to add your displacements, you can add them to the FXGroup, and you&#8217;ll need to pass the FXGroup&#8217;s Buffer to the Displacement or the DisplaceBlob.  For example, a simple PlayState might look like this:</p>
<div class="codecolorer-container actionscript3 default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="actionscript3 codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #9900cc; font-weight: bold;">package</span> com<span style="color: #000066; font-weight: bold;">.</span>tileisle<br />
<span style="color: #000000;">&#123;</span><br />
<span style="color: #0033ff; font-weight: bold;">import</span> org<span style="color: #000066; font-weight: bold;">.</span>flixel<span style="color: #000066; font-weight: bold;">.*;</span><br />
<span style="color: #0033ff; font-weight: bold;">public</span> <span style="color: #9900cc; font-weight: bold;">class</span> SimpleState <span style="color: #0033ff; font-weight: bold;">extends</span> FlxState<br />
<span style="color: #000000;">&#123;</span><br />
<span style="color: #0033ff; font-weight: bold;">private</span> <span style="color: #6699cc; font-weight: bold;">var</span> _fxGroup<span style="color: #000066; font-weight: bold;">:</span>FXGroup<span style="color: #000066; font-weight: bold;">;</span><br />
<span style="color: #0033ff; font-weight: bold;">private</span> <span style="color: #6699cc; font-weight: bold;">var</span> _displacer<span style="color: #000066; font-weight: bold;">:</span>Displacement<span style="color: #000066; font-weight: bold;">;</span><br />
<br />
<span style="color: #0033ff; font-weight: bold;">public</span> <span style="color: #339966; font-weight: bold;">function</span> SimpleState<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><br />
<span style="color: #000000;">&#123;</span><br />
<span style="color: #0033ff; font-weight: bold;">super</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span><br />
<span style="color: #004993;">add</span><span style="color: #000000;">&#40;</span>_fxGroup<span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span><br />
_fxGroup<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">add</span><span style="color: #000000;">&#40;</span>_displacer = <span style="color: #0033ff; font-weight: bold;">new</span> Displacement<span style="color: #000000;">&#40;</span>_fxGroup<span style="color: #000066; font-weight: bold;">.</span>FXBuffer<span style="color: #000066; font-weight: bold;">,</span> <span style="color: #000000; font-weight:bold;">10</span><span style="color: #000066; font-weight: bold;">,</span> <span style="color: #000000; font-weight:bold;">10</span><span style="color: #000066; font-weight: bold;">,</span> <span style="color: #000000; font-weight:bold;">20</span><span style="color: #000066; font-weight: bold;">,</span> <span style="color: #000000; font-weight:bold;">20</span><span style="color: #000066; font-weight: bold;">,</span> <span style="color: #000066; font-weight: bold;">-</span><span style="color: #000000; font-weight:bold;">10</span><span style="color: #000066; font-weight: bold;">,</span> <span style="color: #000000; font-weight:bold;">10</span><span style="color: #000066; font-weight: bold;">,</span> <span style="color: #000066; font-weight: bold;">-</span><span style="color: #000000; font-weight:bold;">10</span><span style="color: #000066; font-weight: bold;">,</span> <span style="color: #000000; font-weight:bold;">10</span><span style="color: #000066; font-weight: bold;">,</span> <span style="color: #000000; font-weight:bold;">2</span><span style="color: #000066; font-weight: bold;">,</span> <span style="color: #000000; font-weight:bold;">2</span><span style="color: #000066; font-weight: bold;">,</span> <span style="color: #000000; font-weight:bold;">0.5</span><span style="color: #000066; font-weight: bold;">,</span> <span style="color: #000000; font-weight:bold;">0.8</span><span style="color: #000066; font-weight: bold;">,</span> <span style="color: #000000; font-weight:bold;">1</span><span style="color: #000066; font-weight: bold;">,</span> <span style="color: #000000; font-weight:bold;">1</span><span style="color: #000000;">&#41;</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span><br />
<span style="color: #000000;">&#125;</span><br />
<br />
override <span style="color: #0033ff; font-weight: bold;">public</span> <span style="color: #339966; font-weight: bold;">function</span> <span style="color: #004993;">render</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">:</span><span style="color: #0033ff; font-weight: bold;">void</span><br />
<span style="color: #000000;">&#123;</span><br />
<span style="color: #0033ff; font-weight: bold;">super</span><span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">render</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span><br />
_fxGroup<span style="color: #000066; font-weight: bold;">.</span>doRender<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span> <span style="color: #009900; font-style: italic;">// This MUST be called AFTER everything else is rendered, or it won't work.</span><br />
<span style="color: #000000;">&#125;</span><br />
<span style="color: #000000;">&#125;</span><br />
<span style="color: #000000;">&#125;</span></div></div>
<h3>Code</h3>
<p>Here are the 3 class files, feel free to use them in your own projects:</p>
<h4>FXGroup:</h4>
<div class="codecolorer-container actionscript3 default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="actionscript3 codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #9900cc; font-weight: bold;">package</span> com<span style="color: #000066; font-weight: bold;">.</span>tileisle<br />
<span style="color: #000000;">&#123;</span><br />
<span style="color: #0033ff; font-weight: bold;">import</span> org<span style="color: #000066; font-weight: bold;">.</span>flixel<span style="color: #000066; font-weight: bold;">.*;</span><br />
<span style="color: #0033ff; font-weight: bold;">import</span> <span style="color: #004993;">flash.display</span><span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">BitmapData</span><span style="color: #000066; font-weight: bold;">;</span><br />
<span style="color: #0033ff; font-weight: bold;">import</span> <span style="color: #004993;">flash.geom</span><span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">Rectangle</span><span style="color: #000066; font-weight: bold;">;</span><br />
<span style="color: #0033ff; font-weight: bold;">import</span> <span style="color: #004993;">flash.geom</span><span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">Point</span><span style="color: #000066; font-weight: bold;">;</span><br />
<br />
<span style="color: #3f5fbf;">/**<br />
* &lt;code&gt;FXGroup&lt;/code&gt; is a special FlxGroup which should only handle rendering effects.<br />
*<br />
* @author Ryan &quot;Rybar&quot; Malm, Tim &quot;SeiferTim&quot; Hely<br />
*/</span><br />
<span style="color: #0033ff; font-weight: bold;">public</span> <span style="color: #9900cc; font-weight: bold;">class</span> FXGroup <span style="color: #0033ff; font-weight: bold;">extends</span> FlxGroup<br />
<span style="color: #000000;">&#123;</span><br />
<span style="color: #0033ff; font-weight: bold;">public</span> <span style="color: #6699cc; font-weight: bold;">var</span> FXBuffer<span style="color: #000066; font-weight: bold;">:</span><span style="color: #004993;">BitmapData</span> = <span style="color: #0033ff; font-weight: bold;">new</span> <span style="color: #004993;">BitmapData</span><span style="color: #000000;">&#40;</span>FlxG<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">width</span><span style="color: #000066; font-weight: bold;">,</span> FlxG<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">height</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span><br />
<br />
<span style="color: #0033ff; font-weight: bold;">public</span> <span style="color: #339966; font-weight: bold;">function</span> FXGroup<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><br />
<span style="color: #000000;">&#123;</span><br />
<br />
<span style="color: #000000;">&#125;</span><br />
<br />
override <span style="color: #0033ff; font-weight: bold;">public</span> <span style="color: #339966; font-weight: bold;">function</span> <span style="color: #004993;">render</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">:</span><span style="color: #0033ff; font-weight: bold;">void</span><br />
<span style="color: #000000;">&#123;</span><br />
<br />
<span style="color: #000000;">&#125;</span><br />
<br />
<span style="color: #3f5fbf;">/**<br />
* Call &lt;code&gt;doRender&lt;/code&gt; in the state's render function (after &lt;code&gt;super.render()&lt;/code&gt;<br />
*/</span><br />
<span style="color: #0033ff; font-weight: bold;">public</span> <span style="color: #339966; font-weight: bold;">function</span> doRender<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">:</span><span style="color: #0033ff; font-weight: bold;">void</span><br />
<span style="color: #000000;">&#123;</span><br />
FXBuffer<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">copyPixels</span><span style="color: #000000;">&#40;</span>FlxG<span style="color: #000066; font-weight: bold;">.</span>buffer<span style="color: #000066; font-weight: bold;">,</span> <span style="color: #0033ff; font-weight: bold;">new</span> <span style="color: #004993;">Rectangle</span><span style="color: #000000;">&#40;</span><span style="color: #000000; font-weight:bold;">0</span><span style="color: #000066; font-weight: bold;">,</span> <span style="color: #000000; font-weight:bold;">0</span><span style="color: #000066; font-weight: bold;">,</span> FlxG<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">width</span><span style="color: #000066; font-weight: bold;">,</span> FlxG<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">height</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">,</span> <span style="color: #0033ff; font-weight: bold;">new</span> <span style="color: #004993;">Point</span><span style="color: #000000;">&#40;</span><span style="color: #000000; font-weight:bold;">0</span><span style="color: #000066; font-weight: bold;">,</span> <span style="color: #000000; font-weight:bold;">0</span><span style="color: #000000;">&#41;</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span><br />
<span style="color: #0033ff; font-weight: bold;">super</span><span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">render</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span><br />
<span style="color: #000000;">&#125;</span><br />
<br />
<span style="color: #000000;">&#125;</span><br />
<br />
<span style="color: #000000;">&#125;</span></div></div>
<h4>DisplaceBlob:</h4>
<div class="codecolorer-container actionscript3 default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;height:450px;"><div class="actionscript3 codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #9900cc; font-weight: bold;">package</span> com<span style="color: #000066; font-weight: bold;">.</span>tileisle<br />
<span style="color: #000000;">&#123;</span><br />
<span style="color: #0033ff; font-weight: bold;">import</span> <span style="color: #004993;">flash.display</span><span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">BitmapData</span><span style="color: #000066; font-weight: bold;">;</span><br />
<span style="color: #0033ff; font-weight: bold;">import</span> <span style="color: #004993;">flash.geom</span><span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">Point</span><span style="color: #000066; font-weight: bold;">;</span><br />
<span style="color: #0033ff; font-weight: bold;">import</span> <span style="color: #004993;">flash.geom</span><span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">Rectangle</span><span style="color: #000066; font-weight: bold;">;</span><br />
<span style="color: #0033ff; font-weight: bold;">import</span> flash<span style="color: #000066; font-weight: bold;">.</span>sampler<span style="color: #000066; font-weight: bold;">.</span>NewObjectSample<span style="color: #000066; font-weight: bold;">;</span><br />
<span style="color: #0033ff; font-weight: bold;">import</span> org<span style="color: #000066; font-weight: bold;">.</span>flixel<span style="color: #000066; font-weight: bold;">.*;</span><br />
<span style="color: #0033ff; font-weight: bold;">import</span> com<span style="color: #000066; font-weight: bold;">.</span>gskinner<span style="color: #000066; font-weight: bold;">.</span>utils<span style="color: #000066; font-weight: bold;">.</span>Rnd<span style="color: #000066; font-weight: bold;">;</span><br />
<br />
<span style="color: #3f5fbf;">/**<br />
* &lt;code&gt;DisplaceBlob&lt;/code&gt; is a &lt;code&gt;FlxSprite&lt;/code&gt; object which copies from an area nearby to make a displacement effect.<br />
* Usually emitted from the &lt;code&gt;Displacement&lt;/code&gt; object, they can be added directly to the stage for neat effects.<br />
*<br />
* @author Ryan &quot;Rybar&quot; Malm, Tim &quot;SeiferTim&quot; Hely<br />
*/</span><br />
<span style="color: #0033ff; font-weight: bold;">public</span> <span style="color: #9900cc; font-weight: bold;">class</span> DisplaceBlob <span style="color: #0033ff; font-weight: bold;">extends</span> FlxSprite<br />
<span style="color: #000000;">&#123;</span><br />
<br />
<span style="color: #0033ff; font-weight: bold;">private</span> <span style="color: #6699cc; font-weight: bold;">var</span> blob<span style="color: #000066; font-weight: bold;">:</span><span style="color: #004993;">Rectangle</span><span style="color: #000066; font-weight: bold;">;</span><br />
<span style="color: #0033ff; font-weight: bold;">private</span> <span style="color: #6699cc; font-weight: bold;">var</span> StartSize<span style="color: #000066; font-weight: bold;">:</span>FlxPoint<span style="color: #000066; font-weight: bold;">;</span><br />
<span style="color: #0033ff; font-weight: bold;">private</span> <span style="color: #6699cc; font-weight: bold;">var</span> maxLife<span style="color: #000066; font-weight: bold;">:</span><span style="color: #004993;">Number</span> = <span style="color: #000066; font-weight: bold;">-</span><span style="color: #000000; font-weight:bold;">1</span><span style="color: #000066; font-weight: bold;">;</span><br />
<span style="color: #0033ff; font-weight: bold;">private</span> <span style="color: #6699cc; font-weight: bold;">var</span> _displaceAmt<span style="color: #000066; font-weight: bold;">:</span>FlxPoint = <span style="color: #0033ff; font-weight: bold;">new</span> FlxPoint<span style="color: #000000;">&#40;</span><span style="color: #000000; font-weight:bold;">1</span><span style="color: #000066; font-weight: bold;">,</span> <span style="color: #000000; font-weight:bold;">1</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span><br />
<span style="color: #0033ff; font-weight: bold;">private</span> <span style="color: #6699cc; font-weight: bold;">var</span> _life<span style="color: #000066; font-weight: bold;">:</span><span style="color: #004993;">Number</span> = <span style="color: #000066; font-weight: bold;">-</span><span style="color: #000000; font-weight:bold;">1</span><span style="color: #000066; font-weight: bold;">;</span><br />
<span style="color: #0033ff; font-weight: bold;">private</span> <span style="color: #6699cc; font-weight: bold;">var</span> Size<span style="color: #000066; font-weight: bold;">:</span>FlxPoint<span style="color: #000066; font-weight: bold;">;</span><br />
<span style="color: #0033ff; font-weight: bold;">private</span> <span style="color: #6699cc; font-weight: bold;">var</span> _buffer<span style="color: #000066; font-weight: bold;">:</span><span style="color: #004993;">BitmapData</span><span style="color: #000066; font-weight: bold;">;</span><br />
<br />
<span style="color: #3f5fbf;">/**<br />
* Use a &lt;code&gt;DisplaceBlob&lt;/code&gt; to make an area on the screen displaced.<br />
*<br />
* @param&nbsp; Buffer&nbsp; &nbsp; &nbsp; This should point to your FXGroup's Buffer<br />
* @param&nbsp; X &nbsp; &nbsp; &nbsp; The X position of the blob.<br />
* @param&nbsp; Y &nbsp; &nbsp; &nbsp; The Y position of the blob.<br />
* @param&nbsp; Size&nbsp; &nbsp; &nbsp; The size of the blob. 1-8 is valid. Defaults to 8.<br />
* @param&nbsp; Life&nbsp; &nbsp; &nbsp; The lifespan of the blob. Defaults to -1 or, never dies.<br />
* @param&nbsp; DisplaceAmtX&nbsp; How much displacement on the X axis to apply.<br />
* @param&nbsp; DisplaceAmtY&nbsp; How much displacement on the Y axis to apply.<br />
*/</span><br />
<span style="color: #0033ff; font-weight: bold;">public</span> <span style="color: #339966; font-weight: bold;">function</span> DisplaceBlob<span style="color: #000000;">&#40;</span>Buffer<span style="color: #000066; font-weight: bold;">:</span><span style="color: #004993;">BitmapData</span><span style="color: #000066; font-weight: bold;">,</span> X<span style="color: #000066; font-weight: bold;">:</span><span style="color: #004993;">Number</span><span style="color: #000066; font-weight: bold;">,</span> Y<span style="color: #000066; font-weight: bold;">:</span><span style="color: #004993;">Number</span><span style="color: #000066; font-weight: bold;">,</span> Width<span style="color: #000066; font-weight: bold;">:</span><span style="color: #004993;">Number</span> = <span style="color: #000000; font-weight:bold;">1</span><span style="color: #000066; font-weight: bold;">,</span> Height<span style="color: #000066; font-weight: bold;">:</span><span style="color: #004993;">Number</span> = <span style="color: #000000; font-weight:bold;">1</span><span style="color: #000066; font-weight: bold;">,</span> Life<span style="color: #000066; font-weight: bold;">:</span><span style="color: #004993;">Number</span> = <span style="color: #000066; font-weight: bold;">-</span><span style="color: #000000; font-weight:bold;">1</span><span style="color: #000066; font-weight: bold;">,</span> DisplaceAmtX<span style="color: #000066; font-weight: bold;">:</span><span style="color: #004993;">Number</span> = <span style="color: #000000; font-weight:bold;">1</span><span style="color: #000066; font-weight: bold;">,</span> DisplaceAmtY<span style="color: #000066; font-weight: bold;">:</span><span style="color: #004993;">Number</span> = <span style="color: #000000; font-weight:bold;">1</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">:</span><span style="color: #0033ff; font-weight: bold;">void</span><br />
<span style="color: #000000;">&#123;</span><br />
_buffer = Buffer<span style="color: #000066; font-weight: bold;">;</span><br />
<span style="color: #0033ff; font-weight: bold;">super</span><span style="color: #000000;">&#40;</span>X<span style="color: #000066; font-weight: bold;">,</span> Y<span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span><br />
_displaceAmt = <span style="color: #0033ff; font-weight: bold;">new</span> FlxPoint<span style="color: #000000;">&#40;</span>DisplaceAmtX<span style="color: #000066; font-weight: bold;">,</span>DisplaceAmtX<span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span><br />
<span style="color: #0033ff; font-weight: bold;">if</span> <span style="color: #000000;">&#40;</span>Width <span style="color: #000066; font-weight: bold;">&amp;</span>lt<span style="color: #000066; font-weight: bold;">;</span> <span style="color: #000000; font-weight:bold;">1</span><span style="color: #000000;">&#41;</span> Width = <span style="color: #000000; font-weight:bold;">1</span><span style="color: #000066; font-weight: bold;">;</span><br />
<span style="color: #0033ff; font-weight: bold;">if</span> <span style="color: #000000;">&#40;</span>Height <span style="color: #000066; font-weight: bold;">&amp;</span>lt<span style="color: #000066; font-weight: bold;">;</span> <span style="color: #000000; font-weight:bold;">1</span><span style="color: #000000;">&#41;</span> Height = <span style="color: #000000; font-weight:bold;">1</span><span style="color: #000066; font-weight: bold;">;</span><br />
StartSize = <span style="color: #0033ff; font-weight: bold;">new</span> FlxPoint<span style="color: #000000;">&#40;</span>Width<span style="color: #000066; font-weight: bold;">,</span> Height<span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span><br />
Size = StartSize<span style="color: #000066; font-weight: bold;">;</span><br />
<span style="color: #0033ff; font-weight: bold;">if</span> <span style="color: #000000;">&#40;</span>Life <span style="color: #000066; font-weight: bold;">&amp;</span>lt<span style="color: #000066; font-weight: bold;">;</span> <span style="color: #000066; font-weight: bold;">-</span><span style="color: #000000; font-weight:bold;">1</span><span style="color: #000000;">&#41;</span> Life = <span style="color: #000066; font-weight: bold;">-</span><span style="color: #000000; font-weight:bold;">1</span><span style="color: #000066; font-weight: bold;">;</span><br />
maxLife = Life<span style="color: #000066; font-weight: bold;">;</span><br />
createGraphic<span style="color: #000000;">&#40;</span>Width<span style="color: #000066; font-weight: bold;">,</span> Height<span style="color: #000066; font-weight: bold;">,</span> 0xffffffff<span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span><br />
<span style="color: #004993;">width</span> = Width<span style="color: #000066; font-weight: bold;">;</span><br />
<span style="color: #004993;">height</span> = Height<span style="color: #000066; font-weight: bold;">;</span><br />
exists = <span style="color: #0033ff; font-weight: bold;">false</span><span style="color: #000066; font-weight: bold;">;</span><br />
<span style="color: #000000;">&#125;</span><br />
<br />
<span style="color: #3f5fbf;">/**<br />
* Call &lt;code&gt;rebuild&lt;/code&gt; to reset the blob back to specific size and position.<br />
*<br />
* @param&nbsp; X &nbsp; &nbsp; &nbsp; The X position of the blob.<br />
* @param&nbsp; Y &nbsp; &nbsp; &nbsp; The Y position of the blob.<br />
* @param&nbsp; Size&nbsp; &nbsp; &nbsp; The size of the blob. 1-8 is valid..<br />
* @param&nbsp; Life&nbsp; &nbsp; &nbsp; The lifespan of the blob. Defaults to -1 or, never dies.<br />
* @param&nbsp; DisplaceAmtX&nbsp; How much displacement on the X axis to apply.<br />
* @param&nbsp; DisplaceAmtY&nbsp; How much displacement on the Y axis to apply.<br />
*/</span><br />
<span style="color: #0033ff; font-weight: bold;">public</span> <span style="color: #339966; font-weight: bold;">function</span> rebuild<span style="color: #000000;">&#40;</span>X<span style="color: #000066; font-weight: bold;">:</span><span style="color: #004993;">Number</span><span style="color: #000066; font-weight: bold;">,</span> Y<span style="color: #000066; font-weight: bold;">:</span><span style="color: #004993;">Number</span><span style="color: #000066; font-weight: bold;">,</span> Width<span style="color: #000066; font-weight: bold;">:</span><span style="color: #004993;">Number</span> = <span style="color: #000000; font-weight:bold;">1</span><span style="color: #000066; font-weight: bold;">,</span> Height<span style="color: #000066; font-weight: bold;">:</span><span style="color: #004993;">Number</span> = <span style="color: #000000; font-weight:bold;">1</span><span style="color: #000066; font-weight: bold;">,</span> Life<span style="color: #000066; font-weight: bold;">:</span><span style="color: #004993;">Number</span> = <span style="color: #000066; font-weight: bold;">-</span><span style="color: #000000; font-weight:bold;">2</span><span style="color: #000066; font-weight: bold;">,</span> DisplaceAmtX<span style="color: #000066; font-weight: bold;">:</span><span style="color: #004993;">Number</span> = <span style="color: #000000; font-weight:bold;">1</span><span style="color: #000066; font-weight: bold;">,</span> DisplaceAmtY<span style="color: #000066; font-weight: bold;">:</span><span style="color: #004993;">Number</span> = <span style="color: #000000; font-weight:bold;">1</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">:</span><span style="color: #0033ff; font-weight: bold;">void</span><br />
<span style="color: #000000;">&#123;</span><br />
<span style="color: #0033ff; font-weight: bold;">super</span><span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">reset</span><span style="color: #000000;">&#40;</span>X<span style="color: #000066; font-weight: bold;">,</span> Y<span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span><br />
_displaceAmt = <span style="color: #0033ff; font-weight: bold;">new</span> FlxPoint<span style="color: #000000;">&#40;</span>DisplaceAmtX<span style="color: #000066; font-weight: bold;">,</span> DisplaceAmtX<span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span><br />
<span style="color: #0033ff; font-weight: bold;">if</span> <span style="color: #000000;">&#40;</span>Width <span style="color: #000066; font-weight: bold;">&amp;</span>lt<span style="color: #000066; font-weight: bold;">;</span> <span style="color: #000000; font-weight:bold;">2</span><span style="color: #000000;">&#41;</span> Width = <span style="color: #000000; font-weight:bold;">2</span><span style="color: #000066; font-weight: bold;">;</span><br />
<span style="color: #0033ff; font-weight: bold;">if</span> <span style="color: #000000;">&#40;</span>Height <span style="color: #000066; font-weight: bold;">&amp;</span>lt<span style="color: #000066; font-weight: bold;">;</span> <span style="color: #000000; font-weight:bold;">2</span><span style="color: #000000;">&#41;</span> Height = <span style="color: #000000; font-weight:bold;">2</span><span style="color: #000066; font-weight: bold;">;</span><br />
StartSize = <span style="color: #0033ff; font-weight: bold;">new</span> FlxPoint<span style="color: #000000;">&#40;</span>Width<span style="color: #000066; font-weight: bold;">,</span> Height<span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span><br />
<span style="color: #0033ff; font-weight: bold;">if</span> <span style="color: #000000;">&#40;</span>Life == <span style="color: #000066; font-weight: bold;">-</span><span style="color: #000000; font-weight:bold;">2</span><span style="color: #000000;">&#41;</span> Life = maxLife<span style="color: #000066; font-weight: bold;">;</span><br />
<span style="color: #0033ff; font-weight: bold;">else</span> <span style="color: #0033ff; font-weight: bold;">if</span> <span style="color: #000000;">&#40;</span>Life <span style="color: #000066; font-weight: bold;">&amp;</span>lt<span style="color: #000066; font-weight: bold;">;</span> <span style="color: #000066; font-weight: bold;">-</span><span style="color: #000000; font-weight:bold;">1</span><span style="color: #000000;">&#41;</span> Life = <span style="color: #000066; font-weight: bold;">-</span><span style="color: #000000; font-weight:bold;">1</span><span style="color: #000066; font-weight: bold;">;</span><br />
maxLife = Life<span style="color: #000066; font-weight: bold;">;</span><br />
Size = StartSize<span style="color: #000066; font-weight: bold;">;</span><br />
<span style="color: #004993;">width</span> = Width<span style="color: #000066; font-weight: bold;">;</span><br />
<span style="color: #004993;">height</span> = Height<span style="color: #000066; font-weight: bold;">;</span><br />
exists = <span style="color: #0033ff; font-weight: bold;">false</span><span style="color: #000066; font-weight: bold;">;</span><br />
<span style="color: #000000;">&#125;</span><br />
<br />
<span style="color: #3f5fbf;">/**<br />
* Set &lt;code&gt;blobWidth&lt;code&gt; to change how wide the blob is.<br />
*/</span><br />
<span style="color: #0033ff; font-weight: bold;">public</span> <span style="color: #339966; font-weight: bold;">function</span> <span style="color: #0033ff; font-weight: bold;">get</span> blobWidth<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">:</span><span style="color: #004993;">Number</span><br />
<span style="color: #000000;">&#123;</span><br />
<span style="color: #0033ff; font-weight: bold;">return</span> StartSize<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">x</span><span style="color: #000066; font-weight: bold;">;</span><br />
<span style="color: #000000;">&#125;</span><span style="color: #000066; font-weight: bold;">&lt;/</span>code<span style="color: #000066; font-weight: bold;">&gt;&lt;/</span>code<span style="color: #000066; font-weight: bold;">&gt;</span><br />
<br />
<span style="color: #3f5fbf;">/**<br />
* Set &lt;code&gt;blobWidth&lt;code&gt; to change how wide the blob is.<br />
*/</span><br />
<span style="color: #0033ff; font-weight: bold;">public</span> <span style="color: #339966; font-weight: bold;">function</span> <span style="color: #0033ff; font-weight: bold;">set</span> blobWidth<span style="color: #000000;">&#40;</span>Width<span style="color: #000066; font-weight: bold;">:</span><span style="color: #004993;">Number</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">:</span><span style="color: #0033ff; font-weight: bold;">void</span><br />
<span style="color: #000000;">&#123;</span><br />
<span style="color: #0033ff; font-weight: bold;">if</span> <span style="color: #000000;">&#40;</span>Width <span style="color: #000066; font-weight: bold;">&amp;</span>lt<span style="color: #000066; font-weight: bold;">;</span> <span style="color: #000000; font-weight:bold;">2</span><span style="color: #000000;">&#41;</span> Width = <span style="color: #000000; font-weight:bold;">2</span><span style="color: #000066; font-weight: bold;">;</span><br />
StartSize<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">x</span> = Width<span style="color: #000066; font-weight: bold;">;</span><br />
<span style="color: #000000;">&#125;</span><span style="color: #000066; font-weight: bold;">&lt;/</span>code<span style="color: #000066; font-weight: bold;">&gt;&lt;/</span>code<span style="color: #000066; font-weight: bold;">&gt;</span><br />
<br />
<span style="color: #3f5fbf;">/**<br />
* Set &lt;code&gt;blobHeight&lt;code&gt; to change how wide the blob is.<br />
*/</span><br />
<span style="color: #0033ff; font-weight: bold;">public</span> <span style="color: #339966; font-weight: bold;">function</span> <span style="color: #0033ff; font-weight: bold;">get</span> blobHeight<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">:</span><span style="color: #004993;">Number</span><br />
<span style="color: #000000;">&#123;</span><br />
<span style="color: #0033ff; font-weight: bold;">return</span> StartSize<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">y</span><span style="color: #000066; font-weight: bold;">;</span><br />
<span style="color: #000000;">&#125;</span><span style="color: #000066; font-weight: bold;">&lt;/</span>code<span style="color: #000066; font-weight: bold;">&gt;&lt;/</span>code<span style="color: #000066; font-weight: bold;">&gt;</span><br />
<br />
<span style="color: #3f5fbf;">/**<br />
* Set &lt;code&gt;blobHeight&lt;code&gt; to change how high the blob is.<br />
*/</span><br />
<span style="color: #0033ff; font-weight: bold;">public</span> <span style="color: #339966; font-weight: bold;">function</span> <span style="color: #0033ff; font-weight: bold;">set</span> blobHeight<span style="color: #000000;">&#40;</span>Height<span style="color: #000066; font-weight: bold;">:</span><span style="color: #004993;">Number</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">:</span><span style="color: #0033ff; font-weight: bold;">void</span><br />
<span style="color: #000000;">&#123;</span><br />
<span style="color: #0033ff; font-weight: bold;">if</span> <span style="color: #000000;">&#40;</span>Height <span style="color: #000066; font-weight: bold;">&amp;</span>lt<span style="color: #000066; font-weight: bold;">;</span> <span style="color: #000000; font-weight:bold;">2</span><span style="color: #000000;">&#41;</span> Height = <span style="color: #000000; font-weight:bold;">2</span><span style="color: #000066; font-weight: bold;">;</span><br />
StartSize<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">y</span> = Height<span style="color: #000066; font-weight: bold;">;</span><br />
<span style="color: #000000;">&#125;</span><span style="color: #000066; font-weight: bold;">&lt;/</span>code<span style="color: #000066; font-weight: bold;">&gt;&lt;/</span>code<span style="color: #000066; font-weight: bold;">&gt;</span><br />
<br />
<span style="color: #3f5fbf;">/**<br />
* Set &lt;code&gt;life&lt;/code&gt; to set how long the blob lives. -1 to make the blob live forever.<br />
*/</span><br />
<span style="color: #0033ff; font-weight: bold;">public</span> <span style="color: #339966; font-weight: bold;">function</span> <span style="color: #0033ff; font-weight: bold;">get</span> life<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">:</span><span style="color: #004993;">Number</span><br />
<span style="color: #000000;">&#123;</span><br />
<span style="color: #0033ff; font-weight: bold;">return</span> maxLife<span style="color: #000066; font-weight: bold;">;</span><br />
<span style="color: #000000;">&#125;</span><br />
<br />
<span style="color: #3f5fbf;">/**<br />
* Set &lt;code&gt;life&lt;/code&gt; to set how long the blob lives. -1 to make the blob live forever.<br />
*/</span><br />
<span style="color: #0033ff; font-weight: bold;">public</span> <span style="color: #339966; font-weight: bold;">function</span> <span style="color: #0033ff; font-weight: bold;">set</span> life<span style="color: #000000;">&#40;</span>Life<span style="color: #000066; font-weight: bold;">:</span><span style="color: #004993;">Number</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">:</span><span style="color: #0033ff; font-weight: bold;">void</span><br />
<span style="color: #000000;">&#123;</span><br />
<span style="color: #0033ff; font-weight: bold;">if</span> <span style="color: #000000;">&#40;</span>Life <span style="color: #000066; font-weight: bold;">&amp;</span>lt<span style="color: #000066; font-weight: bold;">;</span> <span style="color: #000066; font-weight: bold;">-</span><span style="color: #000000; font-weight:bold;">1</span><span style="color: #000000;">&#41;</span> Life = <span style="color: #000066; font-weight: bold;">-</span><span style="color: #000000; font-weight:bold;">1</span><span style="color: #000066; font-weight: bold;">;</span><br />
maxLife = Life<span style="color: #000066; font-weight: bold;">;</span><br />
<span style="color: #000000;">&#125;</span><br />
<br />
<span style="color: #3f5fbf;">/**<br />
* Set &lt;code&gt;displaceAmtX&lt;/code&gt; to set the amount of displacement along the X axis.<br />
*/</span><br />
<span style="color: #0033ff; font-weight: bold;">public</span> <span style="color: #339966; font-weight: bold;">function</span> <span style="color: #0033ff; font-weight: bold;">get</span> displaceAmtX<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">:</span><span style="color: #004993;">Number</span><br />
<span style="color: #000000;">&#123;</span><br />
<span style="color: #0033ff; font-weight: bold;">return</span> _displaceAmt<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">x</span><span style="color: #000066; font-weight: bold;">;</span><br />
<span style="color: #000000;">&#125;</span><br />
<br />
<span style="color: #3f5fbf;">/**<br />
* Set &lt;code&gt;displaceAmtX&lt;/code&gt; to set the amount of displacement along the X axis.<br />
*/</span><br />
<span style="color: #0033ff; font-weight: bold;">public</span> <span style="color: #339966; font-weight: bold;">function</span> <span style="color: #0033ff; font-weight: bold;">set</span> displaceAmtX<span style="color: #000000;">&#40;</span>Amt<span style="color: #000066; font-weight: bold;">:</span><span style="color: #004993;">Number</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">:</span><span style="color: #0033ff; font-weight: bold;">void</span><br />
<span style="color: #000000;">&#123;</span><br />
_displaceAmt<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">x</span> = Amt<span style="color: #000066; font-weight: bold;">;</span><br />
<span style="color: #000000;">&#125;</span><br />
<br />
<span style="color: #3f5fbf;">/**<br />
* Set &lt;code&gt;displaceAmtY&lt;/code&gt; to set the amount of displacement along the Y axis.<br />
*/</span><br />
<span style="color: #0033ff; font-weight: bold;">public</span> <span style="color: #339966; font-weight: bold;">function</span> <span style="color: #0033ff; font-weight: bold;">get</span> displaceAmtY<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">:</span><span style="color: #004993;">Number</span><br />
<span style="color: #000000;">&#123;</span><br />
<span style="color: #0033ff; font-weight: bold;">return</span> _displaceAmt<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">y</span><span style="color: #000066; font-weight: bold;">;</span><br />
<span style="color: #000000;">&#125;</span><br />
<br />
<span style="color: #3f5fbf;">/**<br />
* Set &lt;code&gt;displaceAmtY&lt;/code&gt; to set the amount of displacement along the Y axis.<br />
*/</span><br />
<span style="color: #0033ff; font-weight: bold;">public</span> <span style="color: #339966; font-weight: bold;">function</span> <span style="color: #0033ff; font-weight: bold;">set</span> displaceAmtY<span style="color: #000000;">&#40;</span>Amt<span style="color: #000066; font-weight: bold;">:</span><span style="color: #004993;">Number</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">:</span><span style="color: #0033ff; font-weight: bold;">void</span><br />
<span style="color: #000000;">&#123;</span><br />
_displaceAmt<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">y</span> = Amt<span style="color: #000066; font-weight: bold;">;</span><br />
<span style="color: #000000;">&#125;</span><br />
<br />
<span style="color: #3f5fbf;">/**<br />
* Set &lt;code&gt;displaceAmt&lt;/code&gt; to set the amount of displacement along both axis.<br />
*/</span><br />
<span style="color: #0033ff; font-weight: bold;">public</span> <span style="color: #339966; font-weight: bold;">function</span> <span style="color: #0033ff; font-weight: bold;">get</span> displaceAmt<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">:</span>FlxPoint<br />
<span style="color: #000000;">&#123;</span><br />
<span style="color: #0033ff; font-weight: bold;">return</span> _displaceAmt<span style="color: #000066; font-weight: bold;">;</span><br />
<span style="color: #000000;">&#125;</span><br />
<br />
<span style="color: #3f5fbf;">/**<br />
* Set &lt;code&gt;displaceAmt&lt;/code&gt; to set the amount of displacement along both axis.<br />
*/</span><br />
<span style="color: #0033ff; font-weight: bold;">public</span> <span style="color: #339966; font-weight: bold;">function</span> <span style="color: #0033ff; font-weight: bold;">set</span> displaceAmt<span style="color: #000000;">&#40;</span>Amt<span style="color: #000066; font-weight: bold;">:</span>FlxPoint<span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">:</span><span style="color: #0033ff; font-weight: bold;">void</span><br />
<span style="color: #000000;">&#123;</span><br />
_displaceAmt = Amt<span style="color: #000066; font-weight: bold;">;</span><br />
<span style="color: #000000;">&#125;</span><br />
<br />
override <span style="color: #0033ff; font-weight: bold;">public</span> <span style="color: #339966; font-weight: bold;">function</span> onEmit<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">:</span><span style="color: #0033ff; font-weight: bold;">void</span><br />
<span style="color: #000000;">&#123;</span><br />
<span style="color: #0033ff; font-weight: bold;">super</span><span style="color: #000066; font-weight: bold;">.</span>onEmit<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span><br />
Size = StartSize<span style="color: #000066; font-weight: bold;">;</span><br />
<span style="color: #004993;">width</span> = StartSize<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">x</span><span style="color: #000066; font-weight: bold;">;</span><br />
<span style="color: #004993;">height</span> = StartSize<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">y</span><span style="color: #000066; font-weight: bold;">;</span><br />
_life = maxLife<span style="color: #000066; font-weight: bold;">;</span><br />
exists = <span style="color: #0033ff; font-weight: bold;">true</span><span style="color: #000066; font-weight: bold;">;</span><br />
<span style="color: #000000;">&#125;</span><br />
<br />
override <span style="color: #0033ff; font-weight: bold;">public</span> <span style="color: #339966; font-weight: bold;">function</span> update<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">:</span><span style="color: #0033ff; font-weight: bold;">void</span><br />
<span style="color: #000000;">&#123;</span><br />
<span style="color: #0033ff; font-weight: bold;">if</span> <span style="color: #000000;">&#40;</span><span style="color: #000066; font-weight: bold;">!</span>exists<span style="color: #000000;">&#41;</span> <span style="color: #0033ff; font-weight: bold;">return</span><span style="color: #000066; font-weight: bold;">;</span><br />
<span style="color: #0033ff; font-weight: bold;">super</span><span style="color: #000066; font-weight: bold;">.</span>update<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span><br />
<br />
<span style="color: #0033ff; font-weight: bold;">if</span> <span style="color: #000000;">&#40;</span>maxLife <span style="color: #000066; font-weight: bold;">!</span>= <span style="color: #000066; font-weight: bold;">-</span><span style="color: #000000; font-weight:bold;">1</span><span style="color: #000000;">&#41;</span><br />
<span style="color: #000000;">&#123;</span><br />
<span style="color: #0033ff; font-weight: bold;">if</span> <span style="color: #000000;">&#40;</span>_life <span style="color: #000066; font-weight: bold;">&amp;</span>lt<span style="color: #000066; font-weight: bold;">;</span>= <span style="color: #000000; font-weight:bold;">0</span><span style="color: #000000;">&#41;</span><br />
<span style="color: #000000;">&#123;</span><br />
<span style="color: #0033ff; font-weight: bold;">if</span> <span style="color: #000000;">&#40;</span>_life == <span style="color: #000066; font-weight: bold;">-</span><span style="color: #000000; font-weight:bold;">50</span><span style="color: #000000;">&#41;</span><br />
<span style="color: #000000;">&#123;</span><br />
Size<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">x</span> <span style="color: #000066; font-weight: bold;">-</span>= <span style="color: #000000; font-weight:bold;">2</span><span style="color: #000066; font-weight: bold;">;</span><br />
Size<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">y</span> <span style="color: #000066; font-weight: bold;">-</span>= <span style="color: #000000; font-weight:bold;">2</span><span style="color: #000066; font-weight: bold;">;</span><br />
<span style="color: #0033ff; font-weight: bold;">if</span> <span style="color: #000000;">&#40;</span>Size<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">x</span> <span style="color: #000066; font-weight: bold;">&amp;</span>lt<span style="color: #000066; font-weight: bold;">;</span>= <span style="color: #000000; font-weight:bold;">0</span> <span style="color: #000066; font-weight: bold;">||</span> Size<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">y</span> <span style="color: #000066; font-weight: bold;">&amp;</span>lt<span style="color: #000066; font-weight: bold;">;</span>= <span style="color: #000000; font-weight:bold;">0</span><span style="color: #000000;">&#41;</span> exists = <span style="color: #0033ff; font-weight: bold;">false</span><span style="color: #000066; font-weight: bold;">;</span><br />
<span style="color: #000000;">&#125;</span><br />
<span style="color: #0033ff; font-weight: bold;">else</span><br />
_life = <span style="color: #000066; font-weight: bold;">-</span><span style="color: #000000; font-weight:bold;">50</span><span style="color: #000066; font-weight: bold;">;</span><br />
<span style="color: #000000;">&#125;</span><br />
<span style="color: #0033ff; font-weight: bold;">else</span><br />
_life<span style="color: #000066; font-weight: bold;">-</span>= FlxG<span style="color: #000066; font-weight: bold;">.</span>elapsed<span style="color: #000066; font-weight: bold;">;</span><br />
<span style="color: #000000;">&#125;</span><br />
<span style="color: #000000;">&#125;</span><br />
<br />
override <span style="color: #0033ff; font-weight: bold;">public</span> <span style="color: #339966; font-weight: bold;">function</span> <span style="color: #004993;">render</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">:</span><span style="color: #0033ff; font-weight: bold;">void</span><br />
<span style="color: #000000;">&#123;</span><br />
<span style="color: #0033ff; font-weight: bold;">if</span> <span style="color: #000000;">&#40;</span><span style="color: #000066; font-weight: bold;">!</span>onScreen<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span> <span style="color: #000066; font-weight: bold;">||</span> <span style="color: #000066; font-weight: bold;">!</span>exists<span style="color: #000000;">&#41;</span> <span style="color: #0033ff; font-weight: bold;">return</span><span style="color: #000066; font-weight: bold;">;</span><br />
<span style="color: #6699cc; font-weight: bold;">var</span> pnt<span style="color: #000066; font-weight: bold;">:</span>FlxPoint = getScreenXY<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span><br />
<span style="color: #6699cc; font-weight: bold;">var</span> dx<span style="color: #000066; font-weight: bold;">:</span><span style="color: #004993;">Number</span> = Rnd<span style="color: #000066; font-weight: bold;">.</span>float<span style="color: #000000;">&#40;</span> <span style="color: #000066; font-weight: bold;">-</span>_displaceAmt<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">x</span><span style="color: #000066; font-weight: bold;">,</span> _displaceAmt<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">x</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span><br />
<span style="color: #6699cc; font-weight: bold;">var</span> dy<span style="color: #000066; font-weight: bold;">:</span><span style="color: #004993;">Number</span> = Rnd<span style="color: #000066; font-weight: bold;">.</span>float<span style="color: #000000;">&#40;</span> <span style="color: #000066; font-weight: bold;">-</span>_displaceAmt<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">y</span><span style="color: #000066; font-weight: bold;">,</span> _displaceAmt<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">y</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span><br />
<span style="color: #6699cc; font-weight: bold;">var</span> w<span style="color: #000066; font-weight: bold;">:</span><span style="color: #004993;">int</span> = Size<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">x</span><span style="color: #000066; font-weight: bold;">;</span><br />
<span style="color: #6699cc; font-weight: bold;">var</span> h<span style="color: #000066; font-weight: bold;">:</span><span style="color: #004993;">int</span> = Size<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">y</span><span style="color: #000066; font-weight: bold;">;</span><br />
FlxG<span style="color: #000066; font-weight: bold;">.</span>buffer<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">copyPixels</span><span style="color: #000000;">&#40;</span>_buffer<span style="color: #000066; font-weight: bold;">,</span> <span style="color: #0033ff; font-weight: bold;">new</span> <span style="color: #004993;">Rectangle</span><span style="color: #000000;">&#40;</span>pnt<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">x</span> <span style="color: #000066; font-weight: bold;">+</span> <span style="color: #000000;">&#40;</span>w <span style="color: #000066; font-weight: bold;">*</span> <span style="color: #000066; font-weight: bold;">.</span>5<span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">,</span> pnt<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">y</span> <span style="color: #000066; font-weight: bold;">+</span> <span style="color: #000000;">&#40;</span>h <span style="color: #000066; font-weight: bold;">*</span> <span style="color: #000066; font-weight: bold;">.</span>5<span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">,</span> w<span style="color: #000066; font-weight: bold;">,</span> h<span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">,</span> <span style="color: #0033ff; font-weight: bold;">new</span> <span style="color: #004993;">Point</span><span style="color: #000000;">&#40;</span>pnt<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">x</span> <span style="color: #000066; font-weight: bold;">+</span> dx <span style="color: #000066; font-weight: bold;">+</span> <span style="color: #000000;">&#40;</span>w <span style="color: #000066; font-weight: bold;">*</span> <span style="color: #000066; font-weight: bold;">.</span>5<span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">,</span> pnt<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">y</span> <span style="color: #000066; font-weight: bold;">+</span> dy <span style="color: #000066; font-weight: bold;">+</span> <span style="color: #000000;">&#40;</span>h <span style="color: #000066; font-weight: bold;">*</span> <span style="color: #000066; font-weight: bold;">.</span>5<span style="color: #000000;">&#41;</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">,</span> _framePixels<span style="color: #000066; font-weight: bold;">,</span> <span style="color: #0033ff; font-weight: bold;">null</span><span style="color: #000066; font-weight: bold;">,</span> <span style="color: #0033ff; font-weight: bold;">true</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span><br />
<span style="color: #000000;">&#125;</span><br />
<span style="color: #000000;">&#125;</span><br />
<br />
<span style="color: #000000;">&#125;</span></div></div>
<p><strong>Note:</strong> the DisplaceBlob Class uses the Random class from <a href="Gskinner.com">Gskinner.com</a>. You can find it <a href="http://www.gskinner.com/blog/archives/2008/01/source_code_ran.html">here</a>, or change it to use your own random functions.</p>
<h4>Displacement:</h4>
<div class="codecolorer-container actionscript3 default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;height:450px;"><div class="actionscript3 codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #9900cc; font-weight: bold;">package</span> com<span style="color: #000066; font-weight: bold;">.</span>tileisle<br />
<span style="color: #000000;">&#123;</span><br />
<span style="color: #0033ff; font-weight: bold;">import</span> <span style="color: #004993;">flash.display</span><span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">BitmapData</span><span style="color: #000066; font-weight: bold;">;</span><br />
<span style="color: #0033ff; font-weight: bold;">import</span> org<span style="color: #000066; font-weight: bold;">.</span>flixel<span style="color: #000066; font-weight: bold;">.*;</span><br />
<br />
<span style="color: #3f5fbf;">/**<br />
* &lt;code&gt;Displacement&lt;/code&gt; is an emitter setup to work specifically with DisplaceBlobs.<br />
*<br />
* @author Ryan &quot;Rybar&quot; Malm, Tim &quot;SeiferTim&quot; Hely<br />
*/</span><br />
<span style="color: #0033ff; font-weight: bold;">public</span> <span style="color: #9900cc; font-weight: bold;">class</span> Displacement <span style="color: #0033ff; font-weight: bold;">extends</span> FlxEmitter<br />
<span style="color: #000000;">&#123;</span><br />
<span style="color: #0033ff; font-weight: bold;">private</span> <span style="color: #6699cc; font-weight: bold;">var</span> _life<span style="color: #000066; font-weight: bold;">:</span><span style="color: #004993;">Number</span> = <span style="color: #000066; font-weight: bold;">-</span><span style="color: #000000; font-weight:bold;">1</span><span style="color: #000066; font-weight: bold;">;</span> <span style="color: #009900; font-style: italic;">// how long they live</span><br />
<span style="color: #0033ff; font-weight: bold;">private</span> <span style="color: #6699cc; font-weight: bold;">var</span> _blobCount<span style="color: #000066; font-weight: bold;">:</span><span style="color: #004993;">uint</span> = <span style="color: #000000; font-weight:bold;">100</span><span style="color: #000066; font-weight: bold;">;</span> <span style="color: #009900; font-style: italic;">// how many blobs will be created (determined by height/width)</span><br />
<span style="color: #0033ff; font-weight: bold;">private</span> <span style="color: #6699cc; font-weight: bold;">var</span> _alpha<span style="color: #000066; font-weight: bold;">:</span><span style="color: #004993;">Number</span> = <span style="color: #000000; font-weight:bold;">1</span><span style="color: #000066; font-weight: bold;">;</span> <span style="color: #009900; font-style: italic;">// alpha of the blobs</span><br />
<span style="color: #0033ff; font-weight: bold;">private</span> <span style="color: #6699cc; font-weight: bold;">var</span> _displaceAmt<span style="color: #000066; font-weight: bold;">:</span>FlxPoint<span style="color: #000066; font-weight: bold;">;</span><br />
<span style="color: #0033ff; font-weight: bold;">private</span> <span style="color: #6699cc; font-weight: bold;">var</span> _blobSize<span style="color: #000066; font-weight: bold;">:</span>FlxPoint<span style="color: #000066; font-weight: bold;">;</span><br />
<span style="color: #0033ff; font-weight: bold;">private</span> <span style="color: #6699cc; font-weight: bold;">var</span> _buffer<span style="color: #000066; font-weight: bold;">:</span><span style="color: #004993;">BitmapData</span><span style="color: #000066; font-weight: bold;">;</span><br />
<br />
<span style="color: #3f5fbf;">/**<br />
* Creates a new &lt;code&gt;Displacement&lt;/code&gt; object at a specific position.<br />
*<br />
* @param&nbsp; Buffer&nbsp; &nbsp; &nbsp; This should point to your FXGroup's Buffer<br />
* @param&nbsp; X &nbsp; &nbsp; &nbsp; The X position of the emitter<br />
* @param&nbsp; Y &nbsp; &nbsp; &nbsp; The Y position of the emitter<br />
* @param&nbsp; Width &nbsp; &nbsp; The Width of the emitter<br />
* @param&nbsp; Height&nbsp; &nbsp; &nbsp; The Height of the emitter<br />
* @param&nbsp; MinXSpeed &nbsp; Minimum X Speed of particles emitted<br />
* @param&nbsp; MaxXSpeed &nbsp; Maximum X Speed of particles emitted<br />
* @param&nbsp; MinYSpeed &nbsp; Minimum Y Speed of particles emitted<br />
* @param&nbsp; MaxYSpeed &nbsp; Maximum Y speed of particles emitted<br />
* @param&nbsp; BlobWidth &nbsp; Width of emitted Blobs<br />
* @param&nbsp; BlobHeight&nbsp; &nbsp; Height of emitted Blobs<br />
* @param&nbsp; Life&nbsp; &nbsp; &nbsp; Lifespan of emitted Blobs<br />
* @param&nbsp; Alpha &nbsp; &nbsp; Alpha of emitted Blobs<br />
* @param&nbsp; DisplaceAmtX&nbsp; Amount of Displacement on X axis<br />
* @param&nbsp; DisplaceAmtY&nbsp; Amount of Displacement on Y axis<br />
*/</span><br />
<span style="color: #0033ff; font-weight: bold;">public</span> <span style="color: #339966; font-weight: bold;">function</span> Displacement<span style="color: #000000;">&#40;</span>Buffer<span style="color: #000066; font-weight: bold;">:</span><span style="color: #004993;">BitmapData</span><span style="color: #000066; font-weight: bold;">,</span> X<span style="color: #000066; font-weight: bold;">:</span><span style="color: #004993;">Number</span> = <span style="color: #000000; font-weight:bold;">0</span><span style="color: #000066; font-weight: bold;">,</span> Y<span style="color: #000066; font-weight: bold;">:</span><span style="color: #004993;">Number</span> = <span style="color: #000000; font-weight:bold;">0</span><span style="color: #000066; font-weight: bold;">,</span> Width<span style="color: #000066; font-weight: bold;">:</span><span style="color: #004993;">Number</span> = <span style="color: #000000; font-weight:bold;">1</span><span style="color: #000066; font-weight: bold;">,</span> Height<span style="color: #000066; font-weight: bold;">:</span><span style="color: #004993;">Number</span> = <span style="color: #000000; font-weight:bold;">1</span><span style="color: #000066; font-weight: bold;">,</span> MinXSpeed<span style="color: #000066; font-weight: bold;">:</span><span style="color: #004993;">Number</span> = <span style="color: #000000; font-weight:bold;">1</span><span style="color: #000066; font-weight: bold;">,</span> MaxXSpeed<span style="color: #000066; font-weight: bold;">:</span><span style="color: #004993;">Number</span> = <span style="color: #000000; font-weight:bold;">1</span><span style="color: #000066; font-weight: bold;">,</span> MinYSpeed<span style="color: #000066; font-weight: bold;">:</span><span style="color: #004993;">Number</span> = <span style="color: #000000; font-weight:bold;">1</span><span style="color: #000066; font-weight: bold;">,</span> MaxYSpeed<span style="color: #000066; font-weight: bold;">:</span><span style="color: #004993;">Number</span> = <span style="color: #000000; font-weight:bold;">1</span><span style="color: #000066; font-weight: bold;">,</span> BlobWidth<span style="color: #000066; font-weight: bold;">:</span><span style="color: #004993;">Number</span> = <span style="color: #000000; font-weight:bold;">1</span><span style="color: #000066; font-weight: bold;">,</span> BlobHeight<span style="color: #000066; font-weight: bold;">:</span><span style="color: #004993;">Number</span> = <span style="color: #000000; font-weight:bold;">1</span><span style="color: #000066; font-weight: bold;">,</span> BlobCount<span style="color: #000066; font-weight: bold;">:</span><span style="color: #004993;">int</span>=<span style="color: #000000; font-weight:bold;">50</span><span style="color: #000066; font-weight: bold;">,</span> Life<span style="color: #000066; font-weight: bold;">:</span><span style="color: #004993;">Number</span> = <span style="color: #000000; font-weight:bold;">1</span><span style="color: #000066; font-weight: bold;">,</span> Alpha<span style="color: #000066; font-weight: bold;">:</span><span style="color: #004993;">Number</span> = <span style="color: #000000; font-weight:bold;">1</span><span style="color: #000066; font-weight: bold;">,</span> DisplaceAmtX<span style="color: #000066; font-weight: bold;">:</span><span style="color: #004993;">Number</span> = <span style="color: #000000; font-weight:bold;">1</span><span style="color: #000066; font-weight: bold;">,</span> DisplaceAmtY<span style="color: #000066; font-weight: bold;">:</span><span style="color: #004993;">Number</span> = <span style="color: #000000; font-weight:bold;">1</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">:</span><span style="color: #0033ff; font-weight: bold;">void</span><br />
<span style="color: #000000;">&#123;</span><br />
_buffer = Buffer<span style="color: #000066; font-weight: bold;">;</span><br />
<span style="color: #0033ff; font-weight: bold;">super</span><span style="color: #000000;">&#40;</span>X<span style="color: #000066; font-weight: bold;">,</span> Y<span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span><br />
_displaceAmt = <span style="color: #0033ff; font-weight: bold;">new</span> FlxPoint<span style="color: #000000;">&#40;</span>DisplaceAmtX<span style="color: #000066; font-weight: bold;">,</span> DisplaceAmtY<span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span><br />
<span style="color: #0033ff; font-weight: bold;">if</span> <span style="color: #000000;">&#40;</span>BlobWidth <span style="color: #000066; font-weight: bold;">&amp;</span>lt<span style="color: #000066; font-weight: bold;">;</span> <span style="color: #000000; font-weight:bold;">1</span><span style="color: #000000;">&#41;</span> BlobWidth = <span style="color: #000000; font-weight:bold;">1</span><span style="color: #000066; font-weight: bold;">;</span><br />
<span style="color: #0033ff; font-weight: bold;">if</span> <span style="color: #000000;">&#40;</span>BlobHeight <span style="color: #000066; font-weight: bold;">&amp;</span>lt<span style="color: #000066; font-weight: bold;">;</span> <span style="color: #000000; font-weight:bold;">1</span><span style="color: #000000;">&#41;</span> BlobHeight = <span style="color: #000000; font-weight:bold;">1</span><span style="color: #000066; font-weight: bold;">;</span><br />
_blobSize = <span style="color: #0033ff; font-weight: bold;">new</span> FlxPoint<span style="color: #000000;">&#40;</span>BlobWidth<span style="color: #000066; font-weight: bold;">,</span> BlobHeight<span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span><br />
<span style="color: #0033ff; font-weight: bold;">if</span> <span style="color: #000000;">&#40;</span>Alpha <span style="color: #000066; font-weight: bold;">&amp;</span>gt<span style="color: #000066; font-weight: bold;">;</span> <span style="color: #000000; font-weight:bold;">1</span><span style="color: #000000;">&#41;</span> Alpha = <span style="color: #000000; font-weight:bold;">1</span><span style="color: #000066; font-weight: bold;">;</span><br />
<span style="color: #0033ff; font-weight: bold;">else</span> <span style="color: #0033ff; font-weight: bold;">if</span> <span style="color: #000000;">&#40;</span>Alpha <span style="color: #000066; font-weight: bold;">&amp;</span>lt<span style="color: #000066; font-weight: bold;">;</span> <span style="color: #000000; font-weight:bold;">0.1</span><span style="color: #000000;">&#41;</span> Alpha = <span style="color: #000000; font-weight:bold;">0.1</span><span style="color: #000066; font-weight: bold;">;</span><br />
_alpha = Alpha<span style="color: #000066; font-weight: bold;">;</span><br />
<span style="color: #0033ff; font-weight: bold;">if</span> <span style="color: #000000;">&#40;</span>Life <span style="color: #000066; font-weight: bold;">&amp;</span>lt<span style="color: #000066; font-weight: bold;">;</span> <span style="color: #000066; font-weight: bold;">-</span><span style="color: #000000; font-weight:bold;">1</span><span style="color: #000000;">&#41;</span> Life = <span style="color: #000066; font-weight: bold;">-</span><span style="color: #000000; font-weight:bold;">1</span><span style="color: #000066; font-weight: bold;">;</span><br />
_life = Life<span style="color: #000066; font-weight: bold;">;</span><br />
setSize<span style="color: #000000;">&#40;</span>Width<span style="color: #000066; font-weight: bold;">,</span> Height<span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span><br />
setXSpeed<span style="color: #000000;">&#40;</span>MinXSpeed<span style="color: #000066; font-weight: bold;">,</span> MaxXSpeed<span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span><br />
setYSpeed<span style="color: #000000;">&#40;</span>MinYSpeed<span style="color: #000066; font-weight: bold;">,</span> MaxYSpeed<span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span><br />
gravity = <span style="color: #000000; font-weight:bold;">0</span><span style="color: #000066; font-weight: bold;">;</span><br />
setBlobCount<span style="color: #000000;">&#40;</span>_blobCount<span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span><br />
<span style="color: #000000;">&#125;</span><br />
<br />
<span style="color: #3f5fbf;">/**<br />
* Use &lt;code&gt;setBlobCount&lt;/code&gt; to set the number of blobs in your emitter. This will also rebuild it's buffer.<br />
* @param&nbsp; Count The number of blobs you want to have in your buffer.<br />
*/</span><br />
<span style="color: #0033ff; font-weight: bold;">public</span> <span style="color: #339966; font-weight: bold;">function</span> setBlobCount<span style="color: #000000;">&#40;</span>Count<span style="color: #000066; font-weight: bold;">:</span><span style="color: #004993;">int</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">:</span><span style="color: #0033ff; font-weight: bold;">void</span><br />
<span style="color: #000000;">&#123;</span><br />
members<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">length</span> = <span style="color: #000000; font-weight:bold;">0</span><span style="color: #000066; font-weight: bold;">;</span><br />
<span style="color: #6699cc; font-weight: bold;">var</span> <span style="color: #004993;">d</span><span style="color: #000066; font-weight: bold;">:</span>DisplaceBlob<span style="color: #000066; font-weight: bold;">;</span><br />
<span style="color: #0033ff; font-weight: bold;">for</span> <span style="color: #000000;">&#40;</span><span style="color: #6699cc; font-weight: bold;">var</span> e<span style="color: #000066; font-weight: bold;">:</span><span style="color: #004993;">uint</span> = <span style="color: #000000; font-weight:bold;">0</span><span style="color: #000066; font-weight: bold;">;</span> e <span style="color: #000066; font-weight: bold;">&amp;</span>lt<span style="color: #000066; font-weight: bold;">;</span> Count<span style="color: #000066; font-weight: bold;">;</span> e<span style="color: #000066; font-weight: bold;">++</span><span style="color: #000000;">&#41;</span><br />
<span style="color: #000000;">&#123;</span><br />
<span style="color: #004993;">add</span><span style="color: #000000;">&#40;</span><span style="color: #004993;">d</span> = <span style="color: #0033ff; font-weight: bold;">new</span> DisplaceBlob<span style="color: #000000;">&#40;</span>_buffer<span style="color: #000066; font-weight: bold;">,</span><span style="color: #000000; font-weight:bold;">0</span><span style="color: #000066; font-weight: bold;">,</span> <span style="color: #000000; font-weight:bold;">0</span><span style="color: #000066; font-weight: bold;">,</span> _blobSize<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">x</span><span style="color: #000066; font-weight: bold;">,</span> _blobSize<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">y</span><span style="color: #000066; font-weight: bold;">,</span> _life<span style="color: #000066; font-weight: bold;">,</span> _displaceAmt<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">x</span><span style="color: #000066; font-weight: bold;">,</span> _displaceAmt<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">y</span><span style="color: #000000;">&#41;</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span><br />
<span style="color: #004993;">d</span><span style="color: #000066; font-weight: bold;">.</span>exists = <span style="color: #0033ff; font-weight: bold;">false</span><span style="color: #000066; font-weight: bold;">;</span><br />
<span style="color: #000000;">&#125;</span><br />
<span style="color: #000000;">&#125;</span><br />
<br />
<span style="color: #3f5fbf;">/**<br />
* Set &lt;code&gt;blobWidth&lt;/code&gt; to define the width of the emitted blobs<br />
*/</span><br />
<span style="color: #0033ff; font-weight: bold;">public</span> <span style="color: #339966; font-weight: bold;">function</span> <span style="color: #0033ff; font-weight: bold;">get</span> blobWidth<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">:</span><span style="color: #004993;">Number</span><br />
<span style="color: #000000;">&#123;</span><br />
<span style="color: #0033ff; font-weight: bold;">return</span> _blobSize<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">x</span><span style="color: #000066; font-weight: bold;">;</span><br />
<span style="color: #000000;">&#125;</span><br />
<br />
<span style="color: #3f5fbf;">/**<br />
* Set &lt;code&gt;blobWidth&lt;/code&gt; to define the width of the emitted blobs<br />
*/</span><br />
<span style="color: #0033ff; font-weight: bold;">public</span> <span style="color: #339966; font-weight: bold;">function</span> <span style="color: #0033ff; font-weight: bold;">set</span> blobWidth<span style="color: #000000;">&#40;</span>Width<span style="color: #000066; font-weight: bold;">:</span><span style="color: #004993;">Number</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">:</span><span style="color: #0033ff; font-weight: bold;">void</span><br />
<span style="color: #000000;">&#123;</span><br />
<span style="color: #0033ff; font-weight: bold;">if</span> <span style="color: #000000;">&#40;</span>Width <span style="color: #000066; font-weight: bold;">&amp;</span>lt<span style="color: #000066; font-weight: bold;">;</span> <span style="color: #000000; font-weight:bold;">1</span><span style="color: #000000;">&#41;</span> Width = <span style="color: #000000; font-weight:bold;">1</span><span style="color: #000066; font-weight: bold;">;</span><br />
_blobSize<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">x</span> = Width<span style="color: #000066; font-weight: bold;">;</span><br />
<span style="color: #000000;">&#125;</span><br />
<br />
<span style="color: #3f5fbf;">/**<br />
* Set &lt;code&gt;blobHeight&lt;/code&gt; to define the height of the emitted blobs<br />
*/</span><br />
<span style="color: #0033ff; font-weight: bold;">public</span> <span style="color: #339966; font-weight: bold;">function</span> <span style="color: #0033ff; font-weight: bold;">get</span> blobHeight<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">:</span><span style="color: #004993;">Number</span><br />
<span style="color: #000000;">&#123;</span><br />
<span style="color: #0033ff; font-weight: bold;">return</span> _blobSize<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">y</span><span style="color: #000066; font-weight: bold;">;</span><br />
<span style="color: #000000;">&#125;</span><br />
<br />
<span style="color: #3f5fbf;">/**<br />
* Set &lt;code&gt;blobHeight&lt;/code&gt; to define the height of the emitted blobs<br />
*/</span><br />
<span style="color: #0033ff; font-weight: bold;">public</span> <span style="color: #339966; font-weight: bold;">function</span> <span style="color: #0033ff; font-weight: bold;">set</span> blobHeight<span style="color: #000000;">&#40;</span>Height<span style="color: #000066; font-weight: bold;">:</span><span style="color: #004993;">Number</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">:</span><span style="color: #0033ff; font-weight: bold;">void</span><br />
<span style="color: #000000;">&#123;</span><br />
<span style="color: #0033ff; font-weight: bold;">if</span> <span style="color: #000000;">&#40;</span>Height <span style="color: #000066; font-weight: bold;">&amp;</span>lt<span style="color: #000066; font-weight: bold;">;</span> <span style="color: #000000; font-weight:bold;">1</span><span style="color: #000000;">&#41;</span> Height = <span style="color: #000000; font-weight:bold;">1</span><span style="color: #000066; font-weight: bold;">;</span><br />
_blobSize<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">y</span> = Height<span style="color: #000066; font-weight: bold;">;</span><br />
<span style="color: #000000;">&#125;</span><br />
<br />
<span style="color: #3f5fbf;">/**<br />
* Set &lt;code&gt;blobSize&lt;/code&gt; to define the size of the emitted blobs<br />
*/</span><br />
<span style="color: #0033ff; font-weight: bold;">public</span> <span style="color: #339966; font-weight: bold;">function</span> <span style="color: #0033ff; font-weight: bold;">get</span> blobSize<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">:</span>FlxPoint<br />
<span style="color: #000000;">&#123;</span><br />
<span style="color: #0033ff; font-weight: bold;">return</span> _blobSize<span style="color: #000066; font-weight: bold;">;</span><br />
<span style="color: #000000;">&#125;</span><br />
<br />
<span style="color: #3f5fbf;">/**<br />
* Set &lt;code&gt;blobSize&lt;/code&gt; to define the size of the emitted blobs<br />
*/</span><br />
<span style="color: #0033ff; font-weight: bold;">public</span> <span style="color: #339966; font-weight: bold;">function</span> <span style="color: #0033ff; font-weight: bold;">set</span> blobSize<span style="color: #000000;">&#40;</span>Size<span style="color: #000066; font-weight: bold;">:</span>FlxPoint<span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">:</span><span style="color: #0033ff; font-weight: bold;">void</span><br />
<span style="color: #000000;">&#123;</span><br />
<span style="color: #0033ff; font-weight: bold;">if</span> <span style="color: #000000;">&#40;</span>Size<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">x</span> <span style="color: #000066; font-weight: bold;">&amp;</span>lt<span style="color: #000066; font-weight: bold;">;</span> <span style="color: #000000; font-weight:bold;">1</span><span style="color: #000000;">&#41;</span> Size<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">x</span> = <span style="color: #000000; font-weight:bold;">1</span><span style="color: #000066; font-weight: bold;">;</span><br />
<span style="color: #0033ff; font-weight: bold;">if</span> <span style="color: #000000;">&#40;</span>Size<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">y</span> <span style="color: #000066; font-weight: bold;">&amp;</span>lt<span style="color: #000066; font-weight: bold;">;</span> <span style="color: #000000; font-weight:bold;">1</span><span style="color: #000000;">&#41;</span> Size<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">y</span> = <span style="color: #000000; font-weight:bold;">1</span><span style="color: #000066; font-weight: bold;">;</span><br />
_blobSize = Size<span style="color: #000066; font-weight: bold;">;</span><br />
<span style="color: #000000;">&#125;</span><br />
<br />
<span style="color: #3f5fbf;">/**<br />
* Set &lt;code&gt;alpha&lt;/code&gt; to set the alpha of the emitted blobs.<br />
*/</span><br />
<span style="color: #0033ff; font-weight: bold;">public</span> <span style="color: #339966; font-weight: bold;">function</span> <span style="color: #0033ff; font-weight: bold;">get</span> <span style="color: #004993;">alpha</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">:</span><span style="color: #004993;">Number</span><br />
<span style="color: #000000;">&#123;</span><br />
<span style="color: #0033ff; font-weight: bold;">return</span> _alpha<span style="color: #000066; font-weight: bold;">;</span><br />
<span style="color: #000000;">&#125;</span><br />
<br />
<span style="color: #3f5fbf;">/**<br />
* Set &lt;code&gt;alpha&lt;/code&gt; to set the alpha of the emitted blobs. &nbsp;Valid 0.1 - 1.<br />
*/</span><br />
<span style="color: #0033ff; font-weight: bold;">public</span> <span style="color: #339966; font-weight: bold;">function</span> <span style="color: #0033ff; font-weight: bold;">set</span> <span style="color: #004993;">alpha</span><span style="color: #000000;">&#40;</span>Alpha<span style="color: #000066; font-weight: bold;">:</span><span style="color: #004993;">Number</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">:</span><span style="color: #0033ff; font-weight: bold;">void</span><br />
<span style="color: #000000;">&#123;</span><br />
<span style="color: #0033ff; font-weight: bold;">if</span> <span style="color: #000000;">&#40;</span>Alpha <span style="color: #000066; font-weight: bold;">&amp;</span>gt<span style="color: #000066; font-weight: bold;">;</span> <span style="color: #000000; font-weight:bold;">1</span><span style="color: #000000;">&#41;</span> Alpha = <span style="color: #000000; font-weight:bold;">1</span><span style="color: #000066; font-weight: bold;">;</span><br />
<span style="color: #0033ff; font-weight: bold;">else</span> <span style="color: #0033ff; font-weight: bold;">if</span> <span style="color: #000000;">&#40;</span>Alpha <span style="color: #000066; font-weight: bold;">&amp;</span>lt<span style="color: #000066; font-weight: bold;">;</span> <span style="color: #000000; font-weight:bold;">0.1</span><span style="color: #000000;">&#41;</span> Alpha = <span style="color: #000000; font-weight:bold;">0.1</span><span style="color: #000066; font-weight: bold;">;</span><br />
_alpha = Alpha<span style="color: #000066; font-weight: bold;">;</span><br />
<span style="color: #000000;">&#125;</span><br />
<br />
<span style="color: #3f5fbf;">/**<br />
* &lt;code&gt;blobCount&lt;/code&gt; is the number of Blobs the system determined it will make for this displacement<br />
*/</span><br />
<span style="color: #0033ff; font-weight: bold;">public</span> <span style="color: #339966; font-weight: bold;">function</span> <span style="color: #0033ff; font-weight: bold;">get</span> blobCount<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">:</span><span style="color: #004993;">uint</span><br />
<span style="color: #000000;">&#123;</span><br />
<span style="color: #0033ff; font-weight: bold;">return</span> _blobCount<span style="color: #000066; font-weight: bold;">;</span><br />
<span style="color: #000000;">&#125;</span><br />
<br />
<span style="color: #0033ff; font-weight: bold;">public</span> <span style="color: #339966; font-weight: bold;">function</span> <span style="color: #0033ff; font-weight: bold;">set</span> blobCount<span style="color: #000000;">&#40;</span>BlobCount<span style="color: #000066; font-weight: bold;">:</span><span style="color: #004993;">uint</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">:</span><span style="color: #0033ff; font-weight: bold;">void</span><br />
<span style="color: #000000;">&#123;</span><br />
_blobCount = BlobCount<span style="color: #000066; font-weight: bold;">;</span><br />
setBlobCount<span style="color: #000000;">&#40;</span>_blobCount<span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span><br />
<span style="color: #000000;">&#125;</span><br />
<br />
<span style="color: #3f5fbf;">/**<br />
* Set &lt;code&gt;life&lt;/code&gt; to determine the lifespan of emitted blobs<br />
*/</span><br />
<span style="color: #0033ff; font-weight: bold;">public</span> <span style="color: #339966; font-weight: bold;">function</span> <span style="color: #0033ff; font-weight: bold;">get</span> life<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">:</span><span style="color: #004993;">Number</span><br />
<span style="color: #000000;">&#123;</span><br />
<span style="color: #0033ff; font-weight: bold;">return</span> _life<span style="color: #000066; font-weight: bold;">;</span><br />
<span style="color: #000000;">&#125;</span><br />
<br />
<span style="color: #3f5fbf;">/**<br />
* Set &lt;code&gt;life&lt;/code&gt; to determine the lifespan of emitted blobs<br />
*/</span><br />
<span style="color: #0033ff; font-weight: bold;">public</span> <span style="color: #339966; font-weight: bold;">function</span> <span style="color: #0033ff; font-weight: bold;">set</span> life<span style="color: #000000;">&#40;</span>Life<span style="color: #000066; font-weight: bold;">:</span><span style="color: #004993;">Number</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">:</span><span style="color: #0033ff; font-weight: bold;">void</span><br />
<span style="color: #000000;">&#123;</span><br />
<span style="color: #0033ff; font-weight: bold;">if</span> <span style="color: #000000;">&#40;</span>Life <span style="color: #000066; font-weight: bold;">&amp;</span>lt<span style="color: #000066; font-weight: bold;">;</span> <span style="color: #000066; font-weight: bold;">-</span><span style="color: #000000; font-weight:bold;">1</span><span style="color: #000000;">&#41;</span> Life = <span style="color: #000066; font-weight: bold;">-</span><span style="color: #000000; font-weight:bold;">1</span><span style="color: #000066; font-weight: bold;">;</span><br />
_life = Life<span style="color: #000066; font-weight: bold;">;</span><br />
<span style="color: #000000;">&#125;</span><br />
<br />
<span style="color: #3f5fbf;">/**<br />
* Set &lt;code&gt;displaceAmtX&lt;/code&gt; to change the amount of displacement you want on the X axis.<br />
*/</span><br />
<span style="color: #0033ff; font-weight: bold;">public</span> <span style="color: #339966; font-weight: bold;">function</span> <span style="color: #0033ff; font-weight: bold;">get</span> displaceAmtX<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">:</span><span style="color: #004993;">Number</span><br />
<span style="color: #000000;">&#123;</span><br />
<span style="color: #0033ff; font-weight: bold;">return</span> _displaceAmt<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">x</span><span style="color: #000066; font-weight: bold;">;</span><br />
<span style="color: #000000;">&#125;</span><br />
<br />
<span style="color: #3f5fbf;">/**<br />
* Set &lt;code&gt;displaceAmtX&lt;/code&gt; to change the amount of displacement you want on the X axis.<br />
*/</span><br />
<span style="color: #0033ff; font-weight: bold;">public</span> <span style="color: #339966; font-weight: bold;">function</span> <span style="color: #0033ff; font-weight: bold;">set</span> displaceAmtX<span style="color: #000000;">&#40;</span>Amt<span style="color: #000066; font-weight: bold;">:</span><span style="color: #004993;">Number</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">:</span><span style="color: #0033ff; font-weight: bold;">void</span><br />
<span style="color: #000000;">&#123;</span><br />
_displaceAmt<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">x</span> = Amt<span style="color: #000066; font-weight: bold;">;</span><br />
<span style="color: #000000;">&#125;</span><br />
<br />
<span style="color: #3f5fbf;">/**<br />
* Set &lt;code&gt;displaceAmtY&lt;/code&gt; to change the amount of displacement you want on the Y axis.<br />
*/</span><br />
<span style="color: #0033ff; font-weight: bold;">public</span> <span style="color: #339966; font-weight: bold;">function</span> <span style="color: #0033ff; font-weight: bold;">get</span> displaceAmtY<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">:</span><span style="color: #004993;">Number</span><br />
<span style="color: #000000;">&#123;</span><br />
<span style="color: #0033ff; font-weight: bold;">return</span> _displaceAmt<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">y</span><span style="color: #000066; font-weight: bold;">;</span><br />
<span style="color: #000000;">&#125;</span><br />
<br />
<span style="color: #3f5fbf;">/**<br />
* Set &lt;code&gt;displaceAmtY&lt;/code&gt; to change the amount of displacement you want on the Y axis.<br />
*/</span><br />
<span style="color: #0033ff; font-weight: bold;">public</span> <span style="color: #339966; font-weight: bold;">function</span> <span style="color: #0033ff; font-weight: bold;">set</span> displaceAmtY<span style="color: #000000;">&#40;</span>Amt<span style="color: #000066; font-weight: bold;">:</span><span style="color: #004993;">Number</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">:</span><span style="color: #0033ff; font-weight: bold;">void</span><br />
<span style="color: #000000;">&#123;</span><br />
_displaceAmt<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">y</span> = Amt<span style="color: #000066; font-weight: bold;">;</span><br />
<span style="color: #000000;">&#125;</span><br />
<br />
override <span style="color: #0033ff; font-weight: bold;">protected</span> <span style="color: #339966; font-weight: bold;">function</span> updateEmitter<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">:</span><span style="color: #0033ff; font-weight: bold;">void</span><br />
<span style="color: #000000;">&#123;</span><br />
<span style="color: #0033ff; font-weight: bold;">if</span> <span style="color: #000000;">&#40;</span><span style="color: #000066; font-weight: bold;">!</span>on <span style="color: #000066; font-weight: bold;">||</span> dead <span style="color: #000066; font-weight: bold;">||</span> <span style="color: #000066; font-weight: bold;">!</span>exists <span style="color: #000066; font-weight: bold;">||</span> <span style="color: #000066; font-weight: bold;">!</span>onScreen<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><span style="color: #000000;">&#41;</span> <span style="color: #0033ff; font-weight: bold;">return</span><span style="color: #000066; font-weight: bold;">;</span><br />
<span style="color: #0033ff; font-weight: bold;">for</span> <span style="color: #000000;">&#40;</span><span style="color: #6699cc; font-weight: bold;">var</span> i<span style="color: #000066; font-weight: bold;">:</span><span style="color: #004993;">int</span> = <span style="color: #000000; font-weight:bold;">0</span><span style="color: #000066; font-weight: bold;">;</span> i <span style="color: #000066; font-weight: bold;">&amp;</span>lt<span style="color: #000066; font-weight: bold;">;</span> &nbsp;<span style="color: #004993;">int</span><span style="color: #000000;">&#40;</span>_blobCount <span style="color: #000066; font-weight: bold;">/</span> <span style="color: #000000;">&#40;</span>_life <span style="color: #000066; font-weight: bold;">/</span> FlxG<span style="color: #000066; font-weight: bold;">.</span>elapsed<span style="color: #000000;">&#41;</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span> i<span style="color: #000066; font-weight: bold;">++</span><span style="color: #000000;">&#41;</span><br />
emitParticle<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span><br />
<span style="color: #000000;">&#125;</span><br />
<br />
<span style="color: #3f5fbf;">/**<br />
* Call this function to start emitting.<br />
*/</span><br />
<span style="color: #0033ff; font-weight: bold;">public</span> <span style="color: #339966; font-weight: bold;">function</span> begin<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">:</span><span style="color: #0033ff; font-weight: bold;">void</span><br />
<span style="color: #000000;">&#123;</span><br />
<span style="color: #004993;">start</span><span style="color: #000000;">&#40;</span><span style="color: #0033ff; font-weight: bold;">false</span><span style="color: #000066; font-weight: bold;">,</span> <span style="color: #000000; font-weight:bold;">1</span><span style="color: #000066; font-weight: bold;">,</span><span style="color: #000000; font-weight:bold;">0</span> <span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span><br />
<span style="color: #000000;">&#125;</span><br />
<br />
<span style="color: #3f5fbf;">/**<br />
* Call this function to stop emitting.<br />
*/</span><br />
<span style="color: #0033ff; font-weight: bold;">public</span> <span style="color: #339966; font-weight: bold;">function</span> end<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">:</span><span style="color: #0033ff; font-weight: bold;">void</span><br />
<span style="color: #000000;">&#123;</span><br />
<span style="color: #004993;">stop</span><span style="color: #000000;">&#40;</span><span style="color: #000000; font-weight:bold;">0</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span><br />
<span style="color: #000000;">&#125;</span><br />
<br />
<span style="color: #3f5fbf;">/**<br />
* Call this function to reset the emitter<br />
* @param&nbsp; X The X position of the emitter<br />
* @param&nbsp; Y The Y position of the emitter<br />
*/</span><br />
override <span style="color: #0033ff; font-weight: bold;">public</span> <span style="color: #339966; font-weight: bold;">function</span> <span style="color: #004993;">reset</span><span style="color: #000000;">&#40;</span>X<span style="color: #000066; font-weight: bold;">:</span><span style="color: #004993;">Number</span><span style="color: #000066; font-weight: bold;">,</span> Y<span style="color: #000066; font-weight: bold;">:</span><span style="color: #004993;">Number</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">:</span><span style="color: #0033ff; font-weight: bold;">void</span><br />
<span style="color: #000000;">&#123;</span><br />
<span style="color: #0033ff; font-weight: bold;">super</span><span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">reset</span><span style="color: #000000;">&#40;</span>X<span style="color: #000066; font-weight: bold;">,</span> Y<span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span><br />
<span style="color: #0033ff; font-weight: bold;">for</span> <span style="color: #0033ff; font-weight: bold;">each</span> <span style="color: #000000;">&#40;</span><span style="color: #6699cc; font-weight: bold;">var</span> e<span style="color: #000066; font-weight: bold;">:</span>DisplaceBlob <span style="color: #0033ff; font-weight: bold;">in</span> members<span style="color: #000000;">&#41;</span> e<span style="color: #000066; font-weight: bold;">.</span>rebuild<span style="color: #000000;">&#40;</span><span style="color: #000000; font-weight:bold;">0</span><span style="color: #000066; font-weight: bold;">,</span> <span style="color: #000000; font-weight:bold;">0</span><span style="color: #000066; font-weight: bold;">,</span> _blobSize<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">x</span><span style="color: #000066; font-weight: bold;">,</span> _blobSize<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">y</span><span style="color: #000066; font-weight: bold;">,</span> _life<span style="color: #000066; font-weight: bold;">,</span> _displaceAmt<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">x</span><span style="color: #000066; font-weight: bold;">,</span> _displaceAmt<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">y</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span><br />
<span style="color: #000000;">&#125;</span><br />
<br />
<span style="color: #3f5fbf;">/**<br />
* Call this function to spit out ONE particle.<br />
*/</span><br />
override <span style="color: #0033ff; font-weight: bold;">public</span> <span style="color: #339966; font-weight: bold;">function</span> emitParticle<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">:</span><span style="color: #0033ff; font-weight: bold;">void</span><br />
<span style="color: #000000;">&#123;</span><br />
<span style="color: #0033ff; font-weight: bold;">if</span> <span style="color: #000000;">&#40;</span><span style="color: #000066; font-weight: bold;">!</span>onScreen<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><span style="color: #000000;">&#41;</span> <span style="color: #0033ff; font-weight: bold;">return</span><span style="color: #000066; font-weight: bold;">;</span><br />
_counter<span style="color: #000066; font-weight: bold;">++;</span><br />
<span style="color: #6699cc; font-weight: bold;">var</span> s<span style="color: #000066; font-weight: bold;">:</span>DisplaceBlob = getFirstAvail<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span> <span style="color: #0033ff; font-weight: bold;">as</span> DisplaceBlob<span style="color: #000066; font-weight: bold;">;</span><br />
<span style="color: #0033ff; font-weight: bold;">if</span> <span style="color: #000000;">&#40;</span><span style="color: #000066; font-weight: bold;">!</span>s<span style="color: #000000;">&#41;</span> <span style="color: #0033ff; font-weight: bold;">return</span><span style="color: #000066; font-weight: bold;">;</span><br />
s<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">visible</span> = <span style="color: #0033ff; font-weight: bold;">true</span><span style="color: #000066; font-weight: bold;">;</span><br />
s<span style="color: #000066; font-weight: bold;">.</span>exists = <span style="color: #0033ff; font-weight: bold;">true</span><span style="color: #000066; font-weight: bold;">;</span><br />
s<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">active</span> = <span style="color: #0033ff; font-weight: bold;">true</span><span style="color: #000066; font-weight: bold;">;</span><br />
s<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">alpha</span> = _alpha<span style="color: #000066; font-weight: bold;">;</span><br />
s<span style="color: #000066; font-weight: bold;">.</span>blobWidth = _blobSize<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">x</span><span style="color: #000066; font-weight: bold;">;</span><br />
s<span style="color: #000066; font-weight: bold;">.</span>blobHeight = _blobSize<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">y</span><span style="color: #000066; font-weight: bold;">;</span><br />
s<span style="color: #000066; font-weight: bold;">.</span>life = _life<span style="color: #000066; font-weight: bold;">;</span><br />
s<span style="color: #000066; font-weight: bold;">.</span>displaceAmtX = _displaceAmt<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">x</span><span style="color: #000066; font-weight: bold;">;</span><br />
s<span style="color: #000066; font-weight: bold;">.</span>displaceAmtY = _displaceAmt<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">y</span><span style="color: #000066; font-weight: bold;">;</span><br />
s<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">x</span> = <span style="color: #004993;">x</span> <span style="color: #000066; font-weight: bold;">-</span> <span style="color: #000000;">&#40;</span>s<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">width</span> <span style="color: #000066; font-weight: bold;">&amp;</span>gt<span style="color: #000066; font-weight: bold;">;&amp;</span>gt<span style="color: #000066; font-weight: bold;">;</span> <span style="color: #000000; font-weight:bold;">1</span><span style="color: #000000;">&#41;</span> <span style="color: #000066; font-weight: bold;">+</span> FlxU<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">random</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span> <span style="color: #000066; font-weight: bold;">*</span> <span style="color: #004993;">width</span><span style="color: #000066; font-weight: bold;">;</span><br />
s<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">y</span> = <span style="color: #004993;">y</span> <span style="color: #000066; font-weight: bold;">-</span> <span style="color: #000000;">&#40;</span>s<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">height</span> <span style="color: #000066; font-weight: bold;">&amp;</span>gt<span style="color: #000066; font-weight: bold;">;&amp;</span>gt<span style="color: #000066; font-weight: bold;">;</span> <span style="color: #000000; font-weight:bold;">1</span><span style="color: #000000;">&#41;</span> <span style="color: #000066; font-weight: bold;">+</span> FlxU<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">random</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span> <span style="color: #000066; font-weight: bold;">*</span> <span style="color: #004993;">height</span><span style="color: #000066; font-weight: bold;">;</span><br />
s<span style="color: #000066; font-weight: bold;">.</span>velocity<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">x</span> = minParticleSpeed<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">x</span><span style="color: #000066; font-weight: bold;">;</span><br />
<span style="color: #0033ff; font-weight: bold;">if</span> <span style="color: #000000;">&#40;</span>minParticleSpeed<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">x</span> <span style="color: #000066; font-weight: bold;">!</span>= maxParticleSpeed<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">x</span><span style="color: #000000;">&#41;</span> s<span style="color: #000066; font-weight: bold;">.</span>velocity<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">x</span> <span style="color: #000066; font-weight: bold;">+</span>= FlxU<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">random</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span> <span style="color: #000066; font-weight: bold;">*</span> <span style="color: #000000;">&#40;</span>maxParticleSpeed<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">x</span> <span style="color: #000066; font-weight: bold;">-</span> minParticleSpeed<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">x</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span><br />
s<span style="color: #000066; font-weight: bold;">.</span>velocity<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">y</span> = minParticleSpeed<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">y</span><span style="color: #000066; font-weight: bold;">;</span><br />
<span style="color: #0033ff; font-weight: bold;">if</span> <span style="color: #000000;">&#40;</span>minParticleSpeed<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">y</span> <span style="color: #000066; font-weight: bold;">!</span>= maxParticleSpeed<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">y</span><span style="color: #000000;">&#41;</span> s<span style="color: #000066; font-weight: bold;">.</span>velocity<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">y</span> <span style="color: #000066; font-weight: bold;">+</span>= FlxU<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">random</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span> <span style="color: #000066; font-weight: bold;">*</span> <span style="color: #000000;">&#40;</span>maxParticleSpeed<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">y</span> <span style="color: #000066; font-weight: bold;">-</span> minParticleSpeed<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">y</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span><br />
s<span style="color: #000066; font-weight: bold;">.</span>acceleration<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">y</span> = gravity<span style="color: #000066; font-weight: bold;">;</span><br />
s<span style="color: #000066; font-weight: bold;">.</span>angularVelocity = minRotation<span style="color: #000066; font-weight: bold;">;</span><br />
<span style="color: #0033ff; font-weight: bold;">if</span> <span style="color: #000000;">&#40;</span>minRotation <span style="color: #000066; font-weight: bold;">!</span>= maxRotation<span style="color: #000000;">&#41;</span> s<span style="color: #000066; font-weight: bold;">.</span>angularVelocity <span style="color: #000066; font-weight: bold;">+</span>= FlxU<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">random</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span> <span style="color: #000066; font-weight: bold;">*</span> <span style="color: #000000;">&#40;</span>maxRotation <span style="color: #000066; font-weight: bold;">-</span> minRotation<span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span><br />
<span style="color: #0033ff; font-weight: bold;">if</span> <span style="color: #000000;">&#40;</span>s<span style="color: #000066; font-weight: bold;">.</span>angularVelocity <span style="color: #000066; font-weight: bold;">!</span>= <span style="color: #000000; font-weight:bold;">0</span><span style="color: #000000;">&#41;</span> s<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">angle</span> = FlxU<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">random</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span> <span style="color: #000066; font-weight: bold;">*</span> <span style="color: #000000; font-weight:bold;">360</span> <span style="color: #000066; font-weight: bold;">-</span> <span style="color: #000000; font-weight:bold;">180</span><span style="color: #000066; font-weight: bold;">;</span><br />
s<span style="color: #000066; font-weight: bold;">.</span>drag<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">x</span> = particleDrag<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">x</span><span style="color: #000066; font-weight: bold;">;</span><br />
s<span style="color: #000066; font-weight: bold;">.</span>drag<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">y</span> = particleDrag<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">y</span><span style="color: #000066; font-weight: bold;">;</span><br />
s<span style="color: #000066; font-weight: bold;">.</span>onEmit<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span><br />
justEmitted = <span style="color: #0033ff; font-weight: bold;">true</span><span style="color: #000066; font-weight: bold;">;</span><br />
<span style="color: #000000;">&#125;</span><br />
<br />
<span style="color: #0033ff; font-weight: bold;">public</span> <span style="color: #339966; font-weight: bold;">function</span> emitRing<span style="color: #000000;">&#40;</span>X<span style="color: #000066; font-weight: bold;">:</span><span style="color: #004993;">int</span><span style="color: #000066; font-weight: bold;">,</span> Y<span style="color: #000066; font-weight: bold;">:</span><span style="color: #004993;">int</span><span style="color: #000066; font-weight: bold;">,</span> Velocity<span style="color: #000066; font-weight: bold;">:</span><span style="color: #004993;">Number</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">:</span><span style="color: #0033ff; font-weight: bold;">void</span><br />
<span style="color: #000000;">&#123;</span><br />
<br />
<span style="color: #0033ff; font-weight: bold;">for</span> <span style="color: #000000;">&#40;</span><span style="color: #6699cc; font-weight: bold;">var</span> <span style="color: #004993;">b</span><span style="color: #000066; font-weight: bold;">:</span><span style="color: #004993;">uint</span> = <span style="color: #000000; font-weight:bold;">0</span><span style="color: #000066; font-weight: bold;">;</span> <span style="color: #004993;">b</span> <span style="color: #000066; font-weight: bold;">&amp;</span>lt<span style="color: #000066; font-weight: bold;">;</span> members<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">length</span><span style="color: #000066; font-weight: bold;">;</span> <span style="color: #004993;">b</span><span style="color: #000066; font-weight: bold;">++</span><span style="color: #000000;">&#41;</span><br />
<span style="color: #000000;">&#123;</span><br />
<span style="color: #6699cc; font-weight: bold;">var</span> blob<span style="color: #000066; font-weight: bold;">:</span>DisplaceBlob = members<span style="color: #000000;">&#91;</span><span style="color: #004993;">b</span><span style="color: #000000;">&#93;</span> <span style="color: #0033ff; font-weight: bold;">as</span> DisplaceBlob<span style="color: #000066; font-weight: bold;">;</span><br />
<span style="color: #6699cc; font-weight: bold;">var</span> angleIncrement<span style="color: #000066; font-weight: bold;">:</span><span style="color: #004993;">Number</span> = <span style="color: #000000; font-weight:bold;">360</span> <span style="color: #000066; font-weight: bold;">/</span> members<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">length</span><span style="color: #000066; font-weight: bold;">;</span><br />
<span style="color: #0033ff; font-weight: bold;">if</span> <span style="color: #000000;">&#40;</span><span style="color: #000066; font-weight: bold;">!</span>blob<span style="color: #000000;">&#41;</span> <span style="color: #0033ff; font-weight: bold;">return</span><span style="color: #000066; font-weight: bold;">;</span><br />
blob<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">visible</span> = <span style="color: #0033ff; font-weight: bold;">true</span><span style="color: #000066; font-weight: bold;">;</span><br />
blob<span style="color: #000066; font-weight: bold;">.</span>exists = <span style="color: #0033ff; font-weight: bold;">true</span><span style="color: #000066; font-weight: bold;">;</span><br />
blob<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">active</span> = <span style="color: #0033ff; font-weight: bold;">true</span><span style="color: #000066; font-weight: bold;">;</span><br />
blob<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">alpha</span> = _alpha<span style="color: #000066; font-weight: bold;">;</span><br />
blob<span style="color: #000066; font-weight: bold;">.</span>blobWidth = _blobSize<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">x</span><span style="color: #000066; font-weight: bold;">;</span><br />
blob<span style="color: #000066; font-weight: bold;">.</span>blobHeight = _blobSize<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">y</span><span style="color: #000066; font-weight: bold;">;</span><br />
blob<span style="color: #000066; font-weight: bold;">.</span>life = _life<span style="color: #000066; font-weight: bold;">;</span><br />
blob<span style="color: #000066; font-weight: bold;">.</span>displaceAmtX = _displaceAmt<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">x</span><span style="color: #000066; font-weight: bold;">;</span><br />
blob<span style="color: #000066; font-weight: bold;">.</span>displaceAmtY = _displaceAmt<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">y</span><span style="color: #000066; font-weight: bold;">;</span><br />
blob<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">x</span> = X<span style="color: #000066; font-weight: bold;">;</span><br />
blob<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">y</span> = Y<span style="color: #000066; font-weight: bold;">;</span><br />
blob<span style="color: #000066; font-weight: bold;">.</span>velocity<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">x</span> = <span style="color: #004993;">Math</span><span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">sin</span><span style="color: #000000;">&#40;</span><span style="color: #004993;">b</span><span style="color: #000066; font-weight: bold;">*</span>angleIncrement<span style="color: #000000;">&#41;</span> <span style="color: #000066; font-weight: bold;">*</span> Velocity<span style="color: #000066; font-weight: bold;">;</span><br />
blob<span style="color: #000066; font-weight: bold;">.</span>velocity<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">y</span> = <span style="color: #004993;">Math</span><span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">cos</span><span style="color: #000000;">&#40;</span><span style="color: #004993;">b</span><span style="color: #000066; font-weight: bold;">*</span>angleIncrement<span style="color: #000000;">&#41;</span> <span style="color: #000066; font-weight: bold;">*</span> Velocity<span style="color: #000066; font-weight: bold;">;</span><br />
blob<span style="color: #000066; font-weight: bold;">.</span>acceleration<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">y</span> = gravity<span style="color: #000066; font-weight: bold;">;</span><br />
blob<span style="color: #000066; font-weight: bold;">.</span>drag<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">x</span> = particleDrag<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">x</span><span style="color: #000066; font-weight: bold;">;</span><br />
blob<span style="color: #000066; font-weight: bold;">.</span>drag<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">y</span> = particleDrag<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">y</span><span style="color: #000066; font-weight: bold;">;</span><br />
blob<span style="color: #000066; font-weight: bold;">.</span>onEmit<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span><br />
<span style="color: #000000;">&#125;</span><br />
justEmitted = <span style="color: #0033ff; font-weight: bold;">true</span><span style="color: #000066; font-weight: bold;">;</span><br />
<span style="color: #000000;">&#125;</span><br />
<span style="color: #000000;">&#125;</span><br />
<br />
<span style="color: #000000;">&#125;</span></div></div>
<p>You can use these classes in any of your own projects and for any purpose, or you can tear them apart and make your own! Have fun! If you would like to see the source code for the demo above, you can grab it from Git Hub: <a href="http://github.com/Rybar/Displacement">http://github.com/Rybar/Displacement</a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.tileisle.net/flixel-showcase-displacement-effects/feed/</wfw:commentRss>
		<slash:comments>9</slash:comments>
		</item>
		<item>
		<title>Project in Progress</title>
		<link>http://www.tileisle.net/project-in-progress/</link>
		<comments>http://www.tileisle.net/project-in-progress/#comments</comments>
		<pubDate>Thu, 15 Jul 2010 20:23:44 +0000</pubDate>
		<dc:creator>Tim</dc:creator>
				<category><![CDATA[Games]]></category>
		<category><![CDATA[Site]]></category>
		<category><![CDATA[code]]></category>
		<category><![CDATA[effects]]></category>
		<category><![CDATA[Flixel]]></category>
		<category><![CDATA[news]]></category>
		<category><![CDATA[samples]]></category>
		<category><![CDATA[site]]></category>
		<category><![CDATA[upcoming]]></category>
		<category><![CDATA[update]]></category>

		<guid isPermaLink="false">http://www.tileisle.net/?p=175</guid>
		<description><![CDATA[The Tile Isle crew has been hard at work on a new project and we wanted to show you a little bit of what we&#8217;ve been working on. We&#8217;re still using the Flixel framework, and we&#8217;ve added some of our own tricks to add some awesome effects. We&#8217;ve had 2 talented people join the team: [...]]]></description>
			<content:encoded><![CDATA[<p>The <strong>Tile Isle</strong> crew has been hard at work on a new project and we wanted to show you a little bit of what we&#8217;ve been working on.</p>
<p>We&#8217;re still using the <a href="http://flixel.org/">Flixel</a> framework, and we&#8217;ve added some of our own tricks to add some awesome effects.</p>
<p>We&#8217;ve had 2 talented people join the team: <a href="http://niklofide.net/">Ryan Malm</a> has been working on the code and coming up with some great stuff, and <a href="http://parsakoira.deviantart.com/">Kari Kuukasjärvi</a> who has been working on concept art. </p>
<p>Over the coming weeks, we&#8217;ll be talking about and highlighting some of the features and effects we&#8217;ve implemented.  Stay tuned!</p>
]]></content:encoded>
			<wfw:commentRss>http://www.tileisle.net/project-in-progress/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Release: Blasting Agent Soundtrack – FREE</title>
		<link>http://www.tileisle.net/release-blasting-agent-soundtrack-free/</link>
		<comments>http://www.tileisle.net/release-blasting-agent-soundtrack-free/#comments</comments>
		<pubDate>Wed, 23 Jun 2010 18:23:33 +0000</pubDate>
		<dc:creator>Tim</dc:creator>
				<category><![CDATA[Blasting Agent]]></category>
		<category><![CDATA[Games]]></category>
		<category><![CDATA[Site]]></category>
		<category><![CDATA[download]]></category>
		<category><![CDATA[game]]></category>
		<category><![CDATA[music]]></category>
		<category><![CDATA[release]]></category>
		<category><![CDATA[soundtrack]]></category>

		<guid isPermaLink="false">http://www.tileisle.net/?p=139</guid>
		<description><![CDATA[Well, we tried the donation method, and didn&#8217;t get any takers, so we&#8217;ve decided to release the Blasting Agent Soundtrack for FREE over on Bandcamp! Head on over and download the entire album for free! (Donations still welcome, if you want to help us out )]]></description>
			<content:encoded><![CDATA[<p><a href="http://www.tileisle.net/wp-content/uploads/cover.jpg"><img src="http://www.tileisle.net/wp-content/uploads/cover-300x300.jpg" alt="" title="cover" width="300" height="300" class="alignleft size-medium wp-image-162" /></a>Well, we tried the donation method, and didn&#8217;t get any takers, so we&#8217;ve decided to release the Blasting Agent Soundtrack for FREE over on <a href="http://tileisle.bandcamp.com/">Bandcamp</a>!</p>
<p>Head on over and download the entire album for free! (Donations still welcome, if you want to help us out <img src='http://www.tileisle.net/wp-includes/images/smilies/icon_wink.gif' alt=';)' class='wp-smiley' /> )</p>
]]></content:encoded>
			<wfw:commentRss>http://www.tileisle.net/release-blasting-agent-soundtrack-free/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>What people are saying about Blasting Agent</title>
		<link>http://www.tileisle.net/what-people-are-saying-about-blasting-agent/</link>
		<comments>http://www.tileisle.net/what-people-are-saying-about-blasting-agent/#comments</comments>
		<pubDate>Wed, 27 Jan 2010 21:44:33 +0000</pubDate>
		<dc:creator>Tim</dc:creator>
				<category><![CDATA[Blasting Agent]]></category>
		<category><![CDATA[Games]]></category>
		<category><![CDATA[Site]]></category>
		<category><![CDATA[game]]></category>
		<category><![CDATA[links]]></category>
		<category><![CDATA[mentions]]></category>
		<category><![CDATA[news]]></category>
		<category><![CDATA[reviews]]></category>
		<category><![CDATA[sites]]></category>
		<category><![CDATA[support]]></category>
		<category><![CDATA[updates]]></category>

		<guid isPermaLink="false">http://www.tileisle.net/?p=92</guid>
		<description><![CDATA[Blasting Agent has been out for a whole month now! We hope you&#8217;ve been enjoying it! You can play Blasting Agent for FREE on Newgrounds, and a number of other places as well! Here are some links to what people are saying about our first game release: PixelProspector: A really great platforming experience! IndieGames.com ( [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://www.tileisle.net/wp-content/uploads/blasting2d.png"><img src="http://www.tileisle.net/wp-content/uploads/blasting2d-150x150.png" alt="" title="Blasting Agent!" width="150" height="150" class="alignright size-thumbnail wp-image-107" /></a><br />
Blasting Agent has been out for a whole month now! We hope you&#8217;ve been enjoying it!</p>
<p>You can play <a href="http://www.newgrounds.com/portal/view/522921"><strong>Blasting Agent</strong> for <em>FREE</em> on <strong>Newgrounds</strong></a>, and a number of other places as well!</p>
<p>Here are some links to what people are saying about our first game release:</p>
<ul>
<li><strong><a href="http://www.pixelprospector.com/indev/2009/10/blasting-agent/">PixelProspector</a>:</strong><br />
<blockquote>A really great platforming experience!</p></blockquote>
</li>
<li><strong><a href="http://www.indiegames.com/blog/2009/12/browser_game_pick_blasting_age.html">IndieGames.com</a> ( and <a href="http://www.indiegames.com/features/index.php?c=pb&#038;y=2009&#038;gid=7">#7 in &#8216;Best Browser Platformer 2009&#8242;</a>!):</strong><br />
<blockquote>nice graphics, fine controls, catchy music and good gameplay.<br />
overall a great platforming experience.<br />
highly recommended!</p></blockquote>
</li>
<li>Mentioned on <strong>ByteJacker Episodes <a href="http://www.bytejacker.com/episodes/069">069</a> &#038; <a href="http://www.bytejacker.com/episodes/070">070</a></strong></li>
<li>Mentioned on <strong><a href="http://www.gamasutra.com/view/news/26653/Best_Of_Indie_Games_It_Came_in_a_Dream.php">Gamasutra</a></strong></li>
<li>Mentioned on <strong><a href="http://">8bitrocket Game Review-Cast</a></strong></li>
<li><strong> Daily 4th Place</strong> on 12/31/2009 on <strong><a href="http://www.newgrounds.com/portal/view/522921">Newgrounds</a></strong></li>
<li><strong>1up.com&#8217;s <a href="http://www.1up.com/do/feature?pager.offset=7&#038;cId=3177782">101 Free Games 2010</a></strong></li>
<li><strong>headcaseGames</strong> <a href="http://headcase-games.blogspot.com/2010/07/iphone-app-game-development-blog-34.html">mentioned us</a> on 7/25/2010</li>
</ul>
<p>Very awesome responses so far! If you know anyone else who has talked about us (good or bad), let us know and we&#8217;ll update this list!</p>
]]></content:encoded>
			<wfw:commentRss>http://www.tileisle.net/what-people-are-saying-about-blasting-agent/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Blasting Agent Released!</title>
		<link>http://www.tileisle.net/blasting-agent-released/</link>
		<comments>http://www.tileisle.net/blasting-agent-released/#comments</comments>
		<pubDate>Tue, 22 Dec 2009 16:52:03 +0000</pubDate>
		<dc:creator>Tim</dc:creator>
				<category><![CDATA[Blasting Agent]]></category>
		<category><![CDATA[Games]]></category>
		<category><![CDATA[game]]></category>
		<category><![CDATA[release]]></category>

		<guid isPermaLink="false">http://tileisle.nfshost.com/?p=45</guid>
		<description><![CDATA[We are excited to announce that Blasting Agent has finally been released! You can play it for free on Kongregate: Play Blasting Agent Enjoy!]]></description>
			<content:encoded><![CDATA[<p>We are excited to announce that Blasting Agent has finally been released!</p>
<dl id="attachment_46" class="wp-caption aligncenter" style="width: 485px"><dt><img src="http://tileisle.nfshost.com/wp-content/uploads/BA_screen_01.png" alt="Blasting Agent" title="Blasting Agent" width="640" height="480" class="size-full wp-image-46" /></dt><dd class="wp-caption-text">Blasting Agent</dd></dl>
<p>You can play it for free on Kongregate:</p>
<p><a href="http://www.kongregate.com/games/SeiferTim/blasting-agent?sfa=permalink&#038;referrer=SeiferTim">Play Blasting Agent</a></p>
<p>Enjoy!</p>
]]></content:encoded>
			<wfw:commentRss>http://www.tileisle.net/blasting-agent-released/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Even more Wallpapery goodness!</title>
		<link>http://www.tileisle.net/even-more-wallpapery-goodness/</link>
		<comments>http://www.tileisle.net/even-more-wallpapery-goodness/#comments</comments>
		<pubDate>Fri, 18 Dec 2009 17:08:43 +0000</pubDate>
		<dc:creator>Tim</dc:creator>
				<category><![CDATA[Blasting Agent]]></category>
		<category><![CDATA[Games]]></category>
		<category><![CDATA[download]]></category>
		<category><![CDATA[free]]></category>
		<category><![CDATA[wallpaper]]></category>

		<guid isPermaLink="false">http://tileisle.nfshost.com/?p=40</guid>
		<description><![CDATA[Don&#8217;t let your computer go naked this holiday season &#8211; celebrate our first game with another Blasting Agent wallpaper! This one comes in two flavors: Traditional &#8220;1024&#215;768&#8243;, or the exotic &#8220;1440&#215;900&#8243; take your pick, or try them both! Contains 900% of your recommended daily awesome. Side effects include Screen Envy Syndrome, drymouth, Severe Sensory Overload, [...]]]></description>
			<content:encoded><![CDATA[<p>Don&#8217;t let your computer go naked this holiday season &#8211; celebrate our first game with another Blasting Agent wallpaper!</p>
<p>This one comes in two flavors: Traditional &#8220;1024&#215;768&#8243;, or the exotic &#8220;1440&#215;900&#8243; take your pick, or try them both! </p>
<p><small>Contains 900% of your recommended daily awesome. Side effects include Screen Envy Syndrome, drymouth, Severe Sensory Overload, dizziness, Spontaneous Monitor Explosion, and death. Consult with your doctor if you currently seek treatment for high levels of awesome or if side effects occur.</small></p>
<p><a href="http://tileisle.nfshost.com/Bonus/BlastingAgent-wallpaper-1024x768.png"><img alt="" src="http://tileisle.nfshost.com/Bonus/BlastingAgent-wallpaper-1024x768.png" title="Blasting Agent Wallpaper 1024x768" class="aligncenter" width="160" height="128" /></a></p>
<p><a href="http://tileisle.nfshost.com/Bonus/BlastingAgent-wallpaper-1440x900.png"><img alt="" src="http://tileisle.nfshost.com/Bonus/BlastingAgent-wallpaper-1440x900.png" title="Blasting Agent Wallpaper 1440x900 " class="aligncenter" width="144" height="90" /></a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.tileisle.net/even-more-wallpapery-goodness/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Special Blasting Agent Wallpaper</title>
		<link>http://www.tileisle.net/special-blasting-agent-wallpaper/</link>
		<comments>http://www.tileisle.net/special-blasting-agent-wallpaper/#comments</comments>
		<pubDate>Fri, 04 Dec 2009 21:00:43 +0000</pubDate>
		<dc:creator>Tim</dc:creator>
				<category><![CDATA[Blasting Agent]]></category>
		<category><![CDATA[Games]]></category>
		<category><![CDATA[download]]></category>
		<category><![CDATA[free]]></category>
		<category><![CDATA[wallpaper]]></category>

		<guid isPermaLink="false">http://tileisle.nfshost.com/?p=35</guid>
		<description><![CDATA[To Celebrate the imminent release of Blasting Agent, here&#8217;s a Special Wallpaper! Enjoy!]]></description>
			<content:encoded><![CDATA[<p>To Celebrate the imminent release of Blasting Agent, here&#8217;s a Special Wallpaper! Enjoy!</p>
<p><a href="http://tileisle.nfshost.com/bhf_wallpaper.png"><img alt="" src="http://tileisle.nfshost.com/bhf_wallpaper.png" title="BHF Wallpaper " class="aligncenter" width="160" height="128" /></a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.tileisle.net/special-blasting-agent-wallpaper/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
	</channel>
</rss>

