顯示具有 98160176黃豊翔 標籤的文章。 顯示所有文章
顯示具有 98160176黃豊翔 標籤的文章。 顯示所有文章

2013年1月14日 星期一

week19,final


上面是電腦畫面,不過沒有聲音,下面是配樂。


這是按鈕
我負責軟體,黃豊翔負責硬體
import ddf.minim.*;
import processing.serial.*;
PrintWriter output;
Minim minim;
AudioPlayer bgm;
int score=0,combo=000,ansSum=10,clock,s,ms,m=0,befos=0,befoms=0,befom=0,length;
int [] ansTime={1,2,3,4,5,6,7,8,9,10};//拍子的出現時間(秒)
char ansKey[]={'1','2','3','4','5','6','7','8','9','1'};//要按的紐
boolean[] anesd={false,false,false,false,false,false,false,false,false,false};//是否有按過
//int [] ansTime;
//char ansKey[];
char keyPressd='?',okeyPressd=' ';
BufferedReader reader;
BufferedReader rank;
PrintWriter Edit;
String line;
String[] Ans;
Serial myport;
boolean load,edit,playbeat=false;
String[] pieces;
boolean[] btn={false,false,false,false,false,false,false,false,false};//是否為要按的 按鍵0->1 1->2 其他類推
boolean T1,T2,T3,R1,R2,L1,L2;//要畫出的方塊
Serial myPort;  // Create object from Serial class
int val;      // Data received from the serial port

void setup(){
  //reader = createReader("gangnamhit.txt");  
  size(600,650);
  minim = new Minim(this);

  String portName = Serial.list()[0];
  myPort = new Serial(this, portName, 9600);
  //myport=new Serial(this,"com7",9600);連接物理ardunio
}

void keyPressed(){
   keyPressd=key;
  // judge(s);
   //print(keyPressd);
   switch(keyPressd){
   /* case '1':  case '2': case '3':  case '4': case '5':  case '6': case '7': case '8':  case '9':
      print(int(keyPressd)-48);
        if(btn[int(keyPressd)-49]==true){
          btn[int(keyPressd)-49]=false;
            score++;
            combo++;    
          }
          break;*/
     case 's':
       bgm = minim.loadFile("Elec.mp3");//我爸剛
       bgm.play();//放音樂
       befos=s;
       befoms=ms;
       befom=m;
       break;
     case 'l':
       reader = createReader("songset.txt");
       bgm = minim.loadFile("Elec.mp3");//我爸剛
       load=true;
       break;
     case 'e':
      output = createWriter("songset.txt");
      bgm = minim.loadFile("Elec.mp3");//我爸剛
      bgm.play();
      edit=true;
      break;
  }
  if(edit)edit();
}
void loadsong(){
  try {
    line = reader.readLine();
  } catch (IOException e) {
    e.printStackTrace();
    line = null;
 
  }
  if (line == null) {
    // Stop reading because of an error or file is empty
   // noLoop();
   print("/ndone1");
   bgm.play();//放音樂
   befos=s;
   befoms=ms;
   befom=m;
   print(" and start");
   load=false;
   playbeat=true;
   } else {
     pieces = split(line, " ");
     length=pieces.length;
  for(int i=0;i<pieces.length;i++){
  //*
    if(i%10==1)//id
    print("id:"+pieces[i]);
    if(i%10==3)//beat
    print("beat:"+pieces[i]);
    if(i%10==5)//min
    print("min:"+pieces[i]);
    if(i%10==7)//s
    print("s:"+pieces[i]);
    if(i%10==9)//ms
    print("ms:"+pieces[i]);
    //*/
    //print(pieces[i]);
 }

    //print(pieces[(pieces.length-1)]);
 
  }

}
int i=1;
void edit(){
  if(keyPressd=='q'){
    output.flush();  // Writes the remaining data to the file
    output.close();  // Finishes the file
    exit();  // Stops the program
  }else{
    // case 6: case 7: case 8: case 9:
    output.print("<ID> "+i+" ");
    output.print("<BEAT> "+keyPressd+" ");
    output.println("true "+m+" min "+s+" s "+ms+" ms");
    i++;
  }
}
void beating(int btnl,int NoAnsednber){
 boolean NoAnsed =boolean(pieces[NoAnsednber]);
 if(NoAnsed)
  btn[btnl-1]=true;
  for(int by=0;by<=2;by++)//畫出方形
    for(int bx=0;bx<=2;bx++){
    if(btn[7-3*by+bx-1]) fill(0);
       else  fill(200);
       rect(10+bx*200, 50+by*200, 180, 180);
     }
   if(int(keyPressd)-48==btnl && NoAnsed)//(int(keyPressd)-49)==btnl-1
     {
       btn[btnl-1]=false;
       pieces[NoAnsednber]=str(false);
       score++;
       combo++;
     }
   
}
/*void judge(){
        if(int(keyPressd)>48&&int(keyPressd)<58){
        if(btn[int(keyPressd)-49]==true&&int(okeyPressd)!=int(keyPressd)){
          btn[int(keyPressd)-49]=false;
            score++;
            combo++;
         
         }
         okeyPressd=keyPressd;
       }
   
   }
*/
void draw(){
  if ( myPort.available() > 0) {  // If data is available,
    val = myPort.read();         // read it and store it in val
   // if(val-49<0)val=58;
    //println(val-49);
    switch(val){
      case 50: keyPressd='1';    break;
      case 51: keyPressd='2';    break;
      case 52: keyPressd='3';    break;
      case 53: keyPressd='4';    break;
      case 54: keyPressd='5';    break;
      case 55: keyPressd='6';    break;
      case 56: keyPressd='7';    break;
      case 57: keyPressd='8';    break;
      case 49:
      case 48: keyPressd='9';    break;
    }
   // keyPressd=char(val-1);
  }
  if(load)loadsong();
 // print("  "+s+"秒");
   //方格
   ///////////////
   //00_7 10_8 20_9
   //01_4 11_5 21_6
   //02_1 12_2 22_3
   ///////////////
 // int  pA=myport.read();
   background(255);
   int black=999;
   clock= millis();
   s = clock/1000-m*60-befos;//SECOND s = millis()/1000;
   ms = clock%1000-befoms;//mili-SECOND
   if(s>=60){
     m++;
     s-=60;
 }
 //  m= clock/(60*1000)-befom;
   if(s<=0)s=0;
  char currentI='+';
 if(playbeat)
   for(int i=0;i<length/10;i++){
  // print("進入迴圈"+pieces[i*10+5]+pieces[5]+int(pieces[i*10+5]));
   //if()
   if(int(pieces[i*10+5])<m)continue;
   else if(int(pieces[i*10+5])==m)//分鐘
     {//出來一秒
     
       if(int(pieces[i*10+7])<=s-2)//second
       {  if(boolean(pieces[i*10+4])==true){
           combo=0;
           pieces[i*10+4]=str(false);
         }
           continue;
       }
   
       else if(int(pieces[i*10+7])==s-1)//second
       { // print("進入迴圈分鐘前");
          if(ms<=int(pieces[i*10+9])-250)//ms//ms+(1000-pieces[i*10+9])<=1000間隔一秒
         {
            print("進入迴圈分鐘"+"ID:"+int(pieces[i*10+1])+"<"+int(pieces[i*10+5])+"分"+int(pieces[i*10+7])+"秒");
           beating(int(pieces[i*10+3])/*按鍵*/,i*10+4);//顯示出來
           // print("進入迴圈分鐘前顯示");
         }
       }
       else if(int(pieces[i*10+7])==s)//second
       {
         //print("進入迴圈分鐘後");
         if(ms-int(pieces[i*10+9])>=250)//ms間隔一秒之內
         {
           print("進入迴圈分鐘"+"ID:"+int(pieces[i*10+1])+"<"+int(pieces[i*10+5])+"分"+int(pieces[i*10+7])+"秒");
           beating(int(pieces[i*10+3])/*按鍵*/,i*10+4);
          //  print("進入迴圈分鐘後顯示");
         }else break;//超過一秒跳出
       }
     }
     
   }
    ///////////////
   //00_7 10_8 20_9
   //01_4 11_5 21_6
   //02_1 12_2 22_3
   ///////////////
   for(int i=0;i<9;i++){
    if(btn[i])break;
    else if(i<=7)continue;
    else if(i==8){
         fill(200);
         for(int by=0;by<=2;by++)//畫出方形
          for(int bx=0;bx<=2;bx++)
           rect(10+bx*200, 50+by*200, 180, 180);
        }
     }

  for(int i=0;i<9;i++){
     btn[i]=false;
  }
   //分數
   fill(0,0,0,120);
   for(int digit=0;digit<=2;digit++){
   int drawNumber=(int)(score/pow(10,digit))%10;//找出要畫的數字
   T1=T2=T3=R1=R2=L1=L2=false;
   switch(drawNumber){
   case 0:T1=T3=R1=R2=L1=L2=true;   break;
   case 1:R1=R2=true;               break;
   case 2:T1=T2=T3=R1=L2=true;      break;
   case 3:T1=T2=T3=R1=R2=true;      break;
   case 4:T2=R1=R2=L1=true;         break;
   case 5:T1=T2=T3=R2=L1=true;      break;
   case 6:T1=T2=T3=R2=L1=L2=true;   break;
   case 7:T1=R1=R2=true;            break;
   case 8:T1=T2=T3=R1=R2=L1=L2=true;break;
   case 9:T1=T2=T3=R1=R2=L1=true;   break;
 }
   if(T1)rect(350-150*digit, 260, 60, 20);//橫一Transverse  T1
   if(R1)rect(410-150*digit, 280, 20, 60);//R1
   if(T2)rect(350-150*digit ,340, 60, 20);//T2
   if(R2)rect(410-150*digit, 360, 20, 60);//R2
   if(T3)rect(350-150*digit, 420, 60, 20);//T3
   if(L2)rect(330-150*digit, 360, 20, 60);//L1
   if(L1)rect(330-150*digit, 280, 20, 60);//L2
  }
 for(int digit=0;digit<=2;digit++){
   int drawNumber=(int)(combo/pow(10,digit))%10;//找出要畫的數字
   T1=T2=T3=R1=R2=L1=L2=false;
   switch(drawNumber){
   case 0:T1=T3=R1=R2=L1=L2=true;   break;
   case 1:R1=R2=true;               break;
   case 2:T1=T2=T3=R1=L2=true;      break;
   case 3:T1=T2=T3=R1=R2=true;      break;
   case 4:T2=R1=R2=L1=true;         break;
   case 5:T1=T2=T3=R2=L1=true;      break;
   case 6:T1=T2=T3=R2=L1=L2=true;   break;
   case 7:T1=R1=R2=true;            break;
   case 8:T1=T2=T3=R1=R2=L1=L2=true;break;
   case 9:T1=T2=T3=R1=R2=L1=true;   break;
 }
   if(T1)rect(350-150*digit, 460, 60, 20);//橫一Transverse  T1
   if(R1)rect(410-150*digit, 480, 20, 60);//R1
   if(T2)rect(350-150*digit ,540, 60, 20);//T2
   if(R2)rect(410-150*digit, 560, 20, 60);//R2
   if(T3)rect(350-150*digit, 620, 60, 20);//T3
   if(L2)rect(330-150*digit, 560, 20, 60);//L1
   if(L1)rect(330-150*digit, 480, 20, 60);//L2
  }  

}
ARDUNIO

