<?php
require_once "../../../../account/get_user_path.php";
$GLOBALS["GHOSTS_DIRECTORY"] = "ghosts/";
load_ghost();
function load_ghost()
{
   if (file_exists($path = build_path()))
   {
      ob_start();
      readgzfile($path);
      ob_end_flush();
   }
}
function build_path()
{
   $file = $_GET["level"] . ".gz";
   return account\get_user_path() . $GLOBALS["GHOSTS_DIRECTORY"] . $file;
}
<?php
require_once "../../../../account/get_user_path.php";
$GLOBALS["GHOSTS_DIRECTORY"] = "ghosts/";
save_ghost();
function save_ghost()
{
   create_files();
   $trail = str_replace("|", "\n", $_POST["trail"]);
   gzwrite(gzopen(build_path(), "w"), $trail);
}
function create_files()
{
   create_directory();
   create_file();
}
function create_directory()
{
   $path = build_directory_path();
   if (!file_exists($path))
   {
      mkdir($path, 02770);
   }
}
function create_file()
{
   $path = build_path();
   if (!file_exists($path))
   {
      touch($path);
      chmod($path, 0660);
   }
}
function build_directory_path()
{
   return account\get_user_path() . $GLOBALS["GHOSTS_DIRECTORY"];
}
function build_path()
{
   return build_directory_path() . $_POST["level"] . ".gz";
}
EVR.include("level/road/path/trail/Marker.js");
EVR.Level.Road.Path.Trail = function(level)
{
   this.level = level;
   this.trail = [];
}
EVR.Level.Road.Path.Trail.prototype.add = function(speed, lane)
{
   var level = this.level;
   var time = 0;
   if (!!level.clock)
   {
      time = level.clock.time.get();
   }
   var trail = this.trail;
   var marker = new EVR.Level.Road.Path.Trail.Marker(time, speed, lane);
   trail.push(marker);
}
EVR.Level.Road.Path.Trail.prototype.load = function()
{
   var trail = this.trail;
   var parameters, marker, raw = this.get_raw();
   for (var ii = 0; ii < raw.length; ii++)
   {
      parameters = raw[ii].split(" ");
      marker = new EVR.Level.Road.Path.Trail.Marker();
      EVR.Level.Road.Path.Trail.Marker.apply(marker, parameters);
      trail.push(marker);
   }
}
EVR.Level.Road.Path.Trail.prototype.get_raw = function()
{
   var script = this.get_script_root() + "load_ghost.php";
   var query = this.build_query();
   var raw = new EVR.Requester(script, query, true).execute().split("\n");
   if (raw.length <= 1)
   {
      raw = [];
   }
   return raw;
}
EVR.Level.Road.Path.Trail.prototype.build_query = function()
{
   return "level=" + this.level.id;
}
EVR.Level.Road.Path.Trail.prototype.get_script_root = function()
{
   return SOURCE_PATH + "level/road/path/trail/";
}
EVR.Level.Road.Path.Trail.prototype.save = function()
{
   this.fix();
   var script = this.get_script_root() + "save_ghost.php";
   var query = this.build_query() + "&trail=" + this.serialize();
   new EVR.Requester(script, query, true, true).execute();
}
EVR.Level.Road.Path.Trail.prototype.fix = function()
{
   var trail = this.trail;
   var time;
   for (var ii = 0; ii < trail.length - 1; ii++)
   {
      time = trail[ii].time;
      if (time > 0 && time == trail[ii + 1].time)
      {
	 ii = this.fix_duplicates(ii);
      }
   }
}
EVR.Level.Road.Path.Trail.prototype.fix_duplicates = function(ii)
{
   var trail = this.trail;
   var count = this.count_duplicates(ii);
   var previous = trail[ii - 1].time;
   var difference = trail[ii].time - previous;
   var step = parseInt(difference / count);
   var limit = ii + count;
   while (ii < limit)
   {
      trail[ii].time -= step * (limit - ii++ - 1);
   }
   return ii - 1;
}
EVR.Level.Road.Path.Trail.prototype.count_duplicates = function(ii)
{
   var trail = this.trail;
   var time = trail[ii].time;
   var count = 1;
   while (ii < trail.length - 1 && trail[++ii].time == time)
   {
      count++;
   }
   return count;
}
EVR.Level.Road.Path.Trail.prototype.serialize = function()
{
   return this.trail.join("|");
}
EVR.Level.Road.Path.Trail.prototype.toString = function()
{
   return "[EVR.Level.Road.Path.Trail]";
}
EVR.Level.Road.Path.Trail.Marker = function(time, speed, lane)
{
   this.time = parseInt(time);
   this.speed = parseFloat(speed);
   this.lane = parseInt(lane);
}
EVR.Level.Road.Path.Trail.Marker.prototype.toString = function()
{
   return this.time + " " + this.speed + " " + this.lane;
}
EVR.include("/level/map/Indicator.js");
EVR.Level.Map.Display = function(container, level)
{
   EVR.Component.call(this, container, "table");
   this.level = level;
   this.clusters = level.clusters;
   this.colors = level.beams;
   this.current = 0;
   this.row = this.element.insertRow(-1);
   this.style();
   this.populate();
   this.append();
   this.align();
   this.add_indicators();
}
EVR.Level.Map.Display.prototype = new EVR.Component;
EVR.Level.Map.Display.prototype.style = function()
{
   this.element.cellSpacing = "0";
   this.css.width = MAP_WIDTH;
   this.css.position = "absolute";
   this.css.border = MAP_BORDER;
}
EVR.Level.Map.Display.prototype.populate = function()
{
   var passage, cell;
   for (var ii = 0; ii < this.clusters.length; ii++)
   {
      passage = this.clusters[ii].passage;
      cell = this.row.insertCell(-1);
      cell.style.backgroundColor = this.colors[passage];
   }
}
EVR.Level.Map.Display.prototype.align = function()
{
   var relative = this.level.register.previews[0];
   var coordinates = relative.get_coordinates();
   this.css.height = relative.get_dimensions()[1];
   this.css.left = coordinates[0];
   this.css.top = coordinates[1];
}
EVR.Level.Map.Display.prototype.add_indicators = function()
{
   this.player_indicator = new EVR.Level.Map.Indicator(this, INDICATOR_OPACITY);
   this.ghost_indicator = new EVR.Level.Map.Indicator(
      this, GHOST_INDICATOR_OPACITY);
}
EVR.Level.Map.Display.prototype.draw = function()
{
   this.align();
   this.player_indicator.draw(+this.css.height.slice(0, -2));
   this.ghost_indicator.draw(+this.css.height.slice(0, -2));
}
EVR.Level.Map.Display.prototype.advance_player = function(ii)
{
   var ghost = this.ghost_indicator;
   if (ghost.attached && ghost.get_position() == ii)
   {
      ghost.remove();
   }
   this.player_indicator.advance(ii);
}
EVR.Level.Map.Display.prototype.advance_ghost = function(ii)
{
   var ghost = this.ghost_indicator;
   var player = this.player_indicator;
   if (!player.attached || player.get_position() != ii)
   {
      ghost.advance(ii);
   }
   else
   {
      ghost.remove();
   }
}
EVR.Level.Map.Display.prototype.get_player_position = function()
{
   return this.player_indicator.get_position();
}
EVR.Level.Map.Display.prototype.toString = function()
{
   return "[object EVR.Level.Map.Display]";
}
54.91.16.95
54.91.16.95
54.91.16.95
 
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


↠ RSS Feed ↞