Box_ box1,box2,box3; final int EDGE=400; final int MAX=280; PGraphics[] pg=new PGraphics[10];//texture image PGraphics box_1,box_2,box_3; float r; float rand; int[] ran_num=new int[3]; int[] rand_array=new int[MAX]; int[] date=new int[MAX]; int slot_flag=0; int rd=0; int tmp=0; int count=0; void setup(){ size(1400,700,P3D); hint(ENABLE_DEPTH_SORT); frameRate(60); box1=new Box_(); box2=new Box_(); box3=new Box_(); println("making Image..."); //make graphics for(int k=0;k<10;k++){ pg[k]=createTexture(k); } box_1=pg[0]; box_2=pg[0]; box_3=pg[0]; int j=0; for(int i=0;i=1;i--){ rd=(int)random(1,i); tmp=rand_array[rd]; rand_array[rd]=rand_array[i]; rand_array[i]=tmp; date[j++]=tmp; if(j>=MAX) break; } println("SETUPOK"); } void mousePressed(){ if(mouseButton==LEFT&&slot_flag==0){ slot_flag=1; count++; } if(mouseButton==RIGHT&&slot_flag==0){ slot_flag=1; count--; } rand=date[count]; ran_num[2]=(int)(rand/100); ran_num[1]=(int)(rand/10)-ran_num[2]*10; ran_num[0]=(int)(rand/1)-(ran_num[2]*100+ran_num[1]*10); box_1=pg[ran_num[2]]; box_2=pg[ran_num[1]]; box_3=pg[ran_num[0]]; } PGraphics createTexture(int num){ PGraphics graphic; graphic=createGraphics(EDGE*4,EDGE,JAVA2D); graphic.smooth(); graphic.textSize(500); graphic.beginDraw(); graphic.background(255); graphic.noStroke(); float ran2=random(1,9); //no1 graphic.fill(0); graphic.text(num,EDGE/2-150,EDGE/2+175); //no2 graphic.fill(30); graphic.text((int)ran2,EDGE+EDGE/2-150,EDGE/2+175); //no3 graphic.text((int)ran2/2,2*EDGE+EDGE/2-150,EDGE/2+175); //no4 graphic.text((int)(num/ran2),3*EDGE+EDGE/2-150,EDGE/2+175); graphic.endDraw(); return graphic; } class Box_{ int x,y; Box_(){ x=width/2; y=height/2; } void update(int X,float r){ int pg=X; int half=EDGE/2; float dx1,dx2,dx3,dx4,dz1,dz2,dz3,dz4; dx1=half*cos(radians(r)); dx2=half*cos(radians(r+90)); dx3=half*cos(radians(r+180)); dx4=half*cos(radians(r+270)); dz1=half*sin(radians(r)); dz2=half*sin(radians(r+90)); dz3=half*sin(radians(r+180)); dz4=half*sin(radians(r+270)); X=X*400; beginShape(QUAD); r_texture(pg); vertex(X+dx1,half,dz1,EDGE*1,EDGE*1); vertex(X+dx2,half,dz2,EDGE*0,EDGE*1); vertex(X+dx2,-half,dz2,EDGE*0,EDGE*0); vertex(X+dx1,-half,dz1,EDGE*1,EDGE*0); endShape(CLOSE); beginShape(QUAD); r_texture(pg); vertex(X+dx2,half,dz2,EDGE*2,EDGE*1); vertex(X+dx3,half,dz3,EDGE*1,EDGE*1); vertex(X+dx3,-half,dz3,EDGE*1,EDGE*0); vertex(X+dx2,-half,dz2,EDGE*2,EDGE*0); endShape(CLOSE); beginShape(QUAD); r_texture(pg); vertex(X+dx3,half,dz3,EDGE*3,EDGE*1); vertex(X+dx4,half,dz4,EDGE*2,EDGE*1); vertex(X+dx4,-half,dz4,EDGE*2,EDGE*0); vertex(X+dx3,-half,dz3,EDGE*3,EDGE*0); endShape(CLOSE); beginShape(QUAD); r_texture(pg); vertex(X+dx4,half,dz4,EDGE*4,EDGE*1); vertex(X+dx1,half,dz1,EDGE*3,EDGE*1); vertex(X+dx1,-half,dz1,EDGE*3,EDGE*0); vertex(X+dx4,-half,dz4,EDGE*4,EDGE*0); endShape(CLOSE); } } void r_texture(int i) { if(i==1) texture(box_1); if(i==2) texture(box_2); if(i==3) texture(box_3); } void draw(){ background(204); translate(width/2-800,height/2); if(r<1080&&slot_flag==1){ r+=10; box1.update(1,r); box2.update(2,r); box3.update(3,r); } else { r=0; slot_flag=0; box1.update(1,r+45); box2.update(2,r+45); box3.update(3,r+45); } }