วันอาทิตย์ที่ 6 กันยายน พ.ศ. 2558

LAB 3 Grade verBlog

void setup(){
  size(400,600);
}


void draw(){
  background(0);
  int longY=height-200; // for resize tab of score , set scale and limit value
  draw_grade(100,100,longY);
  draw_line_score(100,100,longY);
}

//make function for draw text score,and grade
void draw_grade(int X,int Y,int longY){
  textSize(25);
  text("Your Score is "+score(Y,longY),X+50,Y+100);
  grade(score(Y,longY),X,Y);

}

//make function for set grade
void grade(int score,int X,int Y){
    if(score>=80){
      text("Your grade is A",X+50,Y+200);
    }else{
      if(score>=70){
        text("Your grade is B",X+50,Y+200);
      }else{
        if(score>=60){
          text("Your grade is C",X+50,Y+200);
        }else{
          if(score>=50){
            text("Your grade is D",X+50,Y+200);
          }else{
            text("Your grade is F",X+50,Y+200);
          }
        }
      }
    }
  }

// make function for draw line score
void draw_line_score(int X,int Y,int longY){
  stroke(255);
  strokeWeight(1);
  line(X,Y,X,Y+longY);

  stroke(255,0,0);
  strokeWeight(10);
  point(X,pointY(longY,Y)); // make point score

  text("0",X+10,Y);
  text("100",X+10,Y+longY);
}

//make point in y line of point score
int pointY(int longY,int Y){
  int pointY=0;
  if(mouseY>=Y&&mouseY<=Y+longY){
    pointY=mouseY;
  }else if(mouseY<Y){
    pointY=Y;
  }else{
    pointY=Y+longY;
  }
  return pointY;
}

//calculater score function
int score(int Y,int longY){
  int score=0;
  if(mouseY>=Y&&mouseY<=Y+longY){
  score=(mouseY-Y)/(longY/100);
  }
  if(mouseY>Y+longY){
    score=100;
  }

  return score;
}



ไม่มีความคิดเห็น:

แสดงความคิดเห็น