Advertisement
MLPE1260

Untitled

Dec 15th, 2019
2,397
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. int[] start = {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0};
  2. int[] toadd = {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0};
  3. String[] names ={"Magenta","Purple","Tan","Orange","Lime","Red","Blue","Lavender","Yellow","Brown","Gray","Navy","Olive","Pink","Cyan","Green"};
  4. int[] waias = {0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15};
  5. int[] waiae = {0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15};
  6. boolean[] taken = {false,false,false,false,
  7. false,false,false,false,false,false,false,false,
  8. false,false,false,false};
  9. int timer, maxScore, x, y;
  10. int[][] colors = {{255,0,255},{120,0,255},{210,180,140},{255,120,0},{0,255,0},{255,0,0},{0,120,255},{202,145,222},{255,255,0},{130,65,0},{120,120,120},{0,30,145},{120,120,0},{255,100,255},{0,255,255},{0,145,0}};
  11. String[] after = {"st","nd","rd","th","th","th",
  12. "th","th","th","th","th","th","th","th","th","th"};
  13. PFont font;
  14. PFont font2;
  15. int margin = 100;
  16. float perc = 0;
  17. void setup(){
  18.   font = loadFont("Arial-BoldMT-48.vlw");
  19.   font2 = loadFont("Impact-48.vlw");
  20.   size(1280,720);
  21.   for(int i = 0; i < 16; i++){
  22.     int record = 0;
  23.     int recordHolder = 0;
  24.     for(int j = 15; j >= 0; j--){
  25.       if(start[j] >= record && !taken[j]){
  26.         record = start[j];
  27.         recordHolder = j;
  28.       }
  29.     }
  30.     taken[recordHolder] = true;
  31.     waias[recordHolder] = i;
  32.   }
  33.   for(int i = 0; i < 16; i++){
  34.     taken[i] = false;
  35.   }
  36.   for(int i = 0; i < 16; i++){
  37.     int record = 0;
  38.     int recordHolder = 0;
  39.     for(int j = 15; j >= 0; j--){
  40.       if(start[j]+toadd[j] >= record && !taken[j]){
  41.         record = start[j]+toadd[j];
  42.         recordHolder = j;
  43.       }
  44.     }
  45.     taken[recordHolder] = true;
  46.     waiae[recordHolder] = i;
  47.     if(i == 0) maxScore = record;
  48.   }
  49.   textFont(font,40);
  50.   noStroke();
  51.   frameRate(60);
  52. }
  53. void draw(){
  54.   background(0);
  55.   if(timer < 1200){
  56.     fill(80);
  57.     rect(0,0,margin,height);
  58.     timer++;
  59.     textAlign(LEFT);
  60.     fill(255);
  61.     for(int i = 0; i < 16; i++){
  62.       text((i+1)+after[i],margin-93,35+45*i);
  63.     }
  64.     if(timer < 480){
  65.       perc = max((float(timer)-180)/300,0);
  66.     }else{
  67.       perc = min(max((float(timer)-480)/300,0),1);
  68.       perc = -cos(perc*PI)/2+0.5;
  69.     }
  70.     for(int j = 0; j < 16; j++){
  71.       fill(colors[j][0],colors[j][1],colors[j][2]);
  72.       if(timer < 480){
  73.         x = int(1020*(start[j]+float(toadd[j])*perc)/maxScore);
  74.         y = 45*waias[j];
  75.       }else{
  76.         x = int(1020*(start[j]+toadd[j])/maxScore);
  77.         y = int((waias[j]+(float(waiae[j])-float(waias[j]))*perc)*45);
  78.       }
  79.       rect(margin,5+y,x,35);
  80.       textAlign(LEFT);
  81.       text(names[j],margin+x+5,35+y);
  82.       fill(0);
  83.       textAlign(RIGHT);
  84.       if(timer < 480){
  85.   text(addCommas(round((start[j]+toadd[j]*perc))),margin+x,35+y);
  86.       }else{
  87.         text(addCommas(start[j]+toadd[j]),margin+x,35+y);
  88.       }
  89.       if(waiae[j] >= 16){
  90.         fill(255,25,0);
  91.         textFont(font2,44);
  92.         textAlign(LEFT);
  93.         text("ELIMINATED",names[j].length()*20+130+x,37+y);
  94.         textFont(font,40);
  95.       }
  96.     }
  97.     //saveFrame("images\\####.png");
  98.   }
  99. }
  100. String addCommas(int n){
  101.   String s = n+"";
  102.   String output = "";
  103.   for(int i = 0; i < s.length(); i++){
  104.     if(i >= 1 && (s.length()-i)%3 == 0){
  105.       output = output+",";
  106.     }
  107.     output = output+s.charAt(i);
  108.   }
  109.   return output;
  110. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement