import ddf.minim.*;
import ddf.minim.signals.*;
import ddf.minim.analysis.*;
import ddf.minim.effects.*;
Minim minim;
AudioPlayer song;
int MARGIN = 20;
Clock myClock = new Clock();
int time1 = 0;
int time2 = 0;
void setup() {
size(700,500);
minim = new Minim(this);
song = minim.loadFile(".mp3");//指定のファイル名
smooth();
frameRate(30);
}
void draw() {
stroke(255);
background(0);
myClock.getTime();
myClock.draw();
}
class Clock {
float s, m, h;
Clock(){
}
void getTime(){
s = second();
m = minute() + (s/60.0);
h = hour()%12 + (m/60.0);
}
void draw(){
fill(255);
//指定の時間になったら音と文字がでる
if(time1==hour() & time2==minute()){
if(song.isPlaying()){
}else{
song.play();
}
text("Get up!!",500,400);
}
//右側の指定時間描画
fill(255);
rect(450,200,120,40);
fill(0);
stroke(0);
ellipse(510,212,2,2);
ellipse(510,230,2,2);
fill(255);
stroke(255);
int a=470;
int b=185;
rect(465,175,20,15);
rect(465+60,175,20,15);
rect(465,175+75,20,15);
rect(465+60,175+75,20,15);
stroke(0);
fill(0);
triangle(a,b,a+8,b,a+4,b-5);
triangle(a,b+70,a+8,b+70,a+4,b+70+5);
triangle(a+60,b,a+8+60,b,a+4+60,b-5);
triangle(a+60,b+70,a+8+60,b+70,a+4+60,b+70+5);
textSize(38);
text(nf(time1,2),455,235);
text(nf(time2,2),455+60,235);
int lenge = 200;
//ストップボタン
fill(255);
rect(460,95,100,45);
fill(0);
textSize(38);
text("Stop",470,130);
//点の描画
translate(lenge, lenge);
rotate(radians(180));
pushMatrix();
fill(128);
noStroke();
for(int i=0; i<60; i++){
rotate(radians(6));
ellipse(lenge-MARGIN,0,3,3);
}
for(int i=0; i<12; i++){
rotate(radians(30));
ellipse(lenge-MARGIN,0,10,10);
}
//針の描画
popMatrix();
noFill();
stroke(255);
pushMatrix();
rotate(radians(s*(360/60)));
strokeWeight(1);
line(0,0,0,lenge-MARGIN);
popMatrix();
pushMatrix();
rotate(radians(m*(360/60)));
strokeWeight(2);
line(0,0,0,lenge-MARGIN);
popMatrix();
pushMatrix();
rotate(radians(h*(360/12)));
strokeWeight(4);
line(0,0,0,(lenge*3)/4-MARGIN);
popMatrix();
}
}
void mousePressed(){
//時間指定
if(mouseX>465 & mouseX<485){
if(mouseY>175 & mouseY<190){
if(time1<23){
time1++;
}else if(time1==23){
time1=0;
}
}else if(mouseY>250 & mouseY<265){
if(time1>0){
time1--;
}else if(time1==0){
time1=23;
}
}
}
if(mouseX>465+60 & mouseX<485+60){
if(mouseY>175 & mouseY<190){
if(time2<59){
time2++;
}else if(time2==59){
time2=0;
}
}else if(mouseY>250 & mouseY<265){
if(time2>0){
time2--;
}else if(time2==0){
time2=59;
}
}
}
//Stopボタンの判定(音が止まる)
if(mouseX>460 & mouseX<560 & mouseY>95 & mouseY<140){
song.close();
song = minim.loadFile(".mp3");//指定の音声ファイル(上と同じ推奨?)
}
}
void stop(){
song.close();
minim.stop();
super.stop();
}
直接あって話とか、メールとか、合宿前までに設定するの面倒だと思うので。
- とりあえず最低限のことは書いたつもり。不足等あればコメントないし直接変更をしてください。 -- 西中 2012-05-11 (金) 01:57:20
- 各班4回生はすごい準備しているぞ~危機感もったほうがいいぞ -- なか 2012-05-17 (木) 16:54:34
- 時間判定を追加 -- 西中 2012-05-19 (土) 01:42:39
- とりあえず基本的な目ざまし時計としての体裁は出来ていると思います。 -- 西中 2012-05-19 (土) 02:23:55
- 申し訳ないですが後はよろしくお願いします。 -- 西中 2012-05-19 (土) 02:24:43
- 時間判定を追加 -- 西中 2012-05-19 (土) 02:33:27