Serial myPort; // Create object from Serial class float value; String inBuffer; int state=0; float tim; float demo=0; int lf = 10; float tmp; float[] rank= new float[5]; String[] rankSt= new String[5]; String[] name= new String[5]; int ranking; int nchar=95; // '_' int poschar=0; String inputName;
if (state==7){ // ランキング表示 dispRank(); tim=millis()+5000; state=8; }
if (state==8){ // 時間が建ったら最初に戻す if (millis()>tim){ demo=millis(); // デモに行かないようにデモの待ち時間をリセット state=0; } }
}
int checkRank(){ int i,j; for (i=0;i<5;i++){ if (rank[i]>value){ for(j=4; j>i; j--){ rank[j]=rank[j-1]; name[j]=name[j-1]; } rank[i]=value; break; } } return(i); }
void dispRank(){ background(0); textSize(100); text("Ranking",50,100); textSize(50); text("1:",100,200); if (rank[0]<100){ text(rank[0],150,200); text(name[0],400,200); } text("2:",100,280); if (rank[1]<100){ text(rank[1],150,280); text(name[1],400,280); } text("3:",100,360); if (rank[2]<100){ text(rank[2],150,360); text(name[2],400,360); } text("4:",100,440); if (rank[3]<100){ text(rank[3],150,440); text(name[3],400,440); } text("5:",100,520); if (rank[4]<100){ text(rank[4],150,520); text(name[4],400,520); } textSize(100); text("*",40, ranking*80+235); saveStrings("rankName.txt",name); for(int i=0;i<5;i++) rankSt[i]= Float.toString(rank[i]); saveStrings("ranking.txt", rankSt); }