<?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>
	<pubDate>Sat, 31 Jul 2010 12:06:33 +0000</pubDate>
	<generator>http://wordpress.org/?v=2.7</generator>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
		<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>"Where?
More exakt plz? =)"

Hi Kalle, put that code I posted in the Ship class in the loop() method right before the "y += vy;" 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 &#62; 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: 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'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 &#62; 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'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 = "headlightson" and "headlightsoff" 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 &#62; stage.stageWidth)
				x = 0;
			else if (x  stage.stageHeight)
				y = 0;
			else if (y &#60; 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&#60;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 ("hit");
	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 (&#8221;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>
	<item>
		<title>By: DMennenoh</title>
		<link>http://asgamer.com/2009/asteroids-style-movement-firing-lasers/comment-page-1#comment-4604</link>
		<dc:creator>DMennenoh</dc:creator>
		<pubDate>Mon, 30 Nov 2009 15:47:17 +0000</pubDate>
		<guid isPermaLink="false">http://asgamer.com/?p=494#comment-4604</guid>
		<description>Nice! I was going to say you just need to add the ships initial velocity to the lasers when they're created, but looks like Par answered it already. 

I just finished a version of the original asteroids...
http://www.blurredistinction.com/test/roids.htm</description>
		<content:encoded><![CDATA[<p>Nice! I was going to say you just need to add the ships initial velocity to the lasers when they&#8217;re created, but looks like Par answered it already. </p>
<p>I just finished a version of the original asteroids&#8230;<br />
<a href="http://www.blurredistinction.com/test/roids.htm" rel="nofollow">http://www.blurredistinction.com/test/roids.htm</a></p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Par</title>
		<link>http://asgamer.com/2009/asteroids-style-movement-firing-lasers/comment-page-1#comment-4593</link>
		<dc:creator>Par</dc:creator>
		<pubDate>Thu, 19 Nov 2009 14:08:02 +0000</pubDate>
		<guid isPermaLink="false">http://asgamer.com/?p=494#comment-4593</guid>
		<description>:D, yes, I think I understand now. I agree with what you said earlier except I'd take care of all the updating in the constructor instead of the loop.

For everyone else wanting this effect:

Just add the vx and vy of the ship to the constructor of the laser. Then when you setup the laser's vx and vy in the constructor just add the vx and vy from the ship to it. This will screw up the rotation a bit so you'd need to adjust it but past that it will work as intended.</description>
		<content:encoded><![CDATA[<p>:D, yes, I think I understand now. I agree with what you said earlier except I&#8217;d take care of all the updating in the constructor instead of the loop.</p>
<p>For everyone else wanting this effect:</p>
<p>Just add the vx and vy of the ship to the constructor of the laser. Then when you setup the laser&#8217;s vx and vy in the constructor just add the vx and vy from the ship to it. This will screw up the rotation a bit so you&#8217;d need to adjust it but past that it will work as intended.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Aro</title>
		<link>http://asgamer.com/2009/asteroids-style-movement-firing-lasers/comment-page-1#comment-4592</link>
		<dc:creator>Aro</dc:creator>
		<pubDate>Thu, 19 Nov 2009 04:06:59 +0000</pubDate>
		<guid isPermaLink="false">http://asgamer.com/?p=494#comment-4592</guid>
		<description>Lol! Par I would be on the lookout for any stalkers if I were you :D.</description>
		<content:encoded><![CDATA[<p>Lol! Par I would be on the lookout for any stalkers if I were you :D.</p>
]]></content:encoded>
	</item>
</channel>
</rss>
