<?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>Mike R :: R ekim &#187; experiments</title>
	<atom:link href="http://www.rekim.com/topics/tech/flash/experiments/feed/" rel="self" type="application/rss+xml" />
	<link>https://www.rekim.com</link>
	<description>Mike Robinson</description>
	<lastBuildDate>Sat, 27 Jan 2024 18:04:13 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
		<item>
		<title>Chaos Pendulum</title>
		<link>https://www.rekim.com/2009/11/07/chaos-pendulum/</link>
		<comments>https://www.rekim.com/2009/11/07/chaos-pendulum/#comments</comments>
		<pubDate>Sat, 07 Nov 2009 13:51:58 +0000</pubDate>
		<dc:creator>Mike</dc:creator>
				<category><![CDATA[experiments]]></category>

		<guid isPermaLink="false">http://www.rekim.com/?p=21</guid>
		<description><![CDATA[We saw a program that had a double pendulum called the chaos pendulum and my girlfriend said I should try and make it, so I had a quick play in quickbox2d. It was being used as an example of chaotic &#8230; <a href="https://www.rekim.com/2009/11/07/chaos-pendulum/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>We saw a program that had a double pendulum called the chaos pendulum and my girlfriend said I should try and make it, so I had a quick play in quickbox2d. It was being used as an example of chaotic looking movement that wasn&#8217;t random. Here&#8217;s a real one.</p>
<p><object width="425" height="350" classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,40,0"><param name="src" value="http://www.youtube.com/v/Whvl6CikDxA" /><embed width="425" height="350" type="application/x-shockwave-flash" src="http://www.youtube.com/v/Whvl6CikDxA" /></object></p>
<p>and here&#8217;s the flash on, it&#8217;s not as good but box2d does an interesting job.</p>

    <object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" id="swfobj_0" width="450" height="350">
      <param name="movie" value="http://www.rekim.com/wp-content/uploads/2009/11/chaos_pendulum_2.swf" />
      <!--[if !IE]>-->
      <object type="application/x-shockwave-flash" data="http://www.rekim.com/wp-content/uploads/2009/11/chaos_pendulum_2.swf" width="450" height="350">
      <!--<![endif]-->
        
      <!--[if !IE]>-->
      </object>
      <!--<![endif]-->
    </object>

<p><span id="more-21"></span></p>
<p>let&#8217;s test putting some code on here..  then you need to get <a href="http://actionsnippet.com/?page_id=1391">quickbox2d</a>&#8230;</p>
<div class="codecolorer-container actionscript3 default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;height:300px;"><div class="actionscript3 codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #0033ff; font-weight: bold;">import</span> com<span style="color: #000066; font-weight: bold;">.</span>actionsnippet<span style="color: #000066; font-weight: bold;">.</span>qbox<span style="color: #000066; font-weight: bold;">.*;</span><br />
<span style="color: #004993;">stage</span><span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">frameRate</span> = <span style="color: #000000; font-weight:bold;">60</span><span style="color: #000066; font-weight: bold;">;</span><br />
<br />
<span style="color: #6699cc; font-weight: bold;">var</span> sim<span style="color: #000066; font-weight: bold;">:</span>QuickBox2D = <span style="color: #0033ff; font-weight: bold;">new</span> QuickBox2D<span style="color: #000000;">&#40;</span><span style="color: #0033ff; font-weight: bold;">this</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span><br />
<br />
<span style="color: #6699cc; font-weight: bold;">var</span> $x<span style="color: #000066; font-weight: bold;">:</span><a href="http://www.google.com/search?q=number%20inurl:http://livedocs.adobe.com/flex/201/langref/%20inurl:number.html"><span style="color: #004993;">Number</span></a> = <span style="color: #000000; font-weight:bold;">9</span><br />
<span style="color: #6699cc; font-weight: bold;">var</span> $y<span style="color: #000066; font-weight: bold;">:</span><a href="http://www.google.com/search?q=int%20inurl:http://livedocs.adobe.com/flex/201/langref/%20inurl:int.html"><span style="color: #004993;">int</span></a> = <span style="color: #000000; font-weight:bold;">4</span><br />
<span style="color: #6699cc; font-weight: bold;">var</span> $length<span style="color: #000066; font-weight: bold;">:</span><a href="http://www.google.com/search?q=int%20inurl:http://livedocs.adobe.com/flex/201/langref/%20inurl:int.html"><span style="color: #004993;">int</span></a> = <span style="color: #000000; font-weight:bold;">5</span><br />
<span style="color: #6699cc; font-weight: bold;">var</span> $radius<span style="color: #000066; font-weight: bold;">:</span><a href="http://www.google.com/search?q=number%20inurl:http://livedocs.adobe.com/flex/201/langref/%20inurl:number.html"><span style="color: #004993;">Number</span></a> = <span style="color: #000000; font-weight:bold;">0.5</span><br />
<br />
<span style="color: #6699cc; font-weight: bold;">var</span> pin_to<span style="color: #000066; font-weight: bold;">:</span>QuickObject = sim<span style="color: #000066; font-weight: bold;">.</span>addBox<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#123;</span><span style="color: #004993;">x</span><span style="color: #000066; font-weight: bold;">:</span>$x<span style="color: #000066; font-weight: bold;">,</span> <span style="color: #004993;">y</span><span style="color: #000066; font-weight: bold;">:</span>$y<span style="color: #000066; font-weight: bold;">,</span> <span style="color: #004993;">width</span><span style="color: #000066; font-weight: bold;">:</span><span style="color: #000000; font-weight:bold;">0.5</span><span style="color: #000066; font-weight: bold;">,</span> <span style="color: #004993;">height</span><span style="color: #000066; font-weight: bold;">:</span><span style="color: #000000; font-weight:bold;">0.25</span><span style="color: #000066; font-weight: bold;">,</span>density<span style="color: #000066; font-weight: bold;">:</span><span style="color: #000000; font-weight:bold;">0</span><span style="color: #000066; font-weight: bold;">,</span> maskBits<span style="color: #000066; font-weight: bold;">:</span>0x0008 <span style="color: #000000;">&#125;</span> <span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span><br />
<span style="color: #6699cc; font-weight: bold;">var</span> top_pendulum<span style="color: #000066; font-weight: bold;">:</span>QuickObject = sim<span style="color: #000066; font-weight: bold;">.</span>addBox<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#123;</span><span style="color: #004993;">x</span><span style="color: #000066; font-weight: bold;">:</span>$x<span style="color: #000066; font-weight: bold;">,</span> <span style="color: #004993;">y</span><span style="color: #000066; font-weight: bold;">:</span>$y<span style="color: #000066; font-weight: bold;">+</span><span style="color: #000000;">&#40;</span>$length <span style="color: #000066; font-weight: bold;">*</span> <span style="color: #000000; font-weight:bold;">0.5</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">,</span> <span style="color: #004993;">height</span><span style="color: #000066; font-weight: bold;">:</span>$length<span style="color: #000066; font-weight: bold;">,</span><span style="color: #004993;">width</span><span style="color: #000066; font-weight: bold;">:</span><span style="color: #000000; font-weight:bold;">1.5</span><span style="color: #000066; font-weight: bold;">,</span>friction<span style="color: #000066; font-weight: bold;">:</span><span style="color: #000000; font-weight:bold;">0</span><span style="color: #000066; font-weight: bold;">,</span>restitution<span style="color: #000066; font-weight: bold;">:</span><span style="color: #000000; font-weight:bold;">0</span> <span style="color: #000000;">&#125;</span> <span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span><br />
<span style="color: #6699cc; font-weight: bold;">var</span> bottom_pendulum<span style="color: #000066; font-weight: bold;">:</span>QuickObject = sim<span style="color: #000066; font-weight: bold;">.</span>addBox<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#123;</span><span style="color: #004993;">x</span><span style="color: #000066; font-weight: bold;">:</span>$x<span style="color: #000066; font-weight: bold;">,</span> <span style="color: #004993;">y</span><span style="color: #000066; font-weight: bold;">:</span>$y <span style="color: #000066; font-weight: bold;">+</span> <span style="color: #000000;">&#40;</span> $length <span style="color: #000066; font-weight: bold;">*</span> <span style="color: #000000; font-weight:bold;">1.3</span> <span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">,</span> <span style="color: #004993;">height</span><span style="color: #000066; font-weight: bold;">:</span>$length<span style="color: #000066; font-weight: bold;">,</span><span style="color: #004993;">width</span><span style="color: #000066; font-weight: bold;">:</span><span style="color: #000000; font-weight:bold;">0.75</span><span style="color: #000066; font-weight: bold;">,</span>friction<span style="color: #000066; font-weight: bold;">:</span><span style="color: #000000; font-weight:bold;">0</span><span style="color: #000066; font-weight: bold;">,</span>restitution<span style="color: #000066; font-weight: bold;">:</span><span style="color: #000000; font-weight:bold;">0</span> <span style="color: #000000;">&#125;</span> <span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span><br />
<br />
<span style="color: #009900; font-style: italic;">//SET UP JOINTS</span><br />
sim<span style="color: #000066; font-weight: bold;">.</span>addJoint<span style="color: #000000;">&#40;</span> <span style="color: #000000;">&#123;</span><span style="color: #004993;">type</span><span style="color: #000066; font-weight: bold;">:</span><span style="color: #990000;">&quot;revolute&quot;</span><span style="color: #000066; font-weight: bold;">,</span>a<span style="color: #000066; font-weight: bold;">:</span>pin_to<span style="color: #000066; font-weight: bold;">.</span>body<span style="color: #000066; font-weight: bold;">,</span><span style="color: #004993;">b</span><span style="color: #000066; font-weight: bold;">:</span>top_pendulum<span style="color: #000066; font-weight: bold;">.</span>body<span style="color: #000066; font-weight: bold;">,</span>collideConnected<span style="color: #000066; font-weight: bold;">:</span><span style="color: #0033ff; font-weight: bold;">false</span><span style="color: #000066; font-weight: bold;">,</span> x1<span style="color: #000066; font-weight: bold;">:</span>$x<span style="color: #000066; font-weight: bold;">,</span> y1<span style="color: #000066; font-weight: bold;">:</span>$y<span style="color: #000066; font-weight: bold;">,</span> x2<span style="color: #000066; font-weight: bold;">:</span>$x<span style="color: #000066; font-weight: bold;">,</span> y2<span style="color: #000066; font-weight: bold;">:</span>$y <span style="color: #000000;">&#125;</span> <span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span><br />
sim<span style="color: #000066; font-weight: bold;">.</span>addJoint<span style="color: #000000;">&#40;</span> <span style="color: #000000;">&#123;</span><span style="color: #004993;">type</span><span style="color: #000066; font-weight: bold;">:</span><span style="color: #990000;">&quot;revolute&quot;</span><span style="color: #000066; font-weight: bold;">,</span>a<span style="color: #000066; font-weight: bold;">:</span>top_pendulum<span style="color: #000066; font-weight: bold;">.</span>body<span style="color: #000066; font-weight: bold;">,</span><span style="color: #004993;">b</span><span style="color: #000066; font-weight: bold;">:</span>bottom_pendulum<span style="color: #000066; font-weight: bold;">.</span>body<span style="color: #000066; font-weight: bold;">,</span>collideConnected<span style="color: #000066; font-weight: bold;">:</span><span style="color: #0033ff; font-weight: bold;">false</span><span style="color: #000066; font-weight: bold;">,</span> x1<span style="color: #000066; font-weight: bold;">:</span>$x<span style="color: #000066; font-weight: bold;">,</span> y1<span style="color: #000066; font-weight: bold;">:</span>$y<span style="color: #000066; font-weight: bold;">+</span><span style="color: #000000;">&#40;</span> $length <span style="color: #000066; font-weight: bold;">*</span> <span style="color: #000000; font-weight:bold;">0.9</span> <span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">,</span> x2<span style="color: #000066; font-weight: bold;">:</span>$x<span style="color: #000066; font-weight: bold;">,</span> y2<span style="color: #000066; font-weight: bold;">:</span>$y<span style="color: #000066; font-weight: bold;">+</span>$length<span style="color: #000066; font-weight: bold;">-</span><span style="color: #000000; font-weight:bold;">0.25</span> <span style="color: #000000;">&#125;</span> <span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span><br />
<br />
sim<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">start</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span><br />
sim<span style="color: #000066; font-weight: bold;">.</span>mouseDrag<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span><br />
<br />
<span style="color: #009900; font-style: italic;">//ADD RANDOM ANGULAR VELOCITY ON CLICK</span><br />
<span style="color: #009900; font-style: italic;">//JUST SETTING THE bottom_pendulum SEEMS TO WORK</span><br />
<span style="color: #004993;">stage</span><span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">addEventListener</span><span style="color: #000000;">&#40;</span> <a href="http://www.google.com/search?q=mouseevent%20inurl:http://livedocs.adobe.com/flex/201/langref/%20inurl:mouseevent.html"><span style="color: #004993;">MouseEvent</span></a><span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">CLICK</span><span style="color: #000066; font-weight: bold;">,</span> clicked <span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span><br />
<br />
<span style="color: #339966; font-weight: bold;">function</span> clicked<span style="color: #000000;">&#40;</span> e<span style="color: #000066; font-weight: bold;">:</span><a href="http://www.google.com/search?q=mouseevent%20inurl:http://livedocs.adobe.com/flex/201/langref/%20inurl:mouseevent.html"><span style="color: #004993;">MouseEvent</span></a> <span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">:</span><span style="color: #0033ff; font-weight: bold;">void</span><br />
<span style="color: #000000;">&#123;</span><br />
bottom_pendulum<span style="color: #000066; font-weight: bold;">.</span>body<span style="color: #000066; font-weight: bold;">.</span>SetAngularVelocity<span style="color: #000000;">&#40;</span> <span style="color: #000000; font-weight:bold;">10000</span><span style="color: #000066; font-weight: bold;">-</span><a href="http://www.google.com/search?q=math%20inurl:http://livedocs.adobe.com/flex/201/langref/%20inurl:math.html"><span style="color: #004993;">Math</span></a><span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">random</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span> <span style="color: #000066; font-weight: bold;">*</span> <span style="color: #000000; font-weight:bold;">20000</span> <span style="color: #000000;">&#41;</span><br />
<span style="color: #000000;">&#125;</span></div></div>
]]></content:encoded>
			<wfw:commentRss>https://www.rekim.com/2009/11/07/chaos-pendulum/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Quickbox2d string and balls</title>
		<link>https://www.rekim.com/2009/11/06/quickbox2d-string-and-balls/</link>
		<comments>https://www.rekim.com/2009/11/06/quickbox2d-string-and-balls/#comments</comments>
		<pubDate>Fri, 06 Nov 2009 00:15:43 +0000</pubDate>
		<dc:creator>Mike</dc:creator>
				<category><![CDATA[experiments]]></category>
		<category><![CDATA[flash]]></category>

		<guid isPermaLink="false">http://www.rekim.com/?p=8</guid>
		<description><![CDATA[Right my first geeky quick flash experiment&#8230;&#8230; Skip past the text and take a look at the fun. A few games I&#8217;ve been working on at the mo have required some 2d physics so I&#8217;ve been looking at box2d again. &#8230; <a href="https://www.rekim.com/2009/11/06/quickbox2d-string-and-balls/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>Right my first geeky quick flash experiment&#8230;&#8230; Skip past the text and take a look at the fun.</p>
<p>A few games I&#8217;ve been working on at the mo have required some 2d physics so I&#8217;ve been looking at box2d again. The last thing I did with it was <a title="gorillaz bananaz cannon" href="http://www.bananazfilm.com/games/bananacannon/">&#8220;banana cannon&#8221;</a> balancing game for Gorillaz Bananaz. Since then <a title="actionsnippet" href="http://www.actionsnippet.org">actionsnippet.org</a> has packaged up box2d into <a title="quickbox2d" href="http://actionsnippet.com/?page_id=1391">quickbox2d</a> making it &#8220;quick&#8221;. It&#8217;s worth a look.</p>
<p>Anyway one of the things needed was a nice looking rope/wire effect connecting 2 objects that would allow them to move freely when the rope wasn&#8217;t tort. I couldn&#8217;t find a single joint that didn&#8217;t affect the rotation of the other object while moving around. I&#8217;m sure there&#8217;s probably a better way, but I managed to achieve the effect by creating a an extra hidden object like a knee inbetween the 2 and applying a distance joint from the knee to each object. Then to cheat a nice bendy/rubbery rope look I drew a line using curveTo going from one object to the other bending towards the knee. Take a look below.</p>

    <object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" id="swfobj_1" width="500" height="370">
      <param name="movie" value="http://www.rekim.com/wp-content/uploads/2009/11/swings.swf" />
      <!--[if !IE]>-->
      <object type="application/x-shockwave-flash" data="http://www.rekim.com/wp-content/uploads/2009/11/swings.swf" width="500" height="370">
      <!--<![endif]-->
        
      <!--[if !IE]>-->
      </object>
      <!--<![endif]-->
    </object>

<p>And behind the scenes</p>

    <object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" id="swfobj_2" width="275" height="200">
      <param name="movie" value="http://www.rekim.com/wp-content/uploads/2009/11/swings_debug1.swf" />
      <!--[if !IE]>-->
      <object type="application/x-shockwave-flash" data="http://www.rekim.com/wp-content/uploads/2009/11/swings_debug1.swf" width="275" height="200">
      <!--<![endif]-->
        
      <!--[if !IE]>-->
      </object>
      <!--<![endif]-->
    </object>

<p>UPDATE:<br />
I&#8217;ve added a post about calculating a point to make curveTo curveThrough a point. It&#8217;s how the string curves towards the knee.<br />
<a href="http://www.rekim.com/2009/11/15/graphics-curveto-through-point/">graphics-curveto-through-point</a></p>
]]></content:encoded>
			<wfw:commentRss>https://www.rekim.com/2009/11/06/quickbox2d-string-and-balls/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
	</channel>
</rss>
