Skip to content

Instantly share code, notes, and snippets.

@ichii731
Created August 4, 2021 07:12
Show Gist options
  • Save ichii731/ae507e488c0c9374c15178a675c6a3c9 to your computer and use it in GitHub Desktop.
Save ichii731/ae507e488c0c9374c15178a675c6a3c9 to your computer and use it in GitHub Desktop.
/*
EP演習3rd - 需要があるかわからんが一応Gistに載せておく…
OPPO RelaxというOPPO社製スマホに標準付属しているアプリをちょっと再現。
※音楽ファイルはないよ
*/
import ddf.minim.*;
import ddf.minim.analysis.*;
import ddf.minim.effects.*;
import ddf.minim.signals.*;
import ddf.minim.spi.*;
import ddf.minim.ugens.*;
Minim minim;
AudioPlayer song;
int count = 6;
int[] exist = new int[6];
int[] size = new int[6];
int[] x = new int[6];
int[] y = new int[6];
int[] R = new int[6];
int[] G = new int[6];
int[] B = new int[6];
void setup() {
stroke(222, 222, 222);
for (int i=0; i<=5; i++) {
exist[i] = 1;
size[i] = int(random(30, 101));
x[i] = int(random(801));
y[i] = int(random(501));
R[i] = int(random(200, 256));
G[i] = int(random(200, 256));
B[i] = int(random(200, 256));
}
size(800, 500);
background(255, 255, 255);
for (int i=0; i<=5; i++) {
if (exist[i] == 1) {
fill(R[i], G[i], B[i]);
ellipse(x[i], y[i], size[i], size[i]);
} else {
}
}
}
void draw() {
background(255, 255, 255);
for (int i=0; i<=5; i++) {
if (exist[i] == 1) {
fill(R[i], G[i], B[i]);
ellipse(x[i], y[i], size[i], size[i]);
} else {
}
if ((exist[0] == 0)&&(exist[1] == 0)&&(exist[2] == 0)&&(exist[3] == 0)&&(exist[4] == 0)&&(exist[5] == 0)) {
for (int j=0; j<=5; j++) {
exist[j] = 1;
x[j] = int(random(801));
y[j] = int(random(501));
R[j] = int(random(200, 256));
G[j] = int(random(200, 256));
B[j] = int(random(200, 256));
fill(R[i], G[i], B[i]);
ellipse(x[i], y[i], 80, 80);
}
}
}
}
void mousePressed() {
int sound = (int)random(2);
for (int i=0; i<=5; i++) {
if (dist(x[i], y[i], mouseX, mouseY) <= size[i]) {
if (exist[i] == 1) {
minim = new Minim( this );
if (sound == 0) {
song = minim.loadFile( "sound.mp3" );
} else {
song = minim.loadFile( "sound2.mp3" );
}
song.play();
exist[i] = 0;
} else {
}
}
}
}
void stop()
{
song.close();
minim.stop();
super.stop();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment