EVR.Color = function(color)
{
   this.set_rgb(color);
}
EVR.Color.prototype.set_rgb = function(color)
{
   if (typeof color == "object")
   {
      this.rgb = color;
   }
   else if (color.slice(0, 3) == "rgb")
   {
      this.rgb = this.extract_rgb_from_tuple(color);
   }
   else
   {
      this.rgb = this.extract_rgb_from_hex_string(color);
   }
}
EVR.Color.prototype.extract_rgb_from_tuple = function(color)
{
   var rgb = color.match(/\d+/g);
   return [+rgb[0], +rgb[1], +rgb[2]];
}
EVR.Color.prototype.extract_rgb_from_hex_string = function(color)
{
   var r = parseInt(color.slice(1, 3), 16);
   var g = parseInt(color.slice(3, 5), 16);
   var b = parseInt(color.slice(5, 7), 16);
   return [r, g, b];
}
EVR.Color.prototype.get_string = function()
{
   var r = parseInt(this.rgb[0]);
   var g = parseInt(this.rgb[1]);
   var b = parseInt(this.rgb[2]);
   return "rgb(" + r + "," + g + "," + b + ")";
}
EVR.Color.prototype.toString = function()
{
   return "[object EVR.Color]";
}
Map = function(parent, colors, beams)
{
   this.apply_style = apply_style;
   this.build_map = build_map;
   this.advance_indicator = advance_indicator;
   this.get_color = get_color;
   this.determine_beam_color = determine_beam_color;
   this.determine_beam_width = determine_beam_width;
   this.determine_beam_lane = determine_beam_lane;
   this.element = document.createElement("table");
   this.tr = document.createElement("tr");
   this.index = 0;
   this.element.appendChild(this.tr);
   this.apply_style();
   this.build_map();
   this.append_self(parent);

   function apply_style()
   {
      this.element.style.position = "absolute";
      this.element.style.left = "0px";
      this.element.style.top = "0px";
      this.element.style.width = "100%";
      this.element.setAttribute("cellspacing", "0");
      this.element.setAttribute("cellpadding", "0");
   }
   function build_map()
   {
      var ii = 0;
      for (; BEAM_PROPERTIES[ii]; ii++)
      {
	 var cell = document.createElement("td");
	 var course = document.createElement("div");
	 var indicator = document.createElement("div");
	 cell.style.verticalAlign = "top";
	 course.style.height = MAP_COURSE_HEIGHT + "px";
	 course.style.marginBottom = MAP_COURSE_MARGIN + "px";
	 course.style.backgroundColor = this.determine_beam_color(ii);
	 indicator.style.height = MAP_INDICATOR_HEIGHT + "px";
	 cell.appendChild(course);
	 cell.appendChild(indicator);
	 this.tr.appendChild(cell);
      }
      this.advance_indicator();
   }
   function advance_indicator()
   {
      var nodes = this.tr.childNodes;
      var index = this.index++;
      if (index > 0)
      {
	 var previous_cell = nodes[index-1].getElementsByTagName("div");
	 previous_cell[1].style.backgroundColor = "";
	 previous_cell[1].style.borderBottom = 0;
      }
      var current_cell = nodes[index].getElementsByTagName("div");
      current_cell[1].style.backgroundColor = MAP_INDICATOR_COLOR;
      current_cell[1].style.borderBottom = MAP_INDICATOR_BORDER;
   }
   function get_color(index)
   {
      return colors[index];
   }
   function determine_beam_color(index)
   {
      return colors[parseInt(beams[index][0])];
   }
   function determine_beam_lane(index)
   {
      return parseInt(beams[index][1])-1;
   }
   function determine_beam_width(index)
   {
      return parseInt(beams[index][2]) * BEAM_WIDTH_MULTIPLIER;
   }
}

Map.prototype = new Element;
Math.get_random_number = function(min, max)
{
   return Math.random() * (max - min) + min;
}
Math.get_random_int = function(min, max)
{
   return Math.floor(Math.random() * (max - min + 1)) + min;
}
function Course(parent, map)
{
   this.apply_style = apply_style;
   this.initialize_beams = initialize_beams;
   this.element = document.createElement("div");
   this.append_self(parent);
   this.apply_style();
   this.initialize_beams();
   function apply_style()
   {
      var background_color = map.determine_beam_color(0);
      this.element.style.backgroundColor = background_color;
      this.element.style.width = parent.clientWidth + "px";
      this.element.style.height = parent.clientHeight * (5/16);
      this.element.style.fontSize = "0px";
      this.element.style.overflow = "hidden";
      this.element.style.marginTop = parent.clientHeight * (5/23);
      this.element.style.borderTopWidth = BEAM_HEIGHT/2 + 1 + "px";
      this.element.style.borderBottomWidth = 2 + "px";
      this.element.style.borderStyle = "solid";
      this.element.style.borderColor = background_color;
   }
   function initialize_beams()
   {
      var ii = 0, jj = 0;
      var initial_color = map.determine_beam_color(0);
      var color = initial_color;
      var lane = map.determine_beam_lane(0);
      var width = map.determine_beam_width(0);
      var x = EMOTICON_START_X + EMOTICON_WIDTH + BEAM_START_OFFSET;
      while (ii++ < BEAM_COUNT)
      {
	 new Beam(this.element, color, width, lane++, x);
	 if (lane > BEAM_COUNT-1) lane = 0;
	 color = map.get_color(jj++);
	 if (color == initial_color) color = map.get_color(jj++);
      }
   }
}

Course.prototype = new Element;
EVR.Requester = function(path, query, text, post)
{
   this.path = path;
   this.query = query;
   this.text = text || false;
   this.set_method(post);
   this.build();
}
EVR.Requester.prototype.set_method = function(post)
{
   var method = "GET";
   if (post == true)
   {
      method = "POST";
   }
   this.method = method;
}
EVR.Requester.prototype.build = function()
{
   if (window.XMLHttpRequest)
   {
      this.request = new XMLHttpRequest();
   }
   else
   {
      this.request = new ActiveXObject("Microsoft.XMLHttp");
   }
}
EVR.Requester.prototype.execute = function()
{
   var request = this.request;
   var method = this.method;
   var url = this.build_url();
   var parameters = null;
   request.open(method, url, false);
   if (method == "POST")
   {
      var mime = "application/x-www-form-urlencoded";
      parameters = this.query;
      request.setRequestHeader("Content-type", mime);
   }
   request.send(parameters);
   return this.text ? request.responseText : request.responseXML;
}
EVR.Requester.prototype.build_url = function()
{
   var url = this.path + "?" + +new Date;
   if (this.method == "GET" && !!this.query)
   {
      url += "&" + this.query;
   }
   return url;
}
EVR.Requester.prototype.toString = function()
{
   return "[object EVR.Requester]";
}
216.73.216.181
216.73.216.181
216.73.216.181
 
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