/*
  DigitalReadSerial
 Reads a digital input on pin 2, prints the result to the serial monitor

 This example code is in the public domain.
 */

// digital pin 2 has a pushbutton attached to it. Give it a name:
int pushButton[] = {2,3,4,5,6,7,8,9,10};
boolean checkstat[] = {false,false,false,false,false,false,false,false,false};
int buttonState=0,otarg=0;
//int targ;
int ans[]= {1,1};
// the setup routine runs once when you press reset:
void setup() {
  // initialize serial communication at 9600 bits per second:
  Serial.begin(9600);
  // make the pushbutton's pin an input:
  for(int i=0;i<9;i++)
  pinMode(pushButton[i], INPUT);
}

// the loop routine runs over and over again forever:
void loop() {
  // read the input pin:

  // print out the state of the button
  for(int targ=0;targ<9;++targ )
 if( digitalRead(targ+2)==1){
 
    //buttonState = digitalRead(targ);
 
   if(otarg!=targ) {
     otarg=targ;
     Serial.print(targ+2);
   }
     //if((targ+1)==otarg)
   
     //Serial.print(otarg);
    // if((otarg+1)==targ)
     //Serial.print(otarg);
    }
  delay(1);        // delay in between reads for stability
}





2012年12月25日 星期二

week15,hw12

我們是打算使用之前其中的程式,作出類似實體的jubeat的遊戲,可選歌並將透明鍵盤放螢幕上在進行遊戲。

2012年12月4日 星期二

Week12,HW11


#include "pitches.h"

const int threshold = 10;    // minimum reading of the sensors that generates a note

// notes to play, corresponding to the 3 sensors:
int notes[] = {
  NOTE_A4, NOTE_B4,NOTE_C3,NOTE_D4,NOTE_E4 };

void setup() {
 
 pinMode(3, INPUT);
 pinMode(4, INPUT);  
 pinMode(5, INPUT);
 pinMode(6, INPUT);
 pinMode(7, INPUT);
 Serial.begin(9600);
}

void loop() {
  for (int thisSensor = 3; thisSensor < 8; thisSensor++) {
    // get a sensor reading:
    int sensorReading = digitalRead(thisSensor);

    // if the sensor is pressed hard enough:
    if (digitalRead(thisSensor) ==HIGH) {
      // play the note corresponding to this sensor:
      tone(8, notes[thisSensor], 20);
      Serial.println(thisSensor, DEC);
    }else if(digitalRead(thisSensor) ==LOW){
    noTone(8);
  }
   delay(20);
   
  }
}
心得:多虧老師的指點才得以debug,不過做完之後有點得意忘形就是了 呵呵

2012年11月27日 星期二

Week12,HW10

1.int sensorPin = A0;    // select the input pin for the potentiometer
int ledPin = 13;      // select the pin for the LED
int sensorValue = 0;  // variable to store the value coming from the sensor
void setup() {
  // declare the ledPin as an OUTPUT:
  Serial.begin(9600);
  Serial.println("2222");
  pinMode(13, OUTPUT); 
   pinMode(12, OUTPUT);
    pinMode(11, OUTPUT);
     pinMode(10, OUTPUT);
      pinMode(9, OUTPUT);
       pinMode(8, OUTPUT);
        pinMode(7, OUTPUT);
}
void loop() {
  // read the value from the sensor:
  sensorValue = analogRead(sensorPin);   
  // turn the ledPin on
  int i=20;
  for(i=0;i<8;i++)
  {
  if(i=0)
  {
  digitalWrite(13, HIGH);
  digitalWrite(12, LOW);
  digitalWrite(11, LOW);
  digitalWrite(10, LOW);
  digitalWrite(9, LOW);
  digitalWrite(8, LOW);
  digitalWrite(7, LOW);
  }
  else if(i==1)
  {
  digitalWrite(12, HIGH);
  digitalWrite(13, LOW);
  digitalWrite(11, LOW);
  digitalWrite(10, LOW);
  digitalWrite(9, LOW);
  digitalWrite(8, LOW);
  digitalWrite(7, LOW);
  }
    else if(i==2)
  {
  digitalWrite(11, HIGH);
  digitalWrite(12, LOW);
  digitalWrite(13, LOW);
  digitalWrite(10, LOW);
  digitalWrite(9, LOW);
  digitalWrite(8, LOW);
  digitalWrite(7, LOW);
  }
    else if(i==3)
  {
  digitalWrite(10, HIGH);
  digitalWrite(12, LOW);
  digitalWrite(11, LOW);
  digitalWrite(13, LOW);
  digitalWrite(9, LOW);
  digitalWrite(8, LOW);
  digitalWrite(7, LOW);
  }
    else if(i==4)
  {
  digitalWrite(9, HIGH);
  digitalWrite(12, LOW);
  digitalWrite(11, LOW);
  digitalWrite(10, LOW);
  digitalWrite(13, LOW);
  digitalWrite(8, LOW);
  digitalWrite(7, LOW);
  }
    else if(i==5)
  {
  digitalWrite(8, HIGH);
  digitalWrite(12, LOW);
  digitalWrite(11, LOW);
  digitalWrite(10, LOW);
  digitalWrite(9, LOW);
  digitalWrite(13, LOW);
  digitalWrite(7, LOW);
  }
    else if(i==6)
  {
  digitalWrite(7, HIGH);
  digitalWrite(12, LOW);
  digitalWrite(11, LOW);
  digitalWrite(10, LOW);
  digitalWrite(9, LOW);
  digitalWrite(8, LOW);
  digitalWrite(13, LOW);
  }
    else if(i==7)
  {
    i==0;
  }
  }
  digitalWrite(ledPin, HIGH); 
  // stop the program for <sensorValue> milliseconds:
  delay(sensorValue);         
  // turn the ledPin off:       
  digitalWrite(ledPin, LOW);  
  // stop the program for for <sensorValue> milliseconds:
  delay(sensorValue);                 
}

