// Door

class Door extends Sprite {
  boolean isPlayerOverMe;
  int type = 0; // 0 is blue, 1 is red
  
  Door(int Type, float X,float Y) {
    type = Type;
    x = X;
    y = Y;
    w = 100;
    h = 180;
  }
  
  void draw() {
    float transparency = 255;
    
    isPlayerOverMe = abs(this.x-player.x) < this.w;
    if (isPlayerOverMe) transparency = 140+sin(frameCount*0.3)*40;
    
    noStroke();
    
    pushMatrix();
    translate(x,y);
    fill(230);
    rect(0,-h*0.5, w+20,h+20);
    
    if (type == 0) {
      fill(140,255,120, transparency);
    }
    else if (type == 1) {
      fill(14,255,160, transparency);
    }
    rect(0,-h*0.5, w,h);
    
    fill(36,255,255, transparency);
    ellipse(w*0.4,-h*0.4, w*0.2,w*0.2);
    popMatrix();
    
    if (isPlayerOverMe && keyDown_UP) {
      sequenceController.alert("doorOpened", type+"");
    }
  }
  
}
