<?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>blog.sokay.net &#187; Actionscript</title>
	<atom:link href="http://blog.sokay.net/category/actionscript/feed/" rel="self" type="application/rss+xml" />
	<link>http://blog.sokay.net</link>
	<description>flash game development discussion</description>
	<lastBuildDate>Thu, 19 Aug 2010 16:00:13 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0.1</generator>
		<item>
		<title>New Game: Rush Hour</title>
		<link>http://blog.sokay.net/2009/11/23/new-game-rush-hour/</link>
		<comments>http://blog.sokay.net/2009/11/23/new-game-rush-hour/#comments</comments>
		<pubDate>Tue, 24 Nov 2009 02:31:05 +0000</pubDate>
		<dc:creator>Christopher J. Rock</dc:creator>
				<category><![CDATA[Actionscript]]></category>
		<category><![CDATA[Everything]]></category>
		<category><![CDATA[Flash Development]]></category>
		<category><![CDATA[Flash Gaming]]></category>
		<category><![CDATA[Independent]]></category>
		<category><![CDATA[Sokay Development]]></category>
		<category><![CDATA[bit-blitting]]></category>
		<category><![CDATA[bitmapdata]]></category>
		<category><![CDATA[blit]]></category>
		<category><![CDATA[collision detection]]></category>
		<category><![CDATA[flash]]></category>
		<category><![CDATA[flash game]]></category>
		<category><![CDATA[independent game]]></category>
		<category><![CDATA[indie]]></category>
		<category><![CDATA[indie game]]></category>
		<category><![CDATA[perlin]]></category>
		<category><![CDATA[perlin noise]]></category>
		<category><![CDATA[procedural]]></category>
		<category><![CDATA[rush hour]]></category>
		<category><![CDATA[theo huxtable]]></category>

		<guid isPermaLink="false">http://blog.sokay.net/?p=716</guid>
		<description><![CDATA[Just finished my first game since going solo and it went pretty well. It&#8217;s a pretty simple top-down shooter. I wanted to test myself with a 1 week schedule, but ended up taking 2 weeks. I&#8217;ve put it on Flash Game License. This is the first time I try out their service, but I&#8217;ve only [...]]]></description>
			<content:encoded><![CDATA[<p style="text-align: left;">Just finished my first game since going solo and it went pretty well. It&#8217;s a pretty simple top-down shooter. I wanted to test myself with a 1 week schedule, but ended up taking 2 weeks.</p>
<p style="text-align: center;"><a href="http://blog.sokay.net/wp-content/uploads/2009/11/rushHourScreen01.jpg" target="_blank"><img class="aligncenter" src="http://blog.sokay.net/wp-content/uploads/2009/11/rushHourScreen01.jpg" alt="Rush Hour" width="320" height="240" /></a></p>
<p>I&#8217;ve put it on Flash Game License. This is the first time I try out their service, but I&#8217;ve only heard good things. I&#8217;ll put a link up after the game&#8217;s live.</p>
<p>The soundtrack was done by my brother, Jonathan Rock. After the game&#8217;s out, I&#8217;ll put the music here for download.</p>
<p><span id="more-716"></span> The game is entirely blitted (using a single bitmap display instead of many sprites), which allowed me to fill it with action without any worry of slow-down. The framerate is a solid 30fps. It even seemed to run well at 60fps, but I didn&#8217;t want to alienate anyone on a crappy machine.</p>
<p>You can see in the screenshot that enemy movement is very fluid. That&#8217;s because I used timeline animation to guide everything. This was done with a &#8216;puppet&#8217; system that updated blit data based on played movieClips even though they weren&#8217;t on the stage.</p>
<p>The background was generated from 4 different bitmapData objects. The 3 star layers were scrolled down (bitmapData.scrollTo(x , y)) by a given distance (their velocity) every frame and the gap left at the top was filled by an image of randomly generated stars using the setVector function which is extremely fast. The most efficient way to handle that was to constantly refresh the values of uint vectors with lengths fixed to exactly the value needed to fill the space of each bitmapData object.</p>
<p>There&#8217;s also a layer of perlin noise used to generate the smoky nebula effect that drifts by all the ships. Just as the stars were generated one piece at a time, the perlin noise was generated just at the top as a slice and then scrolled down as it &#8216;moves&#8217;. However I couldn&#8217;t use setVector to generate perlin noise, so I had to have a separate bitmapData object just for generating perlin noise that was only big enough to fill the space left by the constant downward scroll. Each time the perlinNoise function is called, it is passed an offset array so that the noise always represents the portion that should exist above what came before it. I ran into an annoying problem here until I realized that the &#8216;stitch&#8217; argument in the perlinNoise function was set to true and should not have been. Generating perlin noise is very processor intensive, but I was pleased to find that if you generate it just a little bit at a time, you have no problems at all. I would like to use this same technique in the future to create infinitely large maps that are only generated one slice at a time as the player moves in any particular direction.</p>
<p>I based collision detection in this game on my work in the <a href="http://blog.sokay.net/2009/11/02/new-game-bad-bones-to-demo-at-igcw-in-la/">Bad Bones demo</a> I showed at IGCW a couple weeks ago and found the bitmapData based technique to be very effective. Each ship filled a rectangular area which represented itself on a bitmapData object. They filled this area with a color that acted as an ID tag for that specific object. Other objects could then check a specific part of the bitmapData object to see if any other objects are there. The checker finds a specific color registered with a specific object and a collision is detected. The only limitations are that you cannot collision detect outside of the area of the bitmapData object and if you want collision detection for anything other than a rectangular shape, you must get a bit more complicated than the fillRect function (and lose some efficiency). This technique has proven to be so effective that I expect to make it a standard part of my game development process and recommend it to others.</p>
<p>Check back for the full game.</p>
<p>-Christopher J. Rock</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.sokay.net/2009/11/23/new-game-rush-hour/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>My open source Papervision game demo</title>
		<link>http://blog.sokay.net/2008/09/22/my-open-source-papervision-game-demo/</link>
		<comments>http://blog.sokay.net/2008/09/22/my-open-source-papervision-game-demo/#comments</comments>
		<pubDate>Mon, 22 Sep 2008 08:35:49 +0000</pubDate>
		<dc:creator>Bryson Whiteman</dc:creator>
				<category><![CDATA[3d]]></category>
		<category><![CDATA[Actionscript]]></category>
		<category><![CDATA[Flash Development]]></category>
		<category><![CDATA[Sokay Development]]></category>
		<category><![CDATA[animated character]]></category>
		<category><![CDATA[Animation]]></category>
		<category><![CDATA[bomberman]]></category>
		<category><![CDATA[code]]></category>
		<category><![CDATA[friendly integration]]></category>
		<category><![CDATA[game]]></category>
		<category><![CDATA[multiplayer]]></category>
		<category><![CDATA[open source]]></category>
		<category><![CDATA[papervision]]></category>
		<category><![CDATA[papervision game]]></category>
		<category><![CDATA[papervision3d]]></category>
		<category><![CDATA[poy poy]]></category>

		<guid isPermaLink="false">http://blog.sokay.net/?p=425</guid>
		<description><![CDATA[Friendly Integration: click here to play I&#8217;m releasing the source code for a Papervision3D game I was putting together. This project was meant to be an interactive visual for a party my friend threw last weekend, Friendly Integration. This game was meant to be projected onto a wall and controlled with a DDR pad for [...]]]></description>
			<content:encoded><![CDATA[<p style="text-align: center;"><a title="Friendly Integration demo" href="http://blog.sokay.net/stuff/friendly/friendly_04.html"><img class="size-full wp-image-427 aligncenter" title="Friendly Integration screen" src="http://blog.sokay.net/wp-content/uploads/2008/09/friendly_screen.jpg" alt="" width="480" height="345" /></a><br />
<em><a href="http://blog.sokay.net/stuff/friendly/friendly_04.html">Friendly Integration: click here to play</a><br />
</em></p>
<p style="text-align: left;"><img class="size-full wp-image-428" title="DDR Pad" src="http://blog.sokay.net/wp-content/uploads/2008/09/pad.jpg" alt="" width="124" height="124" align="right" />I&#8217;m releasing the source code for a Papervision3D game I was putting together. This project was meant to be an interactive visual for a party my friend threw last weekend, <a title="Friendly Integration party flyer" href="http://www.droidbehavior.com/images/both2.jpg">Friendly Integration</a>. This game was meant to be projected onto a wall and controlled with a DDR pad for each player. There were also plans to have additional panels that could be stepped on that changed the &#8220;theme&#8221; of the game.</p>
<p style="text-align: left;"><span id="more-425"></span></p>
<p style="text-align: left;">
<p style="text-align: left;">Below is a sketch of my initial idea for the project. I wanted to play with the idea of 2 people interacting with each other. Being side by side with the pads I wanted to give the players the ability to be friendly, or the opposite. I didn&#8217;t get to the point of executing these ideas as I barely had enough time available to get the basic engine running.</p>
<p style="text-align: center;"><img class="alignnone size-full wp-image-426" title="Friendly Integration sketch" src="http://blog.sokay.net/wp-content/uploads/2008/09/friendly_scan_sm.jpg" alt="" width="480" height="345" /><br />
<em>Conceptual sketch</em></p>
<p style="text-align: left;">This turned out to be more fun than I expected and I look forward to continuing development on it. It&#8217;s not a priority right now but I learned a lot about Papervision in the 15 hours it took me to put together. I didn&#8217;t get to doing a serious art pass on it which is unfortunate because it&#8217;ll look a lot cooler with some polish.</p>
<p style="text-align: left;">My inspiration for this was <a href="http://en.wikipedia.org/wiki/Bomberman">Bomberman </a>and <a title="Poy Poy" href="http://en.wikipedia.org/wiki/Poy_Poy">Poy Poy</a> for PS1. I lifted the bomb artwork from a <a href="http://sonofbryce.deviantart.com/art/Bomberman-and-his-best-friend-2381426">Bomberman drawing</a> I did a while ago.</p>
<p style="text-align: left;">And the important part&#8230;</p>
<p style="text-align: left;">Play it here: <a href="http://blog.sokay.net/stuff/friendly/friendly_04.html">http://blog.sokay.net/stuff/friendly/friendly_04.html</a></p>
<p style="text-align: left;">Download source: <a href="http://blog.sokay.net/stuff/friendly/friendly_integration_src.zip">friendly_integration_src.zip</a></p>
<p style="text-align: left;">Note: This uses the Papervision3d 2.0 Great White code library. There are some fine video tutorials at <a href="http://gotoandlearn.com/">gotoandlearn.com</a> if you need help getting started with that.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.sokay.net/2008/09/22/my-open-source-papervision-game-demo/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>TraceManager (AS2) Update</title>
		<link>http://blog.sokay.net/2008/08/20/tracemanager-as2-update/</link>
		<comments>http://blog.sokay.net/2008/08/20/tracemanager-as2-update/#comments</comments>
		<pubDate>Wed, 20 Aug 2008 09:00:15 +0000</pubDate>
		<dc:creator>Christopher J. Rock</dc:creator>
				<category><![CDATA[Actionscript]]></category>
		<category><![CDATA[Everything]]></category>
		<category><![CDATA[Sokay Development]]></category>
		<category><![CDATA[actionscript 2.0]]></category>
		<category><![CDATA[AS2]]></category>
		<category><![CDATA[ASSetPropFlags]]></category>
		<category><![CDATA[class iterator]]></category>
		<category><![CDATA[class wrapper]]></category>
		<category><![CDATA[debug]]></category>
		<category><![CDATA[debugging]]></category>
		<category><![CDATA[function wrapper]]></category>
		<category><![CDATA[functionwrapper]]></category>
		<category><![CDATA[manager]]></category>
		<category><![CDATA[method iterator]]></category>
		<category><![CDATA[organization]]></category>
		<category><![CDATA[readability]]></category>
		<category><![CDATA[trace]]></category>
		<category><![CDATA[tracemanager]]></category>
		<category><![CDATA[wrapper]]></category>

		<guid isPermaLink="false">http://blog.sokay.net/?p=269</guid>
		<description><![CDATA[Long, long ago, I posted about my old TraceManager class for supreme debugging, but it was flawed! Hans from ObjectPainters was kind enough to comment with a link to a similar project he had put together. His did not have as much sophistication in its data tracing, but it did have a &#8220;FunctionWrapper.&#8221; His FuncitonWrapper [...]]]></description>
			<content:encoded><![CDATA[<p>Long, long ago, I posted about my old <a title="TraceManager" href="http://blog.sokay.net/2007/10/10/trace-manager/" target="_blank">TraceManager</a> class for supreme debugging, but it was flawed! Hans from <a title="ObjectPainters" href="http://blog.objectpainters.com" target="_blank">ObjectPainters</a> was kind enough to comment with a link to a similar project he had put together. His did not have as much sophistication in its data tracing, but it <em>did</em> have a &#8220;FunctionWrapper.&#8221; His FuncitonWrapper could modify existing functions in run-time (so you don&#8217;t have to) allowing his tracing capabilities to be applied to any function without requiring the programmer to modify actual class files.</p>
<p>Hans was right about the usefulness of a function wrapper, but I didn&#8217;t feel like getting into it . . . until now. A couple days ago I brought up my old TraceManager and decided it was time to revamp it.</p>
<blockquote><p>//Wrap class<br />
traceManager.wrapClass(testClass , &#8220;testClass&#8221;)<br />
//Run class function<br />
var diff:Number = testClass.Subtract(6 , 3 , &#8220;trace:Infinity&#8221;)</p>
<p>The testClass.Subtract() function above was not capable of producing sophisticated trace data until the traceManager.wrapClass modified it and every other function in the testClass class.</p></blockquote>
<p>I&#8217;ve taken Hans&#8217; proposal one step further, by creating a ClassWrapper (using the undocumented <a title="ObjectPainters: AsSetPropFlags" href="http://objectpainters.com/blog/2007/06/21/assetpropflags-explained/" target="_blank">ASSetPropFlags</a>) that will automatically apply tracing capabilities to all functions within a given class instance. Finally, I feel the TraceManager to be a tool that all actionscripters could use in any project:</p>
<p><a href="http://blog.sokay.net/wp-content/uploads/2008/08/tracemanager.zip">TraceManager.zip</a></p>
<p>I&#8217;ve added those 2 new functions, modified formatting a bit, and made a few other slight adjustments. If you used the previous version you probably will barely notice the differences outside of the 2 new wrapper functions. For a review on the basic ideas check out the original post. Now I give you an example of a trace out and will explain use of the new wrappers.<span id="more-269"></span></p>
<p>The formatting here makes it look a little wobbly, but I assure you the actual trace out is nice and neat.</p>
<blockquote><p>TraceManager: traceManager<br />
_________________________________________<br />
Time(seconds):Â Â Â Â Â  Depth:Â  Function:<br />
&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8211;<br />
0.001Â Â Â Â Â Â Â Â Â Â Â Â Â Â  Â Â Â  +0Â Â  Â Â Â  testClass:Subtract : (6,3){<br />
0.001Â Â Â Â Â Â Â Â Â Â Â Â Â Â  Â Â Â  +1Â Â  Â Â Â  .Â Â Â  testClass:LoopFunctions : (6,3){<br />
0.001Â Â Â Â Â Â Â Â Â Â Â Â Â Â  Â Â Â  +2Â Â  Â Â Â  .Â Â Â  .Â Â Â  testClass:Conditional : (6,3,0){<br />
0.001Â Â Â Â Â Â Â Â Â Â Â Â Â Â  Â Â Â  +3Â Â  Â Â Â  .Â Â Â  .Â Â Â  .Â Â Â  testClass:Increment : (3){<br />
0.001Â Â Â Â Â Â Â Â Â Â Â Â Â Â  Â Â Â  -3Â Â  Â Â Â  .Â Â Â  .Â Â Â  .Â Â Â  } (4)<br />
0.001Â Â Â Â Â Â Â Â Â Â Â Â Â Â  Â Â Â  +3Â Â  Â Â Â  .Â Â Â  .Â Â Â  .Â Â Â  testClass:Increment : (0){<br />
0.001Â Â Â Â Â Â Â Â Â Â Â Â Â Â  Â Â Â  -3Â Â  Â Â Â  .Â Â Â  .Â Â Â  .Â Â Â  } (1)<br />
0.001Â Â Â Â Â Â Â Â Â Â Â Â Â Â  Â Â Â  -2Â Â  Â Â Â  .Â Â Â  .Â Â Â  } (4,1)<br />
0.001Â Â Â Â Â Â Â Â Â Â Â Â Â Â  Â Â Â  +2Â Â  Â Â Â  .Â Â Â  .Â Â Â  testClass:Conditional : (6,4,1){<br />
0.001Â Â Â Â Â Â Â Â Â Â Â Â Â Â  Â Â Â  +3Â Â  Â Â Â  .Â Â Â  .Â Â Â  .Â Â Â  testClass:Increment : (4){<br />
0.001Â Â Â Â Â Â Â Â Â Â Â Â Â Â  Â Â Â  -3Â Â  Â Â Â  .Â Â Â  .Â Â Â  .Â Â Â  } (5)<br />
0.001Â Â Â Â Â Â Â Â Â Â Â Â Â Â  Â Â Â  +3Â Â  Â Â Â  .Â Â Â  .Â Â Â  .Â Â Â  testClass:Increment : (1){<br />
0.001Â Â Â Â Â Â Â Â Â Â Â Â Â Â  Â Â Â  -3Â Â  Â Â Â  .Â Â Â  .Â Â Â  .Â Â Â  } (2)<br />
0.001Â Â Â Â Â Â Â Â Â Â Â Â Â Â  Â Â Â  -2Â Â  Â Â Â  .Â Â Â  .Â Â Â  } (5,2)<br />
0.001Â Â Â Â Â Â Â Â Â Â Â Â Â Â  Â Â Â  +2Â Â  Â Â Â  .Â Â Â  .Â Â Â  testClass:Conditional : (6,5,2){<br />
0.001Â Â Â Â Â Â Â Â Â Â Â Â Â Â  Â Â Â  +3Â Â  Â Â Â  .Â Â Â  .Â Â Â  .Â Â Â  testClass:Increment : (5){<br />
0.001Â Â Â Â Â Â Â Â Â Â Â Â Â Â  Â Â Â  -3Â Â  Â Â Â  .Â Â Â  .Â Â Â  .Â Â Â  } (6)<br />
0.001Â Â Â Â Â Â Â Â Â Â Â Â Â Â  Â Â Â  +3Â Â  Â Â Â  .Â Â Â  .Â Â Â  .Â Â Â  testClass:Increment : (2){<br />
0.001Â Â Â Â Â Â Â Â Â Â Â Â Â Â  Â Â Â  -3Â Â  Â Â Â  .Â Â Â  .Â Â Â  .Â Â Â  } (3)<br />
0.001Â Â Â Â Â Â Â Â Â Â Â Â Â Â  Â Â Â  -2Â Â  Â Â Â  .Â Â Â  .Â Â Â  } (6,3)<br />
0.001Â Â Â Â Â Â Â Â Â Â Â Â Â Â  Â Â Â  -1Â Â  Â Â Â  .Â Â Â  } (3)<br />
0.001Â Â Â Â Â Â Â Â Â Â Â Â Â Â  Â Â Â  -0Â Â  Â Â Â  } (3)</p>
<p>0.004Â Â Â Â Â Â Â Â Â Â Â Â Â Â  Â Â Â  +0Â Â  Â Â Â  function1 : (test1){<br />
0.004Â Â Â Â Â Â Â Â Â Â Â Â Â Â  Â Â Â  +1Â Â  Â Â Â  .Â Â Â  function2 : (test1 1){<br />
0.004Â Â Â Â Â Â Â Â Â Â Â Â Â Â  Â Â Â  +2Â Â  Â Â Â  .Â Â Â  .Â Â Â  function3 : (test1 1 2){<br />
0.004Â Â Â Â Â Â Â Â Â Â Â Â Â Â  Â Â Â  -2Â Â  Â Â Â  .Â Â Â  .Â Â Â  } (test1 1 2 3)<br />
0.004Â Â Â Â Â Â Â Â Â Â Â Â Â Â  Â Â Â  -1Â Â  Â Â Â  .Â Â Â  } (test1 1 2 3)<br />
0.004Â Â Â Â Â Â Â Â Â Â Â Â Â Â  Â Â Â  -0Â Â  Â Â Â  } (test1 1 2 3)</p>
<p>0.005Â Â Â Â Â Â Â Â Â Â Â Â Â Â  Â Â Â  +0Â Â  Â Â Â  function1 : (test2){<br />
0.005Â Â Â Â Â Â Â Â Â Â Â Â Â Â  Â Â Â  +1Â Â  Â Â Â  .Â Â Â  function2 : (test2 1){<br />
0.005Â Â Â Â Â Â Â Â Â Â Â Â Â Â  Â Â Â  -1Â Â  Â Â Â  .Â Â Â  } (test2 1 2 3)<br />
0.005Â Â Â Â Â Â Â Â Â Â Â Â Â Â  Â Â Â  -0Â Â  Â Â Â  } (test2 1 2 3)</p>
<p>0.005Â Â Â Â Â Â Â Â Â Â Â Â Â Â  Â Â Â  +0Â Â  Â Â Â  function1 : (test3){<br />
0.005Â Â Â Â Â Â Â Â Â Â Â Â Â Â  Â Â Â  -0Â Â  Â Â Â  } (test3 1 2 3)</p></blockquote>
<p>This is the trace out you should get after compiling the TraceManager Test fla (contained in TraceManager.zip). The testClass functions listed at the top are used in an unnecessarily complex attempt to subtract the second argument from the first. Obviously a class is overkill for subtraction, but it shows the results of the class wrapper. In the example above, the testClass is used to find 6 &#8211; 3 = 3. As you can see, the first arguments are <em>(6,3)</em> and the result displayed at the end of the function is <em>(3)</em>. The traceDepth given to the testClass:Subtract function is &#8220;trace:Infinity&#8221; so every nested function is traced.</p>
<p>Before these traces could be created, the testClass instance had to be updated for tracing using the classWrapper. The following details that portion of the code:</p>
<blockquote><p>//Importing and initializing TraceManager at the _root level.<br />
import TraceManager<br />
var traceManager:TraceManager = new TraceManager(&#8220;traceManager&#8221; , true , 0 , undefined , getTimer() / 1000)</p>
<p>//Import new class<br />
import TestClass<br />
//Create class instance<br />
var testClass:TestClass = new TestClass ()<br />
<em><strong>//Wrap class<br />
traceManager.wrapClass(testClass , &#8220;testClass&#8221;)</strong></em><br />
//Run class function<br />
var diff:Number = testClass.Subtract(6 , 3 , &#8220;trace:Infinity&#8221;)</p></blockquote>
<p>The next group of function traces are due to a single function being run multiple times with different traceDepth values. The first traceDepth is 3, the next is 2, next is 1, and after one is run with a value of 0 and another with a value of undefined. The 0 and undefined values are not traced, so only 3 versions are visible above. As you can see, each trace from function1 displays fewer nested functions than the one before it.</p>
<p>The following is the code that led to the 2nd half of the trace out:</p>
<blockquote><p>//Defining new functions.<br />
//////////////////////////////////////////////////<br />
function function1(input){<br />
var output = input + &#8221; 1&#8243;</p>
<p>output = function2(output)</p>
<p>return output<br />
}</p>
<p>function function2(input){<br />
var output = input + &#8221; 2&#8243;</p>
<p>output = function3(output)</p>
<p>return output<br />
}</p>
<p>//This is the last function, with no nested functions in it.<br />
function function3(input){<br />
var output = input + &#8221; 3&#8243;</p>
<p>return output<br />
}</p>
<p><em><strong>//Wrapping functions.<br />
function1 = traceManager.wrapFunction(function1 , &#8220;function1&#8243;)<br />
function2 = traceManager.wrapFunction(function2 , &#8220;function2&#8243;)<br />
function3 = traceManager.wrapFunction(function3 , &#8220;function3&#8243;)</strong></em></p>
<p>//Running functions<br />
function1(&#8220;test1&#8243; , &#8220;trace:3&#8243;)<br />
function1(&#8220;test2&#8243; , &#8220;trace:2&#8243;)<br />
function1(&#8220;test3&#8243; , &#8220;trace:1&#8243;)<br />
function1(&#8220;test4&#8243; , &#8220;trace:0&#8243;)<br />
function1(&#8220;test5&#8243;)</p></blockquote>
<p>Notice that these functions were wrapped individually because they were not contained in a class.</p>
<p>One of the added benefits of implementing the wrapper functions is that by flipping the TraceManager onSwitch variable to false, you can prevent the wrapper from engaging and therefore the TraceManager will be prevented from having any effect on your program. You don&#8217;t need to remove the code beforeÂ  publishing, just set onSwitch to false, and TraceManager becomes completely harmless.</p>
<p>Anyway, I&#8217;m happy enough with its functionality that I&#8217;ll be working it into my standard procedure. Pretty soon I&#8217;ll finally be shifting my work to AS3 so there ought to be another version coming up fairly soon.</p>
<p>Let me know if you have any other ideas, Hans!</p>
<p>-Christopher J. Rock</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.sokay.net/2008/08/20/tracemanager-as2-update/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>NorthStar: Intro to Pathfinding around Irregular Polygons</title>
		<link>http://blog.sokay.net/2008/07/23/northstar-intro-to-pathfinding-around-irregular-polygons/</link>
		<comments>http://blog.sokay.net/2008/07/23/northstar-intro-to-pathfinding-around-irregular-polygons/#comments</comments>
		<pubDate>Wed, 23 Jul 2008 09:00:47 +0000</pubDate>
		<dc:creator>Christopher J. Rock</dc:creator>
				<category><![CDATA[Actionscript]]></category>
		<category><![CDATA[Everything]]></category>
		<category><![CDATA[Sokay Development]]></category>
		<category><![CDATA[A star]]></category>
		<category><![CDATA[A*]]></category>
		<category><![CDATA[AI]]></category>
		<category><![CDATA[arbitrary]]></category>
		<category><![CDATA[art based]]></category>
		<category><![CDATA[artificial intelligence]]></category>
		<category><![CDATA[Astar]]></category>
		<category><![CDATA[how-to]]></category>
		<category><![CDATA[irregular]]></category>
		<category><![CDATA[liberty]]></category>
		<category><![CDATA[liberty engine]]></category>
		<category><![CDATA[minimum distance]]></category>
		<category><![CDATA[NorthStar]]></category>
		<category><![CDATA[pathfinding]]></category>
		<category><![CDATA[polygon]]></category>
		<category><![CDATA[real-time]]></category>
		<category><![CDATA[real-time strategy]]></category>
		<category><![CDATA[RTS]]></category>
		<category><![CDATA[search algorithm]]></category>
		<category><![CDATA[strategy]]></category>
		<category><![CDATA[tactics]]></category>
		<category><![CDATA[top-down]]></category>

		<guid isPermaLink="false">http://blog.sokay.net/?p=244</guid>
		<description><![CDATA[NorthStar is my new pathfinder for use with arbitrary, irregular polygons. CHECK IT OUT. Drag around the green and red circles. The green one is used as the start point and the red is the end A couple months ago I decided I would begin working toward my long time dream of producing a real-time [...]]]></description>
			<content:encoded><![CDATA[<p><a href="None"></a>NorthStar is my new pathfinder for use with arbitrary, irregular polygons. CHECK IT OUT. Drag around the green and red circles. The green one is used as the start point and the red is the end</p>
<p><object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" width="480" height="360" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,40,0"><param name="name" value="NorthStar Test" /><param name="bgcolor" value="#ffffff" /><param name="align" value="middle" /><param name="src" value="http://blog.sokay.net/wp-content/uploads/2008/07/northstar_test_072208.swf" /><embed type="application/x-shockwave-flash" width="480" height="360" src="http://blog.sokay.net/wp-content/uploads/2008/07/northstar_test_072208.swf" align="middle" bgcolor="#ffffff" name="NorthStar Test"></embed></object></p>
<p>A couple months ago I decided I would begin working toward my long time dream of producing a real-time strategy game. I actually finished NorthStar and had this written a few weeks later, but I&#8217;m only posting now because I&#8217;ve been hard at work with the rest of the game! Now working on unit logic along with a new Sokay project (more on that later) and editing a new film (later still), so I been a little busy. Expect Demos.</p>
<p>I planned on basing the RTS engine on some of my previous work with physics (perhaps that sounds strange, but it makes sense). Step one was coming up with a pathfinder.</p>
<p><span id="more-244"></span></p>
<p><strong>Demands:</strong></p>
<ol>
<li><em>Irregular Polygons:</em> I dislike tile-based systems and I already had groundwork in my physics engine for handling irregular polygons. I decided the RTS should implement the same ideas and therefore it cannot use traditional, tile-based pathfinding techniques.</li>
<li><em>The Illusion of Intelligence:</em> Paths must appear to have resulted from intelligent decision-making. I didn&#8217;t want to see units going on crazy birdwalks for no apparent reason like they often do in popular RTSes. I&#8217;m disgusted by the presence of such awful pathfinding in blockbusters like Blizzard&#8217;s Warcraft and Starcraft series. I want my units to use paths that make them appear intelligent.</li>
<li><em>Forethought in Navigation:</em> The path must be relatively efficient, demonstrating a knowledge of the overall terrain unless I specify otherwise.Â  If I <em>want</em> a unit to appear ignorant or lost, letting it wander is fine, otherwise it should not bother with any path that will not eventually lead it to the goal.</li>
<li><em>Efficiency:</em> I can&#8217;t have units lagging every time they decide to move somewhere and ideally I can have lots of units deciding to move to different places all at the same time. That means it&#8217;s gotta be quick.</li>
</ol>
<p><strong>A* Logic</strong></p>
<p>I didn&#8217;t have any background in pathfinder&#8217;s, but Bryson had used the popular A* (&#8220;A star&#8221;) for his <a title="Potty Mouthed Ninja" href="http://www.liquidgeneration.com/Media/Games/Action_Arcade/Action/Potty_Mouth_Ninja_Enter_the_Pirate/" target="_blank">Liquid Generation puzzle game</a> a while back and it seemed to work well for him.</p>
<p>The essence of A* is decision-making. It navigates a network of nodes by rating each one available and selecting the node with the best rating (making it a &#8220;best-first&#8221; algorithm). The rating function can be customized for a given project, but generally it is an optimistic estimation of the cost (in distance) of a path through a given node.</p>
<p>So imagine you have to walk around a car. The car may have one node on the left and another node on the right. If walking through the left node costs at least 15 steps, but walking on the right costs at least 10 steps, A* chooses to go right. It is &#8220;optimistic&#8221; in that walking to the right may eventually cost more than 10 steps, but walking to the left will cost <em>at least</em> 15 steps.</p>
<p>A*&#8217;s simplicity and effectiveness made it a good model from which to build NorthStar. But the reason A* is so easy to implement in so many games is because its nodes directly translate into tiles in a tile-based engine. I needed a way to describe a field of arbitrary polygons as nodes before I could apply any of that logic. This proved to be the real challenge.</p>
<p><strong>Creating a Node Network from Arbitrary Polygons</strong></p>
<p><em>Polygon Data</em></p>
<p>Using my old <a title="Liberty Engine Demo" href="http://blog.sokay.net/2008/04/17/liberty-engine-update-running-clean/" target="_blank">physics engine systems</a>, I constructed polygons from movieClip points organized into groups. I drop the point movieClips onto the stage and convert groups of them into new movieClip instances, then the points automatically arrange their data into arrays at run-time. The result is a single array (_root.PolygonArray) indexing each individual polygon (_root.PolygonArray[p]) which are represented as arrays indexing vertices (_root.PolygonArray[p][v]) which are <em>also</em> arrays containing x and y values of the points (_root.PolygonArray[p][v].x , _root.PolygonArray[p][v].y). This is the polygon data I&#8217;m converting into nodes.</p>
<p>Some pathfinder&#8217;s handle this process by identifying all vertices as nodes and creating links between all of them that have no walls between them. That works, but it creates a very wasteful network. A pathfinder has to scan through all the options available before it can make a decision, therefore the pathfinder works most quickly with the least number of options. So yes, you <em>can</em> simply convert all polygon corners into nodes and link them all, but your pathfinder will be much more effective if you only create the most useful links. Plus, having extra links lying around may occasionally put pointless Sunday strolls in your path instead of keeping it nice and tight.</p>
<p>If a link is unnecessary, don&#8217;t create it! Having extra links around will just bog down your pathfinder while it scans the entire network for the best path.</p>
<p><em>Identifying a Good Link</em></p>
<p>I came up with this set of steps for determining whether or not a pair of nodes (A and B) should be linked to one another (read <span style="color: #ffcc00;"><em>Filtering Links for a Lean Network </em></span>for justification):</p>
<ol>
<li>Draw a line connecting vertex A to vertex B. Call this &#8220;lineAB&#8221;</li>
<li>Find the two vertices neighboring vertex A and make sure they are both on the same side of lineAB.</li>
<li>Find the two vertices neighboring vertex B and make sure they are both on the same side of lineAB. (They do not need to be on the same side as vertex A&#8217;s neighbors)</li>
<li>Check for polygon walls blocking lineAB.</li>
</ol>
<p style="text-align: center;"><a href="None"><img class="alignnone size-full wp-image-249 aligncenter" title="northstar-link_illustration" src="http://blog.sokay.net/wp-content/uploads/2008/07/northstar-link_illustration.jpg" alt="" width="380" height="380" /></a></p>
<p>If each node&#8217;s neighbors are to one side of the link and no polygon walls are penetrated by it, the link is worth having.</p>
<p><em>The Math</em></p>
<p>You may be wondering how I applied those steps mathematically. To &#8220;Draw a line&#8221; between vertices A and B, I found the line in Slope-Intercept form that contains the two. To find out if their respective neighbors were on the same side of that line, I ran the x values for each neighboring vertex through the line&#8217;s equation. The result is the y value of a point (call it pointL) on the line with the same x value as the neighbor. If pointL has a y value that is greater than the a neighbor&#8217;s y value, it means that neighbor is below the line. If pointL has a smaller y value than the neighbor, the neighbor is above the line.</p>
<p>The only exception to this is when the slope of the line is Infinity (it points straight up and down when the 2 nodes being tested have the same x value and different y values). In this case, because the 2 nodes being tested have the same x values, you can detect which side each pair of neighbors is on by comparing their x values to the x value of either of the 2 nodes being tested.</p>
<p><em>Organizing Node and Link Data</em></p>
<p>I arranged link information in a new array called &#8220;nodeMap&#8221; which indexes each individual node. Each node is an array with point information in addition to being associated with a &#8220;link&#8221; array (nodeMap[n].link). The &#8220;link&#8221; array lists each of the nodes to which the current node is linked (nodeMap[n].link[m]). Each element in the &#8220;link&#8221; array is an array containing a reference to the linked node (at the zero position, [0]), and the distance between the two nodes (at [1]). A pair of linked nodes must have a reference to each other otherwise the link will only work in one direction.</p>
<p>The nodeMap grows as loops cycle through every vertex on every polygon, checking them against every other vertex in the field, converting polygon data into node data.</p>
<p><strong>Pathfinding</strong></p>
<p><em>Linking the Start and End Points to the Network</em></p>
<p>Now that the polygon map has been converted into a node map, the pathfinder must be given start and end points to represent the desired movement. These points can be anywhere on the field.</p>
<p>NorthStar uses logic just like the node linking process to link the start and end points to the node network. The start and end points are not vertices so they do not need to compliment any nodes to form a link and their linking process is a bit simpler than detecting links between nodes.</p>
<ol>
<li>Draw a line connecting startPoint to node A. Call this &#8220;lineSA&#8221;</li>
<li>Find the two vertices neighboring node A and make sure they are both on the same side of lineSA.</li>
<li>Check for polygon walls blocking lineSA.</li>
</ol>
<p><em>(Run the same process with the endPoint in place of the startPoint.)</em></p>
<p>Finally, the network is ready to be analyzed.</p>
<p><em>Blazing the Path</em></p>
<p>Starting from the startPoint, a path is drawn from one node to the next, through link after link, until a node is reached that is linked to the endPoint. When the endpoint has been reached, the search is over. The path has been found.</p>
<p>NorthStar is continually updating a library of available options, starting with each of the links of the startPoint. Each time it moves from one node to another, it deletes the new node from its library of options and adds all of that node&#8217;s links to the library (except the one it came from).</p>
<p>When selecting the next node, it sorts the entire library by node rating. The one with the best rating is chosen to have its path grown until that path attains a worse rating than another option in the library. All available nodes are constantly checked against one-another so that NorthStar quickly abandon&#8217;s any paths that seem wasteful and returns to old paths with better ratings.</p>
<p><strong>The Rating System</strong></p>
<p>Breeding A* with a few other methods, I rated nodes according to an estimated cost in distance in addition to a few tie-breakers and special cases that would probably change from project to project.</p>
<p>I put rating data into arrays (you can probably tell I use arrays a lot). The first element in the rating array is the path distance required to get to the node. The second element is the estimated distance to the endPoint. These two are added together to get a rating value.</p>
<p>In most cases the estimated distance to the endPoint may simply be the distance of a straight path between the node and the endPoint (an optimistic estimation), however if possible, other information may be used to find an exact distance, like when the current node is indirectly linked to the endPoint. An indirect link is when a node can lead to the endPoint if at least one other node is used between the two.</p>
<p><strong>Indirect Links</strong></p>
<p>I implemented a check for indirect links into my rating system. It just scans to see if there are any links that a node has in common with the endPoint, then selects the one with the shortest path (if one or more exist). When this is used, the resulting rating is exact rather than an estimation.</p>
<p>Another way of taking advantage of indirect links is to create them between nodes as soon as a path is found between them. If the path has already been proven to be effective, you can indirectly link all the nodes within that path to each other and the path can be easily reused in the future without requiring a complete rescan of the network. I did this by adding a third element to any links between nodes that are indirect. This element is an array containing all nodes along the path between the two indirectly linked nodes, in order.</p>
<p><strong>Finding Indirect Links Pre-emptively</strong></p>
<p>I have a function for scanning a node network ahead of time to find all the shortest indirect links between all nodes on the field, but it&#8217;s a little buggy. With that implemented a ton of time can be saved because as soon as the start and end points have been linked to the network, you can instantly find a path between them by picking any of the nodes they&#8217;re linked to and finding the precalculated indirect link between those two nodes.</p>
<p><strong>Why is the path so close to the obstacles?</strong></p>
<p>Fair question. I haven&#8217;t bothered with checking unit thickness yet, so right now the path goes right up against walls and corners (offset by 1 pixel, just so it&#8217;s always clear when a unit is outside or inside a polygon).</p>
<p>There are 3 ways to solve this problem:</p>
<ol>
<li><em>The Ugly Way:</em> Make the art for the obstacles smaller than the actual boundaries. Voila.</li>
<li><em>The Bad Way:</em> Add an outward extension to node locations by a given distance (equal to the radius of your unit). You may want to make that distance a value you can easily change so you can have units of different sizes.</li>
<li><em>The Good Way:</em> This requires that you do the same as in #2, but you also run checks to find out if the units have enough room to fit through all of the passages. Your pathfinder will have to ignore passages that are too thin to fit through. Do this and you never have to worry about units penetrating walls as they walk. (I&#8217;ve postponed this, using <em>The Ugly Way</em> in the meantime)</li>
</ol>
<p><strong>Result</strong></p>
<p>As you can see in the demo, NorthStar&#8217;s workin quite well. It&#8217;s not 100% bug-free yet, but I&#8217;m very pleased with the results and it can easily be implemented into some games. After optimizing it some more, I&#8217;m confident I can have it running quick enough that it can be used for pathfinding in pretty huge settings. One method I haven&#8217;t seen in other pathfinders would involve generalizing start and end points so you don&#8217;t have to calculate linking them to the network so often.</p>
<p>More posts comin.</p>
<p>-Christopher J. Rock</p>
<p><span style="color: #ffcc00;"><em>Filtering Links for a Lean Network</em></span></p>
<p><span style="color: #ffcc00;">The only way to clean up our network is to set up some rules for identifying a useful node link. Our pathfinder will work from the startPoint to the endPoint, but that order is not necessary. If we find a good path, it shouldn&#8217;t matter whether it started from the startPoint and worked to the endPoint or started at the endPoint and worked to the startPoint. Keep this in mind when I refer to &#8220;direct access&#8221; between points. If point A has direct access to point B, point B has direct access to point A.</span></p>
<ol>
<li><span style="color: #ffcc00;"><em>Links cannot penetrate polygon walls:</em> Since you don&#8217;t want paths that lead directly through your polygons, you must check to see if a wall is blocking the path between a pair of nodes before declaring them linked.</span></li>
<li><span style="color: #ffcc00;"><em>Nodes are only important as potential waypoints:</em> Say you&#8217;re traveling from startPoint to endPoint. If an obstacle is blocking the way, you must find a waypoint with direct access to startPoint and endPoint.Â However, if startPoint has direct access to endPoint, it is unnecessary to use any waypoints when moving between them. Therefore, linking to a node is only useful if the node has direct access to a place that you currently do not. This rule describes finding links to your start and end points.</span></li>
<li><span style="color: #ffcc00;"><em>All vertices must be recognized as nodes:</em> Vertices are formed by walls. Walls block nodes from directly accessing areas of the field, but when two walls form a vertex, they do not block that vertex from accessing any point on the field. Therefore, a vertex formed by any two walls will be useful in providing access to spaces around those walls.</span></li>
<li><span style="color: #ffcc00;"><em>Nodes must compliment each other:</em> When the startPoint does not have access to the endPoint and linking to a single node achieves access, only 1 node is necessary. But if that node <em>also</em> has no access to the endPoint, it must use a 2nd node to achieve it. If the startPoint has direct access to this 2nd node, the 1st node can be skipped. In this case, the nodes do not compliment each other. On the other hand, if the startPoint does not have direct access to the 2nd node, it must use the 1st node to obtain it. Another way of looking at it is to say that the 1st node must have direct access to an area that the 2nd node does not (the startPoint) and the 2nd node must have direct access to an area the 1st node does not (the endPoint). The nodes must be linked to share their potential as waypoints. In this way, the pair of nodes compliment each other.</span></li>
<li><span style="color: #ffcc00;"><em>Nodes will only form links on one side of their vertex:</em> Every vertex forms a &#8220;V&#8221; shape pointing in some direction. As a result of rules 1 and 2, a node can only have links on the outside of the &#8220;V&#8221;. Therefore, vertices pointing into the polygon can be labeled &#8220;internal&#8221; because they will only link to other nodes within that polygon. External vertices, pointing out from the polygon, are only linked to nodes on the outside of the polygon.</span></li>
</ol>
]]></content:encoded>
			<wfw:commentRss>http://blog.sokay.net/2008/07/23/northstar-intro-to-pathfinding-around-irregular-polygons/feed/</wfw:commentRss>
		<slash:comments>14</slash:comments>
		</item>
		<item>
		<title>The Eco Zoo &#8211; Amazing 3D Flash Website</title>
		<link>http://blog.sokay.net/2008/06/06/the-eco-zoo-amazing-3d-flash-website/</link>
		<comments>http://blog.sokay.net/2008/06/06/the-eco-zoo-amazing-3d-flash-website/#comments</comments>
		<pubDate>Fri, 06 Jun 2008 08:43:07 +0000</pubDate>
		<dc:creator>Bryson Whiteman</dc:creator>
				<category><![CDATA[3d]]></category>
		<category><![CDATA[Actionscript]]></category>
		<category><![CDATA[Coolio]]></category>
		<category><![CDATA[Everything]]></category>
		<category><![CDATA[3d animation]]></category>
		<category><![CDATA[agency]]></category>
		<category><![CDATA[flash 3d]]></category>
		<category><![CDATA[interactive]]></category>
		<category><![CDATA[motion graphics]]></category>
		<category><![CDATA[papervision]]></category>

		<guid isPermaLink="false">http://blog.sokay.net/?p=230</guid>
		<description><![CDATA[Earlier I found this amazing 3d interactive site in a thread on Flashkit. Completely breathtaking. Needless to say, I couldn&#8217;t wait to make a post about this one! The Eco Zoo This is the best executed 3d Flash site I&#8217;ve seen so far. Just check it out. Apparently this isn&#8217;t created with any open source [...]]]></description>
			<content:encoded><![CDATA[<p>Earlier I found this amazing 3d interactive site in <a title="Nice 3D Website" href="http://board.flashkit.com/board/showthread.php?t=768887">a thread on Flashkit</a>. Completely breathtaking. Needless to say, I couldn&#8217;t wait to make a post about this one!</p>
<p style="text-align: center;"><a title="The Eco Zoo" href="http://www.ecodazoo.com/"><img class="aligncenter size-full wp-image-229" title="The Eco Zoo" src="http://blog.sokay.net/wp-content/uploads/2008/06/ecodazoo.jpg" alt="The Eco Zoo website" width="450" height="255" /></a><em><br />
The Eco Zoo</em></p>
<p>This is the best executed 3d Flash site I&#8217;ve seen so far. Just check it out. Apparently this isn&#8217;t created with any open source 3d engine out there, it&#8217;s a custom engine by <a href="http://roxik.com/">this guy</a>.</p>
<p><a href="http://www.edgy.com.br/frameSet.php?lang=1"><img class="size-full wp-image-231" title="EDGY" src="http://blog.sokay.net/wp-content/uploads/2008/06/edgy.jpg" alt="" width="204" height="180" align="right" /></a></p>
<p>3D on the web is sort of a gimmick right now, as Flash itself was seen as a gimmick in the past (i.e. your site wasn&#8217;t cool unless it had a Flash intro). All it really takes is some progressive individuals to define what&#8217;s possible with the advances of the medium &#8212; beyond spinning cubes and globes. Right now I see opportunities to tell stories in new and exciting ways. I&#8217;m hoping to take design elements from motion graphics and create interactive visual masterpieces. Couldn&#8217;t you imagine <a title="Cartoon Network" href="http://www.cartoonnetwork.com">CartoonNetwork.com</a> as a fully interactive playground? Kids would love that stuff. How come we aren&#8217;t seeing that yet??<a href="http://www.edgy.com.br/frameSet.php?lang=1"> </a></p>
]]></content:encoded>
			<wfw:commentRss>http://blog.sokay.net/2008/06/06/the-eco-zoo-amazing-3d-flash-website/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Papervision Animated Character Demo</title>
		<link>http://blog.sokay.net/2008/05/25/papervision-animated-character-demo/</link>
		<comments>http://blog.sokay.net/2008/05/25/papervision-animated-character-demo/#comments</comments>
		<pubDate>Sun, 25 May 2008 21:26:33 +0000</pubDate>
		<dc:creator>Bryson Whiteman</dc:creator>
				<category><![CDATA[3d]]></category>
		<category><![CDATA[Actionscript]]></category>
		<category><![CDATA[Everything]]></category>
		<category><![CDATA[3dsmax]]></category>
		<category><![CDATA[Animation]]></category>
		<category><![CDATA[character]]></category>
		<category><![CDATA[maya]]></category>
		<category><![CDATA[md2]]></category>
		<category><![CDATA[papervision]]></category>
		<category><![CDATA[parser]]></category>
		<category><![CDATA[quake]]></category>
		<category><![CDATA[quake2]]></category>
		<category><![CDATA[rig]]></category>

		<guid isPermaLink="false">http://blog.sokay.net/?p=226</guid>
		<description><![CDATA[I found this Papervision demo while searching for a method of character animation. Clint Hannaford&#8217;s Papervision Character demo This demo impressed the hell out of me. It was proof that 3d character animation could be awesome in Flash. I&#8217;ve been dabbling in Papervision stuff lately. It&#8217;s an extra layer of complication on top of AS3 [...]]]></description>
			<content:encoded><![CDATA[<p>I found <a href="http://www.pleribus.com/blog/?p=10">this Papervision demo</a> while searching for a method of character animation.</p>
<p style="text-align: center;"><a title="Papervision Character demo" href="http://www.pleribus.com/blog/?p=10"><img class="aligncenter size-full wp-image-227" title="papervision character" src="http://blog.sokay.net/wp-content/uploads/2008/05/papervision_char.png" alt="" width="400" height="300" /></a><em><br />
Clint Hannaford&#8217;s Papervision Character demo</em></p>
<p>This demo impressed the hell out of me. It was proof that 3d character animation could be awesome in Flash. I&#8217;ve been dabbling in Papervision stuff lately. It&#8217;s an extra layer of complication on top of AS3 but the payoff is worth it. I created a model in Maya, textured it, and loaded it into Flash and made it interactive. Unbelievable&#8230;</p>
<p>For animation, I figured I could either setup some complicated character rig by separating the character at the joints and linking the pieces together. Setting all of that up and creating a system to animate the keyframes would be much to time consuming. renderhjs, from the Flashkit forum, was creating his own custom system of animating the character in the 3d software and exporting the animation frame by frame and playing through the keyframes. I don&#8217;t exactly have time to figure that out either so I found Clint&#8217;s post searching Google in distress.</p>
<p>Clint explained to me that his character demo uses <a href="http://en.wikipedia.org/wiki/MD2_%28file_format%29">.md2</a> format, from Quake 2. It&#8217;s similar to, if not the same as, renderhjs&#8217; method of character animation. He linked to this <a title="Papervision md2 parser" href="http://lostboys.epologee.net/papervision/greatwhite.doc/html/org_papervision3d_objects_parsers_MD2.html">Papervision md2 parser</a> and recommended that I try loading in some Quake 2 models and seeing how it works.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.sokay.net/2008/05/25/papervision-animated-character-demo/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Liberty Engine Update: Running Clean</title>
		<link>http://blog.sokay.net/2008/04/17/liberty-engine-update-running-clean/</link>
		<comments>http://blog.sokay.net/2008/04/17/liberty-engine-update-running-clean/#comments</comments>
		<pubDate>Fri, 18 Apr 2008 04:22:33 +0000</pubDate>
		<dc:creator>Christopher J. Rock</dc:creator>
				<category><![CDATA[Actionscript]]></category>
		<category><![CDATA[Everything]]></category>
		<category><![CDATA[Sokay Development]]></category>
		<category><![CDATA[based]]></category>
		<category><![CDATA[bouncing]]></category>
		<category><![CDATA[calculus]]></category>
		<category><![CDATA[circle collision]]></category>
		<category><![CDATA[collision]]></category>
		<category><![CDATA[collision detection]]></category>
		<category><![CDATA[collision testing]]></category>
		<category><![CDATA[derivation]]></category>
		<category><![CDATA[engine]]></category>
		<category><![CDATA[equation]]></category>
		<category><![CDATA[frame]]></category>
		<category><![CDATA[frame-based]]></category>
		<category><![CDATA[geometry]]></category>
		<category><![CDATA[impulse]]></category>
		<category><![CDATA[liberty]]></category>
		<category><![CDATA[liberty engine]]></category>
		<category><![CDATA[physics]]></category>
		<category><![CDATA[platformer]]></category>
		<category><![CDATA[platformer engine]]></category>
		<category><![CDATA[stepped]]></category>
		<category><![CDATA[time]]></category>
		<category><![CDATA[time dilation]]></category>
		<category><![CDATA[time-based]]></category>
		<category><![CDATA[time-stepped]]></category>
		<category><![CDATA[trigonometry]]></category>
		<category><![CDATA[vector]]></category>

		<guid isPermaLink="false">http://blog.sokay.net/?p=205</guid>
		<description><![CDATA[It&#8217;s been a while since I updated on the old Liberty Engine so here it is with a lot more polish than the last demo. You still can&#8217;t modify the objects or forces just yet, but I sharpened up everything else. It&#8217;s running much more efficiently, with stats, an improved console and new keyboard commands. [...]]]></description>
			<content:encoded><![CDATA[<p style="text-align: center;"><a title="Liberty Engine Demo 04.17.08.swf" href="http://blog.sokay.net/wp-content/uploads/2008/04/liberty-engine-demo-041708.swf"><img class="aligncenter size-full wp-image-208" title="liberty-engine-screenshot-1" src="http://blog.sokay.net/wp-content/uploads/2008/04/liberty-engine-screenshot-1.jpg" alt="LE screen 1" width="400" height="300" /></a></p>
<p>It&#8217;s been a while since I updated on the old Liberty Engine so here it is with a lot more polish than the last demo. You still can&#8217;t modify the objects or forces just yet, but I sharpened up everything else. It&#8217;s running much more efficiently, with stats, an improved console and new keyboard commands. It also includes a &#8220;Help&#8221; button that will explain all of its functions on mouse-over.</p>
<p>Here is a swf copy as well as an exe. I haven&#8217;t seen much of a performance difference between the two:</p>
<ul>
<li><a title="Liberty Engine Demo 04.17.08.swf" href="http://blog.sokay.net/wp-content/uploads/2008/04/liberty-engine-demo-041708.swf">liberty-engine-demo-041708.swf</a></li>
<li><a title="Liberty Engine Demo 04.17.08.exe" href="http://blog.sokay.net/wp-content/uploads/2008/04/liberty-engine-demo-041708.exe">liberty-engine-demo-041708.exe</a></li>
</ul>
<p>The default &#8220;memory&#8221; setting is 60 seconds, so if you play more than 60 seconds it will begin deleting old data. This is meant to prevent the program from filling your computers memory and lagging or crashing. However, you can set the memory value to Infinity and see how much you can hold without slowdown. I found a loss of about 2 or 3 fps with 1 hour of data.  I average about 6 or 7 calculated seconds per actual second (S<em>calc</em>/S) so you should be able to set the rate of time passage to as high as 6 without playback time ever passing up calculation time. But play around with it and let me know how it runs on your machine. I could use the feedback!</p>
<p>With your time rate set to 6, you can get through an hour of simulation in 10 minutes.</p>
<p><span id="more-205"></span></p>
<p><strong>Design</strong></p>
<p>There is a great deal of idealism in the design of the Liberty Engine. You might say principles had more to do with it than technical goals. These were my priorities:</p>
<ol>
<li><em>Precision:</em> All data and specifically collisions must be precise. At this point the only rounding off occurs due to flash&#8217;s technical limitations, but I&#8217;ve aimed for accuracy to the 10th decimal place. No collisions are missed, regardless of velocities, and all are calculated exactly.</li>
<li><em>Repeatability:</em> As a result of high level precision and uniform methods of rounding off data when necessary, experiments in this engine are entirely repeatable. No matter what machine is used to run the software, the same events will occur.</li>
<li><em>Preservation:</em> Data is treated as sacred and preserved for potential use in any number of ways. The most significant acknowledgment of this priority is the engine&#8217;s &#8220;memory&#8221; of past events. This allows you to scrub back and forth over hours of animation. Data is compressed in different ways to keep it from costing too much space.</li>
<li><em>Simplicity:</em> The soul of the Liberty Engine concept lies in its ease of use. In the early stages this was a great challenge, but since then its rewards have been great. Engine operation is entirely cut and paste, drag and drop, with minimal for scripting. This engine is built to give the little guys the power of the big guys and the big guys the freedom of the little guys.</li>
<li><em>Efficiency:</em> The framerate must be stable. Even if it drops down, it must be <em>stable</em>. A stable framerate is predictable and provides for a much better experience than one that varies between high and low values. Also, due to the high level of precision, calculations can suck up a lot of processing power so logic must be employed to make as many safe assumptions as possible and minimize unnecessary work. On the other hand, there are a number of high efficiency coding practices that I&#8217;ve ignored for the sake of simplicity. I hope to fix some of this in the future, but clearly it is not high on my list.</li>
<li><em>Power:</em> Power is the #1 concern of every engine out there, but very few games even take advantage of it. I decided that if you need a powerful physics engine you can take from plenty of others, but I would not set it as a high priority until later in development. Fortunately, the nature of the Liberty Engine gives it a significant advantage from the start. It can&#8217;t yet handle as many events as other flash engines, and still doesn&#8217;t have contact forces, but in the right circumstances it can blow them out of the water.</li>
</ol>
<p><strong>How It Works</strong></p>
<p>Everything is coded for a quick pipeline. You drag and drop objects and force vectors from the flash library and they automatically submit themselves to a library of data at the initiation of the engine. This is what it looks like in flash:</p>
<p><a href="http://blog.sokay.net/wp-content/uploads/2008/04/liberty-engine-screenshot-2-fla.jpg"></a></p>
<p style="text-align: center;"><img class="aligncenter size-full wp-image-212" title="liberty-engine-screenshot-2-fla" src="http://blog.sokay.net/wp-content/uploads/2008/04/liberty-engine-screenshot-2-fla.jpg" alt="LE 04.17.08 flah Image" width="400" height="233" /></p>
<p style="text-align: left;"><em>Equations</em></p>
<p>Based on the force vectors and object data, equations are calculated to describe the trajectories of each object relative to time.  Equations are arrays with lengths equal to the number of terms they contain. Each term is described by a coefficient that will be multiplied by time. The exponent of time (t) is determined by the number and order of terms in the equation.</p>
<blockquote><p>e = [2,3,4,5]</p>
<p>position = e(t) = 2 + 3t + 4t^2 + 5t^3</p></blockquote>
<p>Each term represents a derivation of position (position, velocity, acceleration, jerk, yank, etc). Since objects can move over the x and y axes as well as rotate over the z axis, 3 coefficients are needed for each term. These are described with arrays nested in the equation array. Each contains an x, y and z value.</p>
<blockquote><p>e = [[2,2.1,2.2] , [3,3.1,3.2] , [4,4.1,4.2] , [5,5.1,5.2]]</p>
<p>position.x = e[x](t) = 2 + 3t + 4t^2 + 5t^3</p>
<p>position.y = e[y](t) = 2.1 + 3.1t + 4.1t^2 + 5.1t^3</p>
<p>position.z = e[z](t) = 2.2 + 3.2t + 4.2t^2 + 5.2t^3</p></blockquote>
<p>In other words, the equation is made up of coefficient vectors multiplied by exponentially increasing values of time. An EquationAnimator function uses those equations to find the position of each object at a given time and update the stage. That allows the engine to function independently of the actual animation state.</p>
<p>From there, it&#8217;s only a matter of making updates due to collisions. My collision algorithms are geometrically based, so they don&#8217;t yet function for curved movements (accelerations and further derivations of position), but I&#8217;ve plans for that update so hopefully I can get on it pretty soon. The circle-circle collisions, for example, assume each circle to be moving linearly.</p>
<p><em>Circle-Circle Collision Calculation</em></p>
<p>The circle-circle collision algorithm takes advantage of relative motion by combining the movement of each circle into a single vector and applying it to one of the circles (resulting in C-static and C-moving). The nearest point to C-static along the trajectory of C-moving is then found by calculating the intersection point of the C-moving trajectory and a line penetrating C-static and perpendicular to the C-moving trajectory. Let&#8217;s call that intersection point N.</p>
<p style="text-align: center;"><a title="Circle-Circle Illus" href="http://blog.sokay.net/wp-content/uploads/2008/04/circle-circle-collision-illustration-and-physics-math.jpg" target="_blank"><img class="aligncenter size-medium wp-image-213" title="circle-circle-collision-illustration-and-physics-math" src="http://blog.sokay.net/wp-content/uploads/2008/04/circle-circle-collision-illustration-and-physics-math-300x187.jpg" alt="Circle-Circle Collision Illustration and Physics Math" width="300" height="187" /></a></p>
<p>It is assumed that at the time of collision between these circles, their centers will be separated by a distance equal to the sum of their radii. That means that at the time of collision, a right triangle will exist with 2 vertices at the centers of each circle and 1 vertex at point N. The Pythagorean theorem is then used to calculate the position of C-moving at the time of collision by finding the length of the edge of the triangle opposite the vertex located at the center of C-static (the edge which lies along the C-moving trajectory). The resulting length is the distance between point N and the center of C-moving at the time of collision. That is subtracted from the distance between the center of C-moving at start and point N to give the distance between C-moving at start and C-moving at collision. Finally, that distance is divided by the length of the entire trajectory of C-moving (from start to end) and multiplied by the total change in time (from start to end). The result is the exact time of collision, which can then be applied to position equations to find the exact positions of C-static and C-moving at the time of collision. A vector with magnitude equal to the radius of either circle, and in the direction of the opposite circle, can be added to the center&#8217;s position to find the exact point at which collision will occur.</p>
<p>This is not just a &#8220;detected&#8221; collision, it is a calculated result that tells the exact time and place of the collision. Therefore, objects may be moving at any speed and the logic will still apply accurately (as opposed to frame-based or time-stepped logic which only functions accurately at very low speeds or very high framerates). It also saves time because after a collision is known, it never needs to be checked again so the engine doesn&#8217;t need to be vigilantly checking objects every frame. Instead, it jumps ahead into the future and continues calculations from there. The downside is that this kind of calculation sucks on your processing power so you need to find ways to stay accurate while only committing to the fewest calculations possible.</p>
<p><em>Impulses and New Equations</em></p>
<p>For every collision, an impulse must be calculated. That impulse leads to the formulation of a new equation that takes effect at the time of collision. The new equation is added to an array of equations with &#8220;start&#8221; and &#8220;end&#8221; values indicating when they accurately describe object movement and when their usefulness expires. Each array of equations is nested in an array with elements representing each individual object. When the playback time minus the &#8220;end&#8221; value of an equation is greater than the engine&#8217;s &#8220;memory&#8221; value, that equation is deleted. This only applies if the playback time is less than the most recent calculation time.</p>
<p><em>Matters of Optimization</em></p>
<p>As you can see, arrays are nested like crazy, which is not at all the most efficient way to handle things. I&#8217;ve been wanting to use something like a <a title="polygonal.de: Linked Lists" href="http://lab.polygonal.de/index.php?s=linked+nodes" target="_blank">linked list</a>, but arrays are a good temporary solution.</p>
<p>Calculations are capable of predicting collisions indefinitely, but there isn&#8217;t much point in having the engine predict events that won&#8217;t occur for an hour, so it is built to only go 15 seconds into the future before pausing. Then it continues calculations when the playback time is within 10 seconds of the last calculated event. If you pause the animation and push the scrubber far ahead of the calculation marker, you&#8217;ll see it kick into high gear to catch up. Like any arbitrarily selected value in the engine, these numbers can be easily modified.</p>
<p>When predictions are ahead of schedule, the engine will relax by stopping at partial cycles to allow the frame to pass. At the start of the next frame, the engine will continue where it left off. This helps prevent crashing and constant lag due to the engine voraciously seeking results that may never see the light of day anyway.</p>
<p>The engine is self-regulated. It keeps track of the average run-times of each portion of itself and later uses that data to determine whether or not it is necessary to interrupt a cycle for frame passage. If it expects the next segment of calculation to take too long, it ends the sequence, otherwise it continues.</p>
<p>The engine is also capable of running multiple cycles within a single frame (as in the first <a title="Liberty Engine: Puttin my circles where my mouth is" href="http://blog.sokay.net/2008/01/17/the-liberty-engine-puttin-my-circles-where-my-mouth-is/" target="_blank">Liberty Engine Demo</a>), but that function has been turned off for now.</p>
<p><strong>More to Come</strong></p>
<p>I&#8217;ll go into more on the math and methods later, but for now I have enough work to do that I shouldn&#8217;t be blabbing on. If there are formulas you&#8217;re looking for, don&#8217;t be afraid to ask. It&#8217;s a bit of a trick to find all the physics you need for this kind of thing. I was shocked to find out how rare it was for anyone to consider time-based physics instead of frame-based and that adds hours to your research.</p>
<p>I was happy to find <a title="gamepoetry.com: time-based" href="http://www.gamepoetry.com/wpress/2008/04/11/frame-based-code-sucks/" target="_blank">this article</a> from <a title="gamepoetry.com" href="http://www.gamepoetry.com/" target="_blank">gamepoetry.com</a> last week. That&#8217;s really the reason I felt compelled to post this update. Apparently Panayoti will be doing a much needed series on this topic.</p>
<p>Next time I&#8217;ll definitely incorporate some more interactivity so you can drop in some forces and objects. I&#8217;d also like to allow the engine to run backwards, calculating the past in addition to the future. With that capability, it wouldn&#8217;t be necessary to save as much equation data because it can easily be recalculated when necessary.</p>
<p>Too much to do, not enough time to do it.</p>
<p>-Christopher J. Rock</p>
<p><span style="color: #ffcc00;">P.S. At 3491.9 (58 minutes, 11.9 seconds) an error occurs! This is due to simultaneous collisions. Simultaneous collisions are only accounted for in some circumstances right now. That&#8217;s one of the fixes I still have to make, but I think this shows how rarely it actually comes up. Thousands of collisions occur in that first hour before a single error rears its ugly head. Not bad.</span></p>
<p><span style="color: #ffcc00;">I allowed it to calculate 10 hours of data without significant drop-framing. Unfortunately, there seems to be a bit of erroneous energy loss at an extremely gradual rate. After 10 hours, objects are moving much more slowly they they were at the start. That should not be occurring! . . . On the other hand, it&#8217;s not often that you run an engine for 10 hours anyway. . . .</span></p>
<p><span style="color: #ffcc00;">UPDATE: I did the same 10 hour test with memory set to 60 seconds and there was no loss of energy! . . . Flash calculations are becoming less accurate due to all the equation data I was storing. . . . How strange. All the more reason to implement backsolving rather than saving all the information.</span></p>
]]></content:encoded>
			<wfw:commentRss>http://blog.sokay.net/2008/04/17/liberty-engine-update-running-clean/feed/</wfw:commentRss>
		<slash:comments>5</slash:comments>
		</item>
		<item>
		<title>Inspiring 3d Flash tech demos</title>
		<link>http://blog.sokay.net/2008/03/06/inspiring-3d-flash-tech-demos/</link>
		<comments>http://blog.sokay.net/2008/03/06/inspiring-3d-flash-tech-demos/#comments</comments>
		<pubDate>Fri, 07 Mar 2008 01:22:56 +0000</pubDate>
		<dc:creator>Bryson Whiteman</dc:creator>
				<category><![CDATA[3d]]></category>
		<category><![CDATA[Actionscript]]></category>
		<category><![CDATA[Everything]]></category>
		<category><![CDATA[Flash Gaming]]></category>
		<category><![CDATA[flash]]></category>
		<category><![CDATA[games]]></category>
		<category><![CDATA[papervision]]></category>

		<guid isPermaLink="false">http://blog.sokay.net/2008/03/06/inspiring-3d-flash-tech-demos/</guid>
		<description><![CDATA[I&#8217;ve been seeing a lot of cool 3d Flash stuff here and there, mostly on development blogs or forums. When I tell people that Flash can do 3d stuff, I get an impression which is a mixture of shock and disbelief. After checking out an informative PaperVision 3d video tutorial on gotoandlearn.com, I was less [...]]]></description>
			<content:encoded><![CDATA[<p>I&#8217;ve been seeing a lot of cool 3d Flash stuff here and there, mostly on development blogs or forums. When I tell people that Flash can do 3d stuff, I get an impression which is a mixture of shock and disbelief. After checking out an informative PaperVision 3d video tutorial on <a href="http://www.gotoandlearn.com/">gotoandlearn.com</a>, I was less intimidated and ready to jump into it. Been looking for an excuse to brush up on my 3d skillz.</p>
<p align="center"><a href="http://cubo.cc/"><img src="http://blog.sokay.net/wp-content/uploads/2008/03/cubocc.jpg" alt="cubocc" /></a><br />
<em>CUBOCC face demo</em></p>
<p>Anyway, I saw <a href="http://cubo.cc/">this demo</a> at <a href="http://cubo.cc/">http://cubo.cc/</a> today and it kind of shocked me. Apparently it&#8217;s a bit viral already, spreading around the net as it should. Some awesome coding, brilliant texturing and a simple design goes a long way, doesn&#8217;t it? The future of Google Adsense? Unfortunately, most likely! haha</p>
<p>But wait&#8230; that&#8217;s not all!</p>
<p><span id="more-149"></span></p>
<p><a href="http://www.renderhjs.net/bbs/flashkit/color_dune/demo5/"><img src="http://blog.sokay.net/wp-content/uploads/2008/03/renderhjs_3d_demo5.jpg" alt="Renderâ€™s 3d demo" /></a><br />
<em>renderhjs&#8217; 3d texturing demo</em></p>
<p align="left">A dude that&#8217;s always impressing the hell out of me is renderhjs from the <a href="http://board.flashkit.com/board/forumdisplay.php?f=5">Flashkit forums</a>. He&#8217;s always doing incredible tech demos and applications and his artwork kicks ass as well. He&#8217;s currently working on a <a href="http://www.renderhjs.net/bbs/flashkit/color_dune/demo5/">3d engine with a custom 3d format</a>, with UV texturing. Now all he needs to do is an IK animation system. <img src='http://blog.sokay.net/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' />  Check out <a href="http://board.flashkit.com/board/showthread.php?t=760371">his thread</a> for it.</p>
<p align="center">  <a href="http://www.papervision3d.org/"><img src="http://blog.sokay.net/wp-content/uploads/2008/03/papervision_greatwhite.jpg" alt="Papervision Great White" /></a><br />
<em>Papervision3d 2.0 site</em></p>
<p align="left">Just in case you&#8217;re not familiar with what the open source 3d Flash engine Papervision3d is capable of, check out the <a href="http://www.papervision3d.org/">official website</a>. It&#8217;s a 3d underwater scene rendered realtime in Flash. Expect to see interfaces like this more often as developers embrace this technology even further.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.sokay.net/2008/03/06/inspiring-3d-flash-tech-demos/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Trace Manager (AS2)</title>
		<link>http://blog.sokay.net/2007/10/10/trace-manager/</link>
		<comments>http://blog.sokay.net/2007/10/10/trace-manager/#comments</comments>
		<pubDate>Wed, 10 Oct 2007 19:53:46 +0000</pubDate>
		<dc:creator>Christopher J. Rock</dc:creator>
				<category><![CDATA[Actionscript]]></category>
		<category><![CDATA[Everything]]></category>
		<category><![CDATA[Sokay Development]]></category>
		<category><![CDATA[actionscript 2.0]]></category>
		<category><![CDATA[AS2]]></category>
		<category><![CDATA[format]]></category>
		<category><![CDATA[manager]]></category>
		<category><![CDATA[organization]]></category>
		<category><![CDATA[readability]]></category>
		<category><![CDATA[trace]]></category>
		<category><![CDATA[trace manager]]></category>

		<guid isPermaLink="false">http://blog.sokay.net/2007/10/10/trace-manager/</guid>
		<description><![CDATA[(See TraceManager (AS2) Update) Finally I put some code up here: &#8220;TraceManager.as&#8221; &#8220;TraceManager Test.fla&#8221; This is an AS file I put together for some big engine work. When your jamming together a lot of code and a big library of functions, it becomes difficult to keep track of what&#8217;s working and what&#8217;s breaking. For me, [...]]]></description>
			<content:encoded><![CDATA[<p align="left"><em>(See <a title="TraceManager (AS2) Update" href="http://blog.sokay.net/2008/08/20/tracemanager-as2-update/" target="_self">TraceManager (AS2) Update</a>)</em></p>
<p align="left">Finally I put some code up here:<br />
<a href="http://www.sokay.net/files/TraceManager.as">&#8220;TraceManager.as&#8221;</a><br />
<a href="http://www.sokay.net/files/TraceManager%20Test.fla">&#8220;TraceManager Test.fla&#8221;</a></p>
<p align="left">This is an AS file I put together for some big engine work. When your jamming together a lot of code and a big library of functions, it becomes difficult to keep track of what&#8217;s working and what&#8217;s breaking. For me, constantly turning traces on and off and having to figure out the meaning of traces that I wrote weeks (or even months) ago gets old fast.</p>
<p align="left">Lately, my physics work has me running more functions than you can shake a stick at; functions within functions within functions, nesting like you wouldn&#8217;t believe.  This leads to the most hideously complex tracing, almost nullifying the reason you trace data to begin with. So I put together this TraceManager to end such problems once and for all:</p>
<p><span style="font-family: Courier New;">_________________________________________<br />
Time(seconds):      Depth:  Function:<br />
&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8211;<br />
0</span><span style="font-family: Courier New; color: white;">________________</span><span style="font-family: Courier New;">+0</span><span style="font-family: Courier New; color: white;">____</span><span style="font-family: Courier New;">function1 (test1){<br />
0</span><span style="font-family: Courier New; color: white;">________________</span><span style="font-family: Courier New;">+1</span><span style="font-family: Courier New; color: white;">____</span><span style="font-family: Courier New; color: white;">____</span><span style="font-family: Courier New;">function2 (test1 1){<br />
0</span><span style="font-family: Courier New; color: white;">________________</span><span style="font-family: Courier New;">+2</span><span style="font-family: Courier New; color: white;">____</span><span style="font-family: Courier New; color: white;">____</span><span style="font-family: Courier New; color: white;">____</span><span style="font-family: Courier New;">function3 (test1 1 2){<br />
0</span><span style="font-family: Courier New; color: white;">________________</span><span style="font-family: Courier New;">-2</span><span style="font-family: Courier New; color: white;">____</span><span style="font-family: Courier New; color: white;">____</span><span style="font-family: Courier New; color: white;">____</span><span style="font-family: Courier New;">} function3&#8212;RESULT( test1 1 2 3 )<br />
0</span><span style="font-family: Courier New; color: white;">________________</span><span style="font-family: Courier New;">-1</span><span style="font-family: Courier New; color: white;">____</span><span style="font-family: Courier New; color: white;">____</span><span style="font-family: Courier New;">} function2&#8212;RESULT( test1 1 2 3 )<br />
0</span><span style="font-family: Courier New; color: white;">________________</span><span style="font-family: Courier New;">-0</span><span style="font-family: Courier New; color: white;">____</span><span style="font-family: Courier New;">}</span><span style="font-family: Courier New;">function1&#8212;RESULT( test1 1 2 3 )<br />
</span></p>
<p><em>-This trace is from the example fla. It runs like so:   function1 takes a string (&#8220;test1&#8243;) and adds a &#8221; 1&#8243; to it, then passes the result to function2;   function2 adds a &#8221; 2&#8243; and passes the result to function3;   function3 adds a &#8221; 3&#8243; to the string and returns it.    Each function returns its own result to its parent function until all functions are complete.</em></p>
<p align="left"><span id="more-100"></span></p>
<p align="left">The new system just requires that the file be initiated, then at the beginning of each of your functions you run &#8220;TraceCheck,&#8221; and at the end, you run &#8220;TraceResult.&#8221;  Traces are automatically formatted to resemble AS code, including indentation to show function nesting.</p>
<p align="left">Since you may not want to see all your functions traced at the same time, you can limit the &#8220;traceDepth&#8221;.  This will determine how &#8220;deeply&#8221; your nesting will be traced out.  If you don&#8217;t want to see all those nested math functions, just set traceDepth to 1 and only the highest level of functions will trace out, otherwise set it to Infinity and see every step in the greatest detail (or use 2 to see only the top 2 nested layers, etc).</p>
<p align="left">Using the tracesUNIVERSAL element in the constructor will automatically define all traceDepths, while tracesTOP will only define traceDepths for functions that have an undefined traceDepth.  In other words, you can easily go between tracing only a specific few functions, tracing all functions except for a few, and tracing every single function you have.</p>
<p align="left">The &#8220;Time&#8221; values allow you to estimate the processing time spent on a single function.  Time values will even change within a single frame of flash activity, so you can easily see what part of your code is lagging.</p>
<p align="left">You can also save on processing power by delaying all your tracing until after your program is done running.  All the trace data is saved as an array of strings until the &#8220;TracePrint&#8221; function is run and everything is converted to a solid string variable and outputted.  This comes in very handy because constant tracing can slow your framerates way down.  You can also use it to give your programs a &#8220;command line&#8221; kind of output by linking the TracePrint function to a key or manually accessing the outputted string (returned by TracePrint).</p>
<p align="left">When your development phase is complete and you don&#8217;t want to spend any unnecessary processing on the TraceManager, you can set the constructor&#8217;s onSwitch variable to &#8220;false&#8221; and TraceManager functions will no longer run.</p>
<p align="left">There&#8217;s a more specific explanation of the TraceManager in the comments at the top of the file.  I&#8217;ve also included an example fla for experimentation.  If you&#8217;re still confused, you found a bug, or want to share your own update to the file, comment here. I&#8217;ll comment whenever changes are made to the original files.</p>
<p align="left">Those links again:<br />
<a href="http://www.sokay.net/files/TraceManager.as">&#8220;TraceManager.as&#8221;</a><br />
<a href="http://www.sokay.net/files/TraceManager%20Test.fla">&#8220;TraceManager Test.fla&#8221;</a></p>
]]></content:encoded>
			<wfw:commentRss>http://blog.sokay.net/2007/10/10/trace-manager/feed/</wfw:commentRss>
		<slash:comments>5</slash:comments>
		</item>
		<item>
		<title>Doom in Flash</title>
		<link>http://blog.sokay.net/2007/07/26/doom-in-flash/</link>
		<comments>http://blog.sokay.net/2007/07/26/doom-in-flash/#comments</comments>
		<pubDate>Fri, 27 Jul 2007 05:30:48 +0000</pubDate>
		<dc:creator>Bryson Whiteman</dc:creator>
				<category><![CDATA[3d]]></category>
		<category><![CDATA[Actionscript]]></category>
		<category><![CDATA[Everything]]></category>
		<category><![CDATA[Flash Gaming]]></category>
		<category><![CDATA[as3]]></category>
		<category><![CDATA[doom]]></category>
		<category><![CDATA[flash]]></category>

		<guid isPermaLink="false">http://blog.sokay.net/?p=82</guid>
		<description><![CDATA[I just checked out this impressive port of the Doom engine to Flash. It even loads up the original external .wad map files! Check it out! It might not be the first Flash port, but it&#8217;s definitely the first that resembles the original in speed and resolution. I could totally imagine playing some deathmatch in [...]]]></description>
			<content:encoded><![CDATA[<p>I just checked out this impressive port of the Doom engine to Flash. It even loads up the original external .wad map files!</p>
<p><a href="http://blog.brokenfunction.com/2007/07/20/flash-plays-doom/">Check it out!</a></p>
<p><a title="Doom in Flash" href="http://blog.brokenfunction.com/2007/07/20/flash-plays-doom/"><img src="http://blog.sokay.net/wp-content/uploads/2007/07/doomflash.jpg" alt="Doom in Flash" /></a></p>
<p>It might not be the first Flash port, but it&#8217;s definitely the first that resembles the original in speed and resolution. I could totally imagine playing some deathmatch in this thing. Can&#8217;t wait till something like that is available.</p>
<p>It&#8217;s also worth nothing that this was not created using Flash. It was developed on Linux using open-source/free Flex tools.</p>
<p>This reminds of back in 2001 or so when I saw a demo for a Quake 3 looking engine in Shockwave running incredibly fluidly. I recall it being a Q3 port of some sort because it was created by the same company that ported Q3 to Dreamcast, Raster Productions. I&#8217;m assuming it was some kind of port because they removed the demo after a short while, I believe because of legal matters.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.sokay.net/2007/07/26/doom-in-flash/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
	</channel>
</rss>
