<?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: smart.rockets</title>
	<atom:link href="http://blog.blprnt.com/blog/blprnt/smart-rockets/feed" rel="self" type="application/rss+xml" />
	<link>http://blog.blprnt.com/blog/blprnt/smart-rockets</link>
	<description>Jer Thorp &#124; There is an art to evolution...</description>
	<lastBuildDate>Mon, 30 Jan 2012 23:06:08 +0000</lastBuildDate>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	
	<item>
		<title>By: unknown</title>
		<link>http://blog.blprnt.com/blog/blprnt/smart-rockets/comment-page-#comment-100</link>
		<dc:creator>unknown</dc:creator>
		<pubDate>Thu, 01 Jan 1970 00:00:00 +0000</pubDate>
		<guid isPermaLink="false">#comment-100</guid>
		<description>haaa.. this is really fun to&lt;br /&gt;haaa.. this is really fun to watch.. and it would make a good screen-saver: back from the coffee break and see how smart the rockets became..</description>
		<content:encoded><![CDATA[<p>haaa.. this is really fun to<br />haaa.. this is really fun to watch.. and it would make a good screen-saver: back from the coffee break and see how smart the rockets became..</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: unknown</title>
		<link>http://blog.blprnt.com/blog/blprnt/smart-rockets/comment-page-#comment-101</link>
		<dc:creator>unknown</dc:creator>
		<pubDate>Thu, 01 Jan 1970 00:00:00 +0000</pubDate>
		<guid isPermaLink="false">#comment-101</guid>
		<description>Source code&lt;br /&gt;Quick question about the source code: While I&#039;d love to see it all, what I really want to know is how you drew the paths of each rocket. I&#039;m willing to wade thru the source if that&#039;s easier for you.</description>
		<content:encoded><![CDATA[<p>Source code<br />Quick question about the source code: While I&#39;d love to see it all, what I really want to know is how you drew the paths of each rocket. I&#39;m willing to wade thru the source if that&#39;s easier for you.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: unknown</title>
		<link>http://blog.blprnt.com/blog/blprnt/smart-rockets/comment-page-#comment-102</link>
		<dc:creator>unknown</dc:creator>
		<pubDate>Thu, 01 Jan 1970 00:00:00 +0000</pubDate>
		<guid isPermaLink="false">#comment-102</guid>
		<description>There are two parts to the&lt;br /&gt;There are two parts to the path-drawing:

1) Actually drawing the rocket paths, using the drawing API
2) Dumping the paths to a bitmap object periodically to prevent memory drain
3) Slowly changing the colour of the paths to get some distinction between generations.

1: In order for the rockets to draw their paths, they simply draw a line using the drawing API from their last known position to their current position. All of the rocket paths are drawn to the same MC, named &#039;thecanvas_mc&#039;. This code is, of course, called once per frame.

&lt;blockquote&gt;&lt;i&gt;
_root.thecanvas_mc.moveTo(lastx, lasty);
_root.thecanvas_mc.lineTo(_x, _y);
lastx = _x;
lasty = _y;
&lt;/blockquote&gt;&lt;/i&gt;

2: With 25 rockets drawing a line once per frame, the sheer number of lines rises very quicky. Within a second, we have 750 lines. This will get out of control fast, draggin down the speed of our program. To remedy this, we &#039;dump&#039; the line data from thecanvas_mc into a BitmapData object. This BitmapData object is rendered to screen.

I am using an instance of my Canvas Class, which is available &lt;a href=&quot;http://www.blprnt.com/transfer/CanvasClass.zip&quot;&gt;here&lt;/a&gt;.

&lt;blockquote&gt;&lt;i&gt;
//setup:
var can = new Canvas(_root);

//drawing:
doDraw = function() {
	can.etch(thecanvas_mc);
	thecanvas_mc.clear();
};

setInterval(doDraw, 100);
&lt;/blockquote&gt;&lt;/i&gt;

3: To create a color gradient in the lines that are drawn, I simply adjust the values of R,G &amp; B in the lines that are being drawn:

&lt;blockquote&gt;&lt;i&gt;
//setup:
r = 0;
g = 0;
b = 0;
rv = Math.random() / 10;
gv = Math.random() /10;
bv = Math.random() /10;

//drawing:
doDraw = function() {
	can.etch(thecanvas_mc);
	thecanvas_mc.clear();
	
	r += rv;
	g += gv;
	b += bv;
	
	var c = argbtohex(25,r,g,b);
	thecanvas_mc.lineStyle(1, c, 10);
};
&lt;/blockquote&gt;&lt;/i&gt;

Hopefully this helps. If you still want to see the whole source, let me know.

-Jer</description>
		<content:encoded><![CDATA[<p>There are two parts to the<br />There are two parts to the path-drawing:</p>
<p>1) Actually drawing the rocket paths, using the drawing API<br />
2) Dumping the paths to a bitmap object periodically to prevent memory drain<br />
3) Slowly changing the colour of the paths to get some distinction between generations.</p>
<p>1: In order for the rockets to draw their paths, they simply draw a line using the drawing API from their last known position to their current position. All of the rocket paths are drawn to the same MC, named &#8216;thecanvas_mc&#8217;. This code is, of course, called once per frame.</p>
<blockquote><p><i><br />
_root.thecanvas_mc.moveTo(lastx, lasty);<br />
_root.thecanvas_mc.lineTo(_x, _y);<br />
lastx = _x;<br />
lasty = _y;<br />
</i></p></blockquote>
<p>2: With 25 rockets drawing a line once per frame, the sheer number of lines rises very quicky. Within a second, we have 750 lines. This will get out of control fast, draggin down the speed of our program. To remedy this, we &#8216;dump&#8217; the line data from thecanvas_mc into a BitmapData object. This BitmapData object is rendered to screen.</p>
<p>I am using an instance of my Canvas Class, which is available <a href="http://www.blprnt.com/transfer/CanvasClass.zip">here</a>.</p>
<blockquote><p><i><br />
//setup:<br />
var can = new Canvas(_root);</p>
<p>//drawing:<br />
doDraw = function() {<br />
	can.etch(thecanvas_mc);<br />
	thecanvas_mc.clear();<br />
};</p>
<p>setInterval(doDraw, 100);<br />
</i></p></blockquote>
<p>3: To create a color gradient in the lines that are drawn, I simply adjust the values of R,G &#038; B in the lines that are being drawn:</p>
<blockquote><p><i><br />
//setup:<br />
r = 0;<br />
g = 0;<br />
b = 0;<br />
rv = Math.random() / 10;<br />
gv = Math.random() /10;<br />
bv = Math.random() /10;</p>
<p>//drawing:<br />
doDraw = function() {<br />
	can.etch(thecanvas_mc);<br />
	thecanvas_mc.clear();</p>
<p>	r += rv;<br />
	g += gv;<br />
	b += bv;</p>
<p>	var c = argbtohex(25,r,g,b);<br />
	thecanvas_mc.lineStyle(1, c, 10);<br />
};<br />
</i></p></blockquote>
<p>Hopefully this helps. If you still want to see the whole source, let me know.</p>
<p>-Jer</p>
]]></content:encoded>
	</item>
</channel>
</rss>

