I hope you find it useful for learning just as I did
Download the source code on Github
This is an update of my previous post
Update: Post with the source code of the gameAfter spending a lot of time testing and searching on the web, I wasn't able to get the Tic-Tac-R game on my Windows Azure website. I tried a lot of things and can shameless say that I was totally lost, since my application was working fine on a shared hosting environment (GoDaddy) but not on my Windows Azure.
As an experiment for learning HTML5 Canvas, I created this small game based on the popular "Snake" that many of us played on our old mobile phones (A Nokia 3320 in my case)
I deployed the game one of my Windows Azure websites and you can access it here. Initially I was thinking of buying a hosting account on a different place, but I think the cloud is a good place for host this kind of pet projects and Windows Azure is a great option, (IMHO) for 2 things: 1) Is extremely easy to use (saying creating websites, databases, deploying, etc) 2) It is free for 90 days, which is great if you are starting on the cloud "wave". Let's see what happen when the cloud bills begin to come.
So then, enjoy the game online for at least the next 60 days (when my free account expires :P)
The source code is hosted on Github. Feel free to do whatever you want with it
This post is based on Robert Conner's code forCakePHP 1.x., and I made some changes to get it to work onCakePHP 2.x . The original post can be found here.Maybe some people have faced problems trying to send some content to the layout on CakePHP. By content I mean not only a simple string but a whole a piece of HTML code. To solve this, we can create a Helper on CakePHP 2.x, according to the following steps:
class LayoutHelper extends AppHelper {
var $__blockName = null;
function blockStart($name) {
if (empty($name))
trigger_error('LayoutHelper::blockStart - name is a required parameter');
if (!is_null($this->__blockName))
trigger_error('LayoutHelper::blockStart - Blocks cannot overlap');
$this->__blockName = $name;
ob_start();
return null;
}
function blockEnd(&$view){
$buffer = @ob_get_contents();
@ob_end_clean();
$out = $buffer
$view->viewVars[$this->__blockName . '_for_layout'] = $out;
$this->__blockName = null
}
function output($var) {
if (isset($var) && $var != null)
echo $var;
}
}
$layout = $this->Helpers->load('Layout');
$layout->blockStart('custom_content');
Right after this, we specify the content that will be sent to the layout
<div>Custom content</div>and we close the block
$layout->blockEnd($this);
$layout = $this->Helpers->load('Layout');
$layout->output($custom_content_for_layout);
As we can see, this is really simple and also very useful when trying to customize the content on the layout according to the view we are loading
I wrote this article also on The BakeryCodeProject
Copyright @ 2013 A learning journey.