<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	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:series="http://unfoldingneurons.com/"
		>
<channel>
	<title>Comments on: AS3 Avoider Game Tutorial, Part 2: Multiple Enemies</title>
	<atom:link href="http://gamedev.michaeljameswilliams.com/2008/09/22/avoider-game-tutorial-2/feed/" rel="self" type="application/rss+xml" />
	<link>http://gamedev.michaeljameswilliams.com/2008/09/22/avoider-game-tutorial-2/?utm_source=rss&amp;utm_medium=rss&amp;utm_campaign=avoider-game-tutorial-2</link>
	<description>I help people make Flash games</description>
	<lastBuildDate>Wed, 08 Sep 2010 09:17:37 +0000</lastBuildDate>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0.1</generator>
	<item>
		<title>By: Michael Williams</title>
		<link>http://gamedev.michaeljameswilliams.com/2008/09/22/avoider-game-tutorial-2/comment-page-3/#comment-4501</link>
		<dc:creator>Michael Williams</dc:creator>
		<pubDate>Fri, 20 Aug 2010 23:27:01 +0000</pubDate>
		<guid isPermaLink="false">http://gamedev.michaeljameswilliams.com/?p=112#comment-4501</guid>
		<description>&lt;p&gt;Hey PlayHermit. I&#039;m reading them, just a little behind on them -- sorry!&lt;/p&gt;

