<?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>Building Browsergames &#187; javascript</title>
	<atom:link href="http://buildingbrowsergames.com/category/code/javascript/feed/" rel="self" type="application/rss+xml" />
	<link>http://buildingbrowsergames.com</link>
	<description>Ever wanted to build a browsergame?</description>
	<lastBuildDate>Mon, 29 Mar 2010 14:00:39 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.8.5</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Save bandwidth while improving performance!</title>
		<link>http://buildingbrowsergames.com/2009/02/13/save-bandwidth-while-improving-performance/</link>
		<comments>http://buildingbrowsergames.com/2009/02/13/save-bandwidth-while-improving-performance/#comments</comments>
		<pubDate>Fri, 13 Feb 2009 14:00:32 +0000</pubDate>
		<dc:creator>donbonifacio</dc:creator>
				<category><![CDATA[code]]></category>
		<category><![CDATA[hosting]]></category>
		<category><![CDATA[javascript]]></category>
		<category><![CDATA[server]]></category>
		<category><![CDATA[setup]]></category>
		<category><![CDATA[site]]></category>

		<guid isPermaLink="false">http://buildingbrowsergames.com/?p=737</guid>
		<description><![CDATA[Bandwidth can be very troublesome, especially if you&#8217;re at a limited hosting solution, with only a small amount of gigabytes to serve per month. If your site uses a substantial quantity of images and scripts, you may find yourself having a big problem.
Lets imagine that a new user goes to your site and he/she will [...]]]></description>
			<content:encoded><![CDATA[<p>Bandwidth can be very troublesome, especially if you&#8217;re at a limited hosting solution, with only a small amount of gigabytes to serve per month. If your site uses a substantial quantity of images and scripts, you may find yourself having a big problem.</p>
<p>Lets imagine that a new user goes to your site and he/she will need to download 100kb of scripts and images, plus the XHTML page. If you have 50.000 requests, you&#8217;ll serve a significant quantity of bandwidth. And you may even serve static content to old users if you don&#8217;t configure correctly your static content headers.</p>
<h3>Step 1 &#8211; Decouple the static content from the dynamic content</h3>
<p>First you need to prepare your game to be able to get your images/scripts from anywhere. Instead of linking like:</p>
<pre>&lt;img src="/Images/Sample.png" /&gt;</pre>
<p>You need to code your application to link like:</p>
<pre>&lt;img src="http://some_host/Images/Sample.png" /&gt;</pre>
<p>And have the <strong>http://some_host</strong> easily configurable somewhere. That way you&#8217;ll be able to change the location of your static content and make use of <em>content distribution networks</em>. This can be a complex task if you leave it to the end, so you should start as soon as possible using this strategy. Note that this way you may still use your main server URL for static content.</p>
<h3>Step 2 &#8211; Use a Content Distribution Network</h3>
<p>Now that you have a configurable static content location, you have several options to consider. For example, if your game is open source, you may create an account at <a href="http://sf.net">SourceForge.net</a> and then you&#8217;ll have your own web space to use. You could then configure your game to use as a location for static content something like:</p>
<pre>http://your_game_name.sourceforge.net</pre>
<p>And that&#8217;s it! You&#8217;d save a lot of bandwidth and server load just by changing some configuration. But having an open source game isn&#8217;t always an option. Fortunately, there&#8217;s a free content distribution network named <a href="http://www.coralcdn.org/">Coral CDN</a> that is very easy to use. Imagine that your game is at the <em>http://your_game_name.com</em> url and that you configured your static content location to <strong>http://your_game_name.com</strong>. To use Coral CDN you&#8217;d have just to change the static location to:</p>
<pre>http://your_game_name.com.nyud.net</pre>
<p>Appending the <em>&#8220;.nyud.net&#8221;</em> will make Coral to automatically act as a proxy to your content and cache it. For example, you can try it at this site: <a href="http://buildingbrowsergames.com.nyud.net/">buildingbrowsergames.com.nyud.net</a>.</p>
<p>There are other CDN solutions out there, some will cost more money and will be better. A great advantage of CDNs is that they have servers all over the world and will sync your data all over them. So, if your server is in England but you have a user from Japan, the CDN will serve the static content from the nearest server, and your user won&#8217;t need to fetch content from the other part of the world.</p>
<h3>Step 3 &#8211; Configure Static Content Headers</h3>
<p>So, by now you don&#8217;t have to worry about bandwidth, because you&#8217;ll have a third party serving it for you. But there&#8217;s something more you can do to improve user experience. When a browser requests content it may cache it according to the server configuration. But if you don&#8217;t configure the server properly, the browser may ask for the same static file over and over again.</p>
<p>This won&#8217;t be costly for you, but for the user experience. If a user makes a request to your game and the browser has everything cached, the request will be almost instantaneous! However, if the browser needs to refresh data, it may ask for the static content again, and that may implicate that your user will have to wait a second and see loading images.</p>
<h3>Resources</h3>
<p>This article is just an introduction to make you aware of static content problems and how to solve them. To learn more about client side performance, you can study the <a href="http://developer.yahoo.com/performance/rules.html">Yahoo&#8217;s Best Practices for Speeding Up Your Web Site</a>. They have a lot of useful tips, and if you use Firefox, you may install <a href="http://developer.yahoo.com/yslow/">YSlow</a>, an extension that will rate your site in terms of client side performance.</p>
<p>Another great tool to use is something like <a href="http://www.fiddlertool.com/fiddler/">Fiddler</a>, that allows you to see all requests made by the browser, headers, and so on. By using it you&#8217;ll see where you can improve.</p>
]]></content:encoded>
			<wfw:commentRss>http://buildingbrowsergames.com/2009/02/13/save-bandwidth-while-improving-performance/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>Diary a Browsergame: building prototypes</title>
		<link>http://buildingbrowsergames.com/2008/08/01/diary-a-browsergame-building-prototypes/</link>
		<comments>http://buildingbrowsergames.com/2008/08/01/diary-a-browsergame-building-prototypes/#comments</comments>
		<pubDate>Fri, 01 Aug 2008 14:00:38 +0000</pubDate>
		<dc:creator>Luke</dc:creator>
				<category><![CDATA[code]]></category>
		<category><![CDATA[diaryofabrowsergame]]></category>
		<category><![CDATA[javascript]]></category>

		<guid isPermaLink="false">http://buildingbrowsergames.com/?p=130</guid>
		<description><![CDATA[As discussed in Working Title&#8217;s design document, we are going to be using Ajax to dynamically update the screen. Ideally, it will look as if a user has entered an IRC chat-room &#8211; except instead of chatting, they&#8217;ll be playing a game.
I always like to prototype my projects before I start them &#8211; I start [...]]]></description>
			<content:encoded><![CDATA[<p>As discussed in <a href='http://buildingbrowsergames.com/workingtitle/design/1.0.html'>Working Title&#8217;s design document</a>, we are going to be using Ajax to dynamically update the screen. Ideally, it will look as if a user has entered an IRC chat-room &#8211; except instead of chatting, they&#8217;ll be playing a game.</p>
<p>I always like to prototype my projects before I start them &#8211; I start with the template, and then start building quick mockups of functionality I plan to have. Usually, the code that I used to build my prototype can be cleaned up and used to build whatever I&#8217;m building anyways, so I&#8217;m still writing code towards my goal &#8211; with the benefit of having something to show for it a little faster.</p>
<p>With that in mind, I set out to build a simple tester page that shows off some of the Javascript that will be behind Working Title&#8217;s &#8216;play&#8217; page &#8211; while it doesn&#8217;t do any posting back, it demonstrates what the functionality is supposed to look and feel like(albeit a little faster than it would be in the actual game). Here&#8217;s the <a href='http://buildingbrowsergames.com/workingtitle/design/test.html'>Working Title test page</a>, which will let you see how I&#8217;m planning on having the game behave.</p>
]]></content:encoded>
			<wfw:commentRss>http://buildingbrowsergames.com/2008/08/01/diary-a-browsergame-building-prototypes/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Cool Stuff: javascript 3d starmap prototype</title>
		<link>http://buildingbrowsergames.com/2008/07/28/cool-stuff-javascript-3d-starmap-prototype/</link>
		<comments>http://buildingbrowsergames.com/2008/07/28/cool-stuff-javascript-3d-starmap-prototype/#comments</comments>
		<pubDate>Mon, 28 Jul 2008 14:00:43 +0000</pubDate>
		<dc:creator>Luke</dc:creator>
				<category><![CDATA[code]]></category>
		<category><![CDATA[javascript]]></category>

		<guid isPermaLink="false">http://buildingbrowsergames.com/?p=105</guid>
		<description><![CDATA[As you&#8217;re building your own browsergame, you will stumble across a variety of technologies and approaches that you can use to set your game apart. Some creators use Javascript to achieve this through enhanced interfaces, and others build interesting gameplay mechanics.
One interesting element that has recently come into play in the realm of Javascript is [...]]]></description>
			<content:encoded><![CDATA[<p>As you&#8217;re building your own browsergame, you will stumble across a variety of technologies and approaches that you can use to set your game apart. Some creators use Javascript to achieve this through enhanced interfaces, and others build interesting gameplay mechanics.</p>
<p>One interesting element that has recently come into play in the realm of Javascript is the <em>canvas</em> element &#8211; it allows a user to draw whatever they want to inside of it, using nothing but Javascript. The <em>canvas</em> element is still in it&#8217;s infancy at the moment &#8211; and therefore, not supported 100% across every browser. However, that doesn&#8217;t mean that you can&#8217;t do cool things with it(and Firefox 3 supports it, so there&#8217;s no reason not to encourage your users to upgrade).</p>
<p><a href='http://www.soa-world.de/echelon/'>Sebastian Schaetz</a>, a Building Browsergames reader, has recently created something using the <em>canvas</em> element that I thought was pretty cool: a 3D starmap prototype.</p>
<p>You can take a look at the prototype itself <a href='http://www.soa-world.de/dev/release4/index.html'>here</a>, and read Sebastian&#8217;s blog post about it <a href='http://www.soa-world.de/echelon/2008/07/fourth-prototype.html'>here</a>. It&#8217;s important to note that the code to create the starmap is open source, under an MIT license &#8211; which means that as long as you preserve the licensing information, you are free to do whatever you want to with the code.</p>
<p>Now, if you&#8217;re building a browsergame based around the mafia or a medieval-styled RPG, this might not be all that useful to you &#8211; but if you&#8217;re planning on building a game that&#8217;s space-oriented, you might want to keep this in mind.</p>
<p class='blurb'>
Hey, have you built something cool that you think other browsergame creators could benefit from? Send me an e-mail about it at <a href='mailto:buildingbrowsergames@gmail.com'>buildingbrowsergames@gmail.com</a>!</p>
]]></content:encoded>
			<wfw:commentRss>http://buildingbrowsergames.com/2008/07/28/cool-stuff-javascript-3d-starmap-prototype/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Making your forms auto-focus</title>
		<link>http://buildingbrowsergames.com/2008/05/20/making-your-forms-auto-focus/</link>
		<comments>http://buildingbrowsergames.com/2008/05/20/making-your-forms-auto-focus/#comments</comments>
		<pubDate>Tue, 20 May 2008 14:00:57 +0000</pubDate>
		<dc:creator>Luke</dc:creator>
				<category><![CDATA[code]]></category>
		<category><![CDATA[design]]></category>
		<category><![CDATA[javascript]]></category>
		<category><![CDATA[usability]]></category>

		<guid isPermaLink="false">http://buildingbrowsergames.com/?p=37</guid>
		<description><![CDATA[One of the small, hard to notice features that I&#8217;ve encountered on a few games and grown to love is that of the auto-focusing form field. When you go to login or register, as long as your web browser has Javascript enabled, you&#8217;ll automatically be able to type into the first textbox that you need [...]]]></description>
			<content:encoded><![CDATA[<p>One of the small, hard to notice features that I&#8217;ve encountered on a few games and grown to love is that of the auto-focusing form field. When you go to login or register, as long as your web browser has Javascript enabled, you&#8217;ll automatically be able to type into the first textbox that you need to &#8211; which makes signing up or logging in much easier.</p>
<p>It&#8217;s actually a very simple feature to add &#8211; all you need is three lines of Javascript:</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
</pre></td><td class="code"><pre class="javascript" style="font-family:monospace;">window.<span style="color: #000066;">onload</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>
	document.<span style="color: #660066;">getElementById</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'username'</span><span style="color: #009900;">&#41;</span>.<span style="color: #000066;">focus</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>	
<span style="color: #009900;">&#125;</span></pre></td></tr></table></div>

<p>The HTML you need to use looks like this:</p>

<div class="wp_syntax"><div class="code"><pre class="html" style="font-family:monospace;">&lt;input type='text' id='username' /&gt;</pre></div></div>

<p>And as long as you have both of those pieces, whenever a user visits the page the username input box will automatically get focused into. It&#8217;s a small and easy change to implement, and it makes a huge difference to how easy it is to use your game&#8217;s forms. For example, visit <a href='http://www.urbandead.com/'>Urban Dead</a> and <a href='http://www.kingdomofloathing.com/'>Kingdom of Loathing</a> and start typing the moment the page loads up &#8211; as you can see, on Kingdom of Loathing you&#8217;ve been focused into the text box, and can therefore just start typing to log in. On Urban Dead, you need to find the textbox, and then move your mouse over to it and click on it. It&#8217;s just not quite as nice and easy as having the field auto-selected for you.</p>
]]></content:encoded>
			<wfw:commentRss>http://buildingbrowsergames.com/2008/05/20/making-your-forms-auto-focus/feed/</wfw:commentRss>
		<slash:comments>10</slash:comments>
		</item>
	</channel>
</rss>