賴祺清的

int sensorPin = A0;    // select the input pin for the potentiometer
int ledPin = 13;      // select the pin for the LED
int sensorValue =25;  // variable to store the value coming from the sensor
int s=7;
boolean turn =true;
void setup() {
  // declare the ledPin as an OUTPUT:
  for(int i =13;i>=7;i--){

  pinMode( i, OUTPUT);
}

 // pinMode(ledPin, OUTPUT);
  Serial.begin(9600);
}

void loop() {
  // read the value from the sensor:
  sensorValue = analogRead(sensorPin);  
  // turn the ledPin on();

  Serial.println("Hello World!!");

         for(int i =13;i>=7;i--){
          if(s==i||s==i+1){
        digitalWrite(i, HIGH);
      }
        else digitalWrite(i, LOW);
          }
          // stop the program for <sensorValue> milliseconds:
        delay(sensorValue);        
     
      if(turn)s++;
      else s--;
       if(s==14||s==7)turn=!turn;
     
     
    }                

2012年11月20日 星期二

week11,HW09

1.有了Processing+Arduino 可以做出期末的邱比特遊戲
首先先取16個正方形壓克力板,其中一塊的壓克力板的四個角作感測
當壓下壓克力板時,則可以接通,並輸入在Arduino版
並感測在Processing裡的遊戲做配合

2.
可以做遊戲

2012年11月13日 星期二

Midterm

1.音樂以放入
2.未來加強
1.增加預備出現拍子的前置圖片
2.改善目前介面的美工
3.增加斷連段
4.遊戲音樂結速和開始
5.可能增加音樂譜面





import ddf.minim.*;
Minim minim; 
AudioPlayer bgm;
boolean a1=false;
boolean a12=false;
boolean s1=false;
boolean s12=false;
boolean d1=false;
boolean f1=false;
boolean z1=false;
boolean x1=false;
boolean c1=false;
boolean v1=false;
boolean y1=false;
boolean u1=false;
boolean i1=false;
boolean o1=false;
boolean h1=false;
boolean j1=false;
boolean k1=false;
boolean l1=false;
boolean q1=false;
boolean d12=false;
boolean f12=false;
boolean z12=false;
boolean x12=false;
boolean c12=false;
boolean v12=false;
boolean y12=false;
boolean u12=false;
boolean i12=false;
boolean o12=false;
boolean h12=false;
boolean j12=false;
boolean k12=false;
boolean l12=false;
boolean q12=false;
boolean take=false;
int s123=0;
 int sice=0;
 int siceten=0;
 int sicehun=0;
 int m=0;
