xxxxxxxxxx
// Feel free to copy and paste without giving credit
var names = [ "Magenta", "Purple", "Tan", "Orange", "Lime", "Red", "Blue", "Lavender", "Yellow", "Brown", "Gray", "Navy", "Olive", "Pink", "Cyan", "Green" ]
var colors = [{r:255,g:0,b:255},{r:120,g:0,b:255},{r:210,g:180,b:140},{r:255,g:120,b:0},{r:0,g:255,b:0},{r:255,g:0,b:0},{r:0,g:120,b:255},{r:202,g:145,b:222},{r:255,g:255,b:0},{r:130,g:65,b:0},{r:120,g:120,b:120},{r:0,g:30,b:145},{r:120,g:120,b:0},{r:244,g:177,b:200},{r:0,g:255,b:255},{r:0,g:145,b:0}]
var startingPoints = [302,14125,1,4843,18140,7330,94,12614,14692,154,2211,445,3367,13576,22,1516]
var endingPoints = [452,14125,1,4843,18140,13576,13576,12614,14692,154,2211,445,3367,13576,22,1516]
var addPoints = [0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0]
var mode = 1
// If mode is 0 the program will add the points from line 8. If this mode 1, the program will set the end points from line 7
var ejectionCount = 1; // This is how many athletes will be ejected.
var eliminationCount = 10; // This is how many athletes will be eliminated
var eliminatedText = "ELIMINATED" // This is the text that is shown when an athlete is eliminated
var ejectionText = "Has been ELIMINATED and Red and Blue has REJOINED." // This is the text that is shown when an athlete is ejected
var waitSecs = 2; // This is how many seconds until the movement starts
var moveTime = 7; // This is how many seconds the movement will last
var waitEject = 2; // This is how many seconds until the eliminated athletes are ejected
var players = 16 // if you make this higher, you should add more athletes to the top
var font = "GoldmanSans_Rg.ttf" // Change your font here
var doFont = true // Change this to false if you don't want a font
function setup() {
createCanvas(windowWidth, windowHeight);
background(100);
if(ejectionCount>eliminationCount){ejectionCount=eliminationCount}
waitSecs=round(waitSecs)
moveTime=round(moveTime)
startingScores=startingPoints
endingScores=endingPoints
if(mode==0){endingScores=[];for(let i=0;i<players;i++){endingScores.push(startingPoints[i]+addPoints[i])}}
mi = startingScores[0]
ma = startingScores[0]
for(let i=0;i<startingScores.length;i++){
if(startingScores[i]>ma){
ma=startingScores[i]
}
if(startingScores[i]<mi){
mi=startingScores[i]
}
}
mi2 = endingScores[0]
ma2 = endingScores[0]
for(let i=0;i<endingScores.length;i++){
if(endingScores[i]>ma2){
ma2=endingScores[i]
}
if(endingScores[i]<mi2){
mi2=endingScores[i]
}
}
for(let i=0;i<players;i++){
let place = 0;
for(let p=0;p<players;p++){
if(endingScores[i]<endingScores[p]){
place+=1
}
if(endingScores[i]==endingScores[p]&&i!==p){
if(i>p){place+=1}
}
}
let place2 = 0;
for(let p=0;p<players;p++){
if(startingScores[i]<startingScores[p]){
place2+=1
}
if(startingScores[i]==startingScores[p]&&i!==p){
if(i>p){place2+=1}
}
}
if(names.length<i+1){
names[i]="undefined"
}
if(colors.length>=i+1){
sc.push(new Score(120,(height/players)*(place2),color(colors[i].r,colors[i].g,colors[i].b),names[i],startingScores[i],(height/players-6),endingScores[i],(height/players)*(place),place))}
else{
sc.push(new Score(120,(height/players)*(place2),color(random(300),random(200),random(300)),names[i],startingScores[i],(height/players-6),endingScores[i],(height/players)*(place),place))
}
}
for(let i=0;i<sc.length;i++){
if(players-sc[i].place-1<eliminationCount){
dead.push({name:sc[i].name,col:sc[i].col,place:sc[i].place})
}
}
for(let i=0;i<dead.length;i++){
dead2[round(players-dead[i].place-1)]=({name:dead[i].name,col:dead[i].col,place:dead[i].place})
}
num=dead2.length-1
for(let i=0;i<60;i++){
stars.push(new Star())
}
}
var sc = [];
var dead2=[]
p5.disableFriendlyErrors = true;
function preload(){
font2 = loadFont(font);
floatImg=loadImage("any.png")
font3 = loadFont("ARI.ttf")
}
var home = 0
var floatX =-100
var rot = 0;
var rotV=8
var num=0
var eText2=""
var ind=0
var grow=1;
var stars=[]
function draw() {
angleMode(DEGREES)
imageMode(CENTER)
floatImg.resize(75,0)
frameRate(30);
if(home==1){
background(0);
for(let i=0;i<stars.length;i++){
stars[i].show()
}
noStroke()
if(num>=eliminationCount-ejectionCount){
floatX+=15
rot-=rotV
rotV-=0.05
textSize(30)
push()
textFont(font3)
textAlign(CENTER)
fill(255);
let eText = split(dead2[num].name+" "+ejectionText,'')
if(frameCount%2==0&&floatX>width/2&&(ind)<eText.length){eText2+=eText[ind];ind++}
text(eText2,width/2,height/2)
if(floatX>width+500){
textSize(grow)
text(players-eliminationCount+" Athletes remain.",width/2,height/2+40)
if(grow<30){
grow+=5}
}
pop()
push()
translate(floatX,height/2-10)
rotate(rot*1)
noStroke();
fill(dead2[num].col)
ellipse(1,0,40,30)
ellipse(20,20,10,10)
ellipse(20,25,10,10)
ellipse(0,20,8,8)
ellipse(-7,15,12,8)
ellipse(-14,15,12,8)
ellipse(-19,10,8,8)
ellipse(15,10,10,10)
ellipse(27,10,7,10)
ellipse(27,5,7,10)
ellipse(25,-1,4,4)
ellipse(17,15,10,10)
ellipse(-9,0,30,30)
ellipse(-9,-11,40,30)
ellipse(9,0,30,30)
ellipse(-2,-10,30,30)
ellipse(5,-5,30,30)
image(floatImg,0,0)
pop()
}else{home=0}
if(floatX>width+1000){
num--
eText2=""
ind=0
grow=0;
floatX=-100
rot=0;
rotV=8
}
}
if(home == 0){
if(frameCount>(waitSecs+moveTime+waitEject)*30+4){
home=1
}
background(0);
for(let i=0;i<stars.length;i++){
stars[i].show()
}
noStroke();
if(doFont){
textFont(font2)
}
for(let i=0;i<sc.length;i++){
sc[i].show()
}
fill(80);
rect(45,0,170,height)
textAlign(CENTER,CENTER)
fill(255)
textSize((height/players-1))
for(let i=0;i<players;i++){
su="th"
if(i==0){su="st"}
if(i==1){su="nd"}
if(i==2){su="rd"}
if(i==20){su="st"}
if(i==21){su="nd"}
if(i==22){su="rd"}
if(i==30){su="st"}
if(i==31){su="nd"}
if(i==32){su="rd"}
if(i==40){su="st"}
if(i==41){su="nd"}
if(i==42){su="rd"}
text((i+1)+su,170-45,(height/players)*(i+0.1)+((height/players-1)/2)-7)
}
textSize(11)
textAlign(RIGHT,BOTTOM)
text("EliK",width,height)
}
}
var dead = []
function Score(x,y,col,name,s,size,es,y2,place){
this.x = x
this.y = y+3
this.y2 = y2
this.place = place;
this.y3 = y
if(players>30){this.size = size+6}else{
this.size = size}
this.col = col
this.name = name
this.s = s
this.s2 = s
this.es = es
this.w=330+map(s,mi2,ma2,0,width/2)
this.w3=330+map(s,mi2,ma2,0,width/2)
this.w2=330+map(es,mi2,ma2,0,width/2)
this.show=function(){
fill(this.col)
textSize(this.size)
rect(this.x,this.y,this.w-x,this.size)
fill(0);
textAlign(RIGHT,TOP)
text(round(this.s),this.w,this.y)
textAlign(LEFT,TOP)
fill(this.col)
text(this.name,this.w+10,this.y)
if(frameCount>waitSecs*30&&frameCount<=waitSecs*30+(moveTime*30*0.5)){
this.s-=(this.s2-this.es)/(moveTime*30*0.5)
this.w-=(this.w3-this.w2)/(moveTime*30*0.5)
}
if(frameCount>waitSecs*30+(moveTime*30*0.5)&&frameCount<=waitSecs*30+(moveTime*30)){
this.y+=-(this.y3-this.y2)/(moveTime*30*0.5)
}
if(players-this.place-1<eliminationCount){
textAlign(LEFT,TOP)
fill(255,0,0)
textSize(this.size)
text(eliminatedText,this.w+textWidth(this.name)+20,this.y)
}
}
}
function Star(){
this.x=random(width)
this.y=random(height)
this.xVel=random(1,3)
this.size=random(1,5)
this.show=function(){
strokeWeight(this.size)
stroke(255)
point(this.x,this.y)
this.x+=this.xVel
if(this.x>width+20){
this.x=-20;
this.y=random(height);
this.xVel=random(1,3)
this.size=random(1,5)
}
}
}
// Code by EliK