&lt;p&gt;Think about it this way: since the lowest value that Math.random() can be is 0, the lowest value that absoluteX can be using your code above is (0 * 370) = 0. But you need the lowest value to be, what, 15? 25? (I don&#039;t know the width of your avatar.)&lt;/p&gt;

&lt;p&gt;Hope that hint helps :)&lt;/p&gt;
</description>
		<content:encoded><![CDATA[<p>Hey PlayHermit. I&#8217;m reading them, just a little behind on them &#8212; sorry!</p>

<p>Think about it this way: since the lowest value that Math.random() can be is 0, the lowest value that absoluteX can be using your code above is (0 * 370) = 0. But you need the lowest value to be, what, 15? 25? (I don&#8217;t know the width of your avatar.)</p>

<p>Hope that hint helps <img src='http://gamedev.michaeljameswilliams.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>]]></content:encoded>
	</item>
	<item>
		<title>By: PlayHermit</title>
		<link>http://gamedev.michaeljameswilliams.com/2008/09/22/avoider-game-tutorial-2/comment-page-3/#comment-4442</link>
		<dc:creator>PlayHermit</dc:creator>
		<pubDate>Sun, 01 Aug 2010 19:04:01 +0000</pubDate>
		<guid isPermaLink="false">http://gamedev.michaeljameswilliams.com/?p=112#comment-4442</guid>
		<description>&lt;p&gt;I hope you&#039;re still reading these comments MJW. I tried to get the little end activity and I figured out how to get the starting enemy to appear at random places, but I could never figure out how to keep them from only spawning within the box and not appear off the screen.&lt;/p&gt;

&lt;p&gt;I thought just modifying the x value would do the trick but I guess theres more to it, right?&lt;/p&gt;

&lt;p&gt;&lt;pre&gt;
var randomX:Number = Math.random() * 370;
var newEnemy:Enemy = new Enemy( randomX, -15 );
&lt;/pre&gt;&lt;/p&gt;

&lt;p&gt;As you can see, I attempted to fix the problem by lowering the the number in the first line from 400 to 370 but they&#039;re still popping up a little off the screen. =(&lt;/p&gt;
</description>
		<content:encoded><![CDATA[<p>I hope you&#8217;re still reading these comments MJW. I tried to get the little end activity and I figured out how to get the starting enemy to appear at random places, but I could never figure out how to keep them from only spawning within the box and not appear off the screen.</p>

<p>I thought just modifying the x value would do the trick but I guess theres more to it, right?</p>

<p><pre>
var randomX:Number = Math.random() * 370;
var newEnemy:Enemy = new Enemy( randomX, -15 );
</pre></p>

<p>As you can see, I attempted to fix the problem by lowering the the number in the first line from 400 to 370 but they&#8217;re still popping up a little off the screen. =(</p>

<span class="cluv">PlayHermit&#180;s last blog ..<a href="http://www.youtube.com/watch?v=HBp_9onxt6o&amp;feature=youtube_gdata">Gameplay &#8211; Pokemon Stadium 2- Defeating Bugsy</a><span class="heart_tip_box"><img class="heart_tip -1" alt="My ComLuv Profile" border="0" width="16" height="14" src="http://gamedev.michaeljameswilliams.com/wp-content/plugins/commentluv/images/littleheart.gif"/></span></span>]]></content:encoded>
	</item>
	<item>
		<title>By: Michael Williams</title>
		<link>http://gamedev.michaeljameswilliams.com/2008/09/22/avoider-game-tutorial-2/comment-page-3/#comment-4342</link>
		<dc:creator>Michael Williams</dc:creator>
		<pubDate>Wed, 07 Jul 2010 17:55:50 +0000</pubDate>
		<guid isPermaLink="false">http://gamedev.michaeljameswilliams.com/?p=112#comment-4342</guid>
		<description>&lt;p&gt;Let&#039;s hope so :)&lt;/p&gt;
</description>
		<content:encoded><![CDATA[<p>Let&#8217;s hope so <img src='http://gamedev.michaeljameswilliams.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>]]></content:encoded>
	</item>
	<item>
		<title>By: ayumilove</title>
		<link>http://gamedev.michaeljameswilliams.com/2008/09/22/avoider-game-tutorial-2/comment-page-3/#comment-4332</link>
		<dc:creator>ayumilove</dc:creator>
		<pubDate>Tue, 06 Jul 2010 02:15:42 +0000</pubDate>
		<guid isPermaLink="false">http://gamedev.michaeljameswilliams.com/?p=112#comment-4332</guid>
		<description>&lt;p&gt;I did not receive his .fla  and .as files
So I think he has a way to manage that problem ;)&lt;/p&gt;
</description>
		<content:encoded><![CDATA[<p>I did not receive his .fla  and .as files
So I think he has a way to manage that problem <img src='http://gamedev.michaeljameswilliams.com/wp-includes/images/smilies/icon_wink.gif' alt=';)' class='wp-smiley' /> </p>]]></content:encoded>
	</item>
	<item>
		<title>By: Michael Williams</title>
		<link>http://gamedev.michaeljameswilliams.com/2008/09/22/avoider-game-tutorial-2/comment-page-3/#comment-4325</link>
		<dc:creator>Michael Williams</dc:creator>
		<pubDate>Mon, 05 Jul 2010 18:48:23 +0000</pubDate>
		<guid isPermaLink="false">http://gamedev.michaeljameswilliams.com/?p=112#comment-4325</guid>
		<description>&lt;p&gt;@Callum: Not sure what you mean... did ayumilove&#039;s comment about &lt;code&gt;army.length&lt;/code&gt; help?&lt;/p&gt;

&lt;p&gt;@Jake: That is weird :S Higher number should cause higher lag... maybe your curly braces are in the wrong place? If ayumilove&#039;s generous offer of help doesn&#039;t solve it, post again :)&lt;/p&gt;
</description>
		<content:encoded><![CDATA[<p>@Callum: Not sure what you mean&#8230; did ayumilove&#8217;s comment about <code>army.length</code> help?</p>

<p>@Jake: That is weird :S Higher number should cause higher lag&#8230; maybe your <acronym title="Brackets that look like this: { }">curly braces</acronym> are in the wrong place? If ayumilove&#8217;s generous offer of help doesn&#8217;t solve it, post again <img src='http://gamedev.michaeljameswilliams.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>]]></content:encoded>
	</item>
	<item>
		<title>By: ayumilove</title>
		<link>http://gamedev.michaeljameswilliams.com/2008/09/22/avoider-game-tutorial-2/comment-page-3/#comment-4307</link>
		<dc:creator>ayumilove</dc:creator>
		<pubDate>Tue, 29 Jun 2010 23:51:50 +0000</pubDate>
		<guid isPermaLink="false">http://gamedev.michaeljameswilliams.com/?p=112#comment-4307</guid>
		<description>&lt;p&gt;Don&#039;t know, send me your .fla to my email so I could check it out :)
email : ayumiyoutube(at)gmail(d0t)com&lt;/p&gt;
</description>
		<content:encoded><![CDATA[<p>Don&#8217;t know, send me your .fla to my email so I could check it out <img src='http://gamedev.michaeljameswilliams.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> 
email : ayumiyoutube(at)gmail(d0t)com</p>]]></content:encoded>
	</item>
	<item>
		<title>By: Jake</title>
		<link>http://gamedev.michaeljameswilliams.com/2008/09/22/avoider-game-tutorial-2/comment-page-3/#comment-4306</link>
		<dc:creator>Jake</dc:creator>
		<pubDate>Tue, 29 Jun 2010 21:22:24 +0000</pubDate>
		<guid isPermaLink="false">http://gamedev.michaeljameswilliams.com/?p=112#comment-4306</guid>
		<description>&lt;p&gt;@ayumilove
When I put it at 0.1 or less, it lags a ton. The higher the number it is, the less the lag is, but the enemies per second is the same. Know what&#039;s up?&lt;/p&gt;

&lt;p&gt;Thanks!&lt;/p&gt;
</description>
		<content:encoded><![CDATA[<p>@ayumilove
When I put it at 0.1 or less, it lags a ton. The higher the number it is, the less the lag is, but the enemies per second is the same. Know what&#8217;s up?</p>

<p>Thanks!</p>]]></content:encoded>
	</item>
	<item>
		<title>By: ayumilove</title>
		<link>http://gamedev.michaeljameswilliams.com/2008/09/22/avoider-game-tutorial-2/comment-page-3/#comment-4303</link>
		<dc:creator>ayumilove</dc:creator>
		<pubDate>Tue, 29 Jun 2010 04:23:48 +0000</pubDate>
		<guid isPermaLink="false">http://gamedev.michaeljameswilliams.com/?p=112#comment-4303</guid>
		<description>&lt;p&gt;@Jake
sorry, I don&#039;t understand what&#039;s your question about, so I can&#039;t really help you.
Probability of enemy spawning is only from the range of zero to one. Not ten (10).&lt;/p&gt;

&lt;p&gt;I don&#039;t see any errors in your code, should be fine.&lt;/p&gt;
</description>
		<content:encoded><![CDATA[<p>@Jake
sorry, I don&#8217;t understand what&#8217;s your question about, so I can&#8217;t really help you.
Probability of enemy spawning is only from the range of zero to one. Not ten (10).</p>

<p>I don&#8217;t see any errors in your code, should be fine.</p>]]></content:encoded>
	</item>
	<item>
		<title>By: Jake</title>
		<link>http://gamedev.michaeljameswilliams.com/2008/09/22/avoider-game-tutorial-2/comment-page-3/#comment-4302</link>
		<dc:creator>Jake</dc:creator>
		<pubDate>Tue, 29 Jun 2010 01:59:02 +0000</pubDate>
		<guid isPermaLink="false">http://gamedev.michaeljameswilliams.com/?p=112#comment-4302</guid>
		<description>&lt;p&gt;Okay, I can get everything working until the end. Whenever I do &lt;pre&gt;if ( Math.random() &lt; 0.1 )&lt;/pre&gt; part I get tons of lag. If I bring it to say, 10, it doesn&#039;t at all. The time that they&#039;re going down doesn&#039;t change at all, it seems to basiclly only change lag or no lag. Here&#039;s my code...&lt;/p&gt;

&lt;p&gt;&lt;/pre&gt;package
{
    import flash.display.MovieClip;
    import flash.utils.Timer;
    import flash.events.TimerEvent;&lt;/p&gt;

&lt;p&gt;&lt;pre&gt;&lt;code&gt;public class AvoiderGame extends MovieClip
{
    public var army:Array
    public var avatar:Avatar;
    public var gameTimer:Timer;
    public function AvoiderGame()
    {
        army = new Array();
        var newEnemy = new Enemy(100, -15);
        army.push( newEnemy );
        addChild( newEnemy );
        avatar = new Avatar();
        addChild( avatar );
        avatar.x = mouseX;
        avatar.y = mouseY;
        gameTimer = new Timer( 25 );
        gameTimer.addEventListener( TimerEvent.TIMER, onTick );
        gameTimer.start();
    }&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;public function onTick( timerEvent:TimerEvent ):void    
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/p&gt;

&lt;p&gt;{ if (Math.random() &lt; 0.1 )
    {
        var randomX:Number = Math.random() * 600;
        var newEnemy:Enemy = new Enemy( randomX, -15 );
        army.push( newEnemy );
        addChild( newEnemy );
        for each ( var enemy:Enemy in army )&lt;/p&gt;

&lt;p&gt;&lt;pre&gt;&lt;code&gt;    {
    enemy.moveDownABit();
    if ( avatar.hitTestObject( enemy ) ) 
    { gameTimer.stop();&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;    }

}

avatar.x = mouseX;
avatar.y = mouseY
}
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;}
&lt;/code&gt;&lt;/pre&gt;&lt;/p&gt;

&lt;p&gt;}
    }&lt;/pre&gt;&lt;/p&gt;

&lt;p&gt;any help would be appreciated, thanks!&lt;/p&gt;

&lt;p&gt;Jake&lt;/p&gt;
</description>
		<content:encoded><![CDATA[<p>Okay, I can get everything working until the end. Whenever I do <pre>if ( Math.random() &lt; 0.1 )</pre> part I get tons of lag. If I bring it to say, 10, it doesn&#8217;t at all. The time that they&#8217;re going down doesn&#8217;t change at all, it seems to basiclly only change lag or no lag. Here&#8217;s my code&#8230;</p>

<p>package
{
    import flash.display.MovieClip;
    import flash.utils.Timer;
    import flash.events.TimerEvent;</p>

<p><pre><code>public class AvoiderGame extends MovieClip
{
    public var army:Array
    public var avatar:Avatar;
    public var gameTimer:Timer;
    public function AvoiderGame()
    {
        army = new Array();
        var newEnemy = new Enemy(100, -15);
        army.push( newEnemy );
        addChild( newEnemy );
        avatar = new Avatar();
        addChild( avatar );
        avatar.x = mouseX;
        avatar.y = mouseY;
        gameTimer = new Timer( 25 );
        gameTimer.addEventListener( TimerEvent.TIMER, onTick );
        gameTimer.start();
    }</code></pre></p>

<pre><code>public function onTick( timerEvent:TimerEvent ):void    
</code></pre>

<p></p>

<p>{ if (Math.random() &lt; 0.1 )
    {
        var randomX:Number = Math.random() * 600;
        var newEnemy:Enemy = new Enemy( randomX, -15 );
        army.push( newEnemy );
        addChild( newEnemy );
        for each ( var enemy:Enemy in army )</p>

<p><pre><code>    {
    enemy.moveDownABit();
    if ( avatar.hitTestObject( enemy ) ) 
    { gameTimer.stop();</code></pre></p>

<pre><code>    }

}

avatar.x = mouseX;
avatar.y = mouseY
}
</code></pre>

<p>}
</p>

<p>}
    }</p>

<p>any help would be appreciated, thanks!</p>

<p>Jake</p>]]></content:encoded>
	</item>
	<item>
		<title>By: ayumilove</title>
		<link>http://gamedev.michaeljameswilliams.com/2008/09/22/avoider-game-tutorial-2/comment-page-3/#comment-4297</link>
		<dc:creator>ayumilove</dc:creator>
		<pubDate>Sun, 27 Jun 2010 02:56:05 +0000</pubDate>
		<guid isPermaLink="false">http://gamedev.michaeljameswilliams.com/?p=112#comment-4297</guid>
		<description>&lt;p&gt;You can set a constant value of 10 (as shown below) to limit the enemies that can be on screen.
&lt;pre&gt;if ( Math.random() &lt; 0.1 &amp;&amp; army.length &lt; 10) { /* spawn enemy */ }&lt;/pre&gt;&lt;/p&gt;

&lt;p&gt;The previous method that you used, (changing the value of 0.1 in Math.random)
simply increases/decreases the probability of the enemy spawn. The bigger the number (closing in to 1) has higher chance to spawn an enemy compare to the lower number (closing in to zero)&lt;/p&gt;
</description>
		<content:encoded><![CDATA[<p>You can set a constant value of 10 (as shown below) to limit the enemies that can be on screen.
<pre>if ( Math.random() &lt; 0.1 &amp;&amp; army.length &lt; 10) { /* spawn enemy */ }</pre></p>

<p>The previous method that you used, (changing the value of 0.1 in Math.random)
simply increases/decreases the probability of the enemy spawn. The bigger the number (closing in to 1) has higher chance to spawn an enemy compare to the lower number (closing in to zero)</p>]]></content:encoded>
	</item>
</channel>
</rss>
