import ddf.minim.*; Minim sound; AudioPlayer player; Ball maru; int[] iro = {128, 255, 255}; int flagK = 0; //flag by keyboard void setup() { // Initialize size(200, 400); //window background(0, 0, 0); //black noStroke(); //lineless maru = new Ball(100,10,0,1,20); //insta maru.display(iro); sound = new Minim(this); player = sound.loadFile("ssNews.mp3", 2048); } void draw() { // main loop if (flagK == 1) { //watch at flag clear(); maru.display(iro); } if(maru.py >= (height-maru.dia/2)) { player.pause(); flagK = 0; clear(); maru.py = 10; maru.display(iro); } } void keyPressed() { if (key == ' ') { //space flagK = 1; //clear mode set player.play(); } } void clear() { fill(0,0,0); //clear color rect(0, 0, width, height); } void stop() { player.close(); sound.stop(); super.stop(); } class Ball{ float px, py; //position float vx, vy; //velocity float dia; //diameter Ball(float x, float y, float d) { px = x; py = y; dia = d; } Ball(float x, float y, float sx, float sy, float d) { px = x; py = y; vx = sx; vy = sy; dia = d; } void display(int[] col) { fill(col[0], col[1], col[2]); px += vx; py += vy; ellipse(px, py, dia, dia); } }