void setup(){
  size(600,650);
   minim = new Minim(this);
  bgm = minim.loadFile("aas.mp3");
  bgm.play();
}
void sicetake()//////////////////// 計分判斷
{
 if(sice<10)
    {
    sice++;
    }
    if(sice==10)
    {
      sice=0;
      if(siceten<10)
      {
      siceten++;
      }
      if(siceten==10)
      {
        siceten=0;
        if(sicehun<10)
        {
          sicehun++;
        }
      }
      }
          s123=0;
}
void draw()
{
  ////////////////////////////////顯示記分判斷
   if(s1==true&&s12==true)
  {
    sicetake();
    s12=false;
  }
   else if(a1==true&&a12==true)
  {
    sicetake();
    a12=false;
  }
     else if(d1==true&&d12==true)
  {
    sicetake();
    d12=false;
  }
    else if(f1==true&&f12==true)
  {
    sicetake();
    f12=false;
  }
     else if(z1==true&&z12==true)
  {
    sicetake();
    z12=false;
  }
     else if(x1==true&&x12==true)
  {
    sicetake();
    x12=false;
  }
     else if(c1==true&&c12==true)
  {
    sicetake();
    c12=false;
  }
       else if(v1==true&&v12==true)
  {
    sicetake();
    v12=false;
  }
       else if(y1==true&&y12==true)
  {
    sicetake();
    y12=false;
  }
       else if(u1==true&&u12==true)
  {
    sicetake();
    u12=false;
  }
       else if(i1==true&&i12==true)
  {
    sicetake();
    i12=false;
  }
       else if(o1==true&&o12==true)
  {
    sicetake();
    o12=false;
  }
       else if(h1==true&&h12==true)
  {
    sicetake();
    h12=false;
  }
       else if(j1==true&&j12==true)
  {
    sicetake();
    j12=false;
  }
       else if(k1==true&&k12==true)
  {
    sicetake();
    k12=false;
  }
       else if(l1==true&&l12==true)
  {
    sicetake();
    l12=false;
  }
  ///////////////////////////////////////////////////
  background(255);
  
  int m = millis()/1000;

   if(m==1)
  {
  }
  if(m==2)
  {
  }
  if(m==3)
  {
  a1=true;
  s1=true;
  }
  if(m==4)
  {
    a1=false;
    s1=false;
  }
    if(m==5)
  {
    h1=true;
  }
   if(m==6)
  {
    h1=false;
  }
   if(m==7)
  {
  j1=true;
  h1=true;
  }
   if(m==8)
  {
    j1=false;
    h1=false;
  }
   if(m==9)
  {
    d1=true;
  }
   if(m==10)
  {
    d1=false;
    c1=true;
  }
    if(m==11)
  {
    c1=false;
  }
  if(m==12)
  {
    a1=true;
  }
  if(m==13)
  {
    s1=true;
    a1=false;
  }
  if(m==14)
  {
    d1=true;
    s1=false;
  }
    if(m==15)
  {
     f1=true;
     d1=false;
  }
   if(m==16)
  {
    v1=true;
    f1=false;
  }
   if(m==17)
  {
    c1=true;
    v1=false;
  }
   if(m==18)
  {
    x1=true;
    c1=false;
  }
   if(m==19)
  {
    z1=true;
    x1=false;
  }
   if(m==20)
  {
    y1=true;
    z1=false;
  }
     if(m==21)
  {
    u1=true;
    y1=false;
  }
  if(m==22)
  {
    i1=true;
    u1=false;
  }
  if(m==23)
  {
    o1=true;
    i1=false;
  }
  if(m==24)
  {
    l1=true;
    o1=false;
  }
    if(m==25)
  {
   k1=true;
   l1=false;
  }
   if(m==26)
  {
   j1=true;
   k1=false;
  }
   if(m==27)
  {
  h1=true;
  j1=false;
  }
   if(m==28)
  {
    h1=false;
    a1=true;
   
  }
   if(m==29)
  {
    z1=true;
     a1=false;
  }
   if(m==30)
  {
   y1=true;
    z1=false;
  }
     if(m==31)
  {
    h1=true;
    y1=false;
  }
  if(m==32)
  {
     h1=false;
  }
  if(m==33)
  {
  }
  if(m==34)
  {
  }
    if(m==35)
  {
  }
   if(m==36)
  {
  }
   if(m==37)
  {
  }
   if(m==38)
  {
  }
   if(m==39)
  {
  }
   if(m==40)
  {
  }
 
 fill(255);
 /////////////////////////////////////////////第一排
 rect(50, 100, 100, 100);    
 rect(180, 100, 100, 100);
 rect(310, 100, 100, 100);
 rect(440, 100, 100, 100);
 ///////////////////////////////////////////////第二排
 rect(50, 230, 100, 100);
 rect(180, 230, 100, 100);
 rect(310, 230, 100, 100);
 rect(440, 230, 100, 100);
 //////////////////////////////////////////////第三排
 rect(50, 360, 100, 100);
 rect(180, 360, 100, 100);
 rect(310, 360, 100, 100);
 rect(440, 360, 100, 100);
 //////////////////////////////////////////////第四排
 rect(50, 490, 100, 100);
 rect(180, 490, 100, 100);
 rect(310, 490, 100, 100);
 rect(440, 490, 100, 100);
 /////////////////////////////////////////////////////////
  if(a1)
  {
    fill(0);
    rect(50, 100, 100, 100);
  }
   if(s1)
  {
    fill(0);
    rect(180, 100, 100, 100);
  }
   if(d1)
  {
    fill(0);
      rect(310, 100, 100, 100);
  }
   if(f1)
  {
    fill(0);
     rect(440, 100, 100, 100); 
  }
/////////////////////////////////////////////////////第一排
   if (z1)
        {
      fill(0);
      rect(50, 230, 100, 100);
        }
     if(x1)
        {
      fill(0);
      rect(180, 230, 100, 100);  
         
        }
      if(c1)
        {
      fill(0);
      rect(310, 230, 100, 100);      
        }
      if(v1)
        {
      fill(0);
      rect(440, 230, 100, 100);      
        }
//////////////////////////////////////////第二排
   if (y1)
        {
      fill(0);
      rect(50, 360, 100, 100);
        }
   if(u1)
        {
      fill(0);
      rect(180, 360, 100, 100);           
        }
      if(i1)
        {
      fill(0);
      rect(310, 360, 100, 100);      
        }
      if(o1)
        {
      fill(0);
      rect(440, 360, 100, 100);      
        }
/////////////////////////////////////////////////////////////第三排
if (h1)
        {
      fill(0);
      rect(50, 490, 100, 100);
        }
     if(j1)
        {
      fill(0);
      rect(180, 490, 100, 100);  
         
        }
      if(k1)
        {
      fill(0);
      rect(310, 490, 100, 100);      
        }
      if(l1)
        {
      fill(0);
      rect(440, 490, 100, 100);      
        }
 
////////////////////////////////////////////////////////////////第四排////////////X+50.Y+80
if(sice==1)
 {
  fill(0,0,0,120);
 rect(450, 280, 20, 60);
 rect(450, 360, 20, 60);
 }
 if(siceten==1)
 {
  fill(0,0,0,120);
 rect(300, 280, 20, 60);
 rect(300, 360, 20, 60);
 }
 if(sicehun==1)
 {
  fill(0,0,0,120);
 rect(150, 280, 20, 60);
 rect(150, 360, 20, 60);
 }
if(siceten==2)
 {
  fill(0,0,0,120);
 rect(240,260,60,20);
 rect(300, 280, 20, 60);
 rect(240,340,60,20);
 rect(220, 360, 20, 60);
 rect(240,420,60,20);
 }
if(sicehun==2)
 {
  fill(0,0,0,120);
 rect(90,260,60,20);
 rect(150, 280, 20, 60);
 rect(90,340,60,20);
 rect(70, 360, 20, 60);
 rect(90,420,60,20);
 }
if(sice==2)
 {
  fill(0,0,0,120);
 rect(390,260,60,20);
 rect(450, 280, 20, 60);
 rect(390,340,60,20);
 rect(370, 360, 20, 60);
 rect(390,420,60,20);
 }
if(sice==3)
 {
  fill(0,0,0,120);
 rect(390,260,60,20);
 rect(450, 280, 20, 60);
 rect(390,340,60,20);
 rect(450, 360, 20, 60);
 rect(390,420,60,20);
 }
if(siceten==3)
 {
  fill(0,0,0,120);
 rect(240,260,60,20);
 rect(300, 280, 20, 60);
 rect(240,340,60,20);
 rect(300, 360, 20, 60);
 rect(240,420,60,20);
 }
if(sicehun==3)
 {
  fill(0,0,0,120);
 rect(90,260,60,20);
 rect(150, 280, 20, 60);
 rect(90,340,60,20);
 rect(150, 360, 20, 60);
 rect(90,420,60,20);
 }
 if(sice==4)
 {
   fill(0,0,0,120);
   rect(370, 280, 20, 60);
   rect(450, 280, 20, 60);
   rect(390,340,60,20);
   rect(450, 360, 20, 60);
 }
 if(siceten==4)
 {
   fill(0,0,0,120);
   rect(220, 280, 20, 60);
   rect(300, 280, 20, 60);
   rect(240,340,60,20);
   rect(300, 360, 20, 60);
 }
 if(sicehun==4)
 {
   fill(0,0,0,120);
   rect(70, 280, 20, 60);
   rect(150, 280, 20, 60);
   rect(90,340,60,20);
   rect(150, 360, 20, 60);
 }
 if(sice==5)
 {
 fill(0,0,0,120);
 rect(390,260,60,20);
 rect(370, 280, 20, 60);
 rect(390,340,60,20);
 rect(450, 360, 20, 60);
 rect(390,420,60,20);
 }
 if(siceten==5)
 {
 fill(0,0,0,120);
 rect(240,260,60,20);
 rect(220, 280, 20, 60);
 rect(240,340,60,20);
 rect(300, 360, 20, 60);
 rect(240,420,60,20);
 }
 if(sicehun==5)
 {
 fill(0,0,0,120);
 rect(90,260,60,20);
 rect(70, 280, 20, 60);
 rect(90,340,60,20);
 rect(150, 360, 20, 60);
 rect(90,420,60,20);
 }
  if(sice==6)
 {
 fill(0,0,0,120);
 rect(390,260,60,20);
 rect(450, 280, 20, 60);
 rect(390,340,60,20);
 rect(450, 360, 20, 60);
 rect(390,420,60,20);
 rect(370, 360, 20, 60);
 }
 if(siceten==6)
 {
 fill(0,0,0,120);
 rect(240,260,60,20);
 rect(300, 280, 20, 60);
 rect(240,340,60,20);
 rect(300, 360, 20, 60);
 rect(240,420,60,20);
 rect(220, 360, 20, 60);
 }
 if(sicehun==6)
 {
 fill(0,0,0,120);
 rect(90,260,60,20);
 rect(150, 280, 20, 60);
 rect(90,340,60,20);
 rect(150, 360, 20, 60);
 rect(90,420,60,20);
 rect(70, 360, 20, 60);
 }
 if(sice==7)
 {
 fill(0,0,0,120);
 rect(390,260,60,20);
 rect(450, 280, 20, 60);
 rect(450, 360, 20, 60);
 }
 if(siceten==7)
 {
 fill(0,0,0,120);
 rect(240,260,60,20);
 rect(300, 280, 20, 60);
 rect(300, 360, 20, 60);
 }
 if(sicehun==7)
 {
 fill(0,0,0,120);
 rect(90,260,60,20);
 rect(150, 280, 20, 60);
 rect(150, 360, 20, 60);
 }
 if(sice==8)
 {
 fill(0,0,0,120);
 rect(390,260,60,20);
 rect(450, 280, 20, 60);
 rect(390,340,60,20);
 rect(450, 360, 20, 60);
 rect(390,420,60,20);
 rect(370, 360, 20, 60);
 rect(370, 280, 20, 60);
 }
 if(siceten==8)
 {
 fill(0,0,0,120);
 rect(240,260,60,20);
 rect(300, 280, 20, 60);
 rect(240,340,60,20);
 rect(300, 360, 20, 60);
 rect(240,420,60,20);
 rect(220, 360, 20, 60);
 rect(220, 280, 20, 60);
 }
 if(sicehun==8)
 {
 fill(0,0,0,120);
 rect(90,260,60,20);
 rect(150, 280, 20, 60);
 rect(90,340,60,20);
 rect(150, 360, 20, 60);
 rect(90,420,60,20);
 rect(70, 360, 20, 60);
 rect(70, 280, 20, 60);
 }
 if(sice==9)
 {
 fill(0,0,0,120);
 rect(390,260,60,20);
 rect(450, 280, 20, 60);
 rect(390,340,60,20);
 rect(450, 360, 20, 60);
 rect(390,420,60,20);
// rect(320, 280, 20, 60);
 rect(370, 280, 20, 60);
 }
 if(siceten==9)
 {
 fill(0,0,0,120);
 rect(240,260,60,20);
 rect(300, 280, 20, 60);
 rect(240,340,60,20);
 rect(300, 360, 20, 60);
 rect(240,420,60,20);
// rect(320, 280, 20, 60);
 rect(220, 280, 20, 60);
 }
 if(sicehun==9)
 {
 fill(0,0,0,120);
 rect(90,260,60,20);
 rect(150, 280, 20, 60);
 rect(90,340,60,20);
 rect(150, 360, 20, 60);
 rect(90,420,60,20);
// rect(320, 280, 20, 60);
 rect(70, 280, 20, 60);
 }
 if(sice==0)
 {
 fill(0,0,0,120);
 rect(390,260,60,20);
 rect(450, 280, 20, 60);
// rect(390,340,60,20);
 rect(450, 360, 20, 60);
 rect(390,420,60,20);
 rect(370, 360, 20, 60);
 rect(370, 280, 20, 60);
 }
 if(siceten==0)
 {
 fill(0,0,0,120);
 rect(240,260,60,20);
 rect(300, 280, 20, 60);
// rect(390,340,60,20);
 rect(300, 360, 20, 60);
 rect(240,420,60,20);
 rect(220, 360, 20, 60);
 rect(220, 280, 20, 60);
 }
 if(sicehun==0)
 {
 fill(0,0,0,120);
 rect(90,260,60,20);
 rect(150, 280, 20, 60);
// rect(390,340,60,20);
 rect(150, 360, 20, 60);
 rect(90,420,60,20);
 rect(70, 360, 20, 60);
 rect(70, 280, 20, 60);
 }
}
void keyPressed(){
  if(key=='a'|| key == 'A'){
    a12=true;
  }
 else  if(key=='s'|| key == 'S'){
    s12=true;
  }
 else  if(key=='d'|| key == 'D')
{
  d12=true;
}
  else if(key=='f'|| key == 'F')
{
  f12=true;
}
  if(key=='z'|| key == 'Z'){
    z12=true;
  }
 else  if(key=='x'|| key == 'X'){
    x12=true;
  }
 else  if(key=='c'|| key == 'C')
{
  c12=true;
}
  else if(key=='v'|| key == 'V')
{
  v12=true;
}
  if(key=='y'|| key == 'Y'){
    y12=true;
  }
 else  if(key=='u'|| key == 'U'){
    u12=true;
  }
 else  if(key=='i'|| key == 'I')
{
  i12=true;
}
  else if(key=='o'|| key == 'O')
{
  o12=true;
}
  if(key=='h'|| key == 'H'){
    h12=true;
  }
 else  if(key=='j'|| key == 'J'){
    j12=true;
  }
 else  if(key=='k'|| key == 'K')
{
  k12=true;
}
  else if(key=='l'|| key == 'L')
{
  l12=true;
}
else if(key=='q'|| key == 'Q')/////////////////////////////////開始建
{
  q12=true;
}
}
void keyReleased(){
  if(key=='a'|| key == 'A')
  {
    a12=false;
  }
    if(key=='s'|| key == 'S'){
    s12=false;
    s123=3;
  }
   if(key=='d'|| key == 'D')
{
   d12=false;
}
 else  if(key=='f'|| key == 'F')
{
    f12=false;
}
   else if(key=='z'|| key == 'Z')
  {
    z12=false;
  }
   if(key=='x'|| key == 'X'){
    x12=false;
  }
   if(key=='c'|| key == 'C')
{
   c12=false;
}
  else if(key=='v'|| key == 'V')
{
    v12=false;
}
  if(key=='y'|| key == 'Y'){
    y12=false;
  }
 else  if(key=='u'|| key == 'U'){
    u12=false;
  }
 else  if(key=='i'|| key == 'I')
{
  i12=false;
}
  else if(key=='o'|| key == 'O')
{
  o12=false;
}
  if(key=='h'|| key == 'H'){
    h12=false;
  }
 else  if(key=='j'|| key == 'J'){
    j12=false;
  }
 else  if(key=='k'|| key == 'K')
{
  k12=false;
}
  else if(key=='l'|| key == 'L')
{
  l12=false;
}
  else if(key=='q'|| key == 'Q')/////////////////////////開始建
{
  q12=false;
}
}

