<?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>Abhi&#039;s Weblog &#187; Online Games</title>
	<atom:link href="http://abhinavsingh.com/blog/tag/online-games/feed/" rel="self" type="application/rss+xml" />
	<link>http://abhinavsingh.com/blog</link>
	<description>PHP, Memcached, XMPP and Web Development</description>
	<lastBuildDate>Mon, 27 Feb 2012 09:12:57 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
		<item>
		<title>Toggle : A Javascript game, anyone up for the challenge?</title>
		<link>http://abhinavsingh.com/blog/2009/06/toggle-a-javascript-game-anyone-up-for-the-challenge/</link>
		<comments>http://abhinavsingh.com/blog/2009/06/toggle-a-javascript-game-anyone-up-for-the-challenge/#comments</comments>
		<pubDate>Sun, 21 Jun 2009 10:24:09 +0000</pubDate>
		<dc:creator>Abhinav Singh</dc:creator>
				<category><![CDATA[Web Development]]></category>
		<category><![CDATA[javascript]]></category>
		<category><![CDATA[Online Games]]></category>

		<guid isPermaLink="false">http://abhinavsingh.com/blog/?p=438</guid>
		<description><![CDATA[This weekend I came across a game made using java applets. Initially looked like its possible to solve it, but slowly we realized that there might be no solution to this game. Finally I decided to clone it using javascript and see if you can solve the same. Toggle PS: Tested on all browsers except [...]]]></description>
			<content:encoded><![CDATA[<div class="tweetmeme_button" style="float: right; margin-left: 10px;">
			<a href="http://api.tweetmeme.com/share?url=http%3A%2F%2Fabhinavsingh.com%2Fblog%2F2009%2F06%2Ftoggle-a-javascript-game-anyone-up-for-the-challenge%2F"><br />
				<img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Fabhinavsingh.com%2Fblog%2F2009%2F06%2Ftoggle-a-javascript-game-anyone-up-for-the-challenge%2F&amp;source=imoracle&amp;style=normal&amp;service=bit.ly&amp;service_api=R_f027b5a79a20a49b713f16282f1e0857&amp;hashtags=javascript,Online+Games&amp;b=2" height="61" width="50" /><br />
			</a>
		</div>
<p>This weekend I came across a game made using java applets. Initially looked like its possible to solve it, but slowly we realized that there might be no solution to this game. Finally I decided to clone it using javascript and see if you can solve the same.</p>
<div style="font-weight:bold; font-size:32px; color:#000000; margin-left:270px; margin-top:10px;">Toggle</div>
<div id="container" style="position:relative; height:300px; margin-top:5px; margin-left:200px;"></div>
<p><strong style="color:#AA0000">PS: Tested on all browsers except IE</strong></p>
<p><strong><u>Modes:</u></strong><br />
I included a custom mode in this game. Original game had only the classic mode.</p>
<ul>
<li><u>Classic Mode:</u> When you click a square in classic mode, that clicked square and all neighbourhood squares toggle their colors (excluding diagonal neighbours).</li>
<li><u>Custom Mode:</u> In custom mode, when you click a square, the clicked square and all neighbourhood squares toggle their colors (including diagonal neighbours).</li>
</ul>
<p><strong><u>Rules:</u></strong></p>
<ul>
<li>Destination is to fill all the squares with black color.</li>
<li>Ideally game should be played in a single mode only. However I have provided an option where you can switch modes in between the game. So you are free to either play it in a single mode throughout, or switch modes as and when you feel is the requirement</li>
<li>If you are finally able to make it, click view history, copy the steps you followed to conquer this game and post it as a comment to this blog post</li>
</ul>
<p><strong style="font-size:26px;"><u>Source Code:</u></strong><br />
The source code consists of toggle.js and toggle.css. Find below the source code, and towards the end, find how to embed the same on your page/blog.</p>
<p><strong><u>toggle.css</u></strong></p>
<pre class="css" name="code">/*

  Script: toggle.css
  Author: Abhinav Singh mailsforabhinav[at]gmail[dot]com
  Website: http://abhinavsingh.com
  Code license: GNU General Public License v3

*/
.box {
  border:1px solid #000000;
  cursor:pointer;
}
.boxColored {
  border:1px solid #FFFFFF;
  background: #000000;
  cursor:pointer;
}
</pre>
<p><strong><u>toggle.js</u></strong></p>
<pre class="javascript" name="code">/*

  Script: toggle.js
  Author: Abhinav Singh mailsforabhinav[at]gmail[dot]com
  Website: http://abhinavsingh.com
  Code license: GNU General Public License v3

*/
Array.prototype.unique = function(b) {
  var a = [], i, l = this.length;
  for(i=0; i&lt;l; i++) {
    if(a.indexOf(this[i], 0, b) &lt; 0) { a.push(this[i]); }
  }
  return a;
};
var $ = {
  html: '',
  cid: 'container',
  xBoxes: 5,
  yBoxes: 5,
  boxWidth: 50,
  boxHeight: 50,
  version: 'classic',
  history: Array(),
  init: function() {
    var tmp = '';
    for(var i=0;i&lt;this.yBoxes;i++) {
      for(var j=0;j&lt;this.xBoxes;j++) {
        tmp += '&lt;div onclick="$.toggle(this)" name="box" id="box-'+i+'-'+j+'" style="position:absolute; left:'+(j*this.boxWidth)+'px; top:'+(i*this.boxHeight)+'px; height:'+this.boxHeight+'px; width:'+this.boxWidth+'px" class="box"&gt;';
        tmp += '&lt;/div&gt;';
      }
    }
    tmp += '&lt;div style="position:absolute; top:'+((this.yBoxes*this.boxHeight)+5)+'px; left:0px;"&gt;';
    tmp += '  &lt;b style="float:left"&gt;Version:&lt;/b&gt; ';
    tmp += '  &lt;select style="float:left" id="version" onchange="$.version = this.options[this.selectedIndex].value;"&gt;';
    tmp += '    &lt;option value="classic"&gt;Classic&lt;/option&gt;';
    tmp += '    &lt;option value="custom"&gt;Custom&lt;/option&gt;';
    tmp += '  &lt;/select&gt;';
    tmp += '  &lt;div style="float:left; padding-left:20px; text-decoration:underline; cursor:pointer;" onclick="alert($.history.unique())"&gt;View History&lt;/div&gt;';
    tmp += '&lt;/div&gt;';
    document.getElementById(this.cid).innerHTML = tmp;
  },
  toggle: function(t) {
    this.history.push((t.id.toString()).replace('box-',''));
    id = t.id; ids = id.split("-");
    xid = parseInt(ids[1]); yid = parseInt(ids[2]);

    for(var l=xid-1; l&lt;=xid+1; l++) {
      for(var m=yid-1; m&lt;=yid+1; m++) {
        if(l&gt;=0 &#038;&#038; l&lt;this.xBoxes &#038;&#038; m&gt;=0 &#038;&#038; m&lt;this.yBoxes) {
          if(this.version == "classic") {
            if((l == xid-1 &#038;&#038; m == yid-1) || (l == xid+1 &#038;&#038; m == yid-1) || (l == xid-1 &#038;&#038; m == yid+1) || (l == xid+1 &#038;&#038; m == yid+1)) {

            }
            else {
              var boxid = document.getElementById('box-'+l+'-'+m);
              if(boxid.className == "box") boxid.className = "boxColored";
              else if(boxid.className == "boxColored") boxid.className = "box";
            }
          }
          if(this.version == "custom") {
            var boxid = document.getElementById('box-'+l+'-'+m);
            if(boxid.className == "box") boxid.className = "boxColored";
            else if(boxid.className == "boxColored") boxid.className = "box";
          }
        }
      }
    }
  }
}
$.init();</pre>
<p><strong><u>How to embed toggle on my page/blog?</u></strong></p>
<ul>
<li>Simply copy the js and css files from above or download them from here: <a href="http://abhinavsingh.com/toggle/toggle.js">toggle.js</a>, <a href="http://abhinavsingh.com/toggle/toggle.css">toggle.css</a></li>
<li>Include the two on your page/blog. toggle.js automatically calls up <strong>$.init()</strong> on load. $.init() method will look for a div with id <strong>$.cid</strong> on you page, and populate the game in the same div. Hence make sure you have a div with id $.cid on the page.</li>
<li><strong>$.xBoxes</strong>, <strong>$.yBoxes</strong>, <strong>$.boxWidth</strong>, <strong>$.boxHeight</strong> are a few tunable parameters you may want to play with</li>
</ul>
<link rel="stylesheet" href="http://abhinavsingh.com/webdemos/toggle/toggle.css" type="text/css"/>
<script type="text/javascript" src="http://abhinavsingh.com/webdemos/toggle/toggle.js"></script><br />
Happy Toggling!</p>
<script type="text/javascript">var wordpress_toolbar_urls = ["http:\/\/api.tweetmeme.com\/share?url=http%3A%2F%2Fabhinavsingh.com%2Fblog%2F2009%2F06%2Ftoggle-a-javascript-game-anyone-up-for-the-challenge%2F","http:\/\/abhinavsingh.com\/toggle\/toggle.js","http:\/\/abhinavsingh.com\/toggle\/toggle.css"];var wordpress_toolbar_url = "http://abhinavsingh.com/blog/wp-content/plugins/wordpress-toolbar/toolbar.php";var wordpress_toolbar_oinw = "oinw";var wordpress_toolbar_hash = "aHR0cDovL2FiaGluYXZzaW5naC5jb20vYmxvZy8yMDA5LzA2L3RvZ2dsZS1hLWphdmFzY3JpcHQtZ2FtZS1hbnlvbmUtdXAtZm9yLXRoZS1jaGFsbGVuZ2UvPHdwdGI%2BVG9nZ2xlIDogQSBKYXZhc2NyaXB0IGdhbWUsIGFueW9uZSB1cCBmb3IgdGhlIGNoYWxsZW5nZT88d3B0Yj5odHRwOi8vYWJoaW5hdnNpbmdoLmNvbS9ibG9nPHdwdGI%2BQWJoaSYjMDM5O3MgV2VibG9n";</script><ul class="related_post"><li><a href="http://abhinavsingh.com/blog/2009/08/introducing-jslider-a-content-slider-plugin-for-jquery/" title="Introducing jSlider: A Content Slider plugin for JQuery">Introducing jSlider: A Content Slider plugin for JQuery</a> (6)</li><li><a href="http://abhinavsingh.com/blog/2009/08/fixed-js-solution-to-ie6-positionfixed-bug/" title="fixed.js &#8211; Solution to IE6 &quot;position:fixed&quot; Bug">fixed.js &#8211; Solution to IE6 &quot;position:fixed&quot; Bug</a> (4)</li><li><a href="http://abhinavsingh.com/blog/2009/07/facebook-type-image-rotation-and-more-using-php-and-javascript/" title="Facebook type image rotation and more using PHP and Javascript">Facebook type image rotation and more using PHP and Javascript</a> (27)</li><li><a href="http://abhinavsingh.com/blog/2009/06/seo-analyzer-v-12-adding-support-for-bing-along-with-google-and-yahoo/" title="SEO Analyzer v 1.2 &#8211; Adding support for Bing along with Google and Yahoo">SEO Analyzer v 1.2 &#8211; Adding support for Bing along with Google and Yahoo</a> (24)</li><li><a href="http://abhinavsingh.com/blog/2009/04/getting-google-page-rank-using-javascript-for-adobe-air-apps/" title="Getting Google Page Rank using Javascript &#8211; For Adobe AIR Apps">Getting Google Page Rank using Javascript &#8211; For Adobe AIR Apps</a> (2)</li></ul>]]></content:encoded>
			<wfw:commentRss>http://abhinavsingh.com/blog/2009/06/toggle-a-javascript-game-anyone-up-for-the-challenge/feed/</wfw:commentRss>
		<slash:comments>21</slash:comments>
		</item>
		<item>
		<title>games@gtalkbots.com &#8211; Online gaming enabled on Gtalk</title>
		<link>http://abhinavsingh.com/blog/2008/11/gamesgtalkbotscom-online-gaming-enabled-on-gtalk/</link>
		<comments>http://abhinavsingh.com/blog/2008/11/gamesgtalkbotscom-online-gaming-enabled-on-gtalk/#comments</comments>
		<pubDate>Sun, 02 Nov 2008 13:42:22 +0000</pubDate>
		<dc:creator>Abhinav Singh</dc:creator>
				<category><![CDATA[XMPP]]></category>
		<category><![CDATA[Anagram]]></category>
		<category><![CDATA[Gtalk]]></category>
		<category><![CDATA[Gtalkbots]]></category>
		<category><![CDATA[Online Games]]></category>

		<guid isPermaLink="false">http://abhinavsingh.com/blog/2008/11/gamesgtalkbotscom-online-gaming-enabled-on-gtalk/</guid>
		<description><![CDATA[Anagram, many of you might be familiar with it or even played many a times back in school and colleges. Its a simple text based game, where you are given a jumbled word and you need to re-arrange it. E.g. You will be given huldos and you need to quickly identify that as should. So [...]]]></description>
			<content:encoded><![CDATA[<div class="tweetmeme_button" style="float: right; margin-left: 10px;">
			<a href="http://api.tweetmeme.com/share?url=http%3A%2F%2Fabhinavsingh.com%2Fblog%2F2008%2F11%2Fgamesgtalkbotscom-online-gaming-enabled-on-gtalk%2F"><br />
				<img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Fabhinavsingh.com%2Fblog%2F2008%2F11%2Fgamesgtalkbotscom-online-gaming-enabled-on-gtalk%2F&amp;source=imoracle&amp;style=normal&amp;service=bit.ly&amp;service_api=R_f027b5a79a20a49b713f16282f1e0857&amp;hashtags=Anagram,Gtalk,Gtalkbots,Online+Games&amp;b=2" height="61" width="50" /><br />
			</a>
		</div>
<p><span style="font-style: italic;">Anagram</span>, many of you might be familiar with it or even played many a times back in school and colleges. Its a simple text based game, where you are given a jumbled word and you need to re-arrange it. E.g. You will be given <span style="font-style: italic;">huldos</span> and you need to quickly identify that as <span style="font-style: italic;">should</span>.</p>
<p>So getting bored back in college or office, add <span style="font-weight: bold;">games@gtalkbots.com</span> and type <span style="font-weight: bold;">anagram</span> to start gaming. Play and score well. Your score will turn up on the Gtalkbots front page. They have kept this game open for the world i.e. one can play this game even without registering at Gtalkbots.</p>
<p>A few important points:</p>
<ol>
<li>Add <span style="font-weight: bold;">games@gtalkbots.com</span> as your friend in Gtalk Messenger.</li>
<li>Type <span style="font-weight: bold;">rules</span> to read them before you start gaming.<br />
<img src="http://1.bp.blogspot.com/_DRGeZF9Zbaw/SQo-zF5MZAI/AAAAAAAAALM/HAhuYryYs4k/s400/rules.bmp" style="border: 1px solid rgb(68, 68, 68); padding: 2px;" /></li>
<li>Type <span style="font-weight: bold;">anagram</span> to start gaming.</li>
<li>You will be given a jumbled word which you needs to rearrange and reply back.</li>
<li>If your answer is correct you get <span style="font-weight: bold;">10 Points</span>.</li>
<li>If your answer is not correct and you are finding it tough to solve it, Type <span style="font-weight: bold;">hint</span> to get a clue, and a clue will be sent to all users playing the game.<br />
<img src="http://1.bp.blogspot.com/_DRGeZF9Zbaw/SQpAOVdf6yI/AAAAAAAAALU/YoGCjXnrgH4/s400/anagram.bmp" style="border: 1px solid rgb(68, 68, 68); padding: 2px;" /></li>
<li><span style="font-weight: bold; color: rgb(255, 0, 0);">DO NOT FORGET</span> to type <span style="font-weight: bold;">exit</span> when you are finished gaming. If you forget to do so, you will be considered as a part of next round being played and eventually your average score decreases.</li>
<li>If total number of <span style="font-weight: bold;">wrong answers = 5 (including all users)</span>, the bot will automatically reply back with correct answer and moves to the next word.</li>
</ol>
<p>So try out and enjoy.</p>
<script type="text/javascript">var wordpress_toolbar_urls = ["http:\/\/api.tweetmeme.com\/share?url=http%3A%2F%2Fabhinavsingh.com%2Fblog%2F2008%2F11%2Fgamesgtalkbotscom-online-gaming-enabled-on-gtalk%2F"];var wordpress_toolbar_url = "http://abhinavsingh.com/blog/wp-content/plugins/wordpress-toolbar/toolbar.php";var wordpress_toolbar_oinw = "oinw";var wordpress_toolbar_hash = "aHR0cDovL2FiaGluYXZzaW5naC5jb20vYmxvZy8yMDA4LzExL2dhbWVzZ3RhbGtib3RzY29tLW9ubGluZS1nYW1pbmctZW5hYmxlZC1vbi1ndGFsay88d3B0Yj5nYW1lc0BndGFsa2JvdHMuY29tICYjODIxMTsgT25saW5lIGdhbWluZyBlbmFibGVkIG9uIEd0YWxrPHdwdGI%2BaHR0cDovL2FiaGluYXZzaW5naC5jb20vYmxvZzx3cHRiPkFiaGkmIzAzOTtzIFdlYmxvZw%3D%3D";</script><ul class="related_post"><li><a href="http://abhinavsingh.com/blog/2009/05/how-to-broadcast-a-message-to-your-gtalk-friends-using-jaxl/" title="How to broadcast a message to your Gtalk friends using JAXL?">How to broadcast a message to your Gtalk friends using JAXL?</a> (13)</li><li><a href="http://abhinavsingh.com/blog/2009/01/how-to-get-dzone-feeds-as-im-using-jaxl-add-dzonegtalkbotscom/" title="How to get dzone feeds as IM using JAXL? Add dzone@gtalkbots.com">How to get dzone feeds as IM using JAXL? Add dzone@gtalkbots.com</a> (8)</li><li><a href="http://abhinavsingh.com/blog/2009/01/introducing-jaxl-open-source-jabber-xmpp-library/" title="Introducing JAXL &#8211; Open Source Jabber XMPP Library">Introducing JAXL &#8211; Open Source Jabber XMPP Library</a> (93)</li><li><a href="http://abhinavsingh.com/blog/2008/09/save-your-and-your-friends-status-messages-share-and-promote-your-website-through-your-status/" title="Save your and your friend&#039;s status messages. Share and promote your website through your status">Save your and your friend&#039;s status messages. Share and promote your website through your status</a> (1)</li><li><a href="http://abhinavsingh.com/blog/2008/09/gtalk-status-message-collector/" title="GTalk Status Message Collector">GTalk Status Message Collector</a> (3)</li></ul>]]></content:encoded>
			<wfw:commentRss>http://abhinavsingh.com/blog/2008/11/gamesgtalkbotscom-online-gaming-enabled-on-gtalk/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
	</channel>
</rss>

