//// Olympics of Athena!!!! race: String title= "Qlympics of Athena!!!!"; String z=""; String ClosetothefrontLine=""; String author= "Dalin Scarver"; float surface, bottom, sideX, sideY; float Thor, Freiya, ZolY, resetY; float wave=50; int many=10; int race=0, count=0, Champ=-1, champion=-1, delay=0; float sunX,sunY; boolean day=true; int idle=0, maxidle=60; String names[]= { "Zeus", "Odin", "Kronnos", "Loki", "Horus", "Osiris", "Apollo", "Helen", "Sonne", "Neferiti" }; Contenders warrior[]= new Contenders[10]; ////// Setup: screen size, create array, etc. void setup() { size( 800, 600 ); surface= height/4; bottom= height-100; sideX= width-180; sideY= height-280; // Thor= 200; Freiya= surface+120; ZolY= surface+180; resetY= height-80; reset(); } ////// Array of contenderss void reset() { champion= -1; float x= 30; many= int( random(5,10.5) ); if (count==0) many=10; for (int d=0; dmaxidle ) { text( "IDLE > "+ maxidle +" ticks; \nbegin AUTOPILOT.", 20, height-80 ); if (idle % 10 == 0) { if ( champion<0) race(); if (idle>600) reset(); } } } void scene() { if (day) background( #1BACF2 ); else background(#404183); sun(); fill( 0, 80, 40 ); noStroke(); rectMode(CORNER); rect( 0, surface, width, height*3/4 ); // Sea // Waves. if (day) fill( #1BACF2 ); else fill(#404183); for( float x=0; x=0 & champion <0) { fill( warrior[Champ].r, warrior[Champ].g, warrior[Champ].b ); text( warrior[Champ].name + " progressing to becoming the next Champion!", width/8, 130 ); text( warrior[Champ].name + " progressing to becoming the next Champion!", width/8, height-10 ); warrior[Champ].crown(); } } void sun() { if (day) { fill(#F3FC00); } else { fill(#F0F0F0); // Moon colors. (Use sun x y ) } stroke(#4D4A49); strokeWeight(1); ellipse( sunX, sunY, 40,40 ); // sunX -= 1; if (sunX<30) { sunX= width; sunY= random( surface-50 ); day= ! day; } } //////// BUTTONS //////// void buttons() { // GO button, to move upward. textSize(12); text( "Click GO to move all upward.", sideX, Thor-10 ); fill( #F00C64 ); stroke( 0 ); button( " G O ", sideX, Thor ); // Buttons to drop back textSize(10); fill( 255,255,0); text( "Click to return back.", sideX, surface+110 ); fill( #F01F0C ); stroke( 255,0,0 ); button( " ALL back", sideX, Freiya ); fill( #FFFFFF ); stroke(0 ); button( "Champ back", sideX, ZolY ); // RESET fill( #86FF24 ); stroke( 0 ); button( "RESET", sideX, resetY ); } void action() { // Now, reveal all of the warriors. fill( 255,0,255 ); revealAll( warrior, many ); // if (champion>=0) { textSize(20); fill( 255, 0, 0 ) ; text( "G A M E O V E R", width/4, height/2 ); //// Present champion & defeated in the table). strokeWeight(6); // Table // fill( 255,255,255 ); rectMode(CORNER); rect( sideX-10, sideY+60, 180, 100, 10 ); champion( warrior, many ); defeated( warrior, many ); } } //// Draw one button. void button( String s, float x, float y ) { rectMode(CORNER); strokeWeight(4); rect( x,y, 160,30, 10 ); fill(0); textSize(24); text( s, x+10, y+25 ); } ////// Handle keyboard & click void keyPressed() { if (key == 'q') exit(); if (key == 'r') reset(); if (key == ' ') race(); idle=0; } void mousePressed() { if (click( sideX,Thor, 160,40)) race(); if (click( sideX,Freiya, 160,40)) allBack(); if (click( sideX,ZolY, 160,40)) leadBack(); idle=0; } boolean click( float x, float y, float w, float h ) { if (mouseXx+w) return false; if (mouseYy+h) return false; return true; } ////// Move all warriors upward, with a random value. void race() { count++; if (champion<0) { for (int d=0; d=0; d--) k= a[d].y>a[k].y ? d : k; // ..** return k; } //////////////////////////// CLASS Contenders //////////////////// class Contenders { //// PROPERTIES //// String name="?"; float x=40, y=bottom; // Position of this creature. float w=23, h=44; // width & height int legs=10; int r, g, b; // Color. //// CONSTRUCTORS //// Contenders( float x, String s, float w) { this.x= x; this.name= s; this.w= w; h= w * random(1.5, 3); // h is 1.5 to 3 * w legs= int( random(6,16) ); // Random # of legs (2,12) setColors( int(random(365)), int(random(155)), int(random(455)) ); } Contenders() { } // Store colors in member variables. // void setColors( int r, int g, int b ) { this.r= r; this.b= b; } // //// METHODS //// // Present the creature. // void reveal() { noStroke(); fill( r, g, b ); rectMode(CENTER); rect( x, y, w, h ); ellipseMode(CENTER); ellipse( x, y-h/6, w, h ); eye( x, y-h*1/2); revealLegs(); // fill( (r+427)%256, (g+552)%256, (b+324)%256 ); textSize(18); text( name, 3+x-w/2, y ); textSize(18); text( legs+" legs", x-w/3, y+12 ); } void crown() { fill( r, g, b ); triangle( x, y-h-w/2, x-w/2,y-h, x+w/2,y-h ); } void eye( float eyeX, float eyeY ) { fill(#FFFFFF); ellipse( eyeX, eyeY, 34,40 ); // ..** fill(r,g,b); ellipse( eyeX, eyeY, 40,20 ); // ..** } void revealLegs() { float legsX=x-w/2, legsY=y+h/2; float swim=5; if (int(y) % 2 > 0) swim= -2; strokeWeight(1); stroke(r,g,b); float spacing= w/legs; for (legsX= x-w/2+spacing/2; legsX