2012年10月30日 星期二

WEEK HW08

boolean a1=false;
boolean a12=false;
boolean s1=false;
boolean s12=false;
boolean d1=false;
boolean f1=false;
boolean z1=false;
boolean x1=false;
boolean c1=false;
boolean v1=false;
boolean y1=false;
boolean u1=false;
boolean i1=false;
boolean o1=false;
boolean h1=false;
boolean j1=false;
boolean k1=false;
boolean l1=false;
boolean q1=false;
boolean take=false;
int s123=0;
 int sice=0;
 int siceten=0;
 int sicehun=0;
 int m=0;
void setup(){
  size(600,650);
}
void sicetake()//////////////////// 計分判斷
{
 if(sice<10)
    {
    sice++;
    }
    if(sice==10)
    {
      sice=0;
      if(siceten<10)
      {
      siceten++;
      }
      if(siceten==10)
      {
        siceten=0;
        if(sicehun<10)
        {
          sicehun++;
        }
      }
      }
}
void draw()
{
   if(s1==true&&s12==true)
  {
    sicetake();
    s12=false;
  }
  else if(s1==true&&s12==false)
  {
  }
  background(255);
  int m = millis()/1000;
  if(m==3)
  {
  a1=true;
  s1=true;
  }
  else if(m==4)
  {
    a1=false;
    s1=false;
  }
   if(m==7)
  {
  a1=true;
  s1=true;
  }
  else if(m==8)
  {
    a1=false;
    s1=false;
  }
 fill(255);
 /////////////////////////////////////////////第一排
 rect(50, 100, 100, 100);    
 rect(180, 100, 100, 100);
 rect(310, 100, 100, 100);
 rect(440, 100, 100, 100);
 ///////////////////////////////////////////////第二排
 rect(50, 230, 100, 100);
 rect(180, 230, 100, 100);
 rect(310, 230, 100, 100);
 rect(440, 230, 100, 100);
 //////////////////////////////////////////////第三排
 rect(50, 360, 100, 100);
 rect(180, 360, 100, 100);
 rect(310, 360, 100, 100);
 rect(440, 360, 100, 100);
 //////////////////////////////////////////////第四排
 rect(50, 490, 100, 100);
 rect(180, 490, 100, 100);
 rect(310, 490, 100, 100);
 rect(440, 490, 100, 100);
 /////////////////////////////////////////////////////////
  if(a1)
  {
    fill(0);
    rect(50, 100, 100, 100);
  }
   if(s1)
  {
    fill(0);
    rect(180, 100, 100, 100);
  }
   if(d1)
  {
    fill(0);
      rect(310, 100, 100, 100);
  }
   if(f1)
  {
    fill(0);
     rect(440, 100, 100, 100); 
  }
/////////////////////////////////////////////////////第一排
   if (z1)
        {
      fill(0);
      rect(50, 230, 100, 100);
        }
     if(x1)
        {
      fill(0);
      rect(180, 230, 100, 100);  
         
        }
      if(c1)
        {
      fill(0);
      rect(310, 230, 100, 100);      
        }
      if(v1)
        {
      fill(0);
      rect(440, 230, 100, 100);      
        }
//////////////////////////////////////////第二排
   if (y1)
        {
      fill(0);
      rect(50, 360, 100, 100);
        }
   if(u1)
        {
      fill(0);
      rect(180, 360, 100, 100);           
        }
      if(i1)
        {
      fill(0);
      rect(310, 360, 100, 100);      
        }
      if(o1)
        {
      fill(0);
      rect(440, 360, 100, 100);      
        }
/////////////////////////////////////////////////////////////第三排
if (h1)
        {
      fill(0);
      rect(50, 490, 100, 100);
        }
     if(j1)
        {
      fill(0);
      rect(180, 490, 100, 100);  
         
        }
      if(k1)
        {
      fill(0);
      rect(310, 490, 100, 100);      
        }
      if(l1)
        {
      fill(0);
      rect(440, 490, 100, 100);      
        }
 
////////////////////////////////////////////////////////////////第四排////////////X+50.Y+80
if(sice==1)
 {
  fill(0,0,0,120);
 rect(450, 280, 20, 60);
 rect(450, 360, 20, 60);
 }
 if(siceten==1)
 {
  fill(0,0,0,120);
 rect(300, 280, 20, 60);
 rect(300, 360, 20, 60);
 }
 if(sicehun==1)
 {
  fill(0,0,0,120);
 rect(150, 280, 20, 60);
 rect(150, 360, 20, 60);
 }
if(siceten==2)
 {
  fill(0,0,0,120);
 rect(240,260,60,20);
 rect(300, 280, 20, 60);
 rect(240,340,60,20);
 rect(220, 360, 20, 60);
 rect(240,420,60,20);
 }
if(sicehun==2)
 {
  fill(0,0,0,120);
 rect(90,260,60,20);
 rect(150, 280, 20, 60);
 rect(90,340,60,20);
 rect(70, 360, 20, 60);
 rect(90,420,60,20);
 }
if(sice==2)
 {
  fill(0,0,0,120);
 rect(390,260,60,20);
 rect(450, 280, 20, 60);
 rect(390,340,60,20);
 rect(370, 360, 20, 60);
 rect(390,420,60,20);
 }
if(sice==3)
 {
  fill(0,0,0,120);
 rect(390,260,60,20);
 rect(450, 280, 20, 60);
 rect(390,340,60,20);
 rect(450, 360, 20, 60);
 rect(390,420,60,20);
 }
if(siceten==3)
 {
  fill(0,0,0,120);
 rect(240,260,60,20);
 rect(300, 280, 20, 60);
 rect(240,340,60,20);
 rect(300, 360, 20, 60);
 rect(240,420,60,20);
 }
if(sicehun==3)
 {
  fill(0,0,0,120);
 rect(90,260,60,20);
 rect(150, 280, 20, 60);
 rect(90,340,60,20);
 rect(150, 360, 20, 60);
 rect(90,420,60,20);
 }
 if(sice==4)
 {
   fill(0,0,0,120);
   rect(370, 280, 20, 60);
   rect(450, 280, 20, 60);
   rect(390,340,60,20);
   rect(450, 360, 20, 60);
 }
 if(siceten==4)
 {
   fill(0,0,0,120);
   rect(220, 280, 20, 60);
   rect(300, 280, 20, 60);
   rect(240,340,60,20);
   rect(300, 360, 20, 60);
 }
 if(sicehun==4)
 {
   fill(0,0,0,120);
   rect(70, 280, 20, 60);
   rect(150, 280, 20, 60);
   rect(90,340,60,20);
   rect(150, 360, 20, 60);
 }
 if(sice==5)
 {
 fill(0,0,0,120);
 rect(390,260,60,20);
 rect(370, 280, 20, 60);
 rect(390,340,60,20);
 rect(450, 360, 20, 60);
 rect(390,420,60,20);
 }
 if(siceten==5)
 {
 fill(0,0,0,120);
 rect(240,260,60,20);
 rect(220, 280, 20, 60);
 rect(240,340,60,20);
 rect(300, 360, 20, 60);
 rect(240,420,60,20);
 }
 if(sicehun==5)
 {
 fill(0,0,0,120);
 rect(90,260,60,20);
 rect(70, 280, 20, 60);
 rect(90,340,60,20);
 rect(150, 360, 20, 60);
 rect(90,420,60,20);
 }
  if(sice==6)
 {
 fill(0,0,0,120);
 rect(390,260,60,20);
 rect(450, 280, 20, 60);
 rect(390,340,60,20);
 rect(450, 360, 20, 60);
 rect(390,420,60,20);
 rect(370, 360, 20, 60);
 }
 if(siceten==6)
 {
 fill(0,0,0,120);
 rect(240,260,60,20);
 rect(300, 280, 20, 60);
 rect(240,340,60,20);
 rect(300, 360, 20, 60);
 rect(240,420,60,20);
 rect(220, 360, 20, 60);
 }
 if(sicehun==6)
 {
 fill(0,0,0,120);
 rect(90,260,60,20);
 rect(150, 280, 20, 60);
 rect(90,340,60,20);
 rect(150, 360, 20, 60);
 rect(90,420,60,20);
 rect(70, 360, 20, 60);
 }
 if(sice==7)
 {
 fill(0,0,0,120);
 rect(390,260,60,20);
 rect(450, 280, 20, 60);
 rect(450, 360, 20, 60);
 }
 if(siceten==7)
 {
 fill(0,0,0,120);
 rect(240,260,60,20);
 rect(300, 280, 20, 60);
 rect(300, 360, 20, 60);
 }
 if(sicehun==7)
 {
 fill(0,0,0,120);
 rect(90,260,60,20);
 rect(150, 280, 20, 60);
 rect(150, 360, 20, 60);
 }
 if(sice==8)
 {
 fill(0,0,0,120);
 rect(390,260,60,20);
 rect(450, 280, 20, 60);
 rect(390,340,60,20);
 rect(450, 360, 20, 60);
 rect(390,420,60,20);
 rect(370, 360, 20, 60);
 rect(370, 280, 20, 60);
 }
 if(siceten==8)
 {
 fill(0,0,0,120);
 rect(240,260,60,20);
 rect(300, 280, 20, 60);
 rect(240,340,60,20);
 rect(300, 360, 20, 60);
 rect(240,420,60,20);
 rect(220, 360, 20, 60);
 rect(220, 280, 20, 60);
 }
 if(sicehun==8)
 {
 fill(0,0,0,120);
 rect(90,260,60,20);
 rect(150, 280, 20, 60);
 rect(90,340,60,20);
 rect(150, 360, 20, 60);
 rect(90,420,60,20);
 rect(70, 360, 20, 60);
 rect(70, 280, 20, 60);
 }
 if(sice==9)
 {
 fill(0,0,0,120);
 rect(390,260,60,20);
 rect(450, 280, 20, 60);
 rect(390,340,60,20);
 rect(450, 360, 20, 60);
 rect(390,420,60,20);
// rect(320, 280, 20, 60);
 rect(370, 280, 20, 60);
 }
 if(siceten==9)
 {
 fill(0,0,0,120);
 rect(240,260,60,20);
 rect(300, 280, 20, 60);
 rect(240,340,60,20);
 rect(300, 360, 20, 60);
 rect(240,420,60,20);
// rect(320, 280, 20, 60);
 rect(220, 280, 20, 60);
 }
 if(sicehun==9)
 {
 fill(0,0,0,120);
 rect(90,260,60,20);
 rect(150, 280, 20, 60);
 rect(90,340,60,20);
 rect(150, 360, 20, 60);
 rect(90,420,60,20);
// rect(320, 280, 20, 60);
 rect(70, 280, 20, 60);
 }
 if(sice==0)
 {
 fill(0,0,0,120);
 rect(390,260,60,20);
 rect(450, 280, 20, 60);
// rect(390,340,60,20);
 rect(450, 360, 20, 60);
 rect(390,420,60,20);
 rect(370, 360, 20, 60);
 rect(370, 280, 20, 60);
 }
 if(siceten==0)
 {
 fill(0,0,0,120);
 rect(240,260,60,20);
 rect(300, 280, 20, 60);
// rect(390,340,60,20);
 rect(300, 360, 20, 60);
 rect(240,420,60,20);
 rect(220, 360, 20, 60);
 rect(220, 280, 20, 60);
 }
 if(sicehun==0)
 {
 fill(0,0,0,120);
 rect(90,260,60,20);
 rect(150, 280, 20, 60);
// rect(390,340,60,20);
 rect(150, 360, 20, 60);
 rect(90,420,60,20);
 rect(70, 360, 20, 60);
 rect(70, 280, 20, 60);
 }
}
void keyPressed(){
  if(key=='a'|| key == 'A'){
    a12=true;
  }
 else  if(key=='s'|| key == 'S'){
    s12=true;
    s123=1;
  }
 else  if(key=='d'|| key == 'D')
{
  d1=true;
}
  else if(key=='f'|| key == 'F')
{
  f1=true;
}
  if(key=='z'|| key == 'Z'){
    z1=true;
  }
 else  if(key=='x'|| key == 'X'){
    x1=true;
  }
 else  if(key=='c'|| key == 'C')
{
  c1=true;
}
  else if(key=='v'|| key == 'V')
{
  v1=true;
}
  if(key=='y'|| key == 'Y'){
    y1=true;
  }
 else  if(key=='u'|| key == 'U'){
    u1=true;
  }
 else  if(key=='i'|| key == 'I')
{
  i1=true;
}
  else if(key=='o'|| key == 'O')
{
  o1=true;
}
  if(key=='h'|| key == 'H'){
    h1=true;
  }
 else  if(key=='j'|| key == 'J'){
    j1=true;
  }
 else  if(key=='k'|| key == 'K')
{
  k1=true;
}
  else if(key=='l'|| key == 'L')
{
  l1=true;
}
else if(key=='q'|| key == 'Q')/////////////////////////////////開始建
{
  q1=true;
}
}
void keyReleased(){
  if(key=='a'|| key == 'A')
  {
    a12=false;
    if(sice<10)
    {
    sice++;
    }
    if(sice==10)
    {
      sice=0;
      if(siceten<10)
      {
      siceten++;
      }
      if(siceten==10)
      {
        siceten=0;
        if(sicehun<10)
        {
          sicehun++;
        }
      }
    }
  }
    if(key=='s'|| key == 'S'){
    s12=false;
    s123=0;
  }
   if(key=='d'|| key == 'D')
{
   d1=false;
}
 else  if(key=='f'|| key == 'F')
{
    f1=false;
}
   else if(key=='z'|| key == 'Z')
  {
    z1=false;
  }
   if(key=='x'|| key == 'X'){
    x1=false;
  }
   if(key=='c'|| key == 'C')
{
   c1=false;
}
  else if(key=='v'|| key == 'V')
{
    v1=false;
}
  if(key=='y'|| key == 'Y'){
    y1=false;
  }
 else  if(key=='u'|| key == 'U'){
    u1=false;
  }
 else  if(key=='i'|| key == 'I')
{
  i1=false;
}
  else if(key=='o'|| key == 'O')
{
  o1=false;
}
  if(key=='h'|| key == 'H'){
    h1=false;
  }
 else  if(key=='j'|| key == 'J'){
    j1=false;
  }
 else  if(key=='k'|| key == 'K')
{
  k1=false;
}
  else if(key=='l'|| key == 'L')
{
  l1=false;
}
  else if(key=='q'|| key == 'Q')/////////////////////////開始建
{
  q1=false;
}
}
加入時間自動編輯
加入計分判斷

