EVR.include("history/record/Record.js");
EVR.include("history/Parser.js");
EVR.include("history/view/View.js");
EVR.History = function(container)
{
   EVR.Pop_Up.call(this, container, HISTORY_WIDTH, HISTORY_HEIGHT);
   this.set_location();
   this.load();
   this.view = new EVR.History.View(this);
}
EVR.History.prototype = new EVR.Pop_Up;
EVR.History.prototype.set_location = function()
{
   this.location = SOURCE_PATH + "history/";
}
EVR.History.prototype.load = function()
{
   var path = this.location + "fetch.php";
   var document = new EVR.Requester(path, null, true).execute();
   this.records = new EVR.History.Parser(document).records;
}
EVR.History.prototype.set_level = function(level)
{
   this.level = level;
}
EVR.History.prototype.store_newest_record = function()
{
   this.build_newest_record();
   this.store_record(this.newest);
}
EVR.History.prototype.build_newest_record = function()
{
   var level = this.level;
   var time = level.clock.time.get();
   var accuracy = level.road.path.calculate_accuracy();
   this.newest = new EVR.History.Record(level.id, time, accuracy);
}
EVR.History.prototype.store_record = function(record)
{
   this.records.push(record);
   var id = record.level;
   var time = record.time.valueOf();
   var accuracy = record.accuracy.valueOf();
   var path = this.location + "insert.php";
   var query = "level=" + id + "&time=" + time + "&accuracy=" + accuracy;
   new EVR.Requester(path, query).execute();
}
EVR.History.prototype.get_accuracies = function()
{
   return this.get_field("accuracy");
}
EVR.History.prototype.get_times = function()
{
   return this.get_field("time");
}
EVR.History.prototype.get_field = function(field)
{
   var records = this.records;
   var entries = [];
   for (var ii = 0; ii < records.length; ii++)
   {
      if (records[ii].level == this.level.id)
      {
	 entries.push(records[ii][field]);
      }
   }
   return entries;
}
EVR.History.prototype.get_newest = function()
{
   return this.newest;
}
EVR.History.prototype.get_best_time = function()
{
   var times = this.get_times();
   var time, best = null;
   for (var ii = 0; ii < times.length; ii++)
   {
      time = times[ii];
      if (time < best || best == null)
      {
	 best = time;
      }
   }
   return best;
}
EVR.History.prototype.count_records = function()
{
   return this.records.length;
}
EVR.History.prototype.append = function()
{
   EVR.Pop_Up.prototype.append.call(this);
   this.view.build();
}
EVR.History.prototype.draw = function()
{
   EVR.Pop_Up.prototype.draw.call(this);
   this.view.draw();
}
EVR.History.prototype.remove = function()
{
   EVR.Pop_Up.prototype.remove.call(this);
   this.view.reset();
}
EVR.History.prototype.toString = function()
{
   return "[EVR.History]";
}
<?php
require_once "../account/get_user_path.php";
$GLOBALS["HISTORY_FILE_NAME"] = "history.gz";
$path = account\get_user_path() . $GLOBALS["HISTORY_FILE_NAME"];
ob_start();
readgzfile($path);
ob_end_flush();
<?php
require_once "../account/get_user_path.php";
$GLOBALS["HISTORY_FILE_NAME"] = "history.gz";
$path = account\get_user_path() . $GLOBALS["HISTORY_FILE_NAME"];
$level = $_GET["level"];
$time = $_GET["time"];
$accuracy = $_GET["accuracy"];
$file = gzopen($path, "a");
gzwrite($file, "$level $time $accuracy\n");
EVR.include("history/record/Time.js");
EVR.include("history/record/Accuracy.js");
EVR.History.Record = function(level, time, accuracy)
{
   this.level = level;
   this.time = new EVR.History.Record.Time(time);
   this.accuracy = new EVR.History.Record.Accuracy(accuracy);
}
EVR.History.Record.prototype.toString = function()
{
   return "[object EVR.History.Record]";
}
EVR.History.Record.Time = function(time)
{
   EVR.Time.call(this, time);
}
EVR.History.Record.Time.prototype = new EVR.Time;
EVR.History.Record.Time.prototype.toString = function(precision)
{
   if (precision == null)
   {
      precision = CLOCK_PRECISION;
   }
   var minutes = this.get_minutes();
   var seconds = this.pad(this.get_seconds() % 60, 2);
   var display = minutes + ":" + seconds;
   if (precision > 0)
   {
      var milliseconds = this.pad(this.get_milliseconds(precision), precision);
      display += "." + milliseconds;
   }
   return display;
}
EVR.History.Record.Time.prototype.valueOf = function()
{
   return this.get();
}
EVR.History.Record.Accuracy = function(accuracy)
{
   this.accuracy = accuracy;
}
EVR.History.Record.Accuracy.prototype.toString = function(precision)
{
   if (precision == null)
   {
      precision = ACCURACY_PRECISION;
   }
   return (100 * this.accuracy).toFixed(precision) + "%";
}
EVR.History.Record.Accuracy.prototype.valueOf = function()
{
   return parseFloat(this.accuracy);
}
EVR.include("history/view/level/Level.js");
EVR.History.View = function(history)
{
   EVR.Table.call(this, history, "100%", null);
   this.field = history.container;
   this.cell_count = HISTORY_CELL_COUNT;
   this.levels = [];
   this.record_index = 0;
   this.set_attributes();
   this.append();
}
EVR.History.View.prototype = new EVR.Table;
EVR.History.View.prototype.set_attributes = function()
{
   var element = this.element;
   element.cellSpacing = HISTORY_CELL_SPACING;
   var style = element.style;
   style.textAlign = "center";
   style.verticalAlign = "middle";
   style.color = "#404040";
   this.container.set_color(HISTORY_BACKGROUND);
}
EVR.History.View.prototype.build = function()
{
   this.records = this.container.records.sort(this.compare_records);
   while (this.record_index < this.records.length)
   {
      this.levels.push(new EVR.History.View.Level(this));
      this.advance_record_to_next_level();
   }
}
EVR.History.View.prototype.compare_records = function(a, b)
{
   var swap = a.level - b.level;
   if (swap === 0)
   {
      swap = a.time - b.time;
   }
   return swap;
}
EVR.History.View.prototype.advance_record_to_next_level = function()
{
   var ii = this.record_index;
   var records = this.records;
   var current = records[ii].level;
   while (ii < records.length && records[ii].level == current)
   {
      ii++;
   }
   this.record_index = ii;
}
EVR.History.View.prototype.reset = function()
{
   this.clear();
   this.record_index = 0;
   this.levels = [];
}
EVR.History.View.prototype.draw = function()
{
   var levels = this.levels;
   for (var ii = 0; ii < levels.length; ii++)
   {
      levels[ii].draw();
   }
}
EVR.History.View.prototype.toString = function()
{
   return "[object EVR.History.View]";
}
100.26.179.196
100.26.179.196
100.26.179.196
 
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