<?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/"
		>
<channel>
	<title>Comments on: Asteroids Style Movement&#8230; Now with Firing Lasers</title>
	<atom:link href="http://asgamer.com/2009/asteroids-style-movement-firing-lasers/feed" rel="self" type="application/rss+xml" />
	<link>http://asgamer.com/2009/asteroids-style-movement-firing-lasers</link>
	<description>Learn to Make Flash Games, Applications, and Websites</description>
	<lastBuildDate>Fri, 16 Dec 2011 19:32:19 +0000</lastBuildDate>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
	<item>
		<title>By: shah</title>
		<link>http://asgamer.com/2009/asteroids-style-movement-firing-lasers/comment-page-1#comment-5402</link>
		<dc:creator>shah</dc:creator>
		<pubDate>Sun, 06 Feb 2011 16:11:34 +0000</pubDate>
		<guid isPermaLink="false">http://asgamer.com/?p=494#comment-5402</guid>
		<description>Hi i was wondering how i could add objects flying towards it to be shot at?</description>
		<content:encoded><![CDATA[<p>Hi i was wondering how i could add objects flying towards it to be shot at?</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: gotoAndStop</title>
		<link>http://asgamer.com/2009/asteroids-style-movement-firing-lasers/comment-page-1#comment-5200</link>
		<dc:creator>gotoAndStop</dc:creator>
		<pubDate>Tue, 10 Aug 2010 13:54:32 +0000</pubDate>
		<guid isPermaLink="false">http://asgamer.com/?p=494#comment-5200</guid>
		<description>I&#039;m trying to add flames while the ship is flying. When forward button is pressed the flame appears from the center of the ship and when the right or left button is pressed the flame appears from the right or left side of the ship, I&#039;m using gotoAndStop, but it only shows frame by the last pressed button, if I press two keys at same time I see onnly one flame. What should I do to see two frames at the same time?</description>
		<content:encoded><![CDATA[<p>I&#8217;m trying to add flames while the ship is flying. When forward button is pressed the flame appears from the center of the ship and when the right or left button is pressed the flame appears from the right or left side of the ship, I&#8217;m using gotoAndStop, but it only shows frame by the last pressed button, if I press two keys at same time I see onnly one flame. What should I do to see two frames at the same time?</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Ramen Studios</title>
		<link>http://asgamer.com/2009/asteroids-style-movement-firing-lasers/comment-page-1#comment-5148</link>
		<dc:creator>Ramen Studios</dc:creator>
		<pubDate>Wed, 07 Jul 2010 16:37:31 +0000</pubDate>
		<guid isPermaLink="false">http://asgamer.com/?p=494#comment-5148</guid>
		<description>Is there a way to pause the game and show a menu?...</description>
		<content:encoded><![CDATA[<p>Is there a way to pause the game and show a menu?&#8230;</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Aaron</title>
		<link>http://asgamer.com/2009/asteroids-style-movement-firing-lasers/comment-page-1#comment-5120</link>
		<dc:creator>Aaron</dc:creator>
		<pubDate>Sun, 04 Jul 2010 03:49:36 +0000</pubDate>
		<guid isPermaLink="false">http://asgamer.com/?p=494#comment-5120</guid>
		<description>&quot;Where?
More exakt plz? =)&quot;

Hi Kalle, put that code I posted in the Ship class in the loop() method right before the &quot;y += vy;&quot; line. That should do it!</description>
		<content:encoded><![CDATA[<p>&#8220;Where?<br />
More exakt plz? =)&#8221;</p>
<p>Hi Kalle, put that code I posted in the Ship class in the loop() method right before the &#8220;y += vy;&#8221; line. That should do it!</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Kalle</title>
		<link>http://asgamer.com/2009/asteroids-style-movement-firing-lasers/comment-page-1#comment-4949</link>
		<dc:creator>Kalle</dc:creator>
		<pubDate>Wed, 26 May 2010 13:42:20 +0000</pubDate>
		<guid isPermaLink="false">http://asgamer.com/?p=494#comment-4949</guid>
		<description>I don’t mean to be a hater but you really need a max speed limit for this to be usable as a game. It’s very easy:

// enforce speed limit – find length of vector
// and scale down to maxSpeed if necessary
var currentSpeed:Number = Math.sqrt((vx * vx) + (vy * vy));
if(currentSpeed &gt; maxSpeed){
vx *= maxSpeed / currentSpeed;
vy *= maxSpeed / currentSpeed;
}
___________________________________________________________

Where?
More exakt plz? =)</description>
		<content:encoded><![CDATA[<p>I don’t mean to be a hater but you really need a max speed limit for this to be usable as a game. It’s very easy:</p>
<p>// enforce speed limit – find length of vector<br />
// and scale down to maxSpeed if necessary<br />
var currentSpeed:Number = Math.sqrt((vx * vx) + (vy * vy));<br />
if(currentSpeed &gt; maxSpeed){<br />
vx *= maxSpeed / currentSpeed;<br />
vy *= maxSpeed / currentSpeed;<br />
}<br />
___________________________________________________________</p>
<p>Where?<br />
More exakt plz? =)</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Quintus Kilsdonk</title>
		<link>http://asgamer.com/2009/asteroids-style-movement-firing-lasers/comment-page-1#comment-4939</link>
		<dc:creator>Quintus Kilsdonk</dc:creator>
		<pubDate>Mon, 24 May 2010 11:46:35 +0000</pubDate>
		<guid isPermaLink="false">http://asgamer.com/?p=494#comment-4939</guid>
		<description>Its just so awsome that you do everything in .as files and not just code it in frames just like 90% of the as3 tutorial writers do.</description>
		<content:encoded><![CDATA[<p>Its just so awsome that you do everything in .as files and not just code it in frames just like 90% of the as3 tutorial writers do.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Aaron</title>
		<link>http://asgamer.com/2009/asteroids-style-movement-firing-lasers/comment-page-1#comment-4926</link>
		<dc:creator>Aaron</dc:creator>
		<pubDate>Sun, 16 May 2010 20:13:37 +0000</pubDate>
		<guid isPermaLink="false">http://asgamer.com/?p=494#comment-4926</guid>
		<description>I don&#039;t mean to be a hater but you really need a max speed limit for this to be usable as a game. It&#039;s very easy:

// enforce speed limit – find length of vector
// and scale down to maxSpeed if necessary
var currentSpeed:Number = Math.sqrt((vx * vx) + (vy * vy));
if(currentSpeed &gt; maxSpeed){
    vx *= maxSpeed / currentSpeed;
    vy *= maxSpeed / currentSpeed;
}</description>
		<content:encoded><![CDATA[<p>I don&#8217;t mean to be a hater but you really need a max speed limit for this to be usable as a game. It&#8217;s very easy:</p>
<p>// enforce speed limit – find length of vector<br />
// and scale down to maxSpeed if necessary<br />
var currentSpeed:Number = Math.sqrt((vx * vx) + (vy * vy));<br />
if(currentSpeed &gt; maxSpeed){<br />
    vx *= maxSpeed / currentSpeed;<br />
    vy *= maxSpeed / currentSpeed;<br />
}</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: pabloR</title>
		<link>http://asgamer.com/2009/asteroids-style-movement-firing-lasers/comment-page-1#comment-4770</link>
		<dc:creator>pabloR</dc:creator>
		<pubDate>Thu, 04 Mar 2010 14:32:42 +0000</pubDate>
		<guid isPermaLink="false">http://asgamer.com/?p=494#comment-4770</guid>
		<description>Hi. I was looking here and there for something like scenarios to flash games. I would like to for example to set how many enemies are to be displayed or their behavior (not only from Math functions) what time they should appear on stage, what they do etc. What i need is just a concept. I came to do it by arrays and inside of them objects with their specifications, but after all every period of time i check in the loop of all array (which can be quite huge), which object carries out the limitations. I&#039;d like to find out how it is done in games. Maybe there is a better way to set up scenario of the game, and not only do the random function to put objects to the stage. 
Regarding to your shooter game tutorials, there could be objects set up behind the scene and going upward by the space ship means the stage goes downward and objects with their x,y positions set up at the beggining of level for example goes down. If they meet y=0 pos. they could do their job. But i think thats not clever (and killing performance probably too) to set up all the objects in the movie even behind the scene...
So that is what im lookin for? 
Just glimpse here in couple days to check for some idea.
Thanks for so great job. I have never seen better tuts for flash programmers.</description>
		<content:encoded><![CDATA[<p>Hi. I was looking here and there for something like scenarios to flash games. I would like to for example to set how many enemies are to be displayed or their behavior (not only from Math functions) what time they should appear on stage, what they do etc. What i need is just a concept. I came to do it by arrays and inside of them objects with their specifications, but after all every period of time i check in the loop of all array (which can be quite huge), which object carries out the limitations. I&#8217;d like to find out how it is done in games. Maybe there is a better way to set up scenario of the game, and not only do the random function to put objects to the stage.<br />
Regarding to your shooter game tutorials, there could be objects set up behind the scene and going upward by the space ship means the stage goes downward and objects with their x,y positions set up at the beggining of level for example goes down. If they meet y=0 pos. they could do their job. But i think thats not clever (and killing performance probably too) to set up all the objects in the movie even behind the scene&#8230;<br />
So that is what im lookin for?<br />
Just glimpse here in couple days to check for some idea.<br />
Thanks for so great job. I have never seen better tuts for flash programmers.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: JimE</title>
		<link>http://asgamer.com/2009/asteroids-style-movement-firing-lasers/comment-page-1#comment-4687</link>
		<dc:creator>JimE</dc:creator>
		<pubDate>Fri, 18 Dec 2009 23:22:01 +0000</pubDate>
		<guid isPermaLink="false">http://asgamer.com/?p=494#comment-4687</guid>
		<description>I have been reading and following along with your tutorials and have found them perhaps the most intelligible yet.  :)  so many thanks for that.

Been working on using them to build a car game. So far, so good. have the engine.as and car.as built and running. Essentially using your ship.as class.

Now here is the thing I have movieclip built for the car.  within it it has movieclip headlights to turn on and off. with frame labels = &quot;headlightson&quot; and &quot;headlightsoff&quot; similar to what you have done with the laser graphics here but included as movieclip inside the car movieclip.

Can I add keyboard event listener to Car.as so that when ctrl key is pressed the label is sent to headlightson (frame2)? and if pressed a second time to play headlightsoff (frame1)?

Sorry for the long post but movieclips within movieclips cause me no amount of troubles..</description>
		<content:encoded><![CDATA[<p>I have been reading and following along with your tutorials and have found them perhaps the most intelligible yet.  <img src='http://asgamer.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' />   so many thanks for that.</p>
<p>Been working on using them to build a car game. So far, so good. have the engine.as and car.as built and running. Essentially using your ship.as class.</p>
<p>Now here is the thing I have movieclip built for the car.  within it it has movieclip headlights to turn on and off. with frame labels = &#8220;headlightson&#8221; and &#8220;headlightsoff&#8221; similar to what you have done with the laser graphics here but included as movieclip inside the car movieclip.</p>
<p>Can I add keyboard event listener to Car.as so that when ctrl key is pressed the label is sent to headlightson (frame2)? and if pressed a second time to play headlightsoff (frame1)?</p>
<p>Sorry for the long post but movieclips within movieclips cause me no amount of troubles..</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: ant</title>
		<link>http://asgamer.com/2009/asteroids-style-movement-firing-lasers/comment-page-1#comment-4607</link>
		<dc:creator>ant</dc:creator>
		<pubDate>Sun, 06 Dec 2009 09:07:35 +0000</pubDate>
		<guid isPermaLink="false">http://asgamer.com/?p=494#comment-4607</guid>
		<description>thank you very much!

I am a super newbie with OOP of AS and followed through your tutorial and very found it very informative.. however, now I at a brick war as I am trying to add rocks and hitTest... can anyone help?

Other than a new class called Rock.as and added a destroy function in ship as well.. the code for the rest is more of less the same..

Has no clue how to identify which rock to test hit

Rock.as
==============================================================
package {
	
	import flash.display.*;
	import flash.events.*;
	
	public class Rock extends MovieClip{
		public var radius:Number;
		public var cnum:Number;
		var radians:Number=0;
		var speed:Number=0;
		
		public function Rock(inputRadius:Number):void {
			radius=inputRadius;
			speed=0.1+0.5*Math.random();
			this.addEventListener (Event.ENTER_FRAME, moveCircle);
		}
		
		public function moveCircle (e:Event) {
			radians += speed;
			
			x+=Math.round(radius*Math.cos(radians))+1;
			y+=Math.round(radius*Math.sin(radians))+1;
			
			if (x &gt; stage.stageWidth)
				x = 0;
			else if (x  stage.stageHeight)
				y = 0;
			else if (y &lt; 0)
				y = stage.stageHeight;
		}
	}
}
============================================================
ship.as (addition)
		public function destroy():void {
			parent.removeChild(this);
			removeEventListener(Event.ENTER_FRAME, loop);
		}
=========================================================
main.fla

import flash.utils.Timer;

var level:int=1;

genRocks();

function genRocks() {
	for (var count:int=0; count&lt;level+2; count++) {
		var randomSize=Math.random()*2;
		var newRock:Rock=new Rock(randomSize);
		addChild(newRock);

		newRock.x=Math.random()*550;
		newRock.y=Math.random()*400;

		newRock.scaleX=Math.random()*2+1.5;
		newRock.scaleY=Math.random()*2+1.5;
	}
}
var gameTimer:Timer=new Timer(30);
gameTimer.addEventListener(TimerEvent.TIMER,gameTimerFunc);
gameTimer.start();

function gameTimerFunc(t:TimerEvent):void{
	if(ship.hitTestObject(newRock)){
	trace (&quot;hit&quot;);
	ship.destroy();
	gameTimer.stop();
	}
}
=================================================

I get undefined property newRock.. please help! thanks!</description>
		<content:encoded><![CDATA[<p>thank you very much!</p>
<p>I am a super newbie with OOP of AS and followed through your tutorial and very found it very informative.. however, now I at a brick war as I am trying to add rocks and hitTest&#8230; can anyone help?</p>
<p>Other than a new class called Rock.as and added a destroy function in ship as well.. the code for the rest is more of less the same..</p>
<p>Has no clue how to identify which rock to test hit</p>
<p>Rock.as<br />
==============================================================<br />
package {</p>
<p>	import flash.display.*;<br />
	import flash.events.*;</p>
<p>	public class Rock extends MovieClip{<br />
		public var radius:Number;<br />
		public var cnum:Number;<br />
		var radians:Number=0;<br />
		var speed:Number=0;</p>
<p>		public function Rock(inputRadius:Number):void {<br />
			radius=inputRadius;<br />
			speed=0.1+0.5*Math.random();<br />
			this.addEventListener (Event.ENTER_FRAME, moveCircle);<br />
		}</p>
<p>		public function moveCircle (e:Event) {<br />
			radians += speed;</p>
<p>			x+=Math.round(radius*Math.cos(radians))+1;<br />
			y+=Math.round(radius*Math.sin(radians))+1;</p>
<p>			if (x &gt; stage.stageWidth)<br />
				x = 0;<br />
			else if (x  stage.stageHeight)<br />
				y = 0;<br />
			else if (y &lt; 0)<br />
				y = stage.stageHeight;<br />
		}<br />
	}<br />
}<br />
============================================================<br />
ship.as (addition)<br />
		public function destroy():void {<br />
			parent.removeChild(this);<br />
			removeEventListener(Event.ENTER_FRAME, loop);<br />
		}<br />
=========================================================<br />
main.fla</p>
<p>import flash.utils.Timer;</p>
<p>var level:int=1;</p>
<p>genRocks();</p>
<p>function genRocks() {<br />
	for (var count:int=0; count&lt;level+2; count++) {<br />
		var randomSize=Math.random()*2;<br />
		var newRock:Rock=new Rock(randomSize);<br />
		addChild(newRock);</p>
<p>		newRock.x=Math.random()*550;<br />
		newRock.y=Math.random()*400;</p>
<p>		newRock.scaleX=Math.random()*2+1.5;<br />
		newRock.scaleY=Math.random()*2+1.5;<br />
	}<br />
}<br />
var gameTimer:Timer=new Timer(30);<br />
gameTimer.addEventListener(TimerEvent.TIMER,gameTimerFunc);<br />
gameTimer.start();</p>
<p>function gameTimerFunc(t:TimerEvent):void{<br />
	if(ship.hitTestObject(newRock)){<br />
	trace (&#8220;hit&#8221;);<br />
	ship.destroy();<br />
	gameTimer.stop();<br />
	}<br />
}<br />
=================================================</p>
<p>I get undefined property newRock.. please help! thanks!</p>
]]></content:encoded>
	</item>
</channel>
</rss>