2012年10月23日 星期二

week,hw07

1.今天進度
boolean a1=false;
boolean s1=false;
boolean d1=false;
boolean f1=false;
boolean z1=false;
boolean x1=false;
boolean c1=false;
boolean v1=false;
boolean y1=false;
boolean u1=false;
boolean i1=false;
boolean o1=false;
boolean h1=false;
boolean j1=false;
boolean k1=false;
boolean l1=false;
 int sice=0;
 int siceten=0;
void setup(){
  size(600,650);
}
void draw()
{
  background(255);
 fill(255);
 /////////////////////////////////////////////第一排
 rect(50, 100, 100, 100);
 rect(180, 100, 100, 100);
 rect(310, 100, 100, 100);
 rect(440, 100, 100, 100);
 ///////////////////////////////////////////////第二排
 rect(50, 230, 100, 100);
 rect(180, 230, 100, 100);
 rect(310, 230, 100, 100);
 rect(440, 230, 100, 100);
 //////////////////////////////////////////////第三排
 rect(50, 360, 100, 100);
 rect(180, 360, 100, 100);
 rect(310, 360, 100, 100);
 rect(440, 360, 100, 100);
 //////////////////////////////////////////////第四排
 rect(50, 490, 100, 100);
 rect(180, 490, 100, 100);
 rect(310, 490, 100, 100);
 rect(440, 490, 100, 100);
 /////////////////////////////////////////////////////////
  if(a1)
  {
    fill(0);
    rect(50, 100, 100, 100);
  }
   if(s1)
  {
    fill(0);
    rect(180, 100, 100, 100);
  }
   if(d1)
  {
    fill(0);
      rect(310, 100, 100, 100);
  }
   if(f1)
  {
    fill(0);
     rect(440, 100, 100, 100); 
  }
/////////////////////////////////////////////////////第一排
   if (z1)
        {
      fill(0);
      rect(50, 230, 100, 100);
        }
     if(x1)
        {
      fill(0);
      rect(180, 230, 100, 100);  
         
        }
      if(c1)
        {
      fill(0);
      rect(310, 230, 100, 100);      
        }
      if(v1)
        {
      fill(0);
      rect(440, 230, 100, 100);      
        }
//////////////////////////////////////////第二排
   if (y1)
        {
      fill(0);
      rect(50, 360, 100, 100);
        }
   if(u1)
        {
      fill(0);
      rect(180, 360, 100, 100);           
        }
      if(i1)
        {
      fill(0);
      rect(310, 360, 100, 100);      
        }
      if(o1)
        {
      fill(0);
      rect(440, 360, 100, 100);      
        }
/////////////////////////////////////////////////////////////第三排
if (h1)
        {
      fill(0);
      rect(50, 490, 100, 100);
        }
     if(j1)
        {
      fill(0);
      rect(180, 490, 100, 100);  
         
        }
      if(k1)
        {
      fill(0);
      rect(310, 490, 100, 100);      
        }
      if(l1)
        {
      fill(0);
      rect(440, 490, 100, 100);      
        }
 
////////////////////////////////////////////////////////////////第四排////////////X+50.Y+80
if(sice==1)
 {
  fill(0);
 rect(450, 280, 20, 60);
 rect(450, 360, 20, 60);
 }
 if(siceten==1)
 {
  fill(0);
 rect(300, 280, 20, 60);
 rect(300, 360, 20, 60);
 }
if(sice==2)
 {
  fill(0);
 rect(390,260,60,20);
 rect(450, 280, 20, 60);
 rect(390,340,60,20);
 rect(370, 360, 20, 60);
 rect(390,420,60,20);
 }
if(sice==3)
 {
  fill(0);
 rect(390,260,60,20);
 rect(450, 280, 20, 60);
 rect(390,340,60,20);
 rect(450, 360, 20, 60);
 rect(390,420,60,20);
 }
 if(sice==4)
 {
   fill(0);
   rect(370, 280, 20, 60);
   rect(450, 280, 20, 60);
   rect(390,340,60,20);
   rect(450, 360, 20, 60);
 }
 if(sice==5)
 {
 fill(0);
 rect(390,260,60,20);
 rect(370, 280, 20, 60);
 rect(390,340,60,20);
 rect(450, 360, 20, 60);
 rect(390,420,60,20);
 }
  if(sice==6)
 {
 fill(0);
 rect(390,260,60,20);
 rect(450, 280, 20, 60);
 rect(390,340,60,20);
 rect(450, 360, 20, 60);
 rect(390,420,60,20);
 rect(370, 360, 20, 60);
 }
 if(sice==7)
 {
 fill(0);
 rect(390,260,60,20);
 rect(450, 280, 20, 60);
 rect(450, 360, 20, 60);
 }
 if(sice==8)
 {
 fill(0);
 rect(390,260,60,20);
 rect(450, 280, 20, 60);
 rect(390,340,60,20);
 rect(450, 360, 20, 60);
 rect(390,420,60,20);
 rect(370, 360, 20, 60);
 rect(370, 280, 20, 60);
 }
 if(sice==9)
 {
 fill(0);
 rect(390,260,60,20);
 rect(450, 280, 20, 60);
 rect(390,340,60,20);
 rect(450, 360, 20, 60);
 rect(390,420,60,20);
// rect(320, 280, 20, 60);
 rect(370, 280, 20, 60);
 }
 if(sice==0)
 {
 fill(0);
 rect(390,260,60,20);
 rect(450, 280, 20, 60);
// rect(390,340,60,20);
 rect(450, 360, 20, 60);
 rect(390,420,60,20);
 rect(370, 360, 20, 60);
 rect(370, 280, 20, 60);
 }
}
void keyPressed(){
  if(key=='a'|| key == 'A'){
    a1=true;
  }
 else  if(key=='s'|| key == 'S'){
    s1=true;
  }
 else  if(key=='d'|| key == 'D')
{
  d1=true;
}
  else if(key=='f'|| key == 'F')
{
  f1=true;
}
  if(key=='z'|| key == 'Z'){
    z1=true;
  }
 else  if(key=='x'|| key == 'X'){
    x1=true;
  }
 else  if(key=='c'|| key == 'C')
{
  c1=true;
}
  else if(key=='v'|| key == 'V')
{
  v1=true;
}
  if(key=='y'|| key == 'Y'){
    y1=true;
  }
 else  if(key=='u'|| key == 'U'){
    u1=true;
  }
 else  if(key=='i'|| key == 'I')
{
  i1=true;
}
  else if(key=='o'|| key == 'O')
{
  o1=true;
}
  if(key=='h'|| key == 'H'){
    h1=true;
  }
 else  if(key=='j'|| key == 'J'){
    j1=true;
  }
 else  if(key=='k'|| key == 'K')
{
  k1=true;
}
  else if(key=='l'|| key == 'L')
{
  l1=true;
}
}
void keyReleased(){
  if(key=='a'|| key == 'A')
  {
    a1=false;
    if(sice<10)
    {
    sice++;
    }
    if(sice==10)
    {
      sice=0;
      if(siceten<10)
      {
      siceten++;
      }
    }
  }
    if(key=='s'|| key == 'S'){
    s1=false;
  }
   if(key=='d'|| key == 'D')
{
   d1=false;
}
 else  if(key=='f'|| key == 'F')
{
    f1=false;
}
   else if(key=='z'|| key == 'Z')
  {
    z1=false;
  }
   if(key=='x'|| key == 'X'){
    x1=false;
  }
   if(key=='c'|| key == 'C')
{
   c1=false;
}
  else if(key=='v'|| key == 'V')
{
    v1=false;
}
  if(key=='y'|| key == 'Y'){
    y1=false;
  }
 else  if(key=='u'|| key == 'U'){
    u1=false;
  }
 else  if(key=='i'|| key == 'I')
{
  i1=false;
}
  else if(key=='o'|| key == 'O')
{
  o1=false;
}
  if(key=='h'|| key == 'H'){
    h1=false;
  }
 else  if(key=='j'|| key == 'J'){
    j1=false;
  }
 else  if(key=='k'|| key == 'K')
{
  k1=false;
}
  else if(key=='l'|| key == 'L')
{
  l1=false;
}
}
加入計分系統

