<?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"
	>

<channel>
	<title>zylum's Indie Game Development Blog</title>
	<atom:link href="http://www.zylum.net/gameblog/?feed=rss2" rel="self" type="application/rss+xml" />
	<link>http://www.zylum.net/gameblog</link>
	<description>Just another indie game development weblog</description>
	<pubDate>Thu, 03 Sep 2009 15:22:29 +0000</pubDate>
	<generator>http://wordpress.org/?v=2.5.1</generator>
	<language>en</language>
			<item>
		<title>Minimal SWF Analyzer</title>
		<link>http://www.zylum.net/gameblog/?p=14</link>
		<comments>http://www.zylum.net/gameblog/?p=14#comments</comments>
		<pubDate>Tue, 21 Jul 2009 11:00:41 +0000</pubDate>
		<dc:creator>zylum</dc:creator>
		
		<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://www.zylum.net/gameblog/?p=14</guid>
		<description><![CDATA[Here&#8217;s a little snippet of code that generates a very basic swf analyzer. It displays the frame rate as well as memory usage. Just the bare essentials (no fancy graphs or other eye candy). Simply add an instance to the display list and you&#8217;re good to go!

Optional parameters include update interval (in milliseconds) as well [...]]]></description>
			<content:encoded><![CDATA[<p><img class="alignleft" style="margin: 5px 15px; float: left;" src="http://zylum.net/flash/experiments/swf_specs/thumb.png" alt="demo thumbnail" width="131" height="54" />Here&#8217;s a little snippet of code that generates a very basic swf analyzer. It displays the frame rate as well as memory usage. Just the bare essentials (no fancy graphs or other eye candy). Simply add an instance to the display list and you&#8217;re good to go!</p>
<p><span id="more-14"></span></p>
<p>Optional parameters include update interval (in milliseconds) as well as the color of the data/border.</p>
<p>Source: <a title="Main.as" href="http://zylum.net/flash/experiments/swf_specs/SWFSpecs.as" target="_blank">SWFSpecs.as</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.zylum.net/gameblog/?feed=rss2&amp;p=14</wfw:commentRss>
		</item>
		<item>
		<title>TD Pathfinding Demo</title>
		<link>http://www.zylum.net/gameblog/?p=13</link>
		<comments>http://www.zylum.net/gameblog/?p=13#comments</comments>
		<pubDate>Fri, 08 May 2009 12:04:34 +0000</pubDate>
		<dc:creator>zylum</dc:creator>
		
		<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://www.zylum.net/gameblog/?p=13</guid>
		<description><![CDATA[Hey, I haven&#8217;t posted in almost a year because I was quite busy with school and contract work. Now that school is out, I have some extra time to work on personal projects again. So without further adieu, here is something useful I whipped up. It&#8217;s a slightly optimized algorithm for generating all paths from [...]]]></description>
			<content:encoded><![CDATA[<p><img class="alignleft" style="margin: 5px 15px; float: left;" src="http://zylum.net/flash/experiments/td_pathfinding/thumb.png" alt="demo thumbnail" width="117" height="139" />Hey, I haven&#8217;t posted in almost a year because I was quite busy with school and contract work. Now that school is out, I have some extra time to work on personal projects again. So without further adieu, here is something useful I whipped up. It&#8217;s a slightly optimized algorithm for generating all paths from every node to the destination node.<span id="more-13"></span></p>
<p>The algorithm itself is just a simple breadth first search. I think this algorithm is the best for this type of game because each edge has a constant weight thus eliminating the need for more complex algorithms. Furthermore, like Dijkstra&#8217;s algorithm, it generates the shortest path from all nodes to the destination (when initially called from the destination node). Optimizations include using a one dimensional array to represent the map and thus reduce access times as well as generating a border around the map. This border eliminates the need to check whether or not you are accessing an array element that is out of bounds. This check would normally be done many, many times so this simple optimization shaves off a couple milliseconds.</p>
<p>Using straight BFS has one drawback &#8212; it doesn&#8217;t handle diagonal paths by default. Thus I have created a simple &#8220;relax&#8221; method to determine whether a new edge can be relaxed to a diagonal. This slows things down a bit, but the performance is still quite good. In the current demo, the map is 35&#215;35 and I get all square paths in 1-2ms and all paths with corner clipping in 2-3ms. That&#8217;s pretty darn fast!</p>
<p>View <a title="TBW Demo" href="http://zylum.net/flash/experiments/td_pathfinding/td_pathfinding.html" target="_blank">Pathfinding Demo</a>.</p>
<p>Source: <a title="Main.as" href="http://zylum.net/flash/experiments/td_pathfinding/Main.as" target="_blank">Main.as</a>, <a title="BFSDemo.fla" href="http://zylum.net/flash/experiments/td_pathfinding/BFSDemo.fla" target="_blank">BFSDemo.fla</a>.</p>
<p>Also, <a title="Main2D.as" href="http://zylum.net/flash/experiments/td_pathfinding/Main2D.as" target="_blank">here</a> is a version which uses 2D arrays and Points which makes it slightly easier to understand but it runs about twice as slow (still pretty darn fast though <img src='http://www.zylum.net/gameblog/wp-includes/images/smilies/icon_wink.gif' alt=';)' class='wp-smiley' /> ).</p>
]]></content:encoded>
			<wfw:commentRss>http://www.zylum.net/gameblog/?feed=rss2&amp;p=13</wfw:commentRss>
		</item>
		<item>
		<title>Some Progress</title>
		<link>http://www.zylum.net/gameblog/?p=12</link>
		<comments>http://www.zylum.net/gameblog/?p=12#comments</comments>
		<pubDate>Wed, 23 Jul 2008 22:51:47 +0000</pubDate>
		<dc:creator>zylum</dc:creator>
		
		<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://www.zylum.net/gameblog/?p=12</guid>
		<description><![CDATA[I have made a little progress with the bat game and it&#8217;s turning out to be more of a headache than I anticipated. The game engine is more or less done other than optimizations that need to be done. Right now the engine renders 256 tiles as well as 12 trees each of which has [...]]]></description>
			<content:encoded><![CDATA[<p><img class="alignleft" style="margin: 5px 15px; float: left;" src="http://zylum.net/flash/3d_tree/thumb.png" alt="demo thumbnail" width="150" height="150" />I have made a little progress with the bat game and it&#8217;s turning out to be more of a headache than I anticipated. The game engine is more or less done other than optimizations that need to be done. Right now the engine renders 256 tiles as well as 12 trees each of which has 40 limbs and it seems to be running rather slowly. I don&#8217;t know whether it is all the computation that is slowing it down or if it&#8217;s all the shapes being drawn. Either way I&#8217;d like to know how well it performs on your computer as I&#8217;d like to have an idea how heavily I have to optimize the engine.<span id="more-12"></span></p>
<p>Other than the engine, I still have to create all the art for things such as the title screen, the menus, buttons etc as well as program the actual game play. Finally I will have to look for some ambient music and sound effects to bring the game together. But right now I am focusing on the technical aspects of the game to make sure everything is running smoothly in the background. The final piece to be added to the engine will be collision detection but that won&#8217;t be too big of a deal (to implement or speed-wise) because of the way I have designed the engine.</p>
<p>One thing I am happy with is how the erie atmosphere came out. I was originally going to use some form of raytracing to generate the view but quickly abandoned that idea knowing that flash couldn&#8217;t handle it. Instead it is coloring the objects based on distance. So if the object is far enough, it wont be visible to the bat (and its echo location). The sight factor is a variable which will allow it to change during the course of the game with power ups and upgrades. Once I have the bug sprites floating around as well as a big full moon, I think the game will look pretty nice.</p>
<p>*UPDATE* I have finally finished most of the optimizations. The trees seemed to be the biggest problem and I&#8217;m happy to say that I was able to double the tree count from the last demo as well as make it perform better with those extra trees!</p>
<p>View <a title="TBW Demo" href="http://zylum.net/flash/3d_tree/engine_demo.html" target="_blank">Engine Demo</a>.</p>
<p>I probably won&#8217;t release the source for this game unless I decide to scrap it or no one is interested in licensing/sponsoring it (which is more than likely).</p>
]]></content:encoded>
			<wfw:commentRss>http://www.zylum.net/gameblog/?feed=rss2&amp;p=12</wfw:commentRss>
		</item>
		<item>
		<title>3D Fractal Tree</title>
		<link>http://www.zylum.net/gameblog/?p=11</link>
		<comments>http://www.zylum.net/gameblog/?p=11#comments</comments>
		<pubDate>Sun, 20 Jul 2008 08:55:13 +0000</pubDate>
		<dc:creator>zylum</dc:creator>
		
		<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://www.zylum.net/gameblog/?p=11</guid>
		<description><![CDATA[(Please open the article to see the flash file or player.)I decided to take a break from my main project by starting a new project XD. It&#8217;s a new game where the premise is that you are a bat (the flying rodent, not the piece of wood) flying around eating bugs and avoid hitting obstacles. [...]]]></description>
			<content:encoded><![CDATA[<p><object type="application/x-shockwave-flash" data="http://zylum.net/flash/3d_tree/3DTree.swf" width="120" height="120" class="embedflash" style="float:left;margin:15px"><param name="movie" value="http://zylum.net/flash/3d_tree/3DTree.swf" /><param name="allowfullscreen" value="true" /><param name="allowscriptaccess" value="always" /><small>(Please open the article to see the flash file or player.)</small></object>I decided to take a break from my main project by starting a new project XD. It&#8217;s a new game where the premise is that you are a bat (the flying rodent, not the piece of wood) flying around eating bugs and avoid hitting obstacles. The catch is that you have to use echo location. </p>
<p>As you can see by the demo, the game will be in 3D and the trees will be randomly generated fractal trees. I&#8217;m a little worried how my implementation of the echo location will turn out. I have a couple of ideas how I will program it, though I&#8217;m not sure how well flash will be able to handle them speed-wise. This project should be complete soon (if my ideas work) since there is very little artwork to be done other than the title screen which I will attempt to do on my own.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.zylum.net/gameblog/?feed=rss2&amp;p=11</wfw:commentRss>
		</item>
		<item>
		<title>TBW Demo</title>
		<link>http://www.zylum.net/gameblog/?p=10</link>
		<comments>http://www.zylum.net/gameblog/?p=10#comments</comments>
		<pubDate>Tue, 15 Jul 2008 11:40:35 +0000</pubDate>
		<dc:creator>zylum</dc:creator>
		
		<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://www.zylum.net/gameblog/?p=10</guid>
		<description><![CDATA[Here&#8217;s a small demo of the isometric tile engine I am working on. The depth sorting seems to have worked out pretty well. Currently it uses a basic breadth-first search algorithm though implementing A* shouldn&#8217;t be a problem. The source is getting pretty messy so I&#8217;m going to refactor everything once I get the time. [...]]]></description>
			<content:encoded><![CDATA[<p><img class="alignleft" style="margin: 5px 15px; float: left;" src="http://zylum.net/flash/tbw/thumb.png" alt="demo thumbnail" width="78" height="65" />Here&#8217;s a small demo of the isometric tile engine I am working on. The depth sorting seems to have worked out pretty well. Currently it uses a basic breadth-first search algorithm though implementing A* shouldn&#8217;t be a problem. The source is getting pretty messy so I&#8217;m going to refactor everything once I get the time. The animation for the moving block is done completely in AS so it isn&#8217;t very nice plus I hacked it together really quickly because I wanted to release this demo as soon as possible. In fact, the entire demo is done in AS including the drawing of the tiles. The shading on the tiles is done procedurally so you can choose any basic color for the tile and it will compute the colors for the shadows and mouseover highlights. This feature probably wont be necessary as I&#8217;ll have custom graphics for each tile (still looking for an artist!).<span id="more-10"></span></p>
<p>View <a title="TBW Demo" href="http://zylum.net/flash/tbw/tbw_demo.html" target="_blank">TBW Demo</a>.</p>
<p>Since I plan on making some cash on this game, I&#8217;m afraid I won&#8217;t be able to release the source..</p>
]]></content:encoded>
			<wfw:commentRss>http://www.zylum.net/gameblog/?feed=rss2&amp;p=10</wfw:commentRss>
		</item>
		<item>
		<title>AS3 and BB3D!</title>
		<link>http://www.zylum.net/gameblog/?p=9</link>
		<comments>http://www.zylum.net/gameblog/?p=9#comments</comments>
		<pubDate>Tue, 15 Jul 2008 03:48:31 +0000</pubDate>
		<dc:creator>zylum</dc:creator>
		
		<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://www.zylum.net/gameblog/?p=9</guid>
		<description><![CDATA[(Please open the article to see the flash file or player.)Seven years ago, I first started programming in ActionScript v1.0. When ActionScript 3.0 came out, a lot of changes have been made and at it&#8217;s current version it resembles Java quite a bit. Furthermore, it supports aspects of functional programming which makes it a bit [...]]]></description>
			<content:encoded><![CDATA[<p><object type="application/x-shockwave-flash" data="http://zylum.net/flash/bb3d/BB3D.swf" width="200" height="200" class="embedflash" style="float:left;margin:5px"><param name="movie" value="http://zylum.net/flash/bb3d/BB3D.swf" /><param name="allowfullscreen" value="true" /><param name="allowscriptaccess" value="always" /><small>(Please open the article to see the flash file or player.)</small></object>Seven years ago, I first started programming in ActionScript v1.0. When ActionScript 3.0 came out, a lot of changes have been made and at it&#8217;s current version it resembles Java quite a bit. Furthermore, it supports aspects of functional programming which makes it a bit more fun. I decided to start using flash again because I wanted to post my games to some of the flash game portals in order to get some exposure. I am currently working on my first game and the engine is going quite well so I should have a small demo up soon. I am still looking for competent artists and animators for this project so if anyone is interested, let me know. Also I have ported a simple version of my 3D engine to AS3. It is very minimal so I have dubbed it BareBones3D or BB3D for short.<span id="more-9"></span></p>
<p>The engine is actually a stripped down version of my <a title="J3DApplet" href="http://zylum.net/java/J3DApplet/J3DApplet.html" target="_blank">J3DApplet</a> which I wrote a while ago, which is also a port of an earlier engine zylum3Dv2. You can find a copy of zylum3Dv2 somewhere on compsci.ca though it&#8217;s written in Turing. BB3D is currently made up of two classes, the main BB3D class as well as a Vector class to manage all the vector operations. Ideally there should be a transformation class as well as a polygon class to store more polygon properties other than just the vertices. Currently, polygons are stored in a 2D array so there is no information for color or anything else.</p>
<p>Source: <a title="BB3D.as" href="http://zylum.net/flash/bb3d/BB3D.as" target="_blank">BB3D.as</a>, <a title="Vector.as" href="http://zylum.net/flash/bb3d/Vector.as" target="_blank">Vector.as</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.zylum.net/gameblog/?feed=rss2&amp;p=9</wfw:commentRss>
		</item>
		<item>
		<title>Real Time Phong Shading Demo</title>
		<link>http://www.zylum.net/gameblog/?p=8</link>
		<comments>http://www.zylum.net/gameblog/?p=8#comments</comments>
		<pubDate>Tue, 01 Jul 2008 06:41:03 +0000</pubDate>
		<dc:creator>zylum</dc:creator>
		
		<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://www.zylum.net/gameblog/?p=8</guid>
		<description><![CDATA[I haven&#8217;t posted in a while so I thought I&#8217;d share the result of today&#8217;s coding. It&#8217;s the real time Phong shading engine for a pool game I&#8217;m gunna start working on. At the current stage, you can place multiple light sources in 3-space each of which can have a unique color, as well as [...]]]></description>
			<content:encoded><![CDATA[<p><img class="alignleft" style="margin: 5px 15px; float: left;" src="http://zylum.net/java/games/pool/thumb.png" alt="game thumbnail" width="154" height="132" />I haven&#8217;t posted in a while so I thought I&#8217;d share the result of today&#8217;s coding. It&#8217;s the real time Phong shading engine for a pool game I&#8217;m gunna start working on. At the current stage, you can place multiple light sources in 3-space each of which can have a unique color, as well as an ambient, diffuse and specular aspect to them. The balls have a texture associated with them as well as a material which has the same properties as a light but also a shine element which gives it the glare. The texturing of the balls is anti-aliased, though I still have to incorperate anti-aliasing to the outside edge of the balls.<span id="more-8"></span></p>
<p>One of the more challenging aspects of the texturing was mapping each drawn pixel to a pixel in the square texture. The rotation of the ball is represented by 3 perpendicular unit vectors. One vector is points to the center of the texture, another helps determine the polar angle from the first vector to the point that is being drawn, and the third vector aids in figuring out whether or not the angle is greater than 180 degrees since a dot product alone cannot tell you this.</p>
<p>With this outta the way all I need to do is write the physics engine. For the most part this shouldn&#8217;t too difficult as I&#8217;ve written a tutorial on <a title="perfect circle-circle collision detection" href="http://compsci.ca/v3/viewtopic.php?t=14897" target="_blank">perfect circle-circle collision detection</a> as well as understand the physics of 2D and (for the most part) 3D collision reaction. The only thing that I have yet to study is the effect of applying a spin on the ball (ie not striking the cue ball perfectly in the centre with the cue stick). I want this game to be fairly realistic physics wise as well as visually. I&#8217;m thinking of adding RPG elements to the game where you start off as a noobie and as you play your shot becomes more accurate over time. If you tend to shoot more long balls, your long shot will improve faster than your short shot etc.. I&#8217;m still thinking about the design of the game so no code has been written yet. I&#8217;d be glad to hear any suggestions as how to enhance the gameplay.</p>
<p>In the task bar of your browser, the applet should display what kind of load it is experiencing. I have manage to optimize it to the point where it only loads the applet 36% when all the balls are on the screen. When the physics and further drawing is added, this should stay below 50% for my 2 year old laptop. At the moment this applet also takes up 25% of the processor.  I was hoping you guys could let me know the numbers you are seeing so I could do more optimization if necessary.</p>
<p>View <a title="Gem Swapper" href="http://zylum.net/java/games/pool/pool.html" target="_blank">Phong Shading Demo</a>.</p>
<p>Source will become available when the game is released.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.zylum.net/gameblog/?feed=rss2&amp;p=8</wfw:commentRss>
		</item>
		<item>
		<title>Becloned 2</title>
		<link>http://www.zylum.net/gameblog/?p=7</link>
		<comments>http://www.zylum.net/gameblog/?p=7#comments</comments>
		<pubDate>Thu, 22 May 2008 08:40:46 +0000</pubDate>
		<dc:creator>zylum</dc:creator>
		
		<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://www.zylum.net/gameblog/?p=7</guid>
		<description><![CDATA[Finally finished the game last night. Now it pretty much plays like the original game, other than the special gems. This feature wouldn&#8217;t be difficult to add because of the use of bit masks to represent the board and moves. But since I don&#8217;t have appropriate animations for each special gem, I won&#8217;t be adding [...]]]></description>
			<content:encoded><![CDATA[<p><img class="alignleft" style="margin: 5px 15px; float: left;" src="http://zylum.net/java/games/gem_swapper/thumb.png" alt="game thumbnail" width="164" height="163" />Finally finished the game last night. Now it pretty much plays like the original game, other than the special gems. This feature wouldn&#8217;t be difficult to add because of the use of bit masks to represent the board and moves. But since I don&#8217;t have appropriate animations for each special gem, I won&#8217;t be adding this feature. Furthermore, I couldn&#8217;t find any good, free sound effects for my game which I think would really bring everything together. When playing the original game, it is quite satisfying to <em>hear</em> the gems disappear. If anyone knows a good source of free game sound effects, please let me know.<span id="more-7"></span></p>
<p>To manage the complexity of this game, I designed a condensed finite state machine. There are four states in the FSM, though there are many more states in the actual game. I used the current state along with other game information to transition to other states. I played the game for a little while and didn&#8217;t find any bugs, though I&#8217;m sure I probably missed something. To move a gem, you can click on it and then click on the destination, or you can simply drag the gem to it&#8217;s destination. If you don&#8217;t make a legal move in a certain amount of time, you will be given a hint but will be penalized 10% of your score. If you reach a position where there are no legal moves, then you are penalized 50 points and a new board is generated. I managed to get a score of around 450 but only played a few times, so I&#8217;m sure you guys will do much better.</p>
<p>Play <a title="Gem Swapper" href="http://zylum.net/java/games/gem_swapper/gem_swapper.html" target="_blank">Gem Swapper</a>.</p>
<p>Source: <a href="http://www.zylum.net/java/games/gem_swapper/source/GemSwapper.java" target="_blank">GemSwapper.java</a>, <a href="http://www.zylum.net/java/games/gem_swapper/source/Game.java" target="_blank">Game.java</a>, <a href="http://www.zylum.net/java/games/gem_swapper/source/Gem.java" target="_blank">Gem.java</a>, <a href="http://www.zylum.net/java/games/gem_swapper/source/Move.java" target="_blank">Move.java</a>, <a href="http://www.zylum.net/java/games/gem_swapper/source/FPS.java" target="_blank">FPS.java</a></p>
<p>Note that the source isn&#8217;t commented yet as I am tired and a lot of the code is quite complex so there will be tons to comment. I will be glad to comment if anyone requests I do so or answer any specific questions about the code.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.zylum.net/gameblog/?feed=rss2&amp;p=7</wfw:commentRss>
		</item>
		<item>
		<title>Becloned</title>
		<link>http://www.zylum.net/gameblog/?p=6</link>
		<comments>http://www.zylum.net/gameblog/?p=6#comments</comments>
		<pubDate>Fri, 16 May 2008 12:11:35 +0000</pubDate>
		<dc:creator>zylum</dc:creator>
		
		<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://www.zylum.net/gameblog/?p=6</guid>
		<description><![CDATA[I had a few free hours last night so I decided to start on a clone of probably the most popular casual game ever. Rather than use Java&#8217;s built in graphics, I found a free gem graphic and edited it for the necessary amount of colors. I didn&#8217;t have much time last night, plus this [...]]]></description>
			<content:encoded><![CDATA[<p><img class="alignleft" style="margin: 5px 15px; float: left;" src="http://zylum.net/java/games/gem_swapper/thumb.png" alt="game thumbnail" width="164" height="163" />I had a few free hours last night so I decided to start on a clone of probably the most popular casual game ever. Rather than use Java&#8217;s built in graphics, I found a free gem graphic and edited it for the necessary amount of colors. I didn&#8217;t have much time last night, plus this game is slightly more complex than the previous games posted, so it is not quite complete. Most of the mechanics are finished, but I need a few more hours to bring everything together. <span id="more-6"></span>I used bit boards to represent the board state. This makes it very easy to perform operations such as finding gems which should be removed or to check if there are any legal moves left (yet to be implemented) simply by performing some bit masking. I used easing for swapping the gems and gravity for the collapsing animation.</p>
<p>So far I am pretty happy with the way it is turning out. Having some shiny animations like the original game would be cool though. I am going camping this long weekend (leaving this afternoon) so when I get back on Tuesday, hopefully I can find some time to add the finishing touches.</p>
<p>Play <a title="Gem Swapper" href="http://zylum.net/java/games/gem_swapper/gem_swapper.html" target="_blank">Gem Swapper</a>.</p>
<p>Ill post the source when it&#8217;s done as I have to clean up a couple of things.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.zylum.net/gameblog/?feed=rss2&amp;p=6</wfw:commentRss>
		</item>
		<item>
		<title>Hand Drawn Snake</title>
		<link>http://www.zylum.net/gameblog/?p=5</link>
		<comments>http://www.zylum.net/gameblog/?p=5#comments</comments>
		<pubDate>Tue, 13 May 2008 21:29:59 +0000</pubDate>
		<dc:creator>zylum</dc:creator>
		
		<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://www.zylum.net/gameblog/?p=5</guid>
		<description><![CDATA[While watching TV, I saw a cartoon that looks sort of like a flip book style animation. The lines were all squiggly and constantly moving. This gave me inspiration to create a game with a similar style. I chose snake because the game play is very simple which would allow me to focus on achieving [...]]]></description>
			<content:encoded><![CDATA[<p><img class="alignleft" style="margin: 5px 15px; float: left;" src="http://zylum.net/java/games/snake/thumb.png" alt="game thumbnail" width="200" height="250" />While watching TV, I saw a cartoon that looks sort of like a flip book style animation. The lines were all squiggly and constantly moving. This gave me inspiration to create a game with a similar style. I chose snake because the game play is very simple which would allow me to focus on achieving the desired effect.<span id="more-5"></span></p>
<p>To create the effect, I used an adaptation of brownian motion. Basically, you draw a random path from one point to another. Each squiggly line consists of smaller incremental lines. At each stage of drawing the squiggly line, the path chooses a random direction based on the current position of the end point. This ensures that the path doesn&#8217;t go too far off course. Once the path is within the incremental drawing length of the desired endpoint, we connect the current position with the end point.</p>
<p>The main challenge of this project was ensuring that each line segment is drawn only once. For example, at each frame the game draws the border, the food and the snake (in that order). Thus, once the border is drawn, if the piece of food is generated on the border then one of the sides of the food should not be drawn. If it&#8217;s generated on the corner, two sides should not be drawn. Furthermore, if the snake is along the border, or moving along a portion of it&#8217;s tail, many line segments should not be drawn. If in any of those cases the lines were drawn, then the effect would be ruined because the squiggly lines would overlap and create thick, ugly lines.</p>
<p>To solve this problem, I keep track of which lines have been drawn. Specifically, the lines are stored in a TreeSet which is implemented as a red black tree. This ensures fast queries which is good since there could potentially be hundreds of lines drawn per frame. Rather than creating a new class which defines the x-position, y-position and orientation, I decided to generate a unique number for each line based on each of these variables. This way I save some memory and avoid having to write a comparator for the new class. Since each line has a semi-unique position (a horizontal line can share a position with a vertical line), the integer generated is the location of the line plus an offset of N if the line is vertical (where N is the number of positions). This scheme ensures that each line gets a unique number since the problem of shared positions is fixed by adding the offset to vertical lines.</p>
<p>All in all the effect turned out quite nicely. I don&#8217;t know why, but I find snake a very addictive game. After I completed it I played it for quite some time. I managed to get a highscore of 63 &#8212; see if you can beat that!</p>
<p>Play <a href="http://zylum.net/java/games/snake/snake.html" target="_blank">Hand Drawn Snake</a>.</p>
<p>Source code: <a href="http://zylum.net/java/games/snake/source/Snake.java" target="_blank">Snake.java</a>, <a href="http://zylum.net/java/games/snake/source/Game.java" target="_blank">Game.java</a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.zylum.net/gameblog/?feed=rss2&amp;p=5</wfw:commentRss>
		</item>
	</channel>
</rss>
