Charity, Thoughts

What’s my biggest achievement?

The proudest moment of my life, by far, is Adventure Ashram Children Education Fundraisingwhen my good friends Solomon and Fritha told me that some of the children we initially sponsored to attend school (they were no taller than wheel of the bus they rode on) are now going to university! No matter how many cloud services, startups, or mobile apps I launch, this will forever remain my biggest achievement.

For those who don’t know him, Solomon runs the Grace Charitable Trust, and with his tireless work is changing the life, and prospects of the children of the Mudumalai Tiger Reserve in Tamil Nadu by giving them the education they deserve.

Fritha runs Adventure Ashram, a charity in the UK that is fundraising for Solomon among many other projects.

It took a few years of painstaking work dealing with Indian bureaucracy, but Solomon has finally received the official approval for Grace Charitable Trust to receive money from donors abroad. Now that this approval is in the bag, it is time to start planning long term for the future of this project and the children it supports.

Thank you Solomon, Adventure Ashram, Fritha, and all involved!

Games, My Works

Unity3d UI – keep your code organized

Unity UI Demo Screenshot

With the release of Unity 4.6 a whole new set of UI tools are now available. Before we used to write code in the OnGUI method of MonoBehaviour objects, we now edit the UI directly in the Unity Editor with new objects like Canvas, Panel, Image and so on. Recently, I’ve been working on a few projects with the latest version of Unity3d and the new UI tools. Stuck in the old ways, I’ve been using the UI tools in exactly the same way I was using the old GUI library.

With previous versions of Unity I used enums of GUI possible states, I then used the OnGUI method to draw the necessary components.

