• One game a month #8

    I finally ironed out most of the bugs with this demo of my upcomming game. The next month will be spent on creating graphics and textures as well as different levels.

    I hope you enjoy this remake of boulder dash, I am still working on a title for the game. The game is at the bottom of the page btw, until i get the time to update the websites design.

    1.1 : Removed a bug which caused the game to finish once the door threshold was reached.

  • Drupal development

    Just a few modules I use when developing:


    Great for debugging while developing.

    Search krumo

    Once you have outputted your devel data Search krumo enables you to search the data structure and to copy the path to your desired data directly.

    Module filter

    If your sites have lots of modules Module filter makes your life alot easier.

    If you have any more suggestions leave me a comment.

  • Writing a custom panel context

    I recently had to create a list of items based on data entered in a field and since the list would live in a panel I decided to create a new context to deliver the id to my views contextual filter.

    I was guided by Yuriy Gerasimov on how to write the context and I changed a few things in order to make my case work.

    Writing the context i very easy and requires only a very small module, so here is how I went about it:

    First we need to create a new module, we could call it custom_context_example. I presume you know how to create a custom module otherwise lookup how on

    Well in the custom_context_example.module we need to tell ctools that we are providing a new context type. We do this by defining the hook_ctools_plugin_directory and specifying the local path to our context folder.

    1. /**
    2.   * Implements hook_ctools_plugin_directory().
    3.   */
    4. function custom_context_example_ctools_plugin_directory($module, $plugin) {
    5.   if ($module == 'ctools' && $plugin == 'contexts') {
    6.     return "plugins/contexts";
    7.   }
    8. }

    Next we create the plugins and contexts folder. In the contexts folder we can now create the context inc file. Lets call it

    The first thing we need to do here is define the plugin for ctools:

    1. /**
    2.  * Array to describe plugin.
    3.  */
    4. $plugin = array(
    5.   'title' => t('Custom context example'),
    6.   'description' => t('Provide token for referenced item.'),
    7.   'context' => 'ctools_plugin_create_custom_context_example',
    8.   'context name' => 'custom_context_example',
    9.   'keyword' => 'custom_context_example', // Provides a list of items which are exposed as keywords.
    10.   'convert list' => 'custom_context_example_convert_list', // Convert keywords into data.
    11.   'convert' => 'custom_context_example_convert',
    12. );

    Next we need to write the create context function as well as the convert list and the actual convertion. 

    The create context functiion ctools_plugin_create_context_example starts with defining the base context.

    1. function ctools_plugin_create_custom_context_example($empty, $data = NULL, $conf = FALSE) {
    2.   $context = new ctools_context('custom_context_example');
    3.   $context->plugin = 'custom_context_example';
    4.   $context->data = new stdClass();

    next we need to get the object which contains the reference for this context, in this case I knew that the panel would be part of a term view but depending your case you would have to change the next part to match.

    1.   $term = menu_get_object('taxonomy_term', 2)
    3.   if(!empty($term) && !empty($term->field_custom_context_example_data)) {
    4.     $field_lang = field_language('taxonomy_term', $term, 'field_custom_context_example_data');
    5.     $data= $term->field_custom_context_example_data[$field_lang][0]['value'];
    6.     $query = db_select('aggregator_category', 'a')
    7.       ->condition('a.title', $category, '=')
    8.       ->fields('a', array('cid', 'title', 'description'));
    9.     $result = $query->execute();
    11.     foreach ($result as $record) {
    12.       $context->data->cid = $record->cid;
    13.       $context->data->title = $record->title;
    14.       $context->data->description = $record->description;
    15.     }
    16.   }  else {
    17.     $context->data->cid = null;
    18.     $context->data->title = '';
    19.     $context->data->description = '';
    20.   }
    21.   return $context;
    22. }

    For this example I have allowed writers to enter the name of a aggregator category in a text field and now in the context creation function we can use the value in the field to query the aggregator_category table to get the record matching the entered value. On a side not in order for this to function a validation of the entered value should be added to the field, to ensure that the entered value exists as a category.

    It this context is used where there is no term available e.g. the panel page admin UI we will set the default cid to null and the other values to empty strings, this enables us to envoke the "When the filter value is not available" options in view and it should be noted that the function must always be able to run or you will get an error in the admin UI, which is also a reason for the fallback to a null value.

    Once we have the record we can create and fill the appropriate values in our context data object. This values will be used later in the token function. It is also important to note that the keys for the values should correspond to the columns in the table since this enables you to use them as contextual filter values in views.

    Next we will add the two token functions:

    1. function custom_context_example_convert_list() {
    2.   return array(
    3.     'cid' => t('Feed term id'),
    4.     'title' => t('Feed term title'),
    5.     'description' => t('Feed term description'),
    6.   );
    7. }
    9. function custom_context_example_convert($context, $type) {
    10.   switch ($type) {
    11.     case 'title':
    12.       return $context->data->title;
    13.     case 'description':
    14.       return $context->data->description;
    15.     case 'cid':
    16.       return $context->data->cid;
    17.   }
    18. }

    and that is it. Now you can use the context as in your panel pages to provide context based on dynamic values. I hope this helps some of you out there.

  • One game a month#2: February entry

    Here is my february  entry for #1GAM. It was quite fun to make and a challenge to complete since we moved in january, and still had a lot to do, and my wifes birthday was up. But here it is! If you do have any feature requests, please sende them to me via twitter. :)

    And the credits:

    1. The buildings are made with Zombiegons construction kit
    2. The zombie is from Mixamo
    3. The sniper was created by Virtual Motion
    4. And the props on the stage were made by Ruben