<?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>Cameron McKay &#187; Wezzle</title>
	<atom:link href="http://cdmckay.org/blog/category/wezzle/feed/" rel="self" type="application/rss+xml" />
	<link>http://cdmckay.org/blog</link>
	<description>Programming, Politics and Game Design</description>
	<lastBuildDate>Tue, 24 Aug 2010 13:57:53 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>A little bit about Webble and JavaScript games</title>
		<link>http://cdmckay.org/blog/2010/05/19/a-little-bit-about-webble-and-javascript-games/</link>
		<comments>http://cdmckay.org/blog/2010/05/19/a-little-bit-about-webble-and-javascript-games/#comments</comments>
		<pubDate>Wed, 19 May 2010 21:37:48 +0000</pubDate>
		<dc:creator>cdmckay</dc:creator>
				<category><![CDATA[JavaScript]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[Web Development]]></category>
		<category><![CDATA[Wezzle]]></category>
		<category><![CDATA[Wezzle Development]]></category>

		<guid isPermaLink="false">http://cdmckay.org/blog/?p=1535</guid>
		<description><![CDATA[Webble is a pure HTML/CSS/JavaScript implementation of some of the core features Wezzle game engine.  By &#8220;pure&#8221; I mean that there are no external plugins like Flash used.  Furthermore, Webble does not make use of the HTML5 canvas element: all the animation is done purely by moving around HTML elements using JavaScript.
Writing a [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://couchware.ca/webble">Webble</a> is a pure HTML/CSS/JavaScript implementation of some of the core features <a href="http://couchware.ca/www/wezzle">Wezzle game engine</a>.  By &#8220;pure&#8221; I mean that there are no external plugins like Flash used.  Furthermore, Webble does not make use of the HTML5 canvas element: all the animation is done purely by moving around HTML elements using JavaScript.</p>
<p>Writing a simple game engine using the DOM and JavaScript poses some interesting problems that are atypical to regular website development.  In this article I will discuss a few of the problems that I encountered while writing Webble and how I solved them.</p>
<p><span id="more-1535"></span></p>
<h3>Tracking Mouse Movement</h3>
<p>In Wezzle, there is a selector that follows around the mouse cursor.  This was fairly easy to implement in Java, as having a mouse movement listener isn&#8217;t too costly.  In JavaScript, however, listening to the <code>mousemove</code> event is very expensive.  In fact, listening to <code>mousemove</code> slows down the browser window so much that JavaScript animations become unusable.  This is fine if your game does not animate while you listen to mouse movements.  Unfortunately, with Webble, this was not the case.  I needed to be able to follow the cursor at all times.</p>
<p>What was the solution? Webble has a 8&#215;10 grid called the &#8220;board&#8221; (see image below).  Each board cell can contain a tile. Overlayed on that board is a selector centered on whatever board cell the mouse cursor is on. Thus, Webble only needs to know when the mouse moves over a new board cell. This means that instead of using the <code>mousemove</code> event, I could instead use an invisible 8&#215;10 grid of divs and listen for their less expensive <code>mouseover</code> event.  This solution ended up working extremely well, allowing me to easily keep track of the mouse while simultaneously running animations.</p>
<p><img class="aligncenter size-full wp-image-1557" title="The We*le Board" src="http://cdmckay.org/blog/wp-content/blogs.dir/2/files/2010/05/board.png" alt="" width="256" height="320" /></p>
<h3>Animation</h3>
<p>Animation in Webble was quite painless, thanks to jQuery. For most animations, it was as easy as setting the correct parameters for the <a href="http://api.jquery.com/animate/">animate function</a>. In particular, there were some situations were I needed animations to run in lockstep.  In Webble, when you get a line, all the tiles in that line must animated away together.  Thus, doing something like this&#8230;</p>

<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:Consolas, monospace;"><span style="color: #006600; font-style: italic;">// Gets all the line tiles on the board.</span>
<span style="color: #003366; font-weight: bold;">var</span> tiles <span style="color: #339933;">=</span> board.<span style="color: #660066;">findLineTiles</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #006600; font-style: italic;">// Get all the underlying DOM elements.</span>
<span style="color: #003366; font-weight: bold;">var</span> elements <span style="color: #339933;">=</span> $<span style="color: #009900;">&#40;</span>tiles.<span style="color: #660066;">map</span><span style="color: #009900;">&#40;</span><span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span>tile<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span> 
    <span style="color: #000066; font-weight: bold;">return</span> tile.<span style="color: #660066;">element</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#91;</span><span style="color: #CC0000;">0</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span> 
<span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #006600; font-style: italic;">// Fade out the elements.</span>
tiles.<span style="color: #660066;">fadeOut</span><span style="color: #009900;">&#40;</span><span style="color: #CC0000;">500</span><span style="color: #339933;">,</span> <span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
    <span style="color: #006600; font-style: italic;">// Remove tiles from internal board structure.</span>
<span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></div></div>

<p>&#8230;would not work very well and would be inefficient. Why? Because if I had, say, 10 tiles to animate, jQuery would create 10 tile animations.  This wasteful.  Moreover, since they&#8217;re independent animations, there&#8217;s no guarantee they will be moving the same amount each animation step. This visual disparity is exacerbated when the JS engine lags.</p>
<p>Fortunately, the jQuery animate function provides <a href="http://cdmckay.org/blog/2010/03/01/the-jquery-animate-step-callback-function/">a convenient step callback function</a> that allows you to animate many elements in lockstep. As a result, the code above can become a single animation that looks like this:</p>

<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:Consolas, monospace;"><span style="color: #006600; font-style: italic;">// The elements to animate in lockstop.</span>
<span style="color: #003366; font-weight: bold;">var</span> elements <span style="color: #339933;">=</span> <span style="color: #009900;">&#40;</span> ... <span style="color: #660066;">same</span> <span style="color: #000066; font-weight: bold;">as</span> above ... <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #003366; font-weight: bold;">var</span> elementsTail <span style="color: #339933;">=</span> elements.<span style="color: #660066;">slice</span><span style="color: #009900;">&#40;</span><span style="color: #CC0000;">1</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
elements
    .<span style="color: #660066;">eq</span><span style="color: #009900;">&#40;</span><span style="color: #CC0000;">0</span><span style="color: #009900;">&#41;</span>
    .<span style="color: #660066;">animate</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#123;</span>opacity<span style="color: #339933;">:</span> <span style="color: #CC0000;">0</span><span style="color: #009900;">&#125;</span><span style="color: #339933;">,</span> <span style="color: #009900;">&#123;</span>
        duration<span style="color: #339933;">:</span> <span style="color: #CC0000;">500</span><span style="color: #339933;">,</span>
        step<span style="color: #339933;">:</span> <span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span>now<span style="color: #339933;">,</span> fx<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
            elementsTail.<span style="color: #660066;">css</span><span style="color: #009900;">&#40;</span>fx.<span style="color: #660066;">prop</span><span style="color: #339933;">,</span> fx.<span style="color: #660066;">now</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        <span style="color: #009900;">&#125;</span><span style="color: #339933;">,</span>
        complete<span style="color: #339933;">:</span> <span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
            <span style="color: #006600; font-style: italic;">// Remove tiles from internal board structure.</span>
        <span style="color: #009900;">&#125;</span>
    <span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></div></div>

<h3>Audio</h3>
<p>The Wezzle game has several sound effects that need to play at specifc times (i.e. when a tile is inserted, when a line is removed, etc.).  Webble features some experimental sound support via the HTML5 audio element.  Unfortunately, like HTML5 video, not everyone can agree on a format.  Firefox supports Vorbis.  Safari (and Safari Mobile) supports MP3.  Chrome supports both.  IE supports none (until IE9, in the distant, distant future).  Thus, in order to support sounds across all modern browsers I needed to make both Vorbis and MP3 versions of all the sound effects.  This is a minor inconvenience that could have been avoided if Apple just played nice and included Vorbis support, at the very least on desktop Safari.</p>
<p>Other than that issue, HTML5 audio is pretty nice to work with.  All it takes to play a sound is:</p>

<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:Consolas, monospace;"><span style="color: #003366; font-weight: bold;">var</span> lineSound <span style="color: #339933;">=</span> <span style="color: #003366; font-weight: bold;">new</span> Audio<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;sounds/line.ogg&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
lineSound.<span style="color: #660066;">play</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></div></div>

<p>This is a cinche compared to the hoops that need to be jumped through to get decent sound in Java.  Although HTML5 audio still has a little bit further to go, I think it has a happy future in HTML5.</p>
<h3>Conclusion</h3>
<p>Writing games purely in HTML, CSS and JavaScript is easier than it ever has been thanks to wonderful libraries like jQuery and next generation technologies like HTML5.  Although clever hacks are still required to make everything work together across browsers, I firmly believe that HTML/CSS/JavaScript combo will be a viable browser game platform in the near future.</p>
]]></content:encoded>
			<wfw:commentRss>http://cdmckay.org/blog/2010/05/19/a-little-bit-about-webble-and-javascript-games/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Wezzle price drop</title>
		<link>http://cdmckay.org/blog/2010/03/27/wezzle-price-drop/</link>
		<comments>http://cdmckay.org/blog/2010/03/27/wezzle-price-drop/#comments</comments>
		<pubDate>Sun, 28 Mar 2010 02:49:13 +0000</pubDate>
		<dc:creator>cdmckay</dc:creator>
				<category><![CDATA[Gaming]]></category>
		<category><![CDATA[Wezzle]]></category>

		<guid isPermaLink="false">http://cdmckay.org/blog/?p=1218</guid>
		<description><![CDATA[As some of you may know, I&#8217;m a co-founder of the indie games company Couchware Inc.  About a month ago, we released Wezzle, our first title.  A few days ago we released a free web version of the game called Wezzle for Web (which you should try out!  ).
As if there wasn&#8217;t [...]]]></description>
			<content:encoded><![CDATA[<p>As some of you may know, I&#8217;m a co-founder of the <a href="http://couchware.ca/www">indie games company Couchware Inc</a>.  About a month ago, we released <a href="http://couchware.ca/www/blog/2010/02/05/wezzle-now-for-sale/">Wezzle, our first title</a>.  A few days ago we released <a href="http://couchware.ca/www/wezzle/web">a free web version of the game called Wezzle for Web</a> (which you should try out! <img src='http://cdmckay.org/blog/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> ).</p>
<p>As if there wasn&#8217;t already enough Wezzle awesomeness going around, we just reduced the price of the game to $4.99 (from $14.99).  So, if you haven&#8217;t yet grabbed a copy of Wezzle, I highly recommend <a href="http://couchware.ca/www/wezzle/buy">you do it now</a>.</p>
<p>For those of you <a href="http://couchware.ca/www/wezzle">unfamiliar with Wezzle</a>, it&#8217;s a casual puzzler that features four unique items, 3 difficulty modes, 10 original songs and eye-poppingly colourful graphics.</p>
<p><a href="http://cdmckay.org/blog/wp-content/blogs.dir/2/files/2010/03/tutorial-800.jpg"><img src="http://cdmckay.org/blog/wp-content/blogs.dir/2/files/2010/03/tutorial-800-150x150.jpg" alt="" title="tutorial-800" width="150" height="150" class="alignleft size-thumbnail wp-image-1224" /></a> <a href="http://cdmckay.org/blog/wp-content/blogs.dir/2/files/2010/03/star-800.jpg"><img src="http://cdmckay.org/blog/wp-content/blogs.dir/2/files/2010/03/star-800-150x150.jpg" alt="" title="star-800" width="150" height="150" class="alignleft size-thumbnail wp-image-1223" /></a> <a href="http://cdmckay.org/blog/wp-content/blogs.dir/2/files/2010/03/rocket-800.jpg"><img src="http://cdmckay.org/blog/wp-content/blogs.dir/2/files/2010/03/rocket-800-150x150.jpg" alt="" title="rocket-800" width="150" height="150" class="alignleft size-thumbnail wp-image-1222" /></a> </p>
<div style="clear: both;"></div>
]]></content:encoded>
			<wfw:commentRss>http://cdmckay.org/blog/2010/03/27/wezzle-price-drop/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Wezzle Beta 1 Screenshots</title>
		<link>http://cdmckay.org/blog/2009/08/10/wezzle-beta-1-screenshots/</link>
		<comments>http://cdmckay.org/blog/2009/08/10/wezzle-beta-1-screenshots/#comments</comments>
		<pubDate>Tue, 11 Aug 2009 04:53:27 +0000</pubDate>
		<dc:creator>cdmckay</dc:creator>
				<category><![CDATA[Wezzle]]></category>
		<category><![CDATA[Wezzle Development]]></category>
		<category><![CDATA[bomb]]></category>
		<category><![CDATA[screenshots]]></category>

		<guid isPermaLink="false">http://couchware.ca/blogs/cam/?p=876</guid>
		<description><![CDATA[Here are some Wezzle screenshots from the latest beta.
 
]]></description>
			<content:encoded><![CDATA[<p>Here are some Wezzle screenshots from the latest beta.</p>
<p><a href="http://cdmckay.org/blog/wp-content/blogs.dir/2/files/2009/12/bomb.png"><img class="alignnone size-thumbnail wp-image-1096" title="A bomb exploding in Wezzle" src="http://cdmckay.org/blog/wp-content/blogs.dir/2/files/2009/12/bomb-150x150.png" alt="" width="150" height="150" /></a> <a href="http://cdmckay.org/blog/wp-content/blogs.dir/2/files/2009/12/menu.png"><img class="alignnone size-thumbnail wp-image-1097" title="The Wezzle Play Now menu" src="http://cdmckay.org/blog/wp-content/blogs.dir/2/files/2009/12/menu-150x150.png" alt="" width="150" height="150" /></a></p>
]]></content:encoded>
			<wfw:commentRss>http://cdmckay.org/blog/2009/08/10/wezzle-beta-1-screenshots/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Wezzle</title>
		<link>http://cdmckay.org/blog/2009/01/26/wezzle/</link>
		<comments>http://cdmckay.org/blog/2009/01/26/wezzle/#comments</comments>
		<pubDate>Mon, 26 Jan 2009 18:00:52 +0000</pubDate>
		<dc:creator>cdmckay</dc:creator>
				<category><![CDATA[Wezzle]]></category>

		<guid isPermaLink="false">http://couchware.ca/blogs/cam/?p=10</guid>
		<description><![CDATA[So you&#8217;re probably wondering what&#8217;s up with Wezzle?
Since Test6, we&#8217;ve added quite a bit of stuff and are moving quickly towards a release.  However, a lot remains to be done.  Here&#8217;s some of the new stuff we&#8217;ve added since Test6:

An updated Play Now menu that has a look consistent across all menues.
An achievements browser, that [...]]]></description>
			<content:encoded><![CDATA[<p>So you&#8217;re probably wondering what&#8217;s up with Wezzle?</p>
<p>Since Test6, we&#8217;ve added quite a bit of stuff and are moving quickly towards a release.  However, a lot remains to be done.  Here&#8217;s some of the new stuff we&#8217;ve added since Test6:</p>
<ul>
<li>An updated Play Now menu that has a look consistent across all menues.</li>
<li>An achievements browser, that allows you to scroll through all achievements in the game and to see which ones you have done, and when.</li>
<li>An in-game achievement notification.  In fact, we&#8217;ve added a general notification system that will give you tips and other information as the game progresses (these can be turned off, of course).</li>
<li>Improved line sounds.  As you get more and more line chains, the line sound increases by a semi-tone.  It&#8217;s quite exciting.</li>
<li>An improved tile dropping algorithm.  You now get fewer random drop-in lines, so that the game no longer feels like it plays itself.</li>
<li>An improved, peripheral timer.  When you get up to level 10 like the big boys, you need to have a better idea of how much time you have.  Our new timer does just that.</li>
</ul>
<p>Those are just the things I can think of.  There&#8217;s been numerous small bugfixes and graphical updates that would be too tedious to list here.</p>
<p>Since we&#8217;ve added some many new things, it&#8217;s almost time to make a new release.  Beta testers should expect the release of Test7 in the next couple weeks.  If you are not a beta tester, and would like to participate in testing Wezzle, contect us <a href="mailto:dev@couchware.ca">here</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://cdmckay.org/blog/2009/01/26/wezzle/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
