EVR.include("level/cheers/marquee/Spectrum.js");
EVR.Level.Cheers.Marquee = function(
   cheers, color_offset, placement_offset, z_index, opacity)
{
   EVR.Graphic.call(this, cheers);
   this.cheers = cheers;
   this.spectrum = new EVR.Level.Cheers.Marquee.Spectrum(color_offset);
   this.placement_offset = placement_offset || [0, 0];
   this.z_index = z_index || 0;
   this.spectrum_index = CHEERS_SPECTRUM_STARTING_INDEX;
   this.font_size = CHEERS_FONT_SIZE;
   this.opacity = opacity;
   this.glyphs = [];
   this.setAttributes();
   this.append();
}
EVR.Level.Cheers.Marquee.prototype = new EVR.Graphic;
EVR.Level.Cheers.Marquee.prototype.setAttributes = function()
{
   this.set_z(this.z_index);
   this.set_opacity(this.opacity);
   var css = this.css;
   css.fontWeight = "bold";
   css.textAlign = "left";
   css.whiteSpace = "nowrap";
   this.setFontSize();
}
EVR.Level.Cheers.Marquee.prototype.setFontSize = function()
{
   var dimensions = this.cheers.level.container.get_dimensions();
   var modifier = dimensions[1] / dimensions[0];
   var basis = dimensions[0] * modifier;
   var size = parseInt(basis * this.font_size);
   this.css.fontSize = size + "px";
   this.whitespace_length = basis * CHEERS_GLYPH_PADDING;
}
EVR.Level.Cheers.Marquee.prototype.place = function()
{
   EVR.Graphic.prototype.place.call(this, 0, CHEERS_MARQUEE_OFFSET);
   var x = this.get_coordinates()[0] + this.placement_offset[0];
   var y = this.get_coordinates()[1] + this.placement_offset[1];
   this.set_coordinates([x, y]);
}
EVR.Level.Cheers.Marquee.prototype.addCheer = function(cheer)
{
   var parent = this.element;
   for (var ii = cheer.length - 1; ii >= 0; ii--)
   {
      var color = this.spectrum.get(this.spectrum_index);
      this.addGlyph(cheer.charAt(ii), color, ii == cheer.length - 1);
   }
}
EVR.Level.Cheers.Marquee.prototype.addGlyph = function(character, color, pad)
{
   var parent = this.element;
   var element = document.createElement("span");
   element.innerHTML = character;
   element.style.color = color;
   parent.insertBefore(element, parent.firstChild);
   if (pad)
   {
      element.style.paddingRight = this.whitespace_length + "px";
   }
   this.glyphs.push(element);
   this.spectrum_index++;
}
EVR.Level.Cheers.Marquee.prototype.addJeer = function()
{
   var color = CHEERS_JEER_COLOR;
   var jeer = CHEERS_JEER_TEXT;
   for (var ii = jeer.length - 1; ii >= 0; ii--)
   {
      this.addGlyph(jeer.charAt(ii), color, ii == jeer.length - 1);
   }
}
EVR.Level.Cheers.Marquee.prototype.draw = function()
{
   EVR.Graphic.prototype.draw.call(this);
   this.setFontSize();
   var glyph, glyphs = this.glyphs;
   for (var ii = 0; ii < glyphs.length; ii++)
   {
      glyph = glyphs[ii];
      if (parseInt(glyph.style.paddingRight) > 0)
      {
	 glyph.style.paddingRight = this.whitespace_length;
      }
   }
}
EVR.Level.Cheers.Marquee.prototype.toString = function()
{
   return "[EVR.Level.Cheers.Marquee]";
}
EVR.Level.Cheers.Marquee.Spectrum = function(offset)
{
   this.offset = offset;
   this.build();
}
EVR.Level.Cheers.Marquee.Spectrum.prototype.build = function()
{
   var max = 255 - this.offset;
   var count = CHEERS_SPECTRUM_LENGTH;
   var interval = Math.round(count / 6);
   var step = Math.round(max / (interval - 1));
   var component, color, spectrum = [];
   for (var ii = 0; ii < interval; ii++)
   {
      component = step * ii;
      spectrum.push(new EVR.Color([max, component, 0]));
   }
   for (var ii = interval - 1; ii >= 0; ii--)
   {
      component = step * ii;
      spectrum.push(new EVR.Color([component, max, 0]));
   }
   for (var ii = 0; ii < interval; ii++)
   {
      component = step * ii;
      spectrum.push(new EVR.Color([0, max, component]));
   }
   for (var ii = interval - 1; ii >= 0; ii--)
   {
      component = step * ii;
      spectrum.push(new EVR.Color([0, component, max]));
   }
   for (var ii = 0; ii < interval; ii++)
   {
      component = step * ii;
      spectrum.push(new EVR.Color([component, 0, max]));
   }
   for (var ii = interval - 1; ii >= 0; ii--)
   {
      component = step * ii;
      spectrum.push(new EVR.Color([max, 0, component]));
   }
   this.spectrum = spectrum;
}
EVR.Level.Cheers.Marquee.Spectrum.prototype.get = function(index)
{
   var spectrum = this.spectrum;
   return spectrum[index % spectrum.length].get_string();
}
EVR.Level.Cheers.Marquee.Spectrum.toString = function()
{
   return "[object EVR.Level.Cheers.Marquee.Spectrum]";
}
EVR.include("level/loader/Parser.js");
EVR.Level.Loader = function(level)
{
   this.level = level;
}
EVR.Level.Loader.prototype.load = function()
{
   this.build_requester();
   var document = this.requester.execute();
   this.parser = new EVR.Level.Loader.Parser(this.level, document);
}
EVR.Level.Loader.prototype.build_requester = function()
{
   var path = SOURCE_PATH + "level/loader/fetch.php";
   var query = "id=" + this.level.id;
   this.requester = new EVR.Requester(path, query);
}
EVR.Level.Loader.prototype.toString = function()
{
   return "[object EVR.Level.Loader]";
}
EVR.Level.Loader.Parser = function(level, document)
{
   this.level = level;
   this.root = document.getElementsByTagName("level")[0];
   this.parse();
}
EVR.Level.Loader.Parser.prototype.parse = function()
{
   this.parse_attributes();
   this.parse_sky();
   this.parse_beams();
   this.parse_path();
}
EVR.Level.Loader.Parser.prototype.parse_attributes = function()
{
   var level = this.level;
   var root = this.root;
   level.background = root.getAttribute("background");
   level.goal = new EVR.Time(root.getAttribute("goal"));
   level.advanced = new EVR.Time(root.getAttribute("advanced"));
   level.threshold = parseFloat(root.getAttribute("threshold"));
   level.sound.set_song(root.getAttribute("song"));
}
EVR.Level.Loader.Parser.prototype.parse_sky = function()
{
   var node = this.root.getElementsByTagName("sky")[0];
   var tags = node.getElementsByTagName("background");
   var sky = this.level.sky = [];
   for (var ii = 0; ii < tags.length; ii++)
   {
      sky.push(tags[ii].getAttribute("color"));
   }
}
EVR.Level.Loader.Parser.prototype.parse_beams = function()
{
   var node = this.root.getElementsByTagName("beams")[0];
   var tags = node.getElementsByTagName("beam");
   this.level.beams = [];
   for (var ii = 0; ii < tags.length; ii++)
   {
      this.level.beams.push(tags[ii].getAttribute("color"));
   }
}
EVR.Level.Loader.Parser.prototype.parse_path = function()
{
   var node = this.root.getElementsByTagName("path")[0];
   var tags = node.getElementsByTagName("cluster");
   this.level.clusters = [];
   for (var ii = 0; ii < tags.length; ii++)
   {
      this.add_cluster(tags[ii]);
   }
}
EVR.Level.Loader.Parser.prototype.add_cluster = function(tag)
{
   var level = this.level;
   var passage = tag.getAttribute("passage");
   var width = tag.getAttribute("width");
   var gap = tag.getAttribute("gap");
   var cluster = new EVR.Level.Cluster(passage, width, gap, level.practice);
   level.clusters.push(cluster);
}
EVR.Level.Loader.Parser.prototype.toString = function()
{
   return "[object EVR.Level.Loader.Parser]";
}
3.238.121.7
3.238.121.7
3.238.121.7
 
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