<?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>playchilla.com</title>
	<atom:link href="http://www.playchilla.com/feed" rel="self" type="application/rss+xml" />
	<link>http://www.playchilla.com</link>
	<description>Sharing our side projects.</description>
	<lastBuildDate>Tue, 15 May 2012 17:12:07 +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>Runner</title>
		<link>http://playchilla.com/runner</link>
		<comments>http://playchilla.com/runner#comments</comments>
		<pubDate>Sat, 14 Apr 2012 21:30:49 +0000</pubDate>
		<dc:creator>Jon</dc:creator>
				<category><![CDATA[Projects]]></category>

		<guid isPermaLink="false">http://www.playchilla.com/?p=781</guid>
		<description><![CDATA[Try this high paced one button run and jump game!]]></description>
			<content:encoded><![CDATA[<p>Try this high paced one button run and jump game!</p>
]]></content:encoded>
			<wfw:commentRss>http://playchilla.com/runner/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Run &amp; Jump future plans</title>
		<link>http://www.playchilla.com/run-and-jump-future-plans</link>
		<comments>http://www.playchilla.com/run-and-jump-future-plans#comments</comments>
		<pubDate>Thu, 05 Apr 2012 19:38:14 +0000</pubDate>
		<dc:creator>Jon</dc:creator>
				<category><![CDATA[News]]></category>

		<guid isPermaLink="false">http://www.playchilla.com/?p=761</guid>
		<description><![CDATA[Since there was so much positive feedback on the prototype I will make a game out of it. I&#8217;ll not make a big project, just try to keep it simple and focus on the fast run and jump feel. I will try to avoid adding &#8220;fluff&#8221; mostly because I think it&#8217;s so boring to code [...]]]></description>
			<content:encoded><![CDATA[<p>Since there was so much positive feedback on the prototype I will make a game out of it. I&#8217;ll not make a big project, just try to keep it simple and focus on the fast run and jump feel. I will try to avoid adding &#8220;fluff&#8221; mostly because I think it&#8217;s so boring to code stuff like achievements, Facebook integration, explanatory tutorials etc. The only fluff I can think of now is adding some kind of scoring mechanism and a high score system.</p>
<p>Anna did this sketch<br />
<a href="http://www.playchilla.com/wp-content/uploads/2012/04/concept.png"><img src="http://www.playchilla.com/wp-content/uploads/2012/04/concept-1024x723.png" alt="" title="concept" width="640" class="alignnone size-large wp-image-762" /></a></p>
<p>Here is what I will do:<br />
- spend Easter in Paris with Anna, Philip &#038; Louise<br />
- twisting tracks<br />
- looping tracks<br />
- more weird ambient background stuff<br />
- better lightning<br />
- levels in different difficulty<br />
- random levels<br />
- high score<br />
- an infinite track with where you can see how far people have run (markers along the track)<br />
- hardest part: find a good name for the game<br />
- possible to make own levels with json?</p>
<p>This list should be doable in reasonable time, something for me to do in the evenings and on weekends.</p>
<p><a href="http://playchilla.com/run-and-jump">PLAY IT HERE</a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.playchilla.com/run-and-jump-future-plans/feed</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Run and jump</title>
		<link>http://www.playchilla.com/run-and-jump</link>
		<comments>http://www.playchilla.com/run-and-jump#comments</comments>
		<pubDate>Sat, 31 Mar 2012 20:18:47 +0000</pubDate>
		<dc:creator>Jon</dc:creator>
				<category><![CDATA[News]]></category>

		<guid isPermaLink="false">http://www.playchilla.com/?p=737</guid>
		<description><![CDATA[Play the LATEST VERSION here. Here is a little running game I made this week, it&#8217;s a one button game. I came across a cool game called Fotonica and thought I would make a similar using the same control (only space). I wanted the character to be a female and get a bit of the [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://www.playchilla.com/runner" title="Runner">Play the LATEST VERSION here</a>.</p>
<p>Here is a little running game I made this week, it&#8217;s a one button game. I came across a cool game called <a href="http://www.fotonica-game.com/">Fotonica</a> and thought I would make a similar using the same control (only space). I wanted the character to be a female and get a bit of the feel from Mirrors Edge (so far I only managed to add some female sounds).</p>
<p>The 10 levels are randomly generated and not tweaked at all, some might not be finishable? If you finish a level you will snap to the start again.</p>
<p>Anyways, try it here: (no loader, you may have to wait a while)</p>
<p><a href="http://www.playchilla.com/runner" title="Runner">Runner has moved to here</a>.</p>
<p>Music by <a href="http://ccmixter.org/people/7OOP3D">7OOP3D </a> song called Triggernometry (instrumental version)</p>
<p>If I continue with this game I will probably make the track twist and bend, just like in the olden c64 Stunt Car Racer which I used to play a lot when I was young. But I thought I would start simple just making a forward track where segments differs in height. Also I might bring in some Tiny Wings action, timing landings with downhills to get more speed.</p>
<p><a href="http://www.playchilla.com/wp-content/uploads/2012/03/stunt_car_racer_08.gif"><img src="http://www.playchilla.com/wp-content/uploads/2012/03/stunt_car_racer_08.gif" alt="" title="stunt_car_racer_08" width="320" height="200" class="alignnone size-full wp-image-748" /></a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.playchilla.com/run-and-jump/feed</wfw:commentRss>
		<slash:comments>62</slash:comments>
		</item>
		<item>
		<title>Beadly prototype 2</title>
		<link>http://www.playchilla.com/beadly-prototype-2</link>
		<comments>http://www.playchilla.com/beadly-prototype-2#comments</comments>
		<pubDate>Sat, 17 Mar 2012 19:21:54 +0000</pubDate>
		<dc:creator>Jon</dc:creator>
				<category><![CDATA[News]]></category>

		<guid isPermaLink="false">http://www.playchilla.com/?p=724</guid>
		<description><![CDATA[Not much has happen here lately, for one I&#8217;ve been away for on GDC &#8211; which was great. Than I caught an ugly cold that kept me in bed for an entire week. Today is the first day I&#8217;ve been somewhat normally operational so I decided to get the core stuff into the bead editor [...]]]></description>
			<content:encoded><![CDATA[<p>Not much has happen here lately, for one I&#8217;ve been away for on GDC &#8211; which was great. Than I caught an ugly cold that kept me in bed for an entire week. Today is the first day I&#8217;ve been somewhat normally operational so I decided to get the core stuff into the bead editor and try to gather feedback on it.</p>
<p>I&#8217;m specifically looking for feedback on the bead putting interface/controls as I want it to be as good as possible, also I want it to apply to touch screens which means some extra limitations (I had to scrap the bead piles that was in the first version). I&#8217;ve tested the latest prototype on my phone and it works alright. All the menus and icons are mock ups so don&#8217;t go mental on them.</p>
<p>To get more feedback I added a &#8220;leave feedback&#8221; box in the editor, this saves users the trouble of registering on the blog etc.</p>
<p>This is what I did:<br />
<a href="http://www.playchilla.com/wp-content/uploads/2012/03/mario.png"><img src="http://www.playchilla.com/wp-content/uploads/2012/03/mario.png" alt="" title="mario" width="383" height="369" class="alignnone size-full wp-image-725" /></a></p>
<p>I&#8217;m calling it &#8216;Beadly&#8217; for now. I don&#8217;t if that is going to be the final name.<br />

<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000"
			id="fm_bead_865249505"
			class="flashmovie"
			width="800"
			height="600">
	<param name="movie" value="http://www.playchilla.com/swf/bead.swf?v=104" />
	<param name="wmode" value="direct" />
	<!--[if !IE]>-->
	<object	type="application/x-shockwave-flash"
			data="http://www.playchilla.com/swf/bead.swf?v=104"
			name="fm_bead_865249505"
			width="800"
			height="600">
		<param name="wmode" value="direct" />
	<!--<![endif]-->
		<br />
<a href="http://adobe.com/go/getflashplayer"><img src="http://www.adobe.com/images/shared/download_buttons/get_flash_player.gif" alt="Get Adobe Flash player" /></a><br />

	<!--[if !IE]>-->
	</object>
	<!--<![endif]-->
</object>
]]></content:encoded>
			<wfw:commentRss>http://www.playchilla.com/beadly-prototype-2/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Beads</title>
		<link>http://www.playchilla.com/beads</link>
		<comments>http://www.playchilla.com/beads#comments</comments>
		<pubDate>Sun, 26 Feb 2012 18:43:49 +0000</pubDate>
		<dc:creator>Jon</dc:creator>
				<category><![CDATA[News]]></category>

		<guid isPermaLink="false">http://www.playchilla.com/?p=701</guid>
		<description><![CDATA[Yesterday I was at a dinner, when we arrived we had to choose a beermat for our drinks. All beermats where customized for the guests and you had to figure out which one was yours. For me it was really simple (unfortunately I broke it): The next day I woke up with an urge to [...]]]></description>
			<content:encoded><![CDATA[<p>Yesterday I was at a dinner, when we arrived we had to choose a beermat for our drinks. All beermats where customized for the guests and you had to figure out which one was yours. For me it was really simple (unfortunately I broke it):</p>
<p><a href="http://www.playchilla.com/wp-content/uploads/2012/02/IMG_20120226_192512.jpg"><img class="alignnone size-medium wp-image-702" title="IMG_20120226_192512" src="http://www.playchilla.com/wp-content/uploads/2012/02/IMG_20120226_192512-225x300.jpg" alt="" width="225" height="300" /></a></p>
<p>The next day I woke up with an urge to implement a digital bead creator. Actually the idea to this came from my my girlfriend Anna and her friend Matilda who did a cool artsy project a year ago. They had the idea of doing something interactively with digital beads. Check out the <a href="http://ibeadyou.blogspot.com/">I bead you</a> project.</p>
<p>Also I have wanted to try out flash GPU support for some time but never gotten around to do it so I decided to strike two flies in one hit (as we say in Sweden). This was very easy and I only ran into one problem: The GPU support didn&#8217;t work at all at first. After an hour of browsing and reading forums I decided to try update my device drivers and viola, there where more triangles than I could count. I looked around a bit for a 3D engine to use and finally went with Away3D 4 beta. It was really easy to use. Here is the result (you can&#8217;t save your creations or anything so screenshot it if you want to keep).</p>
<p>Latest change list 17/3/2012<br />
- Added mock up menus, new UI, feedback box</p>

<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000"
			id="fm_bead_561250262"
			class="flashmovie"
			width="800"
			height="600">
	<param name="movie" value="http://www.playchilla.com/swf/bead.swf?v=104" />
	<param name="wmode" value="direct" />
	<!--[if !IE]>-->
	<object	type="application/x-shockwave-flash"
			data="http://www.playchilla.com/swf/bead.swf?v=104"
			name="fm_bead_561250262"
			width="800"
			height="600">
		<param name="wmode" value="direct" />
	<!--<![endif]-->
		
<p><a href="http://adobe.com/go/getflashplayer"><img src="http://www.adobe.com/images/shared/download_buttons/get_flash_player.gif" alt="Get Adobe Flash player" /></a></p>

	<!--[if !IE]>-->
	</object>
	<!--<![endif]-->
</object>
<p>I have a cool idea on some expansions of this, not sure if it&#8217;s possible to do yet.. more on that later.</p>
<p>This is what Anna did:<br />
<a href="http://www.playchilla.com/wp-content/uploads/2012/02/bead.png"><img class="alignnone  wp-image-712" title="bead" src="http://www.playchilla.com/wp-content/uploads/2012/02/bead-300x265.png" alt="" width="338" height="299" /></a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.playchilla.com/beads/feed</wfw:commentRss>
		<slash:comments>16</slash:comments>
		</item>
		<item>
		<title>Started on campaign</title>
		<link>http://www.playchilla.com/started-on-campaign</link>
		<comments>http://www.playchilla.com/started-on-campaign#comments</comments>
		<pubDate>Tue, 21 Feb 2012 20:32:34 +0000</pubDate>
		<dc:creator>Jon</dc:creator>
				<category><![CDATA[Tower Defense]]></category>

		<guid isPermaLink="false">http://www.playchilla.com/?p=690</guid>
		<description><![CDATA[Now that I got the level editor running making levels is pretty easy. So I spent some hours throwing together a bunch of levels. I want the start levels to be really easy and basic and incrementally get more complex. I decided to build a world with clusters of levels &#8211; each cluster introduces a [...]]]></description>
			<content:encoded><![CDATA[<p>Now that I got the level editor running making levels is pretty easy. So I spent some hours throwing together a bunch of levels. I want the start levels to be really easy and basic and incrementally get more complex. I decided to build a world with clusters of levels &#8211; each cluster introduces a new tower or enemy or something like that and get unlocked as the player completes levels. I also wanted to add some freedom of choosing a path through the world. You might not want to play all levels.</p>
<p>As you unlock levels you also unlock new towers and upgrades on previously unlocked towers. I&#8217;m not entirely sure how to make all this self explanatory yet. Also, it feels like the game is missing something, it feels kind of stiff. Not sure what exactly. I like the simple graphics and I don&#8217;t wont to spend to much time on that, but it might be that enemy movements are too much moving along a rail. I might make that more organic in a future version.</p>
<p>Thanks to everyone who is testing it and leaving feedback!</p>
<p><a href="http://www.playchilla.com/tower-defense">Try it here and let me know what you think!</a></p>
<p><a href="http://www.playchilla.com/wp-content/uploads/2012/02/campaign.png"><img src="http://www.playchilla.com/wp-content/uploads/2012/02/campaign.png" alt="" title="campaign" width="640" class="alignnone size-full wp-image-691" /></a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.playchilla.com/started-on-campaign/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Laser Towers</title>
		<link>http://www.playchilla.com/laser-towers</link>
		<comments>http://www.playchilla.com/laser-towers#comments</comments>
		<pubDate>Mon, 06 Feb 2012 19:09:53 +0000</pubDate>
		<dc:creator>Jon</dc:creator>
				<category><![CDATA[News]]></category>
		<category><![CDATA[Tower Defense]]></category>

		<guid isPermaLink="false">http://www.playchilla.com/?p=670</guid>
		<description><![CDATA[I had a very productive weekend. Previously I had designed levels directly in xml/json with a standalone simplistic &#8220;level paint program&#8221;. I didn&#8217;t like this setup for many reasons, one being code maintenance in two places another being longer iteration times. Even though I really don&#8217;t like programming editors I decided to spend last weekend [...]]]></description>
			<content:encoded><![CDATA[<p>I had a very productive weekend. Previously I had designed levels directly in xml/json with a standalone simplistic &#8220;level paint program&#8221;. I didn&#8217;t like this setup for many reasons, one being code maintenance in two places another being longer iteration times. Even though I really don&#8217;t like programming editors I decided to spend last weekend just doing that.</p>
<h3>Level Format</h3>
<p>I managed to remove all xml formats and convert them to json and build the editor in game. This means I can actually edit levels while playing them. It was totally worth the effort. I converted the xml because json is so much simpler and lightweight.</p>
<p>If anyone is interested this is how the level format looks:</p>
<pre class="brush:as3">{
	"name": "Algorithmic",
	"uid": "r2_algorithmic",
	"mapPos": [0, 0],
	"mapSize": [12, 12],
	"numberOfLives": 10,
	"seed": 5,
	"energy": 120,
	"easyWaves": 10,
	"mediumWaves": 20,
	"hardWaves": 30,
	"waveInterval": {"init": 7, "add": -0.2, "min":3},
	"level": {"init":1, "add": 0.4, "mul": 1.05},
	"waveSizeDef": {"init":5, "add":0.5},
	"waitDef": false,
	"waves":
	[
		{"queue": ["Xor"]},
		{"queue": ["XorSpeed"]},
		{"queue": ["Xor", "XorSpeed"]},
		{
			"wait": true,
			"size": {"init": 1, "add": 0.2},
			"queue": ["XorBoss"]
		}
	],
	"allowedTowers": ["bullet", "slow"],
	"tilesData": "sssssssssssssssspppsssssssssppppssssssspptppsssssssppttppsssssppprpppssssspptrrtppssspptppptppssspprpppprppsppttpppttppspptptpptptpprrpprrrpprpp",
	"overlayData": "00000000000000000x00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000b00000000000000000000000000000e"
}</pre>
<p>On top of this I added an tree based EditView that allows me to edit instantiated level object on the fly. This was boring to do since it involved so much UI program (which I really dislike). On the right in the image below you can see the palette, all the different tiles and overlays (bases, entrances and exits). I think now it&#8217;s gonna be fun to create levels.</p>
<p><a href="http://www.playchilla.com/wp-content/uploads/2012/02/towdef_editor.png"><img src="http://www.playchilla.com/wp-content/uploads/2012/02/towdef_editor.png" alt="" title="towdef_editor" width="600" class="alignnone size-full wp-image-672" /></a></p>
<p>I will include the level editor when it is usable for and has less bugs.</p>
<h3>New level &#038; laser towers</h3>
<p>So I built a level in my new editor and added a new tower type: Laser Towers. Those shoots beams through one or more enemies giving mass damage. Place it carefully to hit as many as possible.</p>
<p><a href="http://www.playchilla.com/ai-tower-defense"><img src="http://www.playchilla.com/wp-content/uploads/2012/02/towdef_laser.png" alt="" title="towdef_laser" width="332" height="309" class="alignnone size-full wp-image-676" /></a></p>
<p><a href="http://www.playchilla.com/ai-tower-defense">Now go and play the new level here</a>! Remember to leave feedback on what sucks and needs to be improved (and what you like).</p>
]]></content:encoded>
			<wfw:commentRss>http://www.playchilla.com/laser-towers/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Tower Defense is now playable</title>
		<link>http://www.playchilla.com/tower-defense-is-now-playable</link>
		<comments>http://www.playchilla.com/tower-defense-is-now-playable#comments</comments>
		<pubDate>Tue, 31 Jan 2012 19:35:46 +0000</pubDate>
		<dc:creator>Jon</dc:creator>
				<category><![CDATA[News]]></category>

		<guid isPermaLink="false">http://www.playchilla.com/?p=640</guid>
		<description><![CDATA[I&#8217;ve just released a playable level of the tower defense I&#8217;m working on. This first level only contains two simple towers (bullet + slow) and three different enemies, it&#8217;s nothing fancy just plain tower defense. Feedback is appreciated This is a first test in order to get some feedback on controls and game play and [...]]]></description>
			<content:encoded><![CDATA[<p>I&#8217;ve just released a playable level of the tower defense I&#8217;m working on. This first level only contains two simple towers (bullet + slow) and three different enemies, it&#8217;s nothing fancy just plain tower defense.</p>
<h3>Feedback is appreciated</h3>
<p>This is a first test in order to get some feedback on controls and game play and the general feel of the game. Please comment if you try it out.</p>
<h3>Toplist and ads</h3>
<p>I also added a top list to make it a little bit more fun. At first I designed an own high score system (on paper) then, in order to save time, I decided to use an already made API. After some hours of reading I wasn&#8217;t any wiser on what system to use so I decided just to pick one that looked decent (sometimes it&#8217;s more efficient to just try stuff in practice than trying to figure them out in theory). I ended up with mochi media. I wanted to turn off the ads, at least during development but it seems that I had no such option.</p>
<p>As I final note my record has already been broken, a player &#8220;fghj&#8221; managed to stay alive for 33 waves vs my 27.</p>
<p><a href="http://www.playchilla.com/ai-tower-defense">PLAY IY HERE</a></p>
<p><a href="http://www.playchilla.com/ai-tower-defense"><img src="http://www.playchilla.com/wp-content/uploads/2011/12/towdef.png" alt="" title="towdef" width="624" height="650" class="alignnone size-full wp-image-498" /></a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.playchilla.com/tower-defense-is-now-playable/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>AI Tower Defense</title>
		<link>http://www.playchilla.com/tower-defense</link>
		<comments>http://www.playchilla.com/tower-defense#comments</comments>
		<pubDate>Sat, 14 Jan 2012 17:16:06 +0000</pubDate>
		<dc:creator>Jon</dc:creator>
				<category><![CDATA[Projects]]></category>

		<guid isPermaLink="false">http://www.playchilla.com/?p=578</guid>
		<description><![CDATA[I&#8217;m making a tower defense game, check the teaser out!]]></description>
			<content:encoded><![CDATA[<p>I&#8217;m making a tower defense game, check the teaser out!</p>
]]></content:encoded>
			<wfw:commentRss>http://www.playchilla.com/tower-defense/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Making a puzzle game in 4 days</title>
		<link>http://www.playchilla.com/making-a-puzzle-game-in-4-days</link>
		<comments>http://www.playchilla.com/making-a-puzzle-game-in-4-days#comments</comments>
		<pubDate>Mon, 09 Jan 2012 18:35:02 +0000</pubDate>
		<dc:creator>Jon</dc:creator>
				<category><![CDATA[AI and game development]]></category>

		<guid isPermaLink="false">http://www.playchilla.com/?p=553</guid>
		<description><![CDATA[Howdy hackers, once again I got side tracked from the tower defense game and decided to create a puzzle game. The goal was to make it as quickly as possible and not spend time on building overly complicated stuff. The puzzle game is inspired from one of the Machinarium in-game puzzles: I found this puzzle [...]]]></description>
			<content:encoded><![CDATA[<p>Howdy hackers, once again I got side tracked from the tower defense game and decided to create a puzzle game. The goal was to make it as quickly as possible and not spend time on building overly complicated stuff. The puzzle game is inspired from one of the Machinarium in-game puzzles:</p>
<p><a href="http://www.playchilla.com/wp-content/uploads/2012/01/machinarium.jpg"><img class="alignnone size-medium wp-image-554" title="machinarium" src="http://www.playchilla.com/wp-content/uploads/2012/01/machinarium.jpg" alt="" width="600" height="398" /></a></p>
<p>I found this puzzle a lot of fun and decided to create a dedicated game. The objective is to move over all tiles without getting trapped. Select a starting point then choose a direction in which the tiles will be lit all the way until a wall is hit, then select a new direction. You can&#8217;t move through yourself so you need to make sure you don&#8217;t get trapped.</p>
<p>Last weekend was extra long and that was the time span I sat out to do this within.</p>
<h3>Initial development</h3>
<p>I started by created a level format, I kept it simple and used a char matrix to describe the board. Then I implemented a simple view on this that drew rectangles in different colors. And on top of this I added the ability to move over tiles. This was all straight forward and playable within a couple of hours.</p>
<h3>Level Generation</h3>
<p>Once I could actually play some test levels I went ahead and wrote a level generator. This was also pretty straight forward and very brute force. The only thing I had to put some effort in was the difficulty calculations so the levels could be categories into easy, medium and hard. I ended up using the number of choices needed to solve a puzzle going the easiest way (fewest moves). Another thing that I had to do was to remember to throw away duplicates, to do this I mirrored and rotated each solvable to make sure every level was unique. Totally more than 300 levels are used for the game. All in all I probably spent 10 hours on this.</p>
<h3>Adding some nice graphics</h3>
<p>Once this was done, the boring programming was left. Building some kind of menu, making games save, showing dialogs upon level completion or failure. This took the rest of the time. Anna did some cool buttons and tiles for the game to make it look better. This probably took 20 hours. All the fiddling with mouse overs etc. Phew.</p>
<p><a href="http://www.playchilla.com/wp-content/uploads/2012/01/puzzle_27_medium.png"><img class="size-full wp-image-555 alignleft" style="margin-right: 20px; margin-bottom: 20px;" title="puzzle_27_medium" src="http://www.playchilla.com/wp-content/uploads/2012/01/puzzle_27_medium.png" alt="" width="240" height="400" /></a></p>
<p><a href="http://www.playchilla.com/wp-content/uploads/2012/01/puzzle_21_hard.png"><img class="alignnone size-full wp-image-559" title="puzzle_21_hard" src="http://www.playchilla.com/wp-content/uploads/2012/01/puzzle_21_hard.png" alt="" width="240" height="400" /></a></p>
<p>&nbsp;</p>
<h3>Name: Touch All Puzzle</h3>
<p>For now the game is available for free in the Android market. The name is &#8220;Touch All Puzzle&#8221;. I&#8217;m not very happy with the name, but it will do. I will make an IOS and flash version as well.</p>
<p><a class="without_u" href="https://market.android.com/details?id=air.com.playchilla.maze&#038;feature=search_result"><img src="http://www.playchilla.com/wp-content/uploads/2011/07/android_market.png" title="android_market" /></a></p>
<h3>Whats next</h3>
<p>Also I would like to experiment with monetizing it as well. This is something I am really bad at. I&#8217;ve written free software for 15 years now but starting to feel that some money would be nice.</p>
<p>&nbsp;</p>
]]></content:encoded>
			<wfw:commentRss>http://www.playchilla.com/making-a-puzzle-game-in-4-days/feed</wfw:commentRss>
		<slash:comments>6</slash:comments>
		</item>
		<item>
		<title>Shooting at a moving target as3</title>
		<link>http://www.playchilla.com/shooting-at-a-moving-target-as3</link>
		<comments>http://www.playchilla.com/shooting-at-a-moving-target-as3#comments</comments>
		<pubDate>Mon, 26 Dec 2011 11:48:03 +0000</pubDate>
		<dc:creator>Jon</dc:creator>
				<category><![CDATA[AI and game development]]></category>
		<category><![CDATA[Algorithms]]></category>

		<guid isPermaLink="false">http://www.playchilla.com/?p=520</guid>
		<description><![CDATA[As I was implementing the towers I needed them to aim and shoot on the anticipated position of an enemy, assuming they are moving linearly (no acceleration). This is because the bullets in my game are physics entities that won&#8217;t hit the enemy instantly but after some time as it travels towards the predicted interception [...]]]></description>
			<content:encoded><![CDATA[<p>As I was implementing the towers I needed them to aim and shoot on the anticipated position of an enemy, assuming they are moving linearly (no acceleration). This is because the bullets in my game are physics entities that won&#8217;t hit the enemy instantly but after some time as it travels towards the predicted interception point. As a human you do those predictions all the time, for example passing a football to a running team mate, you predict where to pass so that your friend don&#8217;t have to stop and wait for the football to arrive. This is sometimes called leading a target, aim prediction or simply shooting at a moving target.</p>
<p><a href="http://www.playchilla.com/wp-content/uploads/2011/12/aiming.png"><img src="http://www.playchilla.com/wp-content/uploads/2011/12/aiming.png" alt="" title="aiming" width="324" height="304" class="alignnone size-full wp-image-539" /></a></p>
<p>I though I would write up how I did this, much for my own sake (haven&#8217;t fiddled with this in a long time) and as they say repetition is the mother of all knowledge. You can skip to the bottom part to get the code directly. Also sorry for not using a proper font for math symbols. At least I tried to be consistant, * is the dot product and for scalar multiplication I didn&#8217;t use the mul sign (e.g. st).</p>
<p>These are the variables:<br />
v = enemy velocity<br />
p = enemy position in relation to tower (enemyPos-towerPos)<br />
s = bullet speed<br />
t = the time of impact (unknown &#8211; what we want to find out)</p>
<p>Now assuming that the enemy will continue in its path we can calculate where to shoot to get a hit.</p>
<p>The first equation we set up is:<br />
<strong>|p+vt| = st</strong></p>
<p>This happens when the distance from the tower to the bullet and enemy is the same. You can think of p+vt as a point along a line, starting at the enemy pos (p) and extending in the direction of its velocity (v) as the time (t) grows. The |p+vt| simply means the distance (from the tower) of a point on the line at a given time. st is the distance the bullet have traveled after t time units (remember distance = time * speed).</p>
<p>What we want to do is to find out the time (t) when they are at equal distances. To solve it we need to rearrange the expression a bit. Remember that |v| = sqrt(v*v) (* = dot product), in order to &#8220;free&#8221; t from its walls |p + v * t| we start by squaring both sides:</p>
<p><strong>|p+vt|^2 = s^2t^2</strong></p>
<p>Freeing t out of the distance operator (|):<br />
|p+vt|^2 = sqrt((p+vt)*(p+vt))^2 =<br />
(p+vt)*(p+vt) =<br />
p*p + 2p*vt + v*vt^2 = s^2*t^2</p>
<p>Now we set it up as a quadratic equation just as we learnt in school.</p>
<p>v*vt^2 &#8211; s^2t^2 + 2p*vt + p*p = 0</p>
<p><strong>(v*v &#8211; s^2)t^2 + 2p*vt + p*p = 0 </strong>(This is the <a href="http://en.wikipedia.org/wiki/Quadratic_equation">quadratic</a> form ax^2 + bx + c = 0).</p>
<p>Now we only have to solve it, so we plug it into the olden equation:</p>
<p>t1 = (-b + sqrt(d)) / 2a<br />
t2 = (-b &#8211; sqrt(d)) / 2a</p>
<p>where d=b^2-4ac</p>
<p>There are two possible solutions to quadratic equations. The factor inside the sqrt is called the discriminant, d, and reveals information about the solutions, a positive d means we have two real solutions, if d is zero there is only one solution and if it&#8217;s below zero we have complex solutions this means that we don&#8217;t have anyway of hitting the enemy (enemy moving away faster than bullet).</p>
<p>a = v*v &#8211; s^2</p>
<p>b = 2*p*v</p>
<p>c = p * p</p>
<p>This is basically what I implemented, than after I got the solutions I returned the lowest positive t via some ugly if statements. I wasn&#8217;t really happy with this so I kept looking around and ran into  slembcke&#8217;s post &#8216;<a href="http://howlingmoonsoftware.com/wordpress/?p=358">leading target</a>&#8216;, in addition to illustrating the equations nicely with graphs he points out that we can use the <a href="http://en.wikipedia.org/wiki/Quadratic_equation#Alternative_quadratic_formula">alternate quadratic formula</a> if we only are interested in the first possible time of impact (works when there is a positive solution).</p>
<p>t = 2c / (-b+sqrt(d))</p>
<p>After unittesting this bad boy I felt pretty comfortable that it was what I was looking for, even though I haven&#8217;t proved it for myself. One thing to keep in mind is that this will return 2c/0 (division by zero) if  sqrt(d)=b, this happens when the enemy is moving away at the exact  speed as the bullet, in one of the towers axis (the bullet can&#8217;t catch up nor fall behind). I solved this by checking if the t == Infinity, if so I handle it just as if there are no solutions (negative t).</p>
<p>Another small improvement that  <a href="http://playtechs.blogspot.com/2007/04/aiming-at-moving-target.html">James McNeill</a> pointed out is that you can cancel the 2 factor in b. As for this aiming problem we get 2*p*v for our b factor, squaring this in d (b*b) , gives us sqrt(4(pv)^2 &#8211; 4ac) =&gt; 2 * sqrt((pv)^2 &#8211; ac) so now we can cancel the 2 in the top 2c.</p>
<p>The equation we end up with is:</p>
<p>a = v*v &#8211; s^2</p>
<p>b = p*v (removed the 2 factor)</p>
<p>c = p * p</p>
<p>d = b*b &#8211; ac (removed the 4 factor)</p>
<p><strong>t = c / (sqrt(d) &#8211; b)</strong></p>
<p>Here is AS3 source code to calculate how to aim on a moving target:</p>
<pre class="brush:as3">private function _getToi(targetDir:Vec2Const, targetVel:Vec2Const, bulletSpeed:Number):Number
{
	const a:Number = targetVel.lengthSqr() - bulletSpeed * bulletSpeed;
	const b:Number = targetDir.dot(targetVel);
	const c:Number = targetDir.lengthSqr();
	const d:Number = b * b - a * c;
	if (d &lt;= 0) return -1;
	return c / (Math.sqrt(d) - b);
}</pre>
<p>Once you have the time of impact, you check if it&#8217;s negative or infinity &#8211; if so there is no firing solution. Otherwise you can easily calculate the aim position or direction by interpolating from the enemy position in by it&#8217;s velocity scaled by the time:</p>
<pre class="brush:as3">public function getAimPos(shooterPos:Vec2Const, targetPos:Vec2Const, targetVel:Vec2Const, bulletSpeed:Number):Vec2
{
	const targetDir:Vec2Const = targetPos.sub(shooterPos);
	const toi:Number = _getToi(targetDir, targetVel, bulletSpeed);
	if (toi == -1 || toi == Infinity) return null;
	return targetPos.add(targetVel.scale(toi));
}</pre>
<p>As a final note, I assumed that the shooters (towers) are standing still, you can easily modify this by adding a shooterVelocity and pass the relative velocity to the _getToi method.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.playchilla.com/shooting-at-a-moving-target-as3/feed</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Real Time Fluids</title>
		<link>http://www.playchilla.com/real-time-fluids</link>
		<comments>http://www.playchilla.com/real-time-fluids#comments</comments>
		<pubDate>Fri, 23 Dec 2011 17:00:17 +0000</pubDate>
		<dc:creator>Jon</dc:creator>
				<category><![CDATA[Algorithms]]></category>

		<guid isPermaLink="false">http://www.playchilla.com/?p=510</guid>
		<description><![CDATA[This Jul (Swedish for Christmas) I&#8217;m not only eating Julbord, Julfika, Julgröt and drinking Julöl (basically put &#8216;Jul&#8217; before any word and there you go), I&#8217;m also doing some Julcoding. Some time ago I ported a c implementation of a Naiver-Stokes fluid simulation to AS3 and I thought I should share it. It&#8217;s all based [...]]]></description>
			<content:encoded><![CDATA[<p>This Jul (Swedish for Christmas) I&#8217;m not only eating Julbord, Julfika, Julgröt and drinking Julöl (basically put &#8216;Jul&#8217; before any word and there you go), I&#8217;m also doing some Julcoding.</p>
<p>Some time ago I ported a c implementation of a Naiver-Stokes fluid simulation to AS3 and I thought I should share it. It&#8217;s all based on this paper &#8216;<a href="http://www.dgp.toronto.edu/people/stam/reality/Research/pdf/GDC03.pdf">Real Time Fluid Dynamics for Games</a>&#8216; from by Joe Stam. If you want to understand the details about this I suggest you read it, or look around on the web. But the concept is to  set up a velocity and density field to which you add external velocities and densities. For each update you solve the velocities by iterating over the grid and then move the densities accordingly.</p>
<p>On top of that I added some balls that you can play around with by moving a ball with the mouse, it&#8217;s visually not very impressive but it should give an idea of what you can do with it.</p>

<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000"
			id="fm_fluiddemo_1213433123"
			class="flashmovie"
			width="300"
			height="300">
	<param name="movie" value="http://www.playchilla.com/swf/fluiddemo.swf" />
	<!--[if !IE]>-->
	<object	type="application/x-shockwave-flash"
			data="http://www.playchilla.com/swf/fluiddemo.swf"
			name="fm_fluiddemo_1213433123"
			width="300"
			height="300">
	<!--<![endif]-->
		
<p><a href="http://adobe.com/go/getflashplayer"><img src="http://www.adobe.com/images/shared/download_buttons/get_flash_player.gif" alt="Get Adobe Flash player" /></a></p>

	<!--[if !IE]>-->
	</object>
	<!--<![endif]-->
</object>
<p>It seems like the flash bottleneck is the memory access (all the _v[index] etc), I think using Alchemy for memory access would speed it up a lot, and you could probably do really cool simulations. If you decide to try it, let me know how it works!</p>
<p>Use the method &#8216;getDensities&#8217; for rendering (just iterate it and plot it). Here is the AS3 code for the fluid solver:</p>
<pre class="brush:as3">package com.playchilla.algorithm.fluid
{
	public class FluidSolver
	{
		public function FluidSolver(
			width:int,
			height:int,
			solveIterations:int,
			diffusion:Number,
			viscosity:Number)
		{
			_width = width;
			_height = height;
			_solveIterations = solveIterations;
			_diff = diffusion;
			_visc = viscosity;

			_n2 = _width * _height;
			_size = (_width + 2) * (_height + 2);
			_d = _createArr();
			_d0 = _createArr();
			_u = _createArr();
			_v = _createArr();
			_u0 = _createArr();
			_v0 = _createArr();

			_rowAdder = _width + 2;
		}

		public function update(dt:Number):void
		{
			// Add sources from previous to current (last += new)
			_addSource(_u, _u0, dt);
			_addSource(_v, _v0, dt);

			// Diffuse new with old
			_diffuse(1, _u0, _u, _visc, dt);
			_diffuse(2, _v0, _v, _visc, dt);

			// Project velocities onto new velocities
			_project(_u0, _v0, _u, _v);

			// enforce new velocities to uv
			_advect(1, _u, _u0, _u0, _v0, dt);
			_advect(2, _v, _v0, _u0, _v0, dt);

			_project(_u, _v, _u0, _v0);

			// Density step
			_addSource(_d, _d0, dt);
			_diffuse(0, _d0, _d, _diff, dt);
			_advect(0, _d, _d0, _u, _v, dt);

			for (var i:int = 0; i &lt; _size ; i++)
				_d0[i] = _u0[i] = _v0[i] = 0;
		}

		public function getDensities():Vector.&lt;Number&gt; { return _d; }
		public function addDensity(x:int, y:int, amount:Number):void { _d0[_index(x,y)] += amount; }
		public function addVelocity(x:int, y:int, velocityX:Number, velocityY:Number):void
		{
			const index:int = _index(x, y);
			_u0[index] += velocityX;
			_v0[index] += velocityY;
		}
		public function setVelocity(x:int, y:int, velocityX:Number, velocityY:Number):void
		{
			const index:int = _index(x, y);
			_u0[index] = velocityX;
			_v0[index] = velocityY;
		}

		public function getWidth():Number { return _width; }
		public function getHeight():Number { return _height; }

		private function _addSource(x:Vector.&lt;Number&gt;, s:Vector.&lt;Number&gt;, dt:Number):void
		{
			for (var i:int = 0; i &lt; _size; ++i)
				x[i] += dt * s[i];
		}

		private function _diffuse(b:int, x:Vector.&lt;Number&gt;, x0:Vector.&lt;Number&gt;, diff:Number, dt:Number):void
		{
			const a:Number = dt * diff * _n2;
			_linearlySolve(x, x0, a, b, 1 + 4 * a);
		}

		private function _linearlySolve(x:Vector.&lt;Number&gt;, x0:Vector.&lt;Number&gt;, a:Number, b:Number, c:Number):void
		{
			for (var k:int = 0; k &lt; _solveIterations; ++k)
			{
				for (var j:int = 1; j &lt;= _height; ++j)
				{
					var current:int = j * _rowAdder;
					for (var i:int = 1 ; i &lt;= _width; ++i)
					{
						++current;
						x[current] =
							(x0[current] +
							a *
							(x[current-1] +
							 x[current+1] +
							 x[current-_rowAdder] +
							 x[current+_rowAdder])) / c;
					}
				}

				_setBnd(b, x);
			}
		}

		private function _advect(b:Number, d:Vector.&lt;Number&gt;, d0:Vector.&lt;Number&gt;, u:Vector.&lt;Number&gt;, v:Vector.&lt;Number&gt;, dt:Number):void
		{
			const dt0:Number = dt * _width; // FIX
			for (var j:int = 1; j &lt;= _height; ++j)
			{
				const current:int = j * _rowAdder;
				for (var i:int = 1 ; i &lt;= _width; ++i)
				{
					++current;
					const x:Number = Math.min(Math.max(i - dt0 * u[current], 0.5), _width + 0.5);
					const y:Number = Math.min(Math.max(j - dt0 * v[current], 0.5), _height + 0.5);

					const i0:int = int(x);
					const i1:int = i0 + 1;
					const j0:int = int(y);
					const j1:int = j0+1;

					const s1:Number = x - i0;
					const s0:Number = 1 - s1;
					const t1:Number = y - j0;
					const t0:Number = 1 - t1;

					d[current] = s0 *
						(t0 * d0[_index(i0, j0)] +
						 t1 * d0[_index(i0, j1)]) + s1 *
						(t0 * d0[_index(i1, j0)] +
						 t1 * d0[_index(i1, j1)]);
				}
			}
			_setBnd(b, d);
		}

		private function _project(u:Vector.&lt;Number&gt;, v:Vector.&lt;Number&gt;, p:Vector.&lt;Number&gt;, div:Vector.&lt;Number&gt;):void
		{
			for (var j:int = 1; j &lt;= _height; ++j)
			{
				var current:int = j * _rowAdder;
				for (var i:int = 1; i &lt;= _width; ++i)
				{
					++current;
					div[current] = -0.5 *
						(u[current+1] -
						u[current-1] +
						v[current+_rowAdder] -
						v[current-_rowAdder]) / _width; // FIX /_N

					p[current] = 0;
				}
			}

			_setBnd(0, div);
			_setBnd(0, p);
			_linearlySolve(p, div, 1, 0, 4);

			for (j = 1; j &lt;= _height; ++j)
			{
				current = j * _rowAdder;
				for (i = 1 ; i &lt;= _width; ++i)
				{
					++current;
					u[current] -= 0.5 * _width * (p[current+1] - p[current-1]);
					v[current] -= 0.5 * _height * (p[current+_rowAdder] - p[current-_rowAdder]);
				}
			}

			_setBnd(1, u);
			_setBnd(2, v);
		}

		private function _setBnd(b:int, x:Vector.&lt;Number&gt;):void
		{
			for (var i:int = 1; i &lt;= _height; ++i)
			{
				x[_index(0, i)] = b==1 ? -x[_index(1, i)] : x[_index(1, i)];
				x[_index(_width+1, i)] = b==1 ? -x[_index(_width, i)] : x[_index(_width, i)];
			}

			for (i = 0; i &lt;= _width; ++i)
			{
				x[_index(i, 0)] = b == 2 ? -x[_index(i, 1)] : x[_index(i, 1)];
				x[_index(i,_height + 1)] = b == 2 ? -x[_index(i, _height)] : x[_index(i, _height)];
			}

			x[_index(0, 0)] = 0.5 * (x[_index(1,0  )]+x[_index(0  ,1)]);
			x[_index(0, _height + 1)] = 0.5 * (x[_index(1, _height + 1)] + x[_index(0 , _height)]);
			x[_index(_width + 1, 0)] = 0.5 * (x[_index(_width, 0)] + x[_index(_width + 1, 1)]);
			x[_index(_width + 1, _height + 1)] = 0.5 * (x[_index(_width, _height + 1)] + x[_index(_width+1, _height)]);
		}

		private function _index(x:int, y:int):int {	return x + y * _rowAdder; }

		private function _createArr():Vector.&lt;Number&gt;
		{
			const arr:Vector.&lt;Number&gt; = new Vector.&lt;Number&gt;(_size, true);
			for (var i:int = 0; i &lt; _size; ++i)
				arr[i] = 0;
			return arr;
		}

		private var _solveIterations:int;
		private var _diff:Number;
		private var _visc:Number;
		private var _width:int;
		private var _height:int;

		private var _n2:int;
		private var _size:int;
		private var _rowAdder:int;

		private var _d:Vector.&lt;Number&gt;; // dens
		private var _d0:Vector.&lt;Number&gt;; // prev dens
		private var _u:Vector.&lt;Number&gt;; // vel x
		private var _u0:Vector.&lt;Number&gt;;
		private var _v:Vector.&lt;Number&gt;; // vel y
		private var _v0:Vector.&lt;Number&gt;;
	}
}</pre>
<p>Merry Christmas!</p>
]]></content:encoded>
			<wfw:commentRss>http://www.playchilla.com/real-time-fluids/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Making of a Tower Defense</title>
		<link>http://www.playchilla.com/making-tower-defense</link>
		<comments>http://www.playchilla.com/making-tower-defense#comments</comments>
		<pubDate>Wed, 21 Dec 2011 13:46:19 +0000</pubDate>
		<dc:creator>Jon</dc:creator>
				<category><![CDATA[Tower Defense]]></category>

		<guid isPermaLink="false">http://www.playchilla.com/?p=496</guid>
		<description><![CDATA[Right now I&#8217;m between two jobs which gives me a week of creative coding, oh yeah! As I said in an earlier post I wanted to create a tower defense game, then I got sidetracked and made &#8220;Shadowess&#8221; instead, which was a lot of fun and created some of the foundations for this game. I want to create a [...]]]></description>
			<content:encoded><![CDATA[<p>Right now I&#8217;m between two jobs which gives me a week of creative coding, oh yeah! As I said in an earlier post I wanted to create a tower defense game, then I got sidetracked and made &#8220;Shadowess&#8221; instead, which was a lot of fun and created some of the foundations for this game.</p>
<p>I want to create a sandbox Tower Defense game instead of a linear. Here are two key features I am adding:</p>
<p><strong>1) Physics.</strong> Shoot creeps with big canons and knock them off their path, even make them fall of the map.</p>
<p><strong>2) Behaviors.</strong> Creeps can posses different behaviors. So far I&#8217;ve implemented a behavior to avoid incoming artillery fire, this looks really cool &#8211; shooting into a group scatters it as they are fleeing all over. Another behavior is to avoid towers by taking advantage of a weighted graph they can find their way to the goal exposing themselves to as little danger as possible. More to come.</p>
<p>Also I created a little level editor in which I can draw maps using a hexagonal layout. I will not spend so much time on graphics instead focus on the game play. Your objective is to protect your &#8220;souls&#8221; which the creeps try to steal. I&#8217;ve a story line for this in the back of  my head as well, but that&#8217;s for the future.</p>
<p>Here is a first screenshot to show you the progress. This level has allows 2 types of towers, a normal canon and a slow tower, creeps enter at the bottom right and exits in the top. I&#8217;ve built a windy path for them to follow.</p>
<p><a href="http://www.playchilla.com/wp-content/uploads/2011/12/towdef.png"><img class="alignnone size-full wp-image-498" title="towdef" src="http://www.playchilla.com/wp-content/uploads/2011/12/towdef.png" alt="" width="624" height="650" /></a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.playchilla.com/making-tower-defense/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Shadowess update</title>
		<link>http://www.playchilla.com/shadowess-update</link>
		<comments>http://www.playchilla.com/shadowess-update#comments</comments>
		<pubDate>Wed, 19 Oct 2011 17:14:13 +0000</pubDate>
		<dc:creator>Jon</dc:creator>
				<category><![CDATA[shadowess]]></category>

		<guid isPermaLink="false">http://www.playchilla.com/?p=466</guid>
		<description><![CDATA[I did a few level additions and adjustments to Shadowess and a added simple plot. My hope is to wrap this game up pretty soon, and get back on track with my original mission building a tower defense with some cool AI in it. There are many good things that have come out of this [...]]]></description>
			<content:encoded><![CDATA[<p>I did a few level additions and adjustments to Shadowess and a added simple plot. My hope is to wrap this game up pretty soon, and get back on track with my original mission building a tower defense with some cool AI in it.</p>
<p>There are many good things that have come out of this side project, I have a pretty robust testbed for AI, goal selection, astar, physics integration etc.</p>
<p><a href="http://www.playchilla.com/shadowess">TRY IT HERE</a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.playchilla.com/shadowess-update/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Shadowess &#8211; skill puzzle</title>
		<link>http://www.playchilla.com/shadowess</link>
		<comments>http://www.playchilla.com/shadowess#comments</comments>
		<pubDate>Sat, 08 Oct 2011 08:59:40 +0000</pubDate>
		<dc:creator>Jon</dc:creator>
				<category><![CDATA[Projects]]></category>

		<guid isPermaLink="false">http://www.playchilla.com/?p=460</guid>
		<description><![CDATA[Tactical shadow game, sneak around, don&#8217;t get heard and stay in the darkness. Quite difficult.]]></description>
			<content:encoded><![CDATA[<p>Tactical shadow game, sneak around, don&#8217;t get heard and stay in the darkness. Quite difficult.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.playchilla.com/shadowess/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Shadowess new atmoshpere</title>
		<link>http://www.playchilla.com/shadowess-new-atmoshpere</link>
		<comments>http://www.playchilla.com/shadowess-new-atmoshpere#comments</comments>
		<pubDate>Tue, 04 Oct 2011 16:34:05 +0000</pubDate>
		<dc:creator>Jon</dc:creator>
				<category><![CDATA[shadowess]]></category>

		<guid isPermaLink="false">http://www.playchilla.com/?p=447</guid>
		<description><![CDATA[I&#8217;ve recently not had a lot of time to blog, however I&#8217;ve spent some evenings adding some more atmosphere to the game. I&#8217;ve also adding a simple scoring mechanism and a preliminary main menu. This is all crude, and the graphical theme will probably be refined. I&#8217;ve set a kind of dark setting, perhaps on [...]]]></description>
			<content:encoded><![CDATA[<p>I&#8217;ve recently not had a lot of time to blog, however I&#8217;ve spent some evenings adding some more atmosphere to the game. I&#8217;ve also adding a simple scoring mechanism and a preliminary main menu.</p>
<p>This is all crude, and the graphical theme will probably be refined. I&#8217;ve set a kind of dark setting, perhaps on an occupied space ship. I will probably add some little background story to it at some point to make it more interesting.</p>
<p>Well try it and let me know what you think can improve. Any info on levels that are too hard or easy is important.</p>
<p><a href="http://www.playchilla.com/shadowess">TRY IT HERE</a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.playchilla.com/shadowess-new-atmoshpere/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Shadowess teaser, physics and more</title>
		<link>http://www.playchilla.com/shadowess-teaser-physics-and-more</link>
		<comments>http://www.playchilla.com/shadowess-teaser-physics-and-more#comments</comments>
		<pubDate>Wed, 21 Sep 2011 08:10:36 +0000</pubDate>
		<dc:creator>Jon</dc:creator>
				<category><![CDATA[shadowess]]></category>

		<guid isPermaLink="false">http://www.playchilla.com/?p=435</guid>
		<description><![CDATA[Lately things have been hectic at work, every weekend has been filled with birthdays and I also caught a cold. In short, I&#8217;ve had little time to work on my hobby projects. But fear not, progress has been done. I decided to create a teaser video, this took me two evenings and was a lot [...]]]></description>
			<content:encoded><![CDATA[<p>Lately things have been hectic at work, every weekend has been filled with birthdays and I also caught a cold. In short, I&#8217;ve had little time to work on my hobby projects.</p>
<p>But fear not, progress has been done. I decided to create a teaser video, this took me two evenings and was a lot of fun. While looking for music on different free sound sites I found <a href="http://www.bubaproducer.com">Buba Producer</a> on <a href="http://www.soundcloud.com">SoundCloud</a>. This guy creates really high quality scores and shares them freely for attribution. I think that is really cool. The only &#8220;bad&#8221; thing is that the music quality is so much higher than my video.</p>
<p><iframe width="420" height="315" src="http://www.youtube.com/embed/ar63-q5K33g" frameborder="0" allowfullscreen></iframe></p>
<p>I also had some trouble with the compression &#8211; some walls were removed when uploading to youtube. I don&#8217;t want to spend to much time on polishing the video so I will just leave it like that, and improve if I make another one in the future.</p>
<h4>Physics</h4>
<p>Another problem I ran into was level creation, I noticed that I needed a new game play element in order not to repeat myself. I decided to add balls that the player can push and hide in it&#8217;s shadow projection. Now creating levels was easy again.</p>
<p><a href="http://www.playchilla.com/wp-content/uploads/2011/09/shadowess_phys.jpg"><img src="http://www.playchilla.com/wp-content/uploads/2011/09/shadowess_phys.jpg" alt="" title="shadowess_phys" width="459" height="435" class="alignnone size-full wp-image-438" /></a><br />
Pushing the ball to get to the key unseen.</p>
<p>Another idea I&#8217;ve is to shape up the level editor and let you guys create levels and put them into the game? This will probably mean more variation.</p>
<h4>Play it</h4>
<p>Use <strong>ARROWS</strong> to move. Use <strong>MOUSE</strong> to throw pebbles. Use <strong>&#8216;R&#8217;</strong> to restart level. Be quiet. <strong>Stay in the darkness.</strong></p>

<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000"
			id="fm_shadowess_02_280606580"
			class="flashmovie"
			width="640"
			height="960">
	<param name="movie" value="http://www.playchilla.com/shadowess_swf/shadowess_02.swf" />
	<!--[if !IE]>-->
	<object	type="application/x-shockwave-flash"
			data="http://www.playchilla.com/shadowess_swf/shadowess_02.swf"
			name="fm_shadowess_02_280606580"
			width="640"
			height="960">
	<!--<![endif]-->
		
<p><a href="http://adobe.com/go/getflashplayer"><img src="http://www.adobe.com/images/shared/download_buttons/get_flash_player.gif" alt="Get Adobe Flash player" /></a></p>

	<!--[if !IE]>-->
	</object>
	<!--<![endif]-->
</object>
<p>You will always find the latest version under the <a href="http://www.playchilla.com/shadowess">shadowess project page</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.playchilla.com/shadowess-teaser-physics-and-more/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Project Shadowess</title>
		<link>http://www.playchilla.com/projectshadowess</link>
		<comments>http://www.playchilla.com/projectshadowess#comments</comments>
		<pubDate>Wed, 07 Sep 2011 19:04:22 +0000</pubDate>
		<dc:creator>Jon</dc:creator>
				<category><![CDATA[AI and game development]]></category>

		<guid isPermaLink="false">http://www.playchilla.com/?p=417</guid>
		<description><![CDATA[I think the prototype offspring I&#8217;ve been playing with is decent enough to develop further. Therefore I&#8217;ve decided to go forward with it and make a little game. It will probably be a short story, with no spectacular graphics that requires movement and puzzle skills. I&#8217;ll probably make about 30 levels, with only a few [...]]]></description>
			<content:encoded><![CDATA[<p>I think the prototype offspring I&#8217;ve been playing with is decent enough to develop further. Therefore I&#8217;ve decided to go forward with it and make a little game. It will probably be a short story, with no spectacular graphics that requires movement and puzzle skills. I&#8217;ll probably make about 30 levels, with only a few pickups and maybe some physics elements. I also decided to change the original format of the game (square) to something that might fit on an iPhone, (just in case). The problem with iPhone will probably be the control since you will be needing some precision. However in worst case this could be adjusted with a slower iPhone game or easier levels if necessary.</p>
<p>I won&#8217;t tell you more about my ideas now. The &#8216;Shadowess&#8217; page will always contain the latest version of the game (I&#8217;ll not post it in individual blog posts any longer).</p>
<p><a href="http://www.playchilla.com/shadowess">CHECK IT OUT</a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.playchilla.com/projectshadowess/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Game Prototype 2</title>
		<link>http://www.playchilla.com/game-prototype-2</link>
		<comments>http://www.playchilla.com/game-prototype-2#comments</comments>
		<pubDate>Sun, 04 Sep 2011 12:47:17 +0000</pubDate>
		<dc:creator>Jon</dc:creator>
				<category><![CDATA[AI and game development]]></category>

		<guid isPermaLink="false">http://www.playchilla.com/?p=408</guid>
		<description><![CDATA[I&#8217;ve redone some of the previous levels and added a few new. I also added a new pickup that will reveal itself on the last level (12), if anyone can get there. I think some levels are pretty hard, but I won&#8217;t spend too much time on tweaking since this is a prototype. Update: - [...]]]></description>
			<content:encoded><![CDATA[<p>I&#8217;ve redone some of the previous levels and added a few new. I also added a new pickup that will reveal itself on the last level (12), if anyone can get there. I think some levels are pretty hard, but I won&#8217;t spend too much time on tweaking since this is a prototype.</p>
<p>Update:<br />
- Random directions<br />
- Random turn speeds<br />
- Minor control tweak<br />
- More levels<br />
- A new pickup (pebbles)</p>
<p>Use the MOUSE for the last pickup, use ARROWS to control the bot, press &#8216;R&#8217; to restart a level.</p>

<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000"
			id="fm_aidef_06_1208542361"
			class="flashmovie"
			width="600"
			height="600">
	<param name="movie" value="http://www.playchilla.com/aidef/aidef_06.swf" />
	<!--[if !IE]>-->
	<object	type="application/x-shockwave-flash"
			data="http://www.playchilla.com/aidef/aidef_06.swf"
			name="fm_aidef_06_1208542361"
			width="600"
			height="600">
	<!--<![endif]-->
		
<p><a href="http://adobe.com/go/getflashplayer"><img src="http://www.adobe.com/images/shared/download_buttons/get_flash_player.gif" alt="Get Adobe Flash player" /></a></p>

	<!--[if !IE]>-->
	</object>
	<!--<![endif]-->
</object>
<p>What I probably should fix:<br />
- Bots must be able to chase player off the path grap (now the just look crazy)<br />
- Fix different hearing distances<br />
- Make the investigate goal less &#8220;dumb&#8221; (now everyone just runs the shortest path to the sound source)<br />
- Perhaps add some memory to the bots (as soon as player is out of sight the just forget him)</p>
]]></content:encoded>
			<wfw:commentRss>http://www.playchilla.com/game-prototype-2/feed</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Random direction in 2d</title>
		<link>http://www.playchilla.com/random-direction-in-2d</link>
		<comments>http://www.playchilla.com/random-direction-in-2d#comments</comments>
		<pubDate>Sat, 03 Sep 2011 14:44:33 +0000</pubDate>
		<dc:creator>Jon</dc:creator>
				<category><![CDATA[Algorithms]]></category>

		<guid isPermaLink="false">http://www.playchilla.com/?p=376</guid>
		<description><![CDATA[Randomness adds an extra flavor to games by injecting some unpredictability, something that can surprise the player. It also makes the game less mechanical and more organic. In the game prototype I posted earlier, bots always initialized their look directions to (1, 0). So every time a level starts all bots looks in this direction [...]]]></description>
			<content:encoded><![CDATA[<p>Randomness adds an extra flavor to games by injecting some unpredictability, something that can surprise the player. It also makes the game less mechanical and more organic. In the <a href="http://www.playchilla.com/game-prototype">game prototype</a> I posted earlier, bots always initialized their look directions to (1, 0). So every time a level starts all bots looks in this direction after which they start to behave randomly. This may seem like a smally but as a matter of fact it&#8217;s kind of disturbing also it gives the player the handicap of always knowing in what direction the bots will look at startup. Thanks <a href="http://retrocade.net">Maurycy Zarzycki</a> for pointing this out.</p>
<h4>Generating a random direction, three different algorithms</h4>
<p>When I was going to implement this I noticed that I didn&#8217;t have any central code to create a vector in a random direction. This is something I use frequently so I decided to do a proper implementation.</p>
<p>Randomizing a direction can be done in many ways, but be aware: some intuitive approaches are simply wrong and doesn&#8217;t provide a uniform distribution.</p>
<h4>Wrong: normalizing random points in a square</h4>
<p>The first time I was doing this, I didn&#8217;t realize this until a code review. The reviewer asked me if I was aware that my code generated biased directions. It all seemed random in my testing, I replied. I guess my first draft of the code looked a bit like this:</p>
<pre class="brush:as3">private function createRandomDirBad():Vec2
{
	const u:Number = 2 * Math.random() - 1;
	const v:Number = 2 * Math.random() - 1;
	const l:Number = Math.sqrt(u * u + v * v);
	return new Vec2(u / l, v / l);
}</pre>
<p>Can you see why this is skewed? This generates a random point in a square which is normalized to have length one &#8211; this means that diagonal directions will be biased because points outside the circle are &#8220;pushed&#8221; inside. The image below illustrates this bias. (Points are drawn in the circle rather than on the outline to demonstrate this)<br />
<a href="http://www.playchilla.com/wp-content/uploads/2011/09/square_bad.jpg"><img class="alignnone size-full wp-image-387" title="square_bad" src="http://www.playchilla.com/wp-content/uploads/2011/09/square_bad.jpg" alt="" width="237" height="236" /></a></p>
<h4>Discarding points outside of the circle</h4>
<p>I was quickly convinced and changed my code. I fixed it by discarding all randomly generated points outside of the circle (x*x + y*y &gt; 1). This requires more iterations but gives an uniform distribution of points within a circle. See distribution B below.</p>
<pre class="brush:as3">private function createRandomDirSquare():Vec2
{
	var p:Vec2;
	while (true)
	{
		const u:Number = 2 * Math.random() - 1;
		const v:Number = 2 * Math.random() - 1;
		const s:Number = u * u + v * v;
		if (s > 1 || s < Vec2Const.EpsilonSqr) continue;
		const l:Number = Math.sqrt(s);
		p = new Vec2(u / l, v / l);
		break;
	}
	return p;
}
</pre>
<p>Here is the distribution within the circle (on the circle surface it's uniform - but not over the area):<br />
<a href="http://www.playchilla.com/wp-content/uploads/2011/09/square_dir.jpg"><img src="http://www.playchilla.com/wp-content/uploads/2011/09/square_dir.jpg" alt="" title="square_dir" width="227" height="228" class="alignnone size-full wp-image-394" /></a></p>
<h4>Using trigonometry</h4>
<p>Another method for random generation of points in a circle is to use trigonometric functions. This perhaps the most straightforward way, we just grab a random angle and create a vector in that direction:</p>
<pre class="brush:as3">
private function createRandomDirTrigonometry():Vec2
{
	const rads:Number = Math.random() * Math.PI * 2;
	return new Vec2(Math.cos(rads), Math.sin(rads));
}
</pre>
<p>This will put points uniformly along a circle outline.</p>
<p><a href="http://www.playchilla.com/wp-content/uploads/2011/09/circle_trig.jpg"><img src="http://www.playchilla.com/wp-content/uploads/2011/09/circle_trig.jpg" alt="" title="circle_trig" width="247" height="235" class="alignnone size-full wp-image-396"/></a></p>
<h4>No square roots, no trigonometry</h4>
<p>While looking around, I <a href="http://www.gnu.org/s/gsl/manual/html_node/Spherical-Vector-Distributions.html">found</a> a method attributed to <a href="http://en.wikipedia.org/wiki/John_von_Neumann">Von Neumann</a>. This trick allows us to generate a random direction without any use of square roots or trigonometry which can be useful if those are slow.</p>
<pre class="brush:as3">
public static function createRandomDirKnuth():Vec2
{
	var p:Vec2;
	while (true)
	{
		const u:Number = 2 * Math.random() - 1;
		const v:Number = 2 * Math.random() - 1;
		const l:Number = u * u + v * v;
		if (l > 1 || l < EpsilonSqr) continue;
		p = new Vec2((u * u - v * v) / l, 2 * u * v / l);
		break;
	}
	return p;
}
</pre>
<p><a href="http://www.playchilla.com/wp-content/uploads/2011/09/square_neumann.jpg"><img src="http://www.playchilla.com/wp-content/uploads/2011/09/square_neumann.jpg" alt="" title="square_neumann" width="222" height="220" class="alignnone size-full wp-image-399" /></a></p>
<h4>Final note on performance</h3>
<p>The difference from the three methods is very small, today sin and cos are mostly hardware accelerated and as it turns out in my measurements this is the fastest way to do this. So perhaps I would recommend using the one with sin and cos, if not for its performance for its simplicity.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.playchilla.com/random-direction-in-2d/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

