Created
June 27, 2014 00:52
-
-
Save KentaKomai/051fc57a5025fce87725 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
int length = 20; // element count | |
float[] x = new float[length]; //element x | |
float[] y = new float[length]; //element y | |
float[] ang = new float[length]; | |
float[] rot = new float[length]; | |
float[] c = new float[length]; | |
float[] radius = new float[length]; | |
float cx, cy; //center x, y | |
float power = 0; | |
float maxPower = 200; | |
void setup(){ | |
size(400, 400); | |
colorMode(HSB, 100); | |
background(99); | |
frameRate(30); | |
} | |
void draw(){ | |
fadeToWhite(); | |
if(power > 0){ | |
for(int i=0; i<length; i++){ | |
ang[i] += rot[i] * (power / 10); //kasoku | |
x[i] = cx + ( power * sin(radians(ang[i])) ); | |
y[i] = cy + ( power * cos(radians(ang[i])) ); | |
noStroke(); | |
fill( c[i], 80, 100, min(power, 80)); | |
ellipse(x[i], y[i], radius[i], radius[i]); | |
} | |
} | |
if(mousePressed){ | |
cx = mouseX; | |
cy = mouseY; | |
if(power < maxPower) power++; | |
}else{ | |
if(power > 1) power *= 0.98; | |
else power = 0; | |
} | |
} | |
void fadeToWhite(){ | |
noStroke(); | |
fill(99, 30); | |
rectMode(CORNER); | |
rect(0,0,width, height); | |
} | |
void mousePressed(){ | |
//power = 0; | |
for(int i=0; i<length; i++){ | |
radius[i] = random(10, 30); | |
c[i] = random(100); | |
rot[i] = random(-5, 5); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment