EVR.include("level/map/Display.js");
EVR.Level.Map = function(level)
{
   EVR.Graphic.call(
      this, level.road, null, null, ALIGN_TOP_RIGHT, level.road.container);
   this.level = level;
   this.register = level.register;
   this.height = this.level.register.get_dimensions(true)[1];
   this.build();
   this.append();
   this.display = new EVR.Level.Map.Display(this, this.level);
}
EVR.Level.Map.prototype = new EVR.Graphic;
EVR.Level.Map.prototype.build = function()
{
   var level = this.level;
   var register = this.register;
   this.set_color(level.background);
   this.css.borderTop = register.css.borderTop;
}
EVR.Level.Map.prototype.shape = function()
{
   EVR.Graphic.prototype.shape.call(this);
   var dimensions = this.register.get_dimensions();
   var width = this.container.get_dimensions()[0] - dimensions[0];
   this.set_dimensions(width, dimensions[1]);
}
EVR.Level.Map.prototype.place = function(x, y)
{
   EVR.Graphic.prototype.place.call(this);
   var y = this.register.get_coordinates()[1];
   this.set_coordinates([null, y]);
}
EVR.Level.Map.prototype.draw = function()
{
   EVR.Graphic.prototype.draw.call(this);
   !!this.display && this.display.draw();
}
EVR.Level.Map.prototype.advance_player = function(ii)
{
   this.display.advance_player(ii);
}
EVR.Level.Map.prototype.advance_ghost = function(ii)
{
   this.display.advance_ghost(ii);
}
EVR.Level.Map.prototype.get_player_position = function()
{
   return this.display.get_player_position();
}
EVR.Level.Map.prototype.hide_ghost_indicator = function()
{
   this.display.hide_ghost_indicator();
}
EVR.Level.Map.prototype.toString = function()
{
   return "[object EVR.Level.Map]";
}
EVR.Level.Map.Indicator = function(display, opacity)
{
   this.display = display;
   this.cells = display.row.cells;
   this.border_width = INDICATOR_BORDER_WIDTH;
   this.current = -1;
   this.opacity = opacity;
   this.attached = false;
   this.build_outer();
   this.build_inner();
   this.draw();
}
EVR.Level.Map.Indicator.prototype.build_outer = function()
{
   var element = document.createElement("div");
   var cell = this.cells[0];
   var css = element.style;
   css.width = "100%";
   css.background = INDICATOR_BORDER_COLOR;
   css.position = "relative";
   css.opacity = this.opacity;
   css.fontSize = "0px";
   this.element = element;
}
EVR.Level.Map.Indicator.prototype.build_inner = function()
{
   var element = document.createElement("div");
   var css = element.style;
   css.background = INDICATOR_COLOR;
   css.position = "relative";
   css.width = "100%";
   css.top = this.border_width;
   css.fontSize = "0px";
   this.element.appendChild(element);
   this.inner = element;
}
EVR.Level.Map.Indicator.prototype.draw = function(height)
{
   if (height == null)
   {
      height = this.cells[0].clientHeight;
   }
   height -= 2;
   this.element.style.height = height;
   this.inner.style.height = height - this.border_width * 2;
}
EVR.Level.Map.Indicator.prototype.advance = function(ii)
{
   this.current = ii;
   this.append();
}
EVR.Level.Map.Indicator.prototype.append = function()
{
   this.cells[this.current].appendChild(this.element);
   this.attached = true;
}
EVR.Level.Map.Indicator.prototype.remove = function()
{
   if (this.attached)
   {
      this.cells[this.current].removeChild(this.element);
      this.attached = false;
   }
}
EVR.Level.Map.Indicator.prototype.get_position = function()
{
   return this.current;
}
EVR.Level.Map.Indicator.prototype.toString = function()
{
   return "[object EVR.Level.Map.Indicator]";
}
EVR.Level.Records = function(level)
{
   EVR.Table.call(this, level.road, "1%", "100%");
   this.level = level;
   this.history = level.history;
   this.colors = RECORDS_COLORS;
   this.sizes = RECORDS_FONT_SIZES;
   this.lengths = RECORDS_TIER_LENGTHS;
   this.element.style.textAlign = "center";
   this.texts = [];
   this.new_entry_added = false;
   this.set_times();
   this.display();
   this.append();
}
EVR.Level.Records.prototype = new EVR.Table;
EVR.Level.Records.prototype.set_times = function()
{
   this.times = this.history.get_times().sort(this.compare_times);
}
EVR.Level.Records.prototype.compare_times = function(x, y)
{
   if (x.get() < y.get())
   {
      return -1;
   }
   if (x.get() > y.get())
   {
      return 1;
   }
   return 0;
}
EVR.Level.Records.prototype.display = function()
{
   this.insert_rows();
   var times = this.times;
   this.display_first_tier(times.slice(0, 1)[0]);
   this.display_second_tier(times.slice(1, 3));
   this.display_third_tier(times.slice(3));
}
EVR.Level.Records.prototype.insert_rows = function()
{
   var count = this.lengths[2];
   for (var ii = 0; ii < count; ii++)
   {
      var row = this.insert_row();
      if (ii != count - 1)
      {
	 row.style.height = 100 / count + "%";
      }
   }
}
EVR.Level.Records.prototype.display_first_tier = function(time)
{
   var row = this.get_rows()[0];
   var cell = this.insert_cell(row);
   this.fill_cell(cell, time, 0, this.lengths[2]);
}
EVR.Level.Records.prototype.fill_cell = function(cell, time, index, span)
{
   if (!!span)
   {
      cell.rowSpan = span;
   }
   if (!!!time)
   {
      time = RECORDS_BLANK_TIME_TEXT;
   }
   var color = this.determine_font_color(time);
   var font = RECORDS_FONT_FAMILY;
   var size = this.determine_size(index);
   var string = time.toString(RECORDS_PRECISION);
   var container = this.level.container;
   var text = new EVR.Text(cell, string, font, color, size, container);
   this.style_cell(cell, index);
   this.texts.push(text);
}
EVR.Level.Records.prototype.determine_font_color = function(time)
{
   var newest = this.history.get_newest().time;
   if (time instanceof EVR.Time)
   {
      if (!this.new_entry_added && newest.get() == time.get())
      {
	 this.new_entry_added = true;
	 return RECORDS_NEW_FONT_COLOR;
      }
   }
   return RECORDS_FONT_COLOR;
}
EVR.Level.Records.prototype.determine_size = function(index)
{
   var sizes = this.sizes;
   if (index < 1)
   {
      return sizes[0];
   }
   if (index < 3)
   {
      return sizes[1];
   }
   return sizes[2];
}
EVR.Level.Records.prototype.style_cell = function(cell, index)
{
   var style = cell.style;
   style.background = this.determine_background_color(index);
   style.letterSpacing = RECORDS_LETTER_SPACING;
   style.padding = "0 " + RECORDS_PADDING;
   style.verticalAlign = "middle";
   style.fontWeight = RECORDS_FONT_WEIGHT;
   cell.noWrap = true;
}
EVR.Level.Records.prototype.determine_background_color = function(index)
{
   var colors = this.colors;
   if (index < 3)
   {
      return colors[index];
   }
   return colors[3];
}
EVR.Level.Records.prototype.display_second_tier = function(times)
{
   var span, cell, row, row_count = this.lengths[2];
   for (var ii = 0; ii < this.lengths[1]; ii++)
   {
      span = row_count / 2;
      row = this.get_rows()[ii * span];
      cell = this.insert_cell(row);
      this.fill_cell(cell, times[ii], ii + 1, span);
   }
}
EVR.Level.Records.prototype.display_third_tier = function(times)
{
   var cell, row;
   for (var ii = 0; ii < this.lengths[2]; ii++)
   {
      row = this.get_rows()[ii];
      cell = this.insert_cell(row);
      this.fill_cell(cell, times[ii], ii + 3);
   }
}
EVR.Level.Records.prototype.draw = function()
{
   var texts = this.texts;
   for (var ii = 0; ii < texts.length; ii++)
   {
      texts[ii].set_font_size();
   }
}
EVR.Level.Records.prototype.toString = function()
{
   return "[object EVR.Level.Records]";
}
216.73.216.178
216.73.216.178
216.73.216.178
 
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