EVR.Level.Prompt = function(level)
{
   this.level = level;
   this.initialize();
   this.append();
}
EVR.Level.Prompt.prototype = new EVR.Prompt;
EVR.Level.Prompt.prototype.initialize = function()
{
   var container = this.level.container;
   var text = LEVEL_START_PROMPT_TEXT;
   var color = LEVEL_PROMPT_COLOR;
   var size = LEVEL_PROMPT_SIZE;
   var background = LEVEL_PROMPT_BACKGROUND;
   var depth = LEVEL_PROMPT_DEPTH;
   var offset = [null, ROAD_OFFSET];
   EVR.Prompt.call(
      this, container, text, color, size, background, depth, null, offset);
}
EVR.Level.Prompt.prototype.set_finish_text = function()
{
   var level = this.level;
   var text = LEVEL_FINISHED_PROMPT_TEXT;
   if (level.id == LEVEL_LIMIT && level.is_clear())
   {
      text += ", " + LEVEL_VIEW_ENDING_PROMPT_TEXT;
   }
   else if (level.next_level_is_available())
   {
      text = LEVEL_CLEAR_PROMPT_TEXT;
   }
   this.set_text(text);
}
EVR.Level.Prompt.prototype.toggle = function()
{
   var attached = this.attached;
   attached && this.remove();
   !attached && this.append();
}
EVR.Level.Prompt.prototype.toString = function()
{
   return "[object EVR.Level.Prompt]";
}
EVR.include("level/cheers/marquee/Marquee.js");
EVR.Level.Cheers = function(level)
{
   EVR.Graphic.call(this, level.container, null, null, ALIGN_TOP);
   EVR.Animation.call(this, CHEERS_ANIMATION_RATE);
   this.level = level;
   this.cheer_texts = CHEERS_TEXTS;
   this.boost_bounds = [CHEERS_MIN_BOOST_LENGTH, CHEERS_MAX_BOOST_LENGTH];
   this.drag_threshold = CHEERS_DRAG_THRESHOLD;
   this.step = CHEERS_SCROLL_STEP;
   this.delay = CHEERS_SCROLL_DELAY;
   this.last_time = null;
   this.boost_length = null;
   this.drag_length = null;
   this.scrolling = false;
   this.setAttributes();
   this.append();
   this.background = new EVR.Level.Cheers.Marquee(
      this, CHEERS_SHADOW_COLOR_OFFSET, CHEERS_SHADOW_OFFSET,
      CHEERS_SHADOW_OPACITY);
   this.foreground = new EVR.Level.Cheers.Marquee(
      this, null, null, CHEERS_FOREGROUND_Z_INDEX, CHEERS_FOREGROUND_OPACITY);
}
EVR.Level.Cheers.prototype = new EVR.Graphic;
EVR.inherit(EVR.Level.Cheers, EVR.Animation);
EVR.Level.Cheers.prototype.setAttributes = function()
{
   this.set_proportions(CHEERS_MARQUEE_WIDTH, CHEERS_MARQUEE_HEIGHT);
   this.place(0, CHEERS_MARQUEE_OFFSET);
   this.css.overflow = "hidden";
}
EVR.Level.Cheers.prototype.scroll = function()
{
   var marquee_length = this.calculateScrollLength();
   var width = this.get_dimensions()[0];
   var cutoff = -marquee_length + width * (1 - CHEERS_SCROLL_PADDING);
   this.scrolling = true;
   this.play(null, this.delay, cutoff);
}
EVR.Level.Cheers.prototype.calculateScrollLength = function()
{
   var length = 0;
   var glyphs = this.foreground.glyphs;
   for (var ii = 0; ii < glyphs.length; ii++)
   {
      length += glyphs[ii].offsetWidth;
   }
   return length;
}
EVR.Level.Cheers.prototype.sequence = function(cutoff)
{
   var step = this.step;
   var foreground = this.foreground;
   var background = this.background;
   var foreground_x = foreground.get_coordinates()[0] - step;
   var background_x = background.get_coordinates()[0] - step;
   if (background_x < cutoff)
   {
      foreground_x = 0;
      background_x = 0;
      this.stop();
      this.play(null, this.delay, cutoff);
   }
   foreground.set_coordinates([foreground_x]);
   background.set_coordinates([background_x]);
}
EVR.Level.Cheers.prototype.update = function(sprinting, speed)
{
   if (this.level.practice)
   {
      return;
   }
   var time = this.level.clock.time.get();
   var interval = time - this.last_time;
   this.last_time = time;
   this.updateBoostTimer(sprinting, speed, interval);
   this.updateDragTimer(sprinting, speed, interval);
}
EVR.Level.Cheers.prototype.updateBoostTimer =
   function(sprinting, speed, interval)
{
   if (sprinting && speed == PATH_SPRINT_SPEED)
   {
      this.boost_length += interval;
      if (this.boost_length >= this.boost_bounds[1])
      {
	 this.addCheer();
	 this.boost_length = 0;
      }
   }
   else if (this.boost_length != 0)
   {
      this.addCheer();
      this.boost_length = 0;
   }
}
EVR.Level.Cheers.prototype.addCheer = function()
{
   var length = this.boost_length;
   var bounds = this.boost_bounds;
   if (length >= bounds[0])
   {
      this.drag_length = 0;
      if (length > bounds[1])
      {
	 this.boost_length = bounds[1];
      }
      var cheer = this.determineCheerText();
      this.foreground.addCheer(cheer);
      this.background.addCheer(cheer);
   }
}
EVR.Level.Cheers.prototype.determineCheerText = function()
{
   var bounds = this.boost_bounds;
   var range = bounds[1] - bounds[0];
   var offset = this.boost_length - bounds[0];
   var texts = this.cheer_texts;
   var index = Math.round((texts.length - 1) * (offset / range));
   return texts[index];
}
EVR.Level.Cheers.prototype.updateDragTimer = 
   function(sprinting, speed, interval)
{
   if (speed < PATH_INITIAL_SPEED || (speed < PATH_SPRINT_SPEED && sprinting))
   {
      this.drag_length += interval;
      if (this.drag_length >= this.drag_threshold)
      {
	 this.addJeer();
	 this.drag_length = 0;
      }
   }
}
EVR.Level.Cheers.prototype.addJeer = function()
{
   this.foreground.addJeer();
   this.background.addJeer();
}
EVR.Level.Cheers.prototype.draw = function()
{
   EVR.Graphic.prototype.draw.call(this);
   if (!!this.foreground)
   {
      this.foreground.draw();
      this.background.draw();
   }
   if (this.scrolling)
   {
      this.stop();
      this.scroll();
   }
}
EVR.Level.Cheers.prototype.remove = function()
{
   EVR.Graphic.prototype.remove.call(this);
   if (!!this.foreground)
   {
      this.foreground.remove();
      this.background.remove();
   }
   if (this.scrolling)
   {
      this.stop();
      this.scrolling = false;
   }
}
EVR.Level.Cheers.prototype.toString = function()
{
   return "[object EVR.Level.Cheers]";
}
18.97.14.88
18.97.14.88
18.97.14.88
 
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