2012年10月16日 星期二

Week,hw06

1.按鈕操作

void setup(){
  size(600,650);
}
//boolean a=false;
//boolean s=false;
void draw()
{
  int sice=0;
  //if(a=true)
 // {     
   // fill(0);
   //  rect(50, 100, 100, 100);
 
  //}
  if (keyPressed)
  {
    //////////////////////////////////////////////////第一排
    if (key == 'a' || key == 'A')
        {
      fill(0);
      rect(50, 100, 100, 100);
       // a=true;
     
        }
    else if(key == 's' || key == 'S')
        {
      fill(0);
      rect(180, 100, 100, 100);
        // s=true;  
         
        }
     else if(key == 'd' || key == 'D')
        {
      fill(0);
      rect(310, 100, 100, 100);      
        }
     else if(key == 'f' || key == 'F')
        {
      fill(0);
      rect(440, 100, 100, 100);      
        }
  /////////////////////////////////////////////////第二排
   if (key == 'z' || key == 'Z')
        {
      fill(0);
      rect(50, 230, 100, 100);
        }
    else if(key == 'x' || key == 'X')
        {
      fill(0);
      rect(180, 230, 100, 100);  
         
        }
     else if(key == 'c' || key == 'C')
        {
      fill(0);
      rect(310, 230, 100, 100);      
        }
     else if(key == 'v' || key == 'V')
        {
      fill(0);
      rect(440, 230, 100, 100);      
        }
    /////////////////////////////////////////////第三排
   if (key == 'y' || key == 'Y')
        {
      fill(0);
      rect(50, 360, 100, 100);
        }
    else if(key == 'u' || key == 'U')
        {
      fill(0);
      rect(180, 360, 100, 100);  
         
        }
     else if(key == 'i' || key == 'I')
        {
      fill(0);
      rect(310, 360, 100, 100);      
        }
     else if(key == 'o' || key == 'O')
        {
      fill(0);
      rect(440, 360, 100, 100);      
        }
  ////////////////////////////////////////////第四排
    if (key == 'h' || key == 'H')
        {
      fill(0);
      rect(50, 490, 100, 100);
        }
    else if(key == 'j' || key == 'J')
        {
      fill(0);
      rect(180, 490, 100, 100);  
         
        }
     else if(key == 'k' || key == 'K')
        {
      fill(0);
      rect(310, 490, 100, 100);      
        }
     else if(key == 'l' || key == 'L')
        {
      fill(0);
      rect(440, 490, 100, 100);      
        }
  }
  else
  {
 fill(255);
 /////////////////////////////////////////////第一排
 rect(50, 100, 100, 100);
 rect(180, 100, 100, 100);
 rect(310, 100, 100, 100);
 rect(440, 100, 100, 100);
 ///////////////////////////////////////////////第二排
 rect(50, 230, 100, 100);
 rect(180, 230, 100, 100);
 rect(310, 230, 100, 100);
 rect(440, 230, 100, 100);
 //////////////////////////////////////////////第三排
 rect(50, 360, 100, 100);
 rect(180, 360, 100, 100);
 rect(310, 360, 100, 100);
 rect(440, 360, 100, 100);
 //////////////////////////////////////////////第四排
 rect(50, 490, 100, 100);
 rect(180, 490, 100, 100);
 rect(310, 490, 100, 100);
 rect(440, 490, 100, 100);
  }
2.分數的圖片
 if(sice==0)
  {
 
 fill(0);
 rect(340,180,60,20);
 rect(400, 200, 20, 60);
 rect(400, 280, 20, 60);
 rect(340,340,60,20);
 rect(320, 280, 20, 60);
 rect(320, 200, 20, 60);
 
  }
 if(sice==1)
 {
  fill(0);
 rect(400, 200, 20, 60);
 rect(400, 280, 20, 60);
 }
 if(sice==2)
 {
  fill(0);
 rect(340,180,60,20);
 rect(400, 200, 20, 60);
 rect(340,260,60,20);
 rect(320, 280, 20, 60);
 rect(340,340,60,20);
 }
  if(sice==3)
 {
  fill(0);
 rect(340,180,60,20);
 rect(400, 200, 20, 60);
 rect(340,260,60,20);
 rect(400, 280, 20, 60);
 rect(340,340,60,20);
 }
 if(sice==4)
 {
   fill(0);
   rect(320, 200, 20, 60);
   rect(400, 200, 20, 60);
   rect(340,260,60,20);
   rect(400, 280, 20, 60);
 }
 if(sice==5)
 {
 fill(0);
 rect(340,180,60,20);
 rect(320, 200, 20, 60);
 rect(340,260,60,20);
 rect(400, 280, 20, 60);
 rect(340,340,60,20);
 }
  if(sice==6)
 {
 fill(0);
 rect(340,180,60,20);
 rect(400, 200, 20, 60);
 rect(340,260,60,20);
 rect(400, 280, 20, 60);
 rect(340,340,60,20);
 rect(320, 280, 20, 60);
 }
 if(sice==7)
 {
 fill(0);
 rect(340,180,60,20);
 rect(400, 200, 20, 60);
 rect(400, 280, 20, 60);
 }
 if(sice==8)
 {
 fill(0);
 rect(340,180,60,20);
 rect(400, 200, 20, 60);
 rect(340,260,60,20);
 rect(400, 280, 20, 60);
 rect(340,340,60,20);
 rect(320, 280, 20, 60);
 rect(320, 200, 20, 60);
 }
 if(sice==9)
 {
 fill(0);
 rect(340,180,60,20);
 rect(400, 200, 20, 60);
 rect(340,260,60,20);
 rect(400, 280, 20, 60);
 rect(340,340,60,20);
// rect(320, 280, 20, 60);
 rect(320, 200, 20, 60);
 }

2012年10月9日 星期二

Week,HW05

1.void setup(){
  size(600,600);
}
float rr=0.01;
float rra=0.01;
void draw(){
  background(255);
  translate(300,300);
    rotate(rr);
    rr+=0.01;
  //fill(random(255),random(255),random(255));
    for(int i=0;i<100;i++){
     rotate( PI/10);
    fill(1*i,2*i,3*i);
    ellipse(100-i*4,50,200,60-i);
  }
    rotate(rr);
    rra-=0.02;
    for(int i=0;i<100;i++){
    rotate( PI/10);
    fill(3*i,2*i,1*i);
    int a=30;

    ellipse(100-i*4,-50,200,30-i);
  }
}
2.跟滑鼠趴趴走
void setup(){
  size(600,600);
}
float rr=0.01;
float rra=0.01;
void draw(){
  background(255);
  translate(mouseX,mouseY);
    rotate(rr);
    rr+=0.01;
  //fill(random(255),random(255),random(255));
    for(int i=0;i<100;i++){
     rotate( PI/10);
    fill(1*i,2*i,3*i);
    ellipse(100-i*4,50,200,60-i);
  }
    rotate(rr);
    rra-=0.0002*mouseX;
    for(int i=0;i<100;i++){
    rotate( PI/10);
    fill(3*i,2*i,1*i);
    int a=30;
    ellipse(100-i*4,-50,200,30-i);
  }
}
3.我想做Jubeat的練習進行曲

首先可能需要紙板不過可能沒版法看直接看著版面玩

要先導入音樂
再來就是按鈕的判定
之後就是編曲
(遊戲先是必須能用按鍵進行)
然後做把它做出來
接電路
將按下的判定設成通電
最後就完成了

先KEY_IN
void draw() {
  if (keyPressed) {
    if (key == 'b' || key == 'B') {
      fill(0);
    }
  } else {
    fill(255);
  }
  rect(25, 25, 50, 50);
}

\