<?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>hesselboom</title>
	<atom:link href="http://hesselboom.com/feed/" rel="self" type="application/rss+xml" />
	<link>http://hesselboom.com</link>
	<description>Just another WordPress weblog</description>
	<lastBuildDate>Fri, 05 Feb 2010 16:46:24 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.1</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Achtung die Processing</title>
		<link>http://hesselboom.com/2010/02/achtung-die-processing/</link>
		<comments>http://hesselboom.com/2010/02/achtung-die-processing/#comments</comments>
		<pubDate>Fri, 05 Feb 2010 16:40:21 +0000</pubDate>
		<dc:creator>hesselbom</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://hesselboom.com/?p=68</guid>
		<description><![CDATA[A couple of weeks ago I started looking into Processing. It&#8217;s pretty interesting because you can get visual results immediately when trying it. It&#8217;s not something I will continue to use because it&#8217;s more geared towards people new to programming (great place to start btw!) but I quickly whipped out an easy clone of the [...]]]></description>
			<content:encoded><![CDATA[<p>A couple of weeks ago I started looking into <a href="http://processing.org/">Processing</a>. It&#8217;s pretty interesting because you can get visual results immediately when trying it. It&#8217;s not something I will continue to use because it&#8217;s more geared towards people new to programming (great place to start btw!) but I quickly whipped out an easy clone of the game <a href="http://en.wikipedia.org/wiki/Achtung,_die_Kurve!">Acthung, die Kurve!</a></p>
<p>You can try it out at <a href="http://hesselboom.com/achtung/">http://hesselboom.com/achtung/</a>. This version is only for 2 players and the controls are the left and right arrow keys for one player and A and D for the second.</p>
<p>The source code for the game can be found <a href="http://hesselboom.com/achtung/achtung.pde">here</a> and the fonts used can be found <a href="http://hesselboom.com/wp-content/uploads/2010/02/achtungfonts.zip">here</a>. As you can see it&#8217;s very little code required because you don&#8217;t really have to setup much, you can immediately start drawing.</p>
<p>I handled the hit detection by storing each pixel in a 2d boolean array and each iteration check if the new position of each snake is true in the array. And if it is, that snake should <em>&#8220;die&#8221;</em> and when there is only one snake left give that snake a point. It&#8217;s not 100% perfect because once or twice it might miss a pixel because it doesn&#8217;t necessarily move 1 pixel up or down each iteration because the new position is calculated based on rotation, but it&#8217;s good enough and you rarely spot that error.</p>
]]></content:encoded>
			<wfw:commentRss>http://hesselboom.com/2010/02/achtung-die-processing/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Experimenting with simulation of hard-edged shadows</title>
		<link>http://hesselboom.com/2010/02/experimenting-with-simulation-of-hard-edged-shadows/</link>
		<comments>http://hesselboom.com/2010/02/experimenting-with-simulation-of-hard-edged-shadows/#comments</comments>
		<pubDate>Thu, 04 Feb 2010 22:31:02 +0000</pubDate>
		<dc:creator>hesselbom</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://hesselboom.com/?p=5</guid>
		<description><![CDATA[For a game I&#8217;m working on we want to have 2d shadows covering parts of the screen, like in the game Nox, to create a sense of true(ish) line-of-sight. If you&#8217;ve never played Nox it&#8217;s kind of hard to picture how the shadows work without a moving picture but here is a reference picture to get [...]]]></description>
			<content:encoded><![CDATA[<p>For a game I&#8217;m working on we want to have 2d shadows covering parts of the screen, like in the game <a href="http://en.wikipedia.org/wiki/Nox_(video_game)">Nox</a>, to create a sense of true(ish) line-of-sight. If you&#8217;ve never played Nox it&#8217;s kind of hard to picture how the shadows work without a moving picture but here is a reference picture to get a grasp.</p>
<div id="attachment_12" class="wp-caption alignnone" style="width: 510px"><a href="http://hesselboom.com/wp-content/uploads/2010/02/noxshadows.jpg"><img class="size-full wp-image-12 " title="Nox Shadows" src="http://hesselboom.com/wp-content/uploads/2010/02/noxshadows.jpg" alt="Nox Shadows" width="500" height="375" /></a><p class="wp-caption-text">Nox Shadows</p></div>
<p>Basically, it projects shadows from all walls and door, leaving open spots for windows, so the player can&#8217;t see what he&#8217;s not supposed to see. This, in my opinion, is a very cool idea because many bird-view 2d games have this problem, but let&#8217;s not get into that, it will suffice to say that this is the reason we chose to try and simulate Nox&#8217;s conveniently called &#8216;LineSight&#8217;.</p>
<p>Anyway, to try to cut to the chase, here&#8217;s how I started thinking it could be done.</p>
<p>First I create a simple wall, stored as a line segment between two points, <em>p0</em> and <em>p1</em>. Then I want to create a shadow from that wall in the opposite direction of the focused point. In my example I will use the position of the mouse for this. Normally, you&#8217;d probably want to use the position of the player for this. So I will take the <em>x</em> distance and <em>y</em> distance between both the wall&#8217;s points and the mouse, draw lines between <em>p0</em> to <em>p0&#8242;</em> and <em>p1</em> to <em>p1&#8242;</em>, and then fill it in. The code should then look something like this (I added three walls to easier visualize the results):</p>
<pre><code>class Main
{
	static function main ()
	{
		game = flash.Lib.current.graphics;
		flash.Lib.current.stage.addEventListener (flash.events.MouseEvent.MOUSE_MOVE, update);

		walls = new Array ();
		walls.push (new Wall ({ x : 120.0, y : 120.0 },
				      { x : 180.0, y : 180.0 }));
		walls.push (new Wall ({ x : 180.0, y : 180.0 },
				      { x : 240.0, y : 120.0 }));
		walls.push (new Wall ({ x : 180.0, y : 60.0 },
				      { x : 240.0, y : 120.0 }));
	}

	static function update (e)
	{
		game.clear ();
		for (w in walls) drawshadow (w, game, { x : e.stageX, y : e.stageY });
		for (w in walls) w.draw (game);
	}

	static function drawshadow (w : Wall, g : flash.display.Graphics, ref)
	{
		var xdist, ydist;
		g.beginFill (0);

		xdist = w.p0.x - ref.x;
		ydist = w.p0.y - ref.y;
		g.moveTo (w.p0.x, w.p0.y);
		g.lineTo (w.p0.x + xdist, w.p0.y + ydist);

		xdist = w.p1.x - ref.x;
		ydist = w.p1.y - ref.y;
		g.lineTo (w.p1.x + xdist, w.p1.y + ydist);
		g.lineTo (w.p1.x, w.p1.y);
	}

	static var game : flash.display.Graphics;
	static var walls : Array;
}</code></pre>
<p>And the result something like this (click to set focus and then move mouse to see updates):</p>

<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000"
			id="fm_shadowsexample_266410582"
			class="flashmovie"
			width="300"
			height="300">
	<param name="movie" value="http://hesselboom.com/wp-content/uploads/2010/02/shadowsexample.swf" />
	<!--[if !IE]>-->
	<object	type="application/x-shockwave-flash"
			data="http://hesselboom.com/wp-content/uploads/2010/02/shadowsexample.swf"
			name="fm_shadowsexample_266410582"
			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>Now, this doesn&#8217;t look like much. But how about if we multiply the distances by, say, 1000?</p>

<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000"
			id="fm_shadowsexample1000_1674280471"
			class="flashmovie"
			width="300"
			height="300">
	<param name="movie" value="http://hesselboom.com/wp-content/uploads/2010/02/shadowsexample1000.swf" />
	<!--[if !IE]>-->
	<object	type="application/x-shockwave-flash"
			data="http://hesselboom.com/wp-content/uploads/2010/02/shadowsexample1000.swf"
			name="fm_shadowsexample1000_1674280471"
			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>Now we&#8217;re talking! However, this is highly unoptimized. Drawing the edges way outside where it should be drawn? Perhaps Flash Player can optimize this and only draw what needs to be drawn, but what if we were to use some other platform? Or maybe we would want to cache the shadows as bitmaps (for God knows what reason&#8230; filters?) and we will start to notice an unnecessary slowdown.</p>
<p>So to calculate what point each shadow segment ending should be at I calculate how far <em>p0</em>&#8217;s <em>x</em> distance is from reaching it&#8217;s boundary (0 if negative, width of window if positive) in percent and then multiply both <em>x</em> distance and <em>y</em> distance with that value. Then I check if the new point is outside of the vertical boundaries (0 to height of window) and if it is, recalculate percentage with <em>y</em> distance instead. It might sound pretty naive but it works efficiently.</p>
<p>Here is that written in our previous code, with just one wall to easier visualize the difference:</p>
<pre><code>class Main
{
	static function main ()
	{
		game = flash.Lib.current.graphics;
		flash.Lib.current.stage.addEventListener (flash.events.MouseEvent.MOUSE_MOVE, update);

		walls = new Array ();
		walls.push (new Wall ({ x : 120.0, y : 120.0 },
				      { x : 180.0, y : 180.0 }));
	}

	static function update (e)
	{
		game.clear ();
		for (w in walls) drawshadow (w, game, { x : e.stageX, y : e.stageY });
		for (w in walls) w.draw (game);
	}

	static function drawshadow (w : Wall, g : flash.display.Graphics, ref)
	{
		var xdist, ydist, per : Float;
		var width = flash.Lib.current.stage.stageWidth;
		var height = flash.Lib.current.stage.stageHeight;
		g.beginFill (0);

		xdist = (ref.x - w.p0.x);
		ydist = (ref.y - w.p0.y);

		if (xdist &lt; 0)
			per = (xdist/(w.p0.x-width));
		else
			per = (xdist/(w.p0.x-0));

		if (w.p0.y - (ydist/per) &lt; 0)
 			per = (ydist/(w.p0.y-0));
 		else if (w.p0.y - (ydist/per) &gt; height)
			per = (ydist/(w.p0.y-height));

		g.moveTo (w.p0.x, w.p0.y);
		g.lineTo (w.p0.x - (xdist/per), w.p0.y - (ydist/per));

		//p2
		xdist = (ref.x - w.p1.x);
		ydist = (ref.y - w.p1.y);

		if (xdist &lt; 0)
			per = (xdist/(w.p1.x-width));
		else
			per = (xdist/(w.p1.x-0));

		if (w.p1.y - (ydist/per) &lt; 0)
 			per = (ydist/(w.p1.y-0));
 		else if (w.p1.y - (ydist/per) &gt; height)
			per = (ydist/(w.p1.y-height));

		g.lineTo (w.p1.x - (xdist/per), w.p1.y - (ydist/per));
		g.lineTo (w.p1.x, w.p1.y);
	}

	static var game : flash.display.Graphics;
	static var walls : Array;
}</code></pre>
<p>Despite my dreadful explanation of the logic, the code is not very complicated as you can see. Here is what it might output:</p>

<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000"
			id="fm_shadowsexampleupdated_1510392196"
			class="flashmovie"
			width="300"
			height="300">
	<param name="movie" value="http://hesselboom.com/wp-content/uploads/2010/02/shadowsexampleupdated.swf" />
	<!--[if !IE]>-->
	<object	type="application/x-shockwave-flash"
			data="http://hesselboom.com/wp-content/uploads/2010/02/shadowsexampleupdated.swf"
			name="fm_shadowsexampleupdated_1510392196"
			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>As you can see, the points are all hitting the boundaries. My only problem now is how to fill in the corners. I actually haven&#8217;t figured this out yet. I had an idea that because I know what boundary each segment point is hitting I could for instance fill in to the top left corner if one point was at the left boundary and one at the top. But this didn&#8217;t really go that smoothly because sometimes one point hits the top and one the bottom, or left and right etc.</p>
<p>So to sum things up, the point of this article was to first of all get this off my chest and to maybe help others by seeing how I approached this. And second of all, I&#8217;m asking for help. If anyone has an idea on how I could calculate what corner(s) to fill the shadow to or maybe some other way to do shadows I&#8217;m interested to hear what you have to say.</p>
]]></content:encoded>
			<wfw:commentRss>http://hesselboom.com/2010/02/experimenting-with-simulation-of-hard-edged-shadows/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Where has MochiAds in haXe gone?</title>
		<link>http://hesselboom.com/2010/02/where-has-mochiads-in-haxe-gone/</link>
		<comments>http://hesselboom.com/2010/02/where-has-mochiads-in-haxe-gone/#comments</comments>
		<pubDate>Thu, 04 Feb 2010 21:19:48 +0000</pubDate>
		<dc:creator>hesselbom</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://hesselboom.com/?p=47</guid>
		<description><![CDATA[If you&#8217;re looking for the post I wrote on &#8216;Using MochiAds in haXe&#8217; in my old blog it has found a new home at http://hesselboom.com/mochi/.
I won&#8217;t bother rewriting it here in the new blog because I don&#8217;t want to keep changing it&#8217;s URL so it will stay there until the next Titanic sinks.
]]></description>
			<content:encoded><![CDATA[<p>If you&#8217;re looking for the post I wrote on &#8216;Using MochiAds in haXe&#8217; in my old blog it has found a new home at <a href="http://hesselboom.com/mochi/">http://hesselboom.com/mochi/</a>.</p>
<p>I won&#8217;t bother rewriting it here in the new blog because I don&#8217;t want to keep changing it&#8217;s URL so it will stay there until the next Titanic sinks.</p>
]]></content:encoded>
			<wfw:commentRss>http://hesselboom.com/2010/02/where-has-mochiads-in-haxe-gone/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Back in style!</title>
		<link>http://hesselboom.com/2010/02/back-in-style/</link>
		<comments>http://hesselboom.com/2010/02/back-in-style/#comments</comments>
		<pubDate>Thu, 04 Feb 2010 19:10:20 +0000</pubDate>
		<dc:creator>hesselbom</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://hesselboom.com/?p=1</guid>
		<description><![CDATA[So I just recreated this blog because I felt I have some things to share and there was no real reason to close it the last time.
I also have a new design to boot! Without checking, I think it&#8217;s mostly valid CSS and XHTML and all that jazz. The only mischief is probably the &#8216;overflow-y&#8217; [...]]]></description>
			<content:encoded><![CDATA[<p>So I just recreated this blog because I felt I have some things to share and there was no real reason to close it the last time.</p>
<p>I also have a new design to boot! Without checking, I think it&#8217;s mostly valid CSS and XHTML and all that jazz. The only mischief is probably the &#8216;overflow-y&#8217; property, that I use in code blocks, but that is valid CSS3 so I guess you could say I&#8217;m actually ahead of CSS validators defaulting to 2.1!</p>
<p>So anyway, I have some thoughts I&#8217;d like to share in the future so be sure to subscribe to my feed and keep biting your nails waiting in anxiety for my next update.</p>
<p>In the meantime, be sure to check out <a href="http://ludusnovus.net/">Gregory Weir&#8217;s website</a>. I just found his website and he is suddenly one of my favorite game developers.</p>
]]></content:encoded>
			<wfw:commentRss>http://hesselboom.com/2010/02/back-in-style/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
