<?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>SQUARISM &#187; GameDev</title>
	<atom:link href="http://squarism.com/category/gamedev/feed/" rel="self" type="application/rss+xml" />
	<link>http://squarism.com</link>
	<description>until lambs become lions</description>
	<lastBuildDate>Mon, 07 May 2012 17:52:50 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.2</generator>
		<item>
		<title>Hollywood Security BS</title>
		<link>http://squarism.com/2010/12/03/hollywood-security-bs/</link>
		<comments>http://squarism.com/2010/12/03/hollywood-security-bs/#comments</comments>
		<pubDate>Sat, 04 Dec 2010 03:36:51 +0000</pubDate>
		<dc:creator>Dillon</dc:creator>
				<category><![CDATA[GameDev]]></category>
		<category><![CDATA[Java]]></category>
		<category><![CDATA[Processing]]></category>

		<guid isPermaLink="false">http://squarism.com/?p=791</guid>
		<description><![CDATA[I had watched Alicia Silverstone &#8216;hack&#8217; a system recently and decided to make a mostly functional mock up like they do in the movies. I&#8217;m getting pretty comfortable in Processing and even though I really can&#8217;t stand Java anymore, I wanted to get this thing done and out of my head. I was just going [...]]]></description>
			<content:encoded><![CDATA[<p><img src="http://squarism.com/wp-content/uploads/2010/12/sshot_1-580x468.png" alt="" title="HollywoodSecurity" width="580" height="468" class="aligncenter size-large wp-image-792" /></p>
<p>I had watched Alicia Silverstone &#8216;hack&#8217; a system recently and decided to make a mostly functional mock up like they do in the movies.  I&#8217;m getting pretty comfortable in <a href="http://processing.org/">Processing</a> and even though I really can&#8217;t stand <a href="http://www.oracle.com/technetwork/java/index.html">Java</a> anymore, I wanted to get this thing done and out of my head.  I was just going to skip over this idea but inspiration just started flowing and I was idly solving it while getting coffee etc and I just had to get it on paper/code.</p>
<p>So here are the things it does:</p>
<ul>
<li>Switches between two GameState objects login and success</li>
<li>Separate the view and the state (more on this)</li>
<li>Has a super cool blinking cursor</li>
<li>Handles shift, ctrl and meta (windows key) gracefully</li>
<li>Handles backspace</li>
<li>When you type muffin, it takes you to the super secret database &#8230; or whatever</li>
<li>Goes fullscreen (which you can&#8217;t see in this shot)</li>
</ul>
<p>This could get out of hand real quick.  First, I reused a ton of code from Tatris.  But in Tatris, the game state was tied to a view.  I had pictured this project having different views.  Like instead of a password prompt, maybe there&#8217;d be a keypad with a combo.  Same state object (authorized vs unauthorized) so I didn&#8217;t need to recreate the wheel.  The problem is, I don&#8217;t really have a controller so I&#8217;m kinda breaking MVC.  But I didn&#8217;t want this thing to bloat up so I just went with it.</p>
<p>Next, UI layer.  Not great.  I&#8217;m drawing text boxes and blinking cursors.  It&#8217;s really pretty messy.  I&#8217;d be better off picking some UI components or something and using those.  It&#8217;s tough.  Even in games, there&#8217;s so many UI differences.  Different scrollbars, different OK type buttons.  What a usability nightmare.  But I&#8217;m trying to create an old school terminal so all the weirdness is actually good.</p>
<p>Anyway, it was a fun little diversion.  There&#8217;s more on <a href="https://github.com/squarism/HollywoodSecurity">the github page</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://squarism.com/2010/12/03/hollywood-security-bs/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Better tetris collision detection</title>
		<link>http://squarism.com/2009/07/09/better-tetris-collision-detection/</link>
		<comments>http://squarism.com/2009/07/09/better-tetris-collision-detection/#comments</comments>
		<pubDate>Fri, 10 Jul 2009 02:44:26 +0000</pubDate>
		<dc:creator>Dillon</dc:creator>
				<category><![CDATA[GameDev]]></category>
		<category><![CDATA[Processing]]></category>

		<guid isPermaLink="false">http://squarism.com/?p=244</guid>
		<description><![CDATA[As I said in the TODO part of the Making Tetris post, a better way to do collision detection is to have the blocks on the field be bits. This is typically what I saw in academic assignments and student presentations. This is probably the right way to do it in other words. It&#8217;s more [...]]]></description>
			<content:encoded><![CDATA[<p><img src="http://squarism.com/wp-content/uploads/2009/07/deadgrid.png" alt="deadgrid" title="deadgrid" width="336" height="358" class="aligncenter size-full wp-image-247" /></p>
<p>As I said in the TODO part of the <a href="http://squarism.com/2009/06/22/making-tetris/4/">Making Tetris post</a>, a better way to do collision detection is to have the blocks on the field be bits.  This is typically what I saw in academic assignments and student presentations.  This is probably the right way to do it in other words.  It&#8217;s more efficient and it&#8217;s more simple (<a href="http://en.wikipedia.org/wiki/KISS_principle">KISS</a>).</p>
<p>Even though this isn&#8217;t how I did it in the game, I still wanted to play around with the concept so I made a little prototype that demonstrates the basic gist.  Instead of a piece, it&#8217;s a single block.  Instead of a tetris grid of finished blocks, it&#8217;s random blocks.  It&#8217;s really the same thing, it just looks and plays with different shapes.</p>
<p>So here it is.  Space randomizes the grid and the arrow keys move.  <a href="http://squarism.com/files/deadgrid">Play It!</a></p>
]]></content:encoded>
			<wfw:commentRss>http://squarism.com/2009/07/09/better-tetris-collision-detection/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Making Tatris</title>
		<link>http://squarism.com/2009/06/22/making-tatris/</link>
		<comments>http://squarism.com/2009/06/22/making-tatris/#comments</comments>
		<pubDate>Mon, 22 Jun 2009 21:01:23 +0000</pubDate>
		<dc:creator>Dillon</dc:creator>
				<category><![CDATA[GameDev]]></category>
		<category><![CDATA[Noteworthy]]></category>
		<category><![CDATA[Processing]]></category>

		<guid isPermaLink="false">http://squarism.com/?p=153</guid>
		<description><![CDATA[Backstory In my last job, I was a hourly contractor who had finished a project and was transitioning off to other things. By a chance of fortune, I had an opportunity to take some time off and do whatever. I had one week on, one week off for a period of over a month. I [...]]]></description>
			<content:encoded><![CDATA[<p><img src="http://squarism.com/wp-content/uploads/2009/04/tatris_03.png" alt="tatris_03" title="tatris_03" width="400" height="598" class="aligncenter size-full wp-image-235" /></p>
<h2>Backstory</h2>
<p>In my last job, I was a hourly contractor who had finished a project and was transitioning off to other things.  By a chance of fortune, I had an opportunity to take some time off and do whatever.  I had one week on, one week off for a period of over a month.  I was extremely excited because I have a lot of hobbies that are bound by time and this was exactly what I wanted.  Time to do whatever.  I was curious to see whether I&#8217;d waste it or actually produce something.  I&#8217;m happy to say that I did not waste the time I had and I produced the most intense gamedev learning experience I&#8217;ve ever had.  By no means, am I claiming to be an expert.  I&#8217;m just documenting a very large personal effort.</p>
<p>Ok, enough of all that personal crap.  In reading game development community sites (like gamedev.net and idevgames.com), something that was a near cosmological constant is the post &#8220;OMG I wnt to make mmo, pls halp!&#8221;.  It&#8217;s like a nuclear clock.  Someone does some subscription revenue math, gets excited with dreams of being rich, tries to start something ridiculously complicated, gets stuck and runs to a forum looking for members or advice.  On a forum like idevgames.com, there are exceptional members (who should be praised for their patience and humanity) that take the time to respond to this never-ending line of questioning.  The most effective response is, &#8220;have you made tetris yet?&#8221;.  Usually the person has not made a simple game and I doubt that they end up doing so.  However, eventually this idea sunk in and I realized: <em>I do not want to make an MMO but I should make Tetris</em>.  Because someday I might want to make something more complicated (not an MMO).  So let&#8217;s do this.</p>
<h2>The Plan</h2>
<p>Firstly, I had been doing Java at my job for a while now and am fairly comfortable with it.  Outside of this, I had been messing around with a project called <a href="http://processing.org">Processing</a> which makes graphics and generative art really easy.  I knew this was going to be complicated so instead of diving into code, I made a plan first.  I started breaking down what Tetris is and mapped out classes and responsibility.  This planning bit I&#8217;ve always been bad at and I spent maybe a day thinking and writing down like &#8220;what a tetris piece is&#8221; and what minimal features there should be.  The gameplay and design is already done and this fact is a big step compared to coming up with something by yourself.</p>
<p>For sure, the lesson I learned is: &#8220;it&#8217;s just a plan&#8221;.  You can change it as you go and eventually it&#8217;s best to throw it away after things are sufficiently started.  As the code grew, the plan was put away; which is good because my plan wasn&#8217;t really all that special or well organized.  I had some ideas about pieces to be written and what the hard parts were but honestly the best lesson I learned was &#8220;it&#8217;s just a plan&#8221;.  You&#8217;re not going to pre-write and pre-solve all the problems.</p>
<p>Next was research and learning.  I studied other processing games (like <a href="http://lux.vu/blog/2005/01/06/monkey-patrol/">MonkeyPatrol</a> by Joshua Minor) and white papers from university CS classes.  I played Quinn (a mac OSX clone) a bit.  I knew a few things to start with.  For example, game objects should draw themselves.  There are 7 piece types (which look similar to the letters: I L O J S Z T) and many things are similar between them so I planned for a base Piece class and named the pieces after the letters they looked like (IPiece, LPiece, etc).  I collected some screenshots of existing games to use as inspiration.</p>
<h2>Drawing a Piece</h2>
<p>Ok, I had my plan and similar stuff done.  Ok, where to start?  I like to start from the top down.  IE: from the interface backwards.  So I start with a graphical mockup and then make the mockup actually function.  So started out with drawing.  First, I created a Block class.  This is a single square with an x,y,height,width,color etc.  It&#8217;s a component of a Piece.  Before going any further.  I have to explain that I intentionally did not do Tetris the easy way.  The easy way is having a bitmap style grid of blocks and simply moving the bits down and around.  Then you just represent the bitmap with graphics.  I did not do it this way because I wanted an excuse to do sorta a &#8220;2d model&#8221; where the piece is constructed from a central point, rotated etc more like what someone would do with a 3d model in a modern game.  This single decision made things extremely complicated for me but it also made it a more useful learning experience for when I want to do something like a platformer or a shooter because these game types use collision detection in a 2d/3d space similar to how I did it.  So a Piece consists of Blocks with a model describing the shape of the Piece.  For example, an LPiece looks like this:</p>
<p><code>1<br />
2<br />
34</code></p>
<p>And the IPiece looks like this:<br />
<code>1<br />
2<br />
3<br />
4</code></p>
<p>And the OPiece looks like this:<br />
<code>12<br />
34</code></p>
<p>So I created all the Pieces and eventually had a test app that looked like this:<br />
<img src="http://squarism.com/wp-content/uploads/2009/04/tatris_block_test-189x300.png" alt="tatris_block_test" title="tatris_block_test" width="189" height="300" class="aligncenter size-medium wp-image-233" /></p>
<p>Next, let&#8217;s move on to piece movement.</p>
<p><span id="more-153"></span></p>
]]></content:encoded>
			<wfw:commentRss>http://squarism.com/2009/06/22/making-tatris/feed/</wfw:commentRss>
		<slash:comments>5</slash:comments>
		</item>
		<item>
		<title>Elevator Sim update</title>
		<link>http://squarism.com/2009/06/21/elevator-sim-update/</link>
		<comments>http://squarism.com/2009/06/21/elevator-sim-update/#comments</comments>
		<pubDate>Sun, 21 Jun 2009 16:16:47 +0000</pubDate>
		<dc:creator>Dillon</dc:creator>
				<category><![CDATA[GameDev]]></category>
		<category><![CDATA[Processing]]></category>

		<guid isPermaLink="false">http://squarism.com/?p=221</guid>
		<description><![CDATA[Quick update about the elevator sim post. Currently the cars are animating fine. IE: you press 3 and car #1 goes to floor three, stops, opens the door and waits. If you press 1, the car closes the door, moves to floor 1 and opens the door. The building controller is aware of the care [...]]]></description>
			<content:encoded><![CDATA[<p><img src="http://squarism.com/wp-content/uploads/2009/06/elevator_sim_2.png" alt="elevator_sim_2" title="elevator_sim_2" width="314" height="227" class="aligncenter size-full wp-image-222" /><br />
Quick update about <a href="http://squarism.com/2009/04/26/elevator-sim-wip/">the elevator sim post</a>.  Currently the cars are animating fine.  IE: you press 3 and car #1 goes to floor three, stops, opens the door and waits.  If you press 1, the car closes the door, moves to floor 1 and opens the door.  The building controller is aware of the care state as evidenced by the little labels you see.</p>
<p>The person sprite (on that line there) is currently a placeholder.  He paths over to wait for the elevator but I don&#8217;t have the &#8220;AI&#8221; done for him to wait.</p>
<p>This has lost a bit of traction since I&#8217;ve been cranking on the iPhone class.</p>
]]></content:encoded>
			<wfw:commentRss>http://squarism.com/2009/06/21/elevator-sim-update/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Parallax Clouds</title>
		<link>http://squarism.com/2009/05/06/parallax-clouds/</link>
		<comments>http://squarism.com/2009/05/06/parallax-clouds/#comments</comments>
		<pubDate>Thu, 07 May 2009 02:51:56 +0000</pubDate>
		<dc:creator>Dillon</dc:creator>
				<category><![CDATA[GameDev]]></category>
		<category><![CDATA[Processing]]></category>

		<guid isPermaLink="false">http://squarism.com/?p=206</guid>
		<description><![CDATA[Updated this a bit. Added sound, scanlines, mouse following, bird sprite thing. Made a few performance tweaks. It still runs a bit slow, it&#8217;s better under OpenGL but you can&#8217;t embed it in a web page. The code is from a while back and I just polished it a bit so the source is fugly, [...]]]></description>
			<content:encoded><![CDATA[<p><img src="http://squarism.com/wp-content/uploads/2009/05/paraclouds.png" alt="paraclouds" title="paraclouds" width="470" height="303" class="aligncenter size-full wp-image-217" /></p>
<p>Updated this a bit.  Added sound, scanlines, mouse following, bird sprite thing.  Made a few performance tweaks.  It still runs a bit slow, it&#8217;s better under OpenGL but you can&#8217;t embed it in a web page.  The code is from a while back and I just polished it a bit so the source is fugly, fugly, fugly.  I like the tune though.  The ableton live demo has turned into a musical idea notebook and a short idea is all I seem to grind on.</p>
<p>The music is original (no samples).</p>
<p>View it <a href="http://squarism.com/files/parallaxmusic/">here</a>.</p>
<p><a href="http://squarism.com/files/ParallaxClouds-mac-fullscreen.zip">Download here &#8211; Mac</a>, if you want to run it fullscreen.</p>
]]></content:encoded>
			<wfw:commentRss>http://squarism.com/2009/05/06/parallax-clouds/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Elevator Sim [wip]</title>
		<link>http://squarism.com/2009/04/26/elevator-sim-wip/</link>
		<comments>http://squarism.com/2009/04/26/elevator-sim-wip/#comments</comments>
		<pubDate>Mon, 27 Apr 2009 02:25:29 +0000</pubDate>
		<dc:creator>Dillon</dc:creator>
				<category><![CDATA[GameDev]]></category>
		<category><![CDATA[Processing]]></category>

		<guid isPermaLink="false">http://squarism.com/?p=183</guid>
		<description><![CDATA[Car idle: Car called, doors open. Some shots from a work in progress. Elevator simulator. People are going to get on and off and ride the cars down. It&#8217;s an exercise in 3d, queuing, event detection (without using events) and a boat load of other stuff. It&#8217;s coming along nicely. The car motion is really [...]]]></description>
			<content:encoded><![CDATA[<p>Car idle:<br />
<img src="http://squarism.com/wp-content/uploads/2009/04/elevator_sim_wip_1.png" alt="elevator_sim_wip_1" title="elevator_sim_wip_1" width="480" height="302" class="aligncenter size-full wp-image-184" /></p>
<p>Car called, doors open.<br />
<img src="http://squarism.com/wp-content/uploads/2009/04/elevator_sim_wip_2.png" alt="elevator_sim_wip_2" title="elevator_sim_wip_2" width="480" height="302" class="aligncenter size-full wp-image-185" /></p>
<p>Some shots from a work in progress.  Elevator simulator.  People are going to get on and off and ride the cars down.  It&#8217;s an exercise in 3d, queuing, event detection (without using events) and a boat load of other stuff.  It&#8217;s coming along nicely.  The car motion is really convincing.</p>
]]></content:encoded>
			<wfw:commentRss>http://squarism.com/2009/04/26/elevator-sim-wip/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Triangle Building</title>
		<link>http://squarism.com/2009/04/03/triangle-building/</link>
		<comments>http://squarism.com/2009/04/03/triangle-building/#comments</comments>
		<pubDate>Sat, 04 Apr 2009 03:44:24 +0000</pubDate>
		<dc:creator>Dillon</dc:creator>
				<category><![CDATA[GameDev]]></category>
		<category><![CDATA[Processing]]></category>

		<guid isPermaLink="false">http://squarism.com/?p=129</guid>
		<description><![CDATA[I got distracted while working on an actual game and started messing around with image recognition. I was greatly inspired by the LevelHead tech demo and thoroughly depressed by Julian Oliver&#8217;s talent. I started messing around with OpenCV and wanted to track rotation of objects. I figured out that a triangle would be the best [...]]]></description>
			<content:encoded><![CDATA[<p><img src="http://squarism.com/wp-content/uploads/2009/04/triangle_building_1-580x435.jpg" alt="triangle_building_1" title="triangle_building_1" width="580" height="435" class="aligncenter size-large wp-image-130" /><br />
I got distracted while working on an actual game and started messing around with image recognition.  I was greatly inspired by <a href="http://vimeo.com/1320756">the LevelHead tech demo</a> and thoroughly depressed by Julian Oliver&#8217;s talent.  I started messing around with OpenCV and wanted to track rotation of objects.  I figured out that a triangle would be the best way to track rotation because a right-triangle is unique when rotated 90º four times.</p>
<p>So the magic triangle again.  It seems it has endless uses.  I started trying to draw one programmatically. But my trig skills are lacking and I needed to create a test program.  My math didn&#8217;t work out that great so I asked yahoo answers.  Someone named Mathmom28 answered my question perfectly and the above sheet of paper shows the end result of her answer.  It&#8217;s a bit disheartening to be relying on a homework forum for answers from &#8220;Mathmom28&#8243; but I don&#8217;t think I&#8217;m going to pass judgement on my superiors.  Suddenly I feel like I&#8217;m in high school again.</p>
<p>The magic to this madness was a formula she posted which is something I&#8217;ve since long-forgotten: the point-slope form of a line.  A line 90º perpendicular to another one is it&#8217;s negative reciprocal.  In other words, y = 3x/5y at 90º is y=-5y/3x.  Once I got that, it was cake to finish something that&#8217;s pretty polished.</p>
<p>Try out <a href="http://squarism.com/files/triangle_building/">Triangle Building</a>.  The instructions are at the bottom of the screen.</p>
<p><img src="http://squarism.com/wp-content/uploads/2009/04/triangle_building.png" alt="triangle_building" title="triangle_building" width="380" height="402" class="aligncenter size-full wp-image-136" /></p>
]]></content:encoded>
			<wfw:commentRss>http://squarism.com/2009/04/03/triangle-building/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Boom Threads</title>
		<link>http://squarism.com/2009/03/10/boom-threads/</link>
		<comments>http://squarism.com/2009/03/10/boom-threads/#comments</comments>
		<pubDate>Wed, 11 Mar 2009 03:28:23 +0000</pubDate>
		<dc:creator>Dillon</dc:creator>
				<category><![CDATA[GameDev]]></category>
		<category><![CDATA[Processing]]></category>

		<guid isPermaLink="false">http://squarism.com/?p=91</guid>
		<description><![CDATA[I was messing around with threaded drawing. I really don&#8217;t know how much of an advantage this gives. I needed to figure out a way to animate something on the side for performance gains. I think this is how I&#8217;d do it (not with 78 threads running). I did see a ton of threads created [...]]]></description>
			<content:encoded><![CDATA[<p><img src="http://squarism.com/wp-content/uploads/2009/03/boomthreads_sshot-580x297.png" alt="boomthreads_sshot" title="boomthreads_sshot" width="580" height="297" class="aligncenter size-large wp-image-98" /><br />
I was messing around with threaded drawing.  I really don&#8217;t know how much of an advantage this gives.  I needed to figure out a way to animate something on the side for performance gains.  I think this is how I&#8217;d do it (not with 78 threads running).</p>
<p>I did see a ton of threads created though.  You can see below out of Activity Monitor.  Each of the boxes displayed is a thread that draws itself.  They all maintain elapsed which might be a design flaw.  I couldn&#8217;t figure out a way to sync the drawing to all the threads running by themselves.<br />
<img src="http://squarism.com/wp-content/uploads/2009/03/boomthreads_threads.png" alt="boomthreads_threads" title="boomthreads_threads" width="434" height="34" class="aligncenter size-full wp-image-100" /></p>
<p>Animation is done with timeElapsed in mind.  That&#8217;s so it runs about the same on fast and slow computers.</p>
<p>Hit the link here to check it out: <a href="/files/BoomThreads/">BoomThreads</a></p>
<p><strong>UPDATE: I was thinking about this and this is not actually accomplishing any threaded performance gains.  It sequentially calls draw which doesn&#8217;t thread the drawing itself.  I need to take out the random waits and have it look like this.  Right now, there is artifical randomness (which is why all the boxes move at different speeds).  I&#8217;ll update this soon if drawing can be threaded.</strong></p>
]]></content:encoded>
			<wfw:commentRss>http://squarism.com/2009/03/10/boom-threads/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Linked</title>
		<link>http://squarism.com/2008/03/25/linked/</link>
		<comments>http://squarism.com/2008/03/25/linked/#comments</comments>
		<pubDate>Tue, 25 Mar 2008 23:41:25 +0000</pubDate>
		<dc:creator>Dillon</dc:creator>
				<category><![CDATA[GameDev]]></category>
		<category><![CDATA[Processing]]></category>

		<guid isPermaLink="false">http://squarism.com/2008/03/25/linked/</guid>
		<description><![CDATA[I just finished a book called Linked. It&#8217;s a book about network theory and covers a wide variety of topics very quickly. It&#8217;s not incredibly long but I found it very interesting just because of speculation I&#8217;ve done over the years. Sometimes, I&#8217;ve wondered if the patterns I see in some subject translate (either by [...]]]></description>
			<content:encoded><![CDATA[<p>I just finished a book called <a href="http://www.amazon.com/Linked-Everything-Connected-Else-Means/dp/0452284392/ref=pd_bbs_1?ie=UTF8&#038;s=books&#038;sr=8-1">Linked</a>.  It&#8217;s a book about network theory and covers a wide variety of topics very quickly.  It&#8217;s not incredibly long but I found it very interesting just because of speculation I&#8217;ve done over the years.</p>
<p>Sometimes, I&#8217;ve wondered if the patterns I see in some subject translate (either by divine will or mathematics) into other subjects.  For example, if the 80/20 rule applies in software, does it apply to business or biology or anything else?  The author covers these kinds of things in a much more journalistic approach than my everyday speculation and casual daydreaming could.  It was reinforcing in a way.</p>
<p>Towards the end of the book, the author has a diagram of a three-point triangle.  He relates the node map to society and members of society as connectors and hubs.  The chapter covered topics like infection and how certain hub-people will transmit disease faster than others.  It&#8217;s a bit more complicated than how I&#8217;m summarizing but the diagram caught my attention none-the-less.  The author started with a node and then added nodes recursively (whether he knew it or not).  So I fired up the <a href="http://processing.org">processing.org</a> program and tried to draw what he had made but make it configurable with depth.  Here&#8217;s the result, was fun.</p>
<p>The depth goes 1,2,4,8.  After that it becomes a white mess.</p>
<p><a href="http://squarism.com/2008/03/25/linked/linkedrecursion1/"><img src="http://squarism.com/wp-content/uploads/2008/03/linkedRecursion1-288x300.png" alt="linkedRecursion1" title="linkedRecursion1" width="288" height="300" class="alignnone size-medium wp-image-1296" /></a><br />
<a href="http://squarism.com/2008/03/25/linked/linkedrecursion2/"><img src="http://squarism.com/wp-content/uploads/2008/03/linkedRecursion2-288x300.png" alt="linkedRecursion2" title="linkedRecursion2" width="288" height="300" class="alignnone size-medium wp-image-1297" /></a><br />
<a href="http://squarism.com/2008/03/25/linked/linkedrecursion3/"><img src="http://squarism.com/wp-content/uploads/2008/03/linkedRecursion3-288x300.png" alt="linkedRecursion3" title="linkedRecursion3" width="288" height="300" class="alignnone size-medium wp-image-1298" /></a><br />
<a href="http://squarism.com/2008/03/25/linked/linkedrecursion4/"><img src="http://squarism.com/wp-content/uploads/2008/03/linkedRecursion4-288x300.png" alt="linkedRecursion4" title="linkedRecursion4" width="288" height="300" class="alignnone size-medium wp-image-1299" /></a> </p>
<pre>
int scale = 100;  // size of initial triangle
int w = 500;
int h = 500;

void setup()
{

  background(40);
  size(w,h);
  noStroke();
  smooth();
  noLoop();
}

void draw()
{
  drawHorseshit(w/2, h/2, 9, scale);
}

class tri {
  int ax;
  int ay;
  int bx;
  int by;
  int cx;
  int cy;
}

void drawHorseshit(int x, int y, int depth, int s)
{
  fill(140);
  stroke(255);

  stroke(255,5);
  line(0,y,w,y);  //horizontal line
  line(x,0,x,h);  //vertical line
  stroke(255);

  // interior lines
  tri outline = new tri();

  //center
  ellipse(x, y, s/4, s/4);

  //top
  ellipse(x, y-s, s/8, s/8);
  outline.ax = x;
  outline.ay = y-s;

  //right
  float ra = s * sin(60);
  float rb = s * cos(60);
  ellipse( (x-rb), (y-ra), s/8, s/8);
  outline.bx = (int)(x-rb);
  outline.by = (int)(y-ra);

  //left
  float la = s * sin(60);
  float lb = s * cos(60);
  ellipse( (x+lb), (y-la), s/8, s/8);
  outline.cx = (int)(x+lb);
  outline.cy = (int)(y-la);

  stroke(255,50);
  line(outline.ax, outline.ay, x,y);
  line(outline.bx, outline.by, x,y);
  line(outline.cx, outline.cy, x,y);
  stroke(255);

  if(depth > 1) {
    depth--;
    s = s/2;
    drawHorseshit(outline.ax, outline.ay, depth, s);
    drawHorseshit(outline.bx, outline.by, depth, s);
    drawHorseshit(outline.cx, outline.cy, depth, s);
  }

}
</pre>
]]></content:encoded>
			<wfw:commentRss>http://squarism.com/2008/03/25/linked/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Parabola</title>
		<link>http://squarism.com/2007/04/15/parabola/</link>
		<comments>http://squarism.com/2007/04/15/parabola/#comments</comments>
		<pubDate>Mon, 16 Apr 2007 00:44:24 +0000</pubDate>
		<dc:creator>Dillon</dc:creator>
				<category><![CDATA[C/C++]]></category>
		<category><![CDATA[GameDev]]></category>

		<guid isPermaLink="false">http://squarism.com/2007/04/15/parabola/</guid>
		<description><![CDATA[My goal was to create the curves above. I knew if I could draw it then I could move a box or game object along that path. It took me about two weeks of casual time and many math questions posted to yahoo answers. The problem is, implementing a math formula in C++. It&#8217;s just [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://squarism.com/2007/04/15/parabola/parabola-sketch/"><img src="http://squarism.com/wp-content/uploads/2007/04/parabola_sketch-300x185.jpg" alt="parabola sketch" title="parabola sketch" width="300" height="185" class="alignnone size-medium wp-image-1293" /></a> </p>
<p>My goal was to create the curves above.  I knew if I could draw it then I could move a box or game object along that path.  It took me about two weeks of casual time and many math questions posted to yahoo answers.</p>
<p>The problem is, implementing a math formula in C++.  It&#8217;s just not as pretty as the equation and any algebra tricks are hard to express in code.  Not to mention remembering algebra period.  ?</p>
<p>Eventually, I ended up with this.  I specified the starting point, the ending point and how tall I want the curve.  A series of horrible equations builds the rest into a vector of x,y point structs.  There&#8217;s an LOD thing too that says how pretty the curve should be.</p>
<p><a href="http://squarism.com/2007/04/15/parabola/parabola3/"><img src="http://squarism.com/wp-content/uploads/2007/04/parabola3-300x273.png" alt="parabola3" title="parabola3" width="300" height="273" class="alignnone size-medium wp-image-1294" /></a> </p>
<p>Of course, it&#8217;s pixilated and kinda ugly.  I tried anti-aliasing it but it doesn&#8217;t look much better.  Also, I might have some math issues because in some places there seems to be small humps.  I might be running into precision problems again.  ?</p>
<p>Overall, I&#8217;m pretty exhausted.  I don&#8217;t know what my next project will be, I don&#8217;t know if I want to make more of a game that&#8217;s interactive instead of these little graphics tests.</p>
<p>Also, C++ is pretty ugly imo.  It&#8217;s used everywhere, I understand but I might pick up an actionscript book and see how much of this graphics stuff could be wrapped up in flash.  I bet you can do some cool low-level drawing in flash; and then it&#8217;d be more &#8216;portable&#8217; than an OSX app.</p>
<p>Anyway &#8230; it&#8217;s a thing of goddamn beauty for now.  Except <a href="http://wiki.ubernub.com/parabola">the code</a>, which is ugly, untidy and probably doesn&#8217;t compile by itself.  I&#8217;ll update it so it&#8217;s stand-alone.</p>
]]></content:encoded>
			<wfw:commentRss>http://squarism.com/2007/04/15/parabola/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
	</channel>
</rss>