// an enum used by the behaviour to draw the correct GUI
public enum GuiStatus {

void OnGUI () {
    switch ( CurrentStatus ) {
        case GuiStatus.NewPlayer:
        case GuiStatus.MainMenu:

Mistakenly, I have been doing exactly the same thing with the new UI tools, creating all the Canvas objects I need in my scene and showing/hiding them as needed in the OnGUI method. Pretty silly thing to do, but I’ve been too lazy to truly pick up the new system, until now.

I need to keep my UI logic as separate as possible from my game controller scripts. After a few attempts I think I’ve come up with a reasonably efficient way to deal with this. I’d love to hear your feedback.

In my UI I have a number of windows that can be visible on the screen, such as a loading window, a countdown window and a profile information window. When the loading window is visible all other windows are hidden. However, when the countdown is showing the profile window can also be shown. I decided to setup my objects this way:

  • I have a Window class that implements MonoBehaviour
  • Each Canvas has an implementation of the Window class controlling its logic
  • The Canvas is saved as a prefab in my resources folder

The Window Component contains a reference to the Canvas object it is associated with, a boolean property that tells me whether it is visible alongside other windows and a Show() and Hide() methods.

All windows are controlled by a UIController object, also an implementation of MonoBehaviour, and what my main game-controller script uses to interact with the UI. Below is an example of the countdown window implementation, this is attached to the Canvas element in the prefab, and the reference to the Text Component is setup through the Unity Editor. I first load it through the UI controller and then call the StartCountdown() method to kick off the countdown. I have also added an event to the object to be notified when the countdown finishes.

// the actual implementation receives some parameters here.
// I left it empty for simplicity's sake
public delegate void CountdownCompletedHandler();

public class CountdownWindow : Window {
    // A reference to the UI Text element
    public Text CountdownText;

    // Methods attached to this event are notified when the countdown completes
    public event CountdownCompletedHandler OnCountdownCompleted;

    // temporary variables used for state control
    private bool CountdownStarted = false;
    private float TmpCountdownTimer;

    // Update is called once per frame
    void Update () {
        if (CountdownStarted) {
            TmpCountdownTimer -= Time.deltaTime;

            if (Mathf.CeilToInt (TmpCountdownTimer) == -1) {
                if ( OnCountdownCompleted != null )

            if (Mathf.CeilToInt (TmpCountdownTimer) == 0) {
                CountdownText.text = "Ready...";
            } else {
                CountdownText.text =  Mathf.CeilToInt (TmpCountdownTimer).ToString();

    public void StartCountdown(int countdownDuration = 3) {
        TmpCountdownTimer = countdownDuration;
        CountdownText.text = countdownDuration.ToString ();
        CountdownStarted = true;

Once the prefab is saved I then use the UIController to load it as needed from my resources. Below is the basic implementation of the UI controller with 3 methods: ShowWindow(), HideWindow() and GetWindow<T>(). GetWindow retrieves the Component requested from the given window and returns it. I use this from the main game controller script to quickly access methods in my UI.

// this is serializable to be accessible through the Unity editor UI
public class UIElement {
    public string Name;
    public GameObject Prefab;

public class UIController : MonoBehaviour {
    // this is an array of UI elements (prefabs). This is pre-populated
    // through the Unity Editor UI
    public UIElement[] UIElements;

    public void ShowWindow(string windowName, bool forceHideOthers = false) {
        // 1. Lookup window in array
        UIElement uiElement = GetWindow (windowName);

        // 2. instantiate the prefab and set the name
        // This is very inefficient. If your game switches windows a lot you should
        // preload all objects and just switch them on or off
        GameObject uiWindow = Instantiate (uiElement.Prefab) as GameObject; = uiElement.Name;

        // 3. Get the Window component
        Window windowInfo = uiWindow.GetComponent<Window> ();

        // 4. Hide others
        // the CanCoexist property is inherited from the Window object
        if (!windowInfo.CanCoexist) {
            HideOtherWindows(uiElement.Name, forceHideOthers);

    public void HideWindow(string windowName) {
        GameObject window = GameObject.Find (windowName);
        if (window != null) {
            Destroy(window); // Same comment as point 2 above

    public T GetWindow<T> (string windowName) where T: Component {
        GameObject window = GameObject.Find (windowName);
        return window.GetComponent<T> ();

    // private utility methods beyond this point //
    private UIElement GetWindow(string windowName) {
        foreach (UIElement curElement in UIElements) {
            if (curElement.Name == windowName)
                return curElement;

        return null;

    private void HideOtherWindows(string windowName, bool KillEvenIfCanCoexists = false) {

With this implementation I can easily load and unload the UI from my game controller script. For example to manage the count down window I can do this:

void Start() {
    UIController.ShowWindow (COUNTDOWN_WINDOW_NAME);
    CountdownWindow cdController = UIController.GetWindow<CountdownWindow> ("countdown_window");
    cdController.OnCountdownCompleted += CountdownCompleted;
    cdController.StartCountdown (5);

public void CountdownCompleted() {
    UIController.HideWindow ("countdown_window");

There are lots of awesome tutorials about the new UI system on the Unity website. I’d love to hear your feedback about my implementation!

Games, Technology

Picking the right engine for an indie game: Unity3d vs Unreal Engine 4

Unreal Engine 4 GraphicsIndie game developers have never had so many options when it comes to cheap, easy-to-use game engines. Picking the right engine is a very subjective decision and often depends on language preferences as well as graphical requirements. I know CryEngine is also available but based on other reviews I’m not considering it for my projects (seems too complicated to use for my basic knowledge of game development).

  1. Unity3d
    • C# or JS (Relatively easy languages to learn)
    • Intuitive UI
    • Not as powerful as the alternatives when it comes to next-gen graphics
    • Great asset store full of content
    • For mobile games license is $1,500 per platform or $75 per platform per month
  2. Unreal Engine 4
    • C++ (Arguably a slightly harder language to master)
    • Intuitive UI (I would argue that the latest release UE4 is at par with Unity 3d)
    • All the power you will ever need from an engine
    • Have never tried the marketplace, opinions?
    • License is $19 per month + 5% of profits when the game makes over $3K

I have only worked with Unity3D and I love how fast it is to get started, the great asset store content makes building prototypes even faster. However, Looking at the video tutorials for Unreal Engine 4 it seems that the editor is now just as user-friendly as Unity’s. The only barrier remaining is C++, I have a very basic knowledge of C++ and it would be a steep learning curve.

The price point is also a very important consideration. 5% of profits is potentially a very steep price to pay. But in the interest of not putting the cart before the horse the likelihood of one of my games succeeding is low, so the idea of paying only $19 per month at the beginning against the $150 for Unity is appealing. Opinions?

Check out the Unreal Engine tutorials channel on YouTube.

Photos, Travel

Day trip to Bowen Island

After months of hesitation and procrastination we finally moved to Vancouver. It wasn’t easy to pick everything up, say goodbye to good friends in London and just leave. However, it was time for our new life to start – new place, new job, new continent.

I often repeat this to myself: “There ain’t stopping us going but the leaving of it all”

We have now been in Vancouver for one month. Almost settled in and as the summer approaches and the weather turns we took our first day trip. Bowen Island for a day trekking in Crippen Regional Park as suggested by my new favourite book. This was also the perfect excuse to pick up my camera again, my flickr account has been inactive for way too long!


We took the 10am ferry from Horseshoe bay and arrived at Bowen Island bright and early. From Snug Cove we first walked the Dorman Point Trail as we were promised a stunning view over Snug Cove – disappointingly the view was obscured by trees. Nevertheless it was a great way to start the day as the walk was short and at times steep, makes for a great warm up.


After resting for a bit at Dorman Point we came back down and had lunch at Doc Morgan’s, a nice local pub just next to the Union Steamship Company Store. The pub offers a great view on the cove from the patio but the food wasn’t anything to write home about.

After lunch we picked up the Killarney Lake Trail. This is a beautiful, easy walk. It can easily take up to a couple of hours to complete the entire loop from Snug cove and the panoramas are great.


We will definitely go back and perhaps bring our bicycles for a more complete tour of the island.

General Babbling

MotoGP is back!

Rossi Wallpaper
The doctor in action

I can’t wait for the MotoGP season to start again. It is pretty much the only sport I wach on television and actually follow. My occasional forays into F1 are simply a palliative for the lack of motorbike action.

This should be a cracking season with Rossi back at Yamaha, Pedrosa on a mission to finally get his first world title and Marquez ready to jump in the mix.

I am a huge fan of Rossi and watching him languish in the middle of nowhere (4th or less) with Ducati was painful – the guy is a hero to me and I think he deserves to leave MotoGP with a few more victories under his belt, another world championship would be astounding.

Stoner was hugely fast and I admire his riding style and skills to push that Ducati to the limit. Even so, I have never been a big fan, something about his attitude. I completely understand his decision to retire. It clearly looked like he wasn’t having fun and decided it was time to dedicate himself to his new family, while doing a bit of racing on the side, rather than the other way around.

Lorenzo is always a favorite for the title. He is a spectacularly good rider and incredibly consistent. I know many people blame him for the lack of “action” over the past 2 seasons in MotoGP but I think that is unfair. He was racing to win the championship, points over risks, and I don’t think he was challenged enough by his rivals. They were either too far ahead and impossible to catch up without taking too many risks or so much slower that there was no need to push. Either way, with Vale on the same bike hopefully they should be some excitement as they battle it out.

Bring on Qatar this weekend!


keeping your code in shape

Not too long ago ID Software published a document detailing its coding guidelines. It makes for interesting reading and we can all learn something from it.

I certainly picked a few rules from it as I was putting together a set of coding guidelines for

However, web development is very different from game development. Iterations over a piece of software in the web world can be as brief as half an hour, production bugs need to be fixed and released promptly. When building a game you spend months testing and refining your code.

Fast iteration is one of the biggest advantages of web development, a centralised code-base that can be adjusted and updated without needing to re-distribute your software. Unfortunately the speed of development and release is also what causes “spaghetti” code to appear.

What I thought I’d do is try to set, on top of some detailed coding standard rules, more architectural and structural rules for the code. These will hopefully guide developers when they are furiously fixing issues and adding functionality.

These are in no particular order and I’m writing them as they come to mind. I would like to hear from developers and CTOs out there to complete and adjust this list.

  1. If parts of your software need to interact with some code without knowing its entire structure and meaning, in an interface-like style, then it should be an Object. Weakly typed languages are no excuse to produce code that will be harder to debug and maintain in the future.
  2. Your variables should be your comments – use readable variable names and split an instruction in three separate steps if needed for the sake of readability.
  3. Think big – when fixing a bug or adding new functionality think about the rest of the code and how it interacts with what you are re-writing, you are most likely missing something. Then pause again and think even bigger, what will your business look like in the future, in which direction is it heading, perhaps you could add some hooks in your code which will make it easier to re-use as your software evolves.
  4. Objects are nice and keep your code clean – however, if the object you are creating will not be reused, or you already know it can’t be reused because it’s not going to be compatible with the rest of your code, then it probably shouldn’t be an object, keep it simple.
  5. Divide to conquer. If your application can be separated in different components, for example an API and a management console, make sure they can run independently from each other. If one is down ideally it shouldn’t take down the other. This will also make your code easier to re-engineer, you will be able to do it one little logical component at a time without having to go through a monolithic rewrite which almost never works.
  6. If you are writing a 10 lines IF statement there’s probably something wrong with your logic, review and simplify.
  7. Prototype your code quickly but make sure to cover the entire business case from beginning to end. Once you have mastered all of the use cases, write the code for your application.
  8. When adding new functionality also write a test case for it.
  9. If the functionality you are building already exists in a library your project is using or could use, use that library. DO NOT REINVENT THE WHEEL.
  10. Write some java-doc style documentation for your functions. It will make other developer’s life easier, your business will be able to produce a documentation for all of its code.
  11. Write comments to explain the logic of your code if it’s needed. don’t state the obvious.
  12. We are building web apps. The web server is already multi-threaded, each page loads in its thread, you don’t need to spawn sub-threads in a page.

Is London still the right place for a startup?

I moved to London 8 years ago because of the booming job market and, well, because it was London. Many things have changed since then.  I now find myself in the position to start my own business.

Naturally, I assumed that London and the UK was a great place to do it. Simplified bureaucracy, great talent from all over the world constantly flowing in and out of the country, the ever-more prominent Silicon Roundabout, a tory-led coalition government which, for all its faults, should be trying to boost business and entrepreneurship (isn’t that what torys are all about?) – London is the right place to do it.

aboriginal population of englandOver the past few months, I have grown sceptical and wonder if London is the right place for me.

  • Cooling off period – Businesses big and small around London rely on the flow of skilled immigrants to hire the talent they need. The aboriginal population, whose new generation is pictured here on the right, seems to have decided to leave these jobs to immigrants and focus on other things.
    The government has now introduced a cooling-off period for Tier 2 VISA holders – what this means is that if someone’s VISA is sponsored by a business and I decide to hire them, they will have to spend 12 months (12 MONTHS!!!??!!?) outside of the UK cooling off before they begin working for me. I struggle find a justification for this, other than that they were probably red hot by having such an easy time getting the VISA to begin with and needed to cool off a bit before they can work for me here.
    An idiotic populist rule. Clearly drawn up by people who have never had to hold a real job, hire anybody other than their wives and close relations, to keep receiving the votes of the very same aboriginal population who isn’t producing any wealth for their country
  • Commercial real estate – The next step, after taking skilled immigrants off the table, is clearly to take the offices away from small business by making commercial real-estate in London prohibitively expensive. Because of the recession a lot of the commercial spaces in London remain empty. The root cause of the problem is the weak economy not encouraging businesses to expand and new ones to start. As usual, politicians decided that instead of fixing the underlying cause of the issue they will put a patch on it, by making it easier for property developers to convert commercial real estate into blocks of flats. These are properties in the heart of London, no Londoner will ever be able to afford them given that the average salary is $56,000 per year. What we will end up with is a lot more Emirati and Sheiks owning penthouses in central London, the price of commercial real will go up, business will have to move out.

I thought London was a great place to start a business because the benefit of the inflow of skilled immigrants from all over the world (everybody wants to live in London, like New York) far outweighed the high prices.

They have taken both away – I think it’s time we move to another great city in the world.