int iParam; void setup(){ size(400, 400); noCursor(); smooth(); framerate(100); } void draw(){ iParam++; if(iParam > 500) iParam = 0; if( 0 < iParam && iParam < 100) iParam++; background(255); strokeWeight(2); stroke(0); noFill(); pushMatrix(); scale(1.2); /* beginShape(); vertex(100, 180); vertex(300, 180); vertex(350, 300); vertex(50, 300); endShape(); */ drawStage(); Point shadowPos = getShadow(iParam); int shadowX = getX(shadowPos.x); int shadowY = getY(shadowPos.y)+10; int ballX = getX(shadowPos.x); int ballY = getY(shadowPos.x); noStroke(); fill(100,100,100,100); ellipse(shadowX, shadowY, 25, 10); stroke(0); fill(255); pushMatrix(); translate(ballX, ballY); rotate((float)shadowPos.x/10.0); ellipse(0, 0, 20, 20); line(-10, 0, -8, 0); line(10, 0, 8, 0); popMatrix(); if(mousePressed){ stroke(100); line(getX(0), getY(0), getX(1000), getY(1000)); } popMatrix(); } int getX(int x){ return (int)((float)x*0.8)-30; } int getY(int y){ return -y/3 + 290; } void drawStage(){ // saku line(getX(130), getY(140), getX(130), getY(220)); line(getX(210), getY(30), getX(210), getY(110)); line(getX(130), getY(200), getX(210), getY(90)); // rail // line(getX(200), getY(220), getX(300), getY(300)); line(getX(180), getY(180), getX(280), getY(280)); line(getX(200), getY(160), getX(300), getY(260)); line(getX(180), getY(180), getX(180), getY(160)); line(getX(200), getY(160), getX(200), getY(140)); line(getX(200), getY(160), getX(180), getY(180)); line(getX(280), getY(280), getX(300), getY(280)); line(getX(300), getY(260), getX(320), getY(260)); line(getX(280), getY(280), getX(300), getY(260)); line(getX(300), getY(280), getX(320), getY(260)); line(getX(300), getY(200), getX(300), getY(280)); line(getX(320), getY(180), getX(320), getY(260)); fill(255); //tranporin int yy = 0; if( abs(400 - iParam) < 10) yy = 10-abs(400 - iParam); line(getX(420), getY(380), getX(420), getY(335)); line(getX(380), getY(380), getX(380), getY(335)); line(getX(410), getY(395), getX(410), getY(350)); line(getX(390), getY(365), getX(390), getY(320)); ellipse(getX(400), getY(380-yy), 32, 22); fill(0); ellipse(getX(400), getY(380-yy), 10, 7); } Point getShadow(int i){ int iOffset = i % 100; int iMode = (i - iOffset)/100; Point retval = new Point(); retval.x = iMode * 100; retval.y = iMode * 100; float yy = (float)iOffset/100.; float xx = (float)iOffset/100.; switch(iMode){ case 0: retval.x += iOffset; retval.y += iOffset; break; case 1: retval.x += iOffset; retval.y += iOffset * yy * yy * yy * yy * 0.8; break; case 2: retval.x += iOffset *(-(xx-1.0)*(xx-1.0) +1.0 ); retval.y += -20 + yy*30 ; break; case 3: retval.x += iOffset * ( -(xx-1.0)*(xx-1.0) +1.0 ); retval.y += -100. + iOffset*2.0 * yy * yy * yy *yy *yy + 10; break; case 4: retval.x += iOffset; retval.y += -iOffset*4; break; case 5: retval.x += iOffset; retval.y += -iOffset*4; break; case 6: retval.x += iOffset; retval.y += -iOffset*4; break; case 7: retval.x += iOffset; retval.y += -iOffset*4; break; } return retval; }