EVR.include("account/form/Form.js");
EVR.Account = function(evr)
{
   EVR.Pop_Up.call(this, evr.field, ACCOUNT_WIDTH, ACCOUNT_HEIGHT);
   this.evr = evr;
   this.forms = new EVR.Account.Form.Forms(this);
   this.set_color(ACCOUNT_BACKGROUND);
   this.add_cancel_button();
   this.forms.append();
}
EVR.Account.prototype = new EVR.Pop_Up;
EVR.Account.prototype.add_cancel_button = function()
{
   var element = document.createElement("button");
   var current = this;
   element.innerHTML = ACCOUNT_BUTTON_TEXT;
   element.onclick =
      function() {
	 current.evr.unload_account();
      };
   this.element.appendChild(element);
   this.button = element;
}
EVR.Account.prototype.append = function()
{
   EVR.Pop_Up.prototype.append.call(this);
   var button = this.button;
   setTimeout(function() { button.focus() }, 100);
}
EVR.Account.prototype.remove = function()
{
   EVR.Pop_Up.prototype.remove.call(this);
   this.forms.reset();
}
EVR.Account.prototype.toString = function()
{
   return "[object EVR.Account]";
}
<?php
namespace account;
require_once "get_user_path.php";
require_once "add_account.php";
$GLOBALS["HASH_FILE_NAME"] = "hash";
$GLOBALS["EMAIL_ADDRESS_FILE_NAME"] = "email";
$GLOBALS["ADDRESSES_FILE_NAME"] = "addresses";
$GLOBALS["GHOSTS_DIRECTORY"] = "ghosts/";
function add_user_account($name, $password, $email_address)
{
   $root = create_directory(find_users_root(), $name);
   store_password($root, $password);
   store_email_address($root, $email_address);
   create_addresses_file($root);
   copy_history_file($root);
   copy_expert_file($root);
   copy_progress_file($root);
   copy_ghost_directory($root);
}
function store_password($root, $password)
{
   $path = create_file($root, $GLOBALS["HASH_FILE_NAME"]);
   $hash = hash_password($password);
   file_put_contents($path, $hash . "\n");
}
function hash_password($password)
{
   return crypt($password, generate_salt());
}
function generate_salt()
{
   return chr(rand(65, 90)) . rand(0, 9);
}
function store_email_address($root, $email_address)
{
   $path = create_file($root, $GLOBALS["EMAIL_ADDRESS_FILE_NAME"]);
   file_put_contents($path, $email_address . "\n");
}
function create_addresses_file($root)
{
   create_file($root, $GLOBALS["ADDRESSES_FILE_NAME"]);
}
function copy_source($name, $root)
{
   $source = get_user_path() . $name;
   if (is_dir($source))
   {
      $destination = $root . $name;
      mkdir($destination);
      chmod($destination, $GLOBALS["DIRECTORY_PERMISSIONS"]);
      foreach (scandir($source) as $file_name)
      {
         if ($file_name[0] != ".")
         {
            $path = $destination . $file_name;
            copy_and_set_permissions($source . $file_name, $path);
         }
      }
   }
   else if (file_exists($source))
   {
      copy_and_set_permissions($source, $root . $name);
   }
}
function copy_and_set_permissions($source, $destination)
{
   copy($source, $destination);
   chmod($destination, $GLOBALS["FILE_PERMISSIONS"]);
}
function copy_history_file($root)
{
   copy_source($GLOBALS["HISTORY_FILE_NAME"], $root);
}
function copy_expert_file($root)
{
   copy_source($GLOBALS["EXPERT_FILE_NAME"], $root);
}
function copy_progress_file($root)
{
   copy_source($GLOBALS["PROGRESS_FILE_NAME"], $root);
}
function copy_ghost_directory($root)
{
   copy_source($GLOBALS["GHOSTS_DIRECTORY"], $root);
}
<?php
namespace account;
require_once "get_user_path.php";
$GLOBALS["CODE_FILE_NAME"] = "code";
function verify_temporary_credentials($id, $code)
{
   $path = find_temp_users_root() . $id . "/";
   if (is_dir($path))
   {
      if (match_codes($path, $code))
      {
         return true;
      }
   }
   return false;
}
function match_codes($root, $submitted_code)
{
   $existing_code = trim(file_get_contents($root . $GLOBALS["CODE_FILE_NAME"]));
   return $submitted_code == $existing_code;
}
<?php
namespace account;
$GLOBALS["FILE_PERMISSIONS"] = 0660;
$GLOBALS["DIRECTORY_PERMISSIONS"] = 0770;
$GLOBALS["HISTORY_FILE_NAME"] = "history.gz";
$GLOBALS["EXPERT_FILE_NAME"] = "expert";
$GLOBALS["PROGRESS_FILE_NAME"] = "progress";
function create_file($root, $name)
{
   $path = $root . $name;
   touch($path);
   chmod($path, $GLOBALS["FILE_PERMISSIONS"]);
   return $path;
}
function create_directory($root, $name)
{
   $saved = umask(0);
   $path = "$root$name/";
   mkdir($path, $GLOBALS["DIRECTORY_PERMISSIONS"]);
   umask($saved);
   return $path;
}
function create_history_file($root)
{
   create_file($root, $GLOBALS["HISTORY_FILE_NAME"]);
}
function create_expert_file($root)
{
   create_file($root, $GLOBALS["EXPERT_FILE_NAME"]);
}
function initialize_progress_file($root)
{
   $path = create_file($root, $GLOBALS["PROGRESS_FILE_NAME"]);
   file_put_contents($path, "0\n");
}
<?php
namespace account;
require_once "get_user_path.php";
function user_exists($name)
{
   return strlen($name) && is_dir(build_user_path($name));
}
<?php
namespace account;
require_once "get_user_path.php";
require_once "add_account.php";
$GLOBALS["ID_LENGTH"] = 7;
$GLOBALS["CODE_LENGTH"] = 10;
$GLOBALS["FILE_PERMISSIONS"] = 0660;
$GLOBALS["CODE_FILE_NAME"] = "code";
$GLOBALS["PROGRESS_FILE_NAME"] = "progress";
$GLOBALS["HISTORY_FILE_NAME"] = "history.gz";
$GLOBALS["EXPERT_FILE_NAME"] = "expert";
function add_temporary_account()
{
   $temp_path = find_temp_users_root();
   $id = build_id($temp_path);
   $root = create_directory($temp_path, $id);
   $code = store_code($root);
   initialize_progress_file($root);
   create_history_file($root);
   create_expert_file($root);
   add_temporary_cookie($id, $code);
   return $id;
}
function build_id($root)
{
   if (!is_dir($root))
   {
      mkdir($root, 0770);
   }
   $ids = scandir($root);
   $next = intval($ids[count($ids) - 1]) + 1;
   return str_pad($next, $GLOBALS["ID_LENGTH"], "0", STR_PAD_LEFT);
}
function store_code($root)
{
   $code = generate_code();
   $path = create_file($root, $GLOBALS["CODE_FILE_NAME"]);
   file_put_contents($path, $code . "\n");
   return $code;
}
function generate_code()
{
   $code = "";
   for ($ii = 0; $ii < $GLOBALS["CODE_LENGTH"]; $ii++)
   {
      $code .= chr(rand(65, 90));
   }
   return $code;
}
function add_temporary_cookie($id, $code)
{
   $expiration = time() + 30 * 24 * 60 * 60;
   $path = "/";
   setcookie("id", $id, $expiration, $path);
   setcookie("code", $code, $expiration, $path);
}
3.137.178.133
3.137.178.133
3.137.178.133
 
August 12, 2013

I've been researching tartan/plaid recently for decoration in my updated version of Ball & Cup, now called Send. I want to create the atmosphere of a sports event, so I plan on drawing tartan patterns at the vertical edges of the screen as backgrounds for areas where spectator ants generate based on player performance. I figured I would make my own patterns, but after browsing tartans available in the official register, I decided to use existing ones instead.

I made a list of the tartans that had what I thought were interesting titles and chose 30 to base the game's levels on. I sequenced them, using their titles to form a loose narrative related to the concept of sending. Here are three tartans in the sequence (levels 6, 7 and 8) generated by an algorithm I inferred by looking at examples that reads a tartan specification and draws its pattern using a simple dithering technique to blend the color stripes.


Acadia


Eve


Spice Apple

It would be wasting an opportunity if I didn't animate the tartans, so I'm thinking about animations for them. One effect I want to try is making them look like water washing over the area where the ants are spectating. I've also recorded some music for the game. Here are the loops for the game over and high scores screens.

Game Over

High Scores