class SpeedChange extends ScrollElement
{
 
  protected int m_speedChangeAmt;
  protected float m_speedFactor;
  protected PFont m_helperFont;
  
  public SpeedChange(Staff staff, int x, int y, int oldAmt, int newAmt)
  {
    super(staff,x,y);
    
    m_speedChangeAmt = newAmt;
    m_speedFactor = (float)oldAmt / newAmt;
    
    m_helperFont = loadFont("Helvetica-20.vlw"); 
  }
  
  public boolean isNote() { return false; }
  public boolean isSpeedChange() { return true; }
  
  public int getSpeedChange() { return m_speedChangeAmt; }
  
  // When this element hits the boundary, change the speed of the game
  public void hitBoundary()
  {
    m_staff.setScrollSpeed(m_speedChangeAmt);
    super.hitBoundary();
  }
  
  public void draw()
  {
    int w = 20;
    int h = 20;
    
    fill(0);
    rect(m_x, m_y, w, h);
    textFont(m_helperFont);
    
    if (m_speedFactor > 1) // slower
    {
      textAlign(CENTER);
      text("slower", m_x + w/2, m_y - 10);
      textAlign(LEFT);
    }
    else // faster
    {
      textAlign(CENTER);
      text("faster", m_x + w/2, m_y - 10);
      textAlign(LEFT);
    }
  }
  
}
