Created
April 14, 2014 07:12
-
-
Save sasamijp/10623373 to your computer and use it in GitHub Desktop.
回る箱
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
RollingBox box3d; | |
float counter; | |
void setup(){ | |
size(500, 800, P3D); | |
box3d = new RollingBox(); | |
counter = 0; | |
frameRate(60); | |
} | |
void draw(){ | |
background(0); | |
box3d.rotate3d(width/2,height/2,counter); | |
counter += 1; | |
} | |
class RollingBox { | |
float angle = 0; | |
color c = color(0,0,0); | |
float boxSize = 100; | |
int plus; | |
RollingBox () { | |
angle=0; | |
boxSize = 300; | |
plus = 0; | |
} | |
void rotate3d(int xpos,int ypos, float counter){ | |
translate(xpos, ypos, 0); | |
rotateY(angle); | |
if((counter % 2) == 0){ | |
boxSize -= 3; | |
}else{ | |
boxSize += 3; | |
} | |
if((counter % 30) == 0){ | |
c = randomColor(); | |
} | |
box(boxSize); | |
fill(c); | |
angle += 0.03; | |
if(angle == 360){ | |
angle = 0; | |
} | |
} | |
private color randomColor(){ | |
color c = color(random(255),random(255),random(255)); | |
return c; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment