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);
text("Your grade is "+grade(score(Y,longY)),X+50,Y+200);
}
//make function for set grade
char grade(int score){
char grade= 'A';
if(score>=80){
grade='A';
}else{
if(score>=70){
grade='B';
}else{
if(score>=60){
grade='C';
}else{
if(score>=50){
grade='D';
}else{
grade ='F';
}
}
}
}
return grade;
}
// 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;
}
ไม่มีความคิดเห็น:
แสดงความคิดเห็น