Advertisement
AlgicosathlonFun

Algotriacontathlon Source Code

Sep 17th, 2023 (edited)
1,758
2
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 3.91 KB | Source Code | 2 0
  1. int[] start = {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0};
  2. int[] toadd = {70,100,500,4,350,125,175,275,300,400,25,1,6,150,325,30,225,250,10,3,50,15,2,40,20,450,8,375,200,12};
  3. String[] names = {"Magenta","Purple","Tan","Orange","Lime","Red","Blue","Lavender","Yellow","Brown","Gray","Navy","Olive","Pink","Cyan","Green","White","Black","Mint","Scarlet","Gold","Silver","RoyalBlue","LightBrown","Sky","Cream","Teal","Lilac","Maroon","Crimson"};
  4. int[] waias = {0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30};
  5. int[] waiae = {0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30};
  6. boolean[] taken = {false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,
  7. false,false,false,false,false,false,false,false,false,false,false,false,false,false};
  8. int timer, maxScore, x, y;
  9. 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},{130,130,0},{248,174,207},{0,255,255},{0,145,0},{255,255,255},{65,65,65},{191,248,151},{255,55,0},{255,190,4},{192,192,192},{0,0,255},{174,127,0},{143,216,245},{249,248,158},{49,133,156},{238,188,248},{130,0,0},{220,20,60}};
  10. String[] after = {"st","nd","rd","th","th","th",
  11. "th","th","th","th","th","th","th","th","th","th","th","th","th","th","st","nd","rd","th","th","th","th","th","th","th","st"};
  12. PFont font;
  13. PFont font2;
  14. int margin = 250;
  15. float perc = 0;
  16. void setup(){
  17.   font = loadFont("Helvetica-48.vlw");
  18.   font2 = loadFont("HelveticaNeueLTCom-BlkCn-48.vlw");
  19.   size(1530,960);    
  20.   for(int i = 0; i < 30; i++){
  21.     int record = 0;
  22.     int recordHolder = 0;
  23.     for(int j = 29; j >= 0; j--){
  24.       if(start[j] >= record && !taken[j]){
  25.         record = start[j];
  26.         recordHolder = j;
  27.       }
  28.     }
  29.     taken[recordHolder] = true;
  30.     waias[recordHolder] = i;
  31.   }
  32.   for(int i = 0; i < 30; i++){
  33.     taken[i] = false;
  34.   }
  35.   for(int i = 0; i < 30; i++){
  36.     int record = 0;
  37.     int recordHolder = 0;
  38.     for(int j = 29; j >= 0; j--){
  39.       if(start[j]+toadd[j] >= record && !taken[j]){
  40.         record = start[j]+toadd[j];
  41.         recordHolder = j;
  42.       }
  43.     }
  44.     taken[recordHolder] = true;
  45.     waiae[recordHolder] = i;
  46.     if(i == 0) maxScore = record;
  47.   }
  48.   textFont(font,30);
  49.   noStroke();
  50.   frameRate(60);
  51. }
  52. void draw(){
  53.   background(0);
  54.   if(timer < 1200){
  55.     fill(80);
  56.     rect(0,0,margin,height);
  57.     timer++;
  58.     textAlign(RIGHT);
  59.     fill(255);
  60.     for(int i = 0; i < 30; i++){
  61.       text((i+1)+after[i],margin-100,27+32*i);
  62.     }
  63.     if(timer < 480){
  64.       perc = max((float(timer)-180)/300,0);
  65.     }else{
  66.       perc = min(max((float(timer)-480)/300,0),1);
  67.       perc = -cos(perc*PI)/2+0.5;
  68.     }
  69.     for(int j = 0; j < 30; j++){
  70.       fill(colors[j][0],colors[j][1],colors[j][2]);
  71.       if(timer < 480){
  72.         x = int(790*(start[j]+float(toadd[j])*perc)/maxScore);
  73.         y = 32*waias[j];
  74.       }else{
  75.         x = int(790*(start[j]+toadd[j])/maxScore);
  76.         y = int((waias[j]+(float(waiae[j])-float(waias[j]))*perc)*32);
  77.       }
  78.       rect(margin,5+y,x,25.5);
  79.       textAlign(LEFT);
  80.       text(names[j],margin+x+5,27+y);
  81.       fill(0);
  82.       textAlign(RIGHT);
  83.       if(timer < 480){
  84.         text(addCommas(round((start[j]+toadd[j]*perc))),margin+x,27.5+y);
  85.       }else{
  86.         text(addCommas(start[j]+toadd[j]),margin+x,27.5+y);
  87.       }
  88.       if(waiae[j] >= 30){
  89.         fill(255,25,0);
  90.         textFont(font2,33);
  91.         textAlign(LEFT);
  92.         text("ELIMINATED",names[j].length()*20+305+x,27+y);
  93.         textFont(font,30);
  94.       }
  95.     }
  96.     saveFrame("images\\####.png");
  97.   }
  98. }
  99. String addCommas(int n){
  100.   String s = n+"";
  101.   String output = "";
  102.   for(int i = 0; i < s.length(); i++){
  103.     if(i >= 1 && (s.length()-i)%3 == 0){
  104.       output = output+",";
  105.     }
  106.     output = output+s.charAt(i);
  107.   }
  108.   return output;
  109. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement