<?php

function include_configuration_file($file_path, $languages="all")
{
   if (!file_exists($file_path)) return;

   $content = file($file_path);
   $operations = array("define_in_php", "write_to_javascript_file");

   if ($languages == "all" || $languages == "javascript")
   {
      erase_file_contents(JAVASCRIPT_CONFIG_FILE_PATH);
   }

   switch ($languages)
   {
      case "php":
         return parse_configuration($content, $operations[0]);
      case "javascript":
         return parse_configuration($content, $operations[1]);
      default:
         return parse_configuration($content, $operations);
   }
}

function parse_configuration($body, $operations=NULL)
{
   $operations = (!is_array($operations)) ? array($operations) : $operations;
   foreach ($body as $line)
   {
      if (preg_match("/^ *#.*$/", $line) || trim($line) == "") continue;
      $equality = explode("=", $line, 2);
      $variable = strtoupper(trim($equality[0]));
      $variable = str_replace(" ", "_", $variable);
      $value = trim($equality[1]);
      foreach ($operations as $operation)
      {
         call_user_func($operation, $variable, $value);
      }
   }
}

function write_to_javascript_file($variable, $value)
{
   $equality = "var " . $variable . " = \"" . $value . "\";\n";
   file_put_contents(JAVASCRIPT_CONFIG_FILE_PATH, $equality, FILE_APPEND);
}

function define_in_php($variable, $value)
{
   $GLOBALS[$variable] = $value;
}

function erase_file_contents($file_path)
{
   $fp = fopen($file_path, 'w');
   fclose($fp);
}
<?php
namespace type;

function convert_to_array($item)
{
   if (is_array($item) == False)
   {
      return array($item);
   }

   return $item;
}
<?php
namespace sort;

function quick_sort(array &$array, $comparer=null, $left=0, $right=null)
{
   $right = set_right_index($right, $array);
   if ($right > $left)
   {
      $pivot = calculate_pivot_index($left, $right);
      $new_pivot = partition($array, $comparer, $left, $right, $pivot);
      quick_sort($array, $comparer, $left, $new_pivot - 1);
      quick_sort($array, $comparer, $new_pivot + 1, $right);
   }
}

function set_right_index($index, $array)
{
   if (is_null($index))
   {
      $index = count($array) - 1;
   }
   return $index;
}

function calculate_pivot_index($left_index, $right_index)
{
   $pivot_index = $right_index - ($right_index - $left_index) / 2;
   return $pivot_index;
}

function partition(&$array, $comparer, $left, $right, $pivot_index)
{
   $pivot_value = $array[$pivot_index];
   swap($array, $right, $pivot_index);
   $current = $left;
   for ($ii = $left; $ii < $right; $ii++)
   {
      $comparison = make_comparison($comparer, $array[$ii], $pivot_value);
      if ($comparison === True)
      {
         swap($array, $ii, $current++);
      }
   }
   swap($array, $current, $right);
   return $current;
}

function swap(&$array, $index_1, $index_2)
{
   $value = $array[$index_1];
   $array[$index_1] = $array[$index_2];
   $array[$index_2] = $value;
}

function make_comparison($comparer, $value_1, $value_2)
{
   if (!is_null($comparer))
   {
      $comparison = call_user_func($comparer, $value_1, $value_2);
   }
   else
   {
      $comparison = ($value_1 < $value_2);
   }
   return $comparison;
}
<?php
namespace file;

function count_depth($path)
{
   $stripped_path = trim($path, "/");
   return sizeof(explode("/", $path));
}
<?php

function remove_directory($directory_path, $remove_self=True)
{
   $directory_path = rtrim($directory_path, "/") . "/";
   $directory = opendir($directory_path);
   while ($file = readdir($directory))
   {
      if ($file[0] == '.') continue;
      
      $relative_path = $directory_path . $file;
      if (is_dir($relative_path))
      {
         remove_directory($relative_path);
         continue;
      }
      unlink($relative_path);
   }
   if ($remove_self) rmdir($directory_path);
}
<?php
namespace file;

function is_directory_empty($directory_path)
{
   $files = scandir($directory_path);
   return count($files) > 2;
}
<?php

function print_file_range($fp, $start, $end)
{
   fseek($fp, $start);
   echo "$start - $end\n";
   echo fread($fp, $end-$start) . "\n";
   
}
<?php

function build_path($directory_path, $file_path)
{
   $directory_path = rtrim($directory_path, "/") . "/";
   $path = $directory_path . $file_path;
   return $path;
}
216.73.216.60
216.73.216.60
216.73.216.60
 
June 29, 2013

A few weeks ago, for Fishing Jam, I made a fishing simulation from what was originally designed to be a time attack arcade game. In the program, Dark Stew, the player controls Aphids, an anthropod who fishes for aquatic creatures living in nine pools of black water.



Fishing means waiting by the pool with the line in. The longer you wait before pulling the line out, the more likely a creature will appear. Aside from walking, it's the only interaction in the game. The creatures are drawings of things you maybe could find underwater in a dream.

The background music is a mix of clips from licensed to share songs on the Free Music Archive. Particularly, Seed64 is an album I used a lot of songs from. The full list of music credits is in the game's README file.

I'm still planning to use the original design in a future version. There would be a reaction-based mini game for catching fish, and the goal would be to catch as many fish as possible within the time limit. I also want to add details and obstacles to the background, which is now a little boring, being a plain, tiled, white floor.

If you want to look at all the drawings or hear the music in the context of the program, there are Windows and source versions available. The source should work on any system with Python and Pygame. If it doesn't, bug reports are much appreciated. Comments are also welcome :)

Dark Stew: Windows, Pygame Source

I wrote in my last post that I would be working on an old prototype about searching a cloud for organisms for Fishing Jam. I decided to wait a while before developing that game, tentatively titled Xenographic Barrier. Its main interactive element is a first-person scope/flashlight, so I'd like to make a Wii version of it.

I'm about to start working on a complete version of Ball & Cup. If I make anything interesting for it, I'll post something. There are a lot of other things I want to write about, like game analyses, my new GP2X and arcades in Korea, and there's still music to release. Lots of fun stuff coming!