顯示具有 99160743紀詠心 標籤的文章。 顯示所有文章
顯示具有 99160743紀詠心 標籤的文章。 顯示所有文章

2013年1月14日 星期一

期末作品 Final


系統名稱:  <piano>

如何製作:

  1、用黑白膠帶纏住由冰棍製成的黑鍵與白鍵
  2、連接電路板、七個電阻、一個喇叭。
  3、製作由processing點選開始的畫面、進入鋼琴的畫面。
  4、撰寫arduino的程式碼。
  5、搜尋processing與arduino相互連接的程式。

圖片:
一開始執行的畫面
點選"Enter to play"後的畫面
按第一個按鈕,發出Do的聲音
按第二個按鈕,發出Re的聲音
按第三個按鈕,發出Me的聲音
按第四個按鈕,發出Fa的聲音
按第五個按鈕,發出So的聲音
小鋼琴圖片-1
小鋼琴圖片-2
小鋼琴圖片-3
電路板接線圖

程式碼

processing程式碼


import processing.serial.*;
Serial myPort;

PImage bg1,Do,Re,Mi,Fa,So,La,Si;

void setup() {
  size(800, 600);
  bg1 = loadImage("piano.jpg");  //載入圖檔
  Do = loadImage("piano-Do1.jpg");
  Re = loadImage("piano-Re1.jpg");
  Mi = loadImage("piano-Mi1.jpg");
  Fa = loadImage("piano-Fa1.jpg");
  So = loadImage("piano-So1.jpg");
  La = loadImage("piano-La1.jpg");
  Si = loadImage("piano-Si1.jpg");
  myPort = new Serial(this, "COM15", 9600);
}

void draw() {
  image(bg1, 0, 0, 800, 600);
  image(Do, 86, 82, 89, 333);
  image(Re, 169, 80, 89, 333);
  image(Mi, 253, 81, 89, 333);;
  image(Fa, 338.5, 84, 89, 333);
  image(So, 425, 81, 89, 333);;
  image(La, 509, 82, 89, 333);
  image(Si, 593, 82, 89, 333);
}


arduino程式碼


const int inPin1 = 1;
const int inPin2 = 2;
const int inPin3 = 3;
const int inPin4 = 4;
const int inPin5 = 5;
const int inPin6 = 6;
const int inPin7 = 7;

int val1 = 0, val2 = 0, val3 = 0, val4 = 0, val5 = 0, val6 = 0, val7 = 0;

void setup() {
   Serial.begin(9600);

   pinMode(inPin1, INPUT);
   pinMode(inPin2, INPUT);
   pinMode(inPin3, INPUT);
   pinMode(inPin4, INPUT);
   pinMode(inPin5, INPUT);
   pinMode(inPin6, INPUT);
   pinMode(inPin7, INPUT);
}

void loop() {
   val1 = digitalRead(inPin1);
   val2 = digitalRead(inPin2);
   val3 = digitalRead(inPin3);
   val4 = digitalRead(inPin4);
   val5 = digitalRead(inPin5);
   val6 = digitalRead(inPin6);
   val7 = digitalRead(inPin7);

      if(val1==HIGH){
         tone(8,524,8);
      }
      if(val2==HIGH){
         tone(8,588,8);
      }
      if(val3==HIGH){
         tone(8,660,8);
      }
      if(val4==HIGH){
         tone(8,698,8);
      }
      if(val5==HIGH){
         tone(8,784,8);
      }
       if(val6==HIGH){
         tone(8,880,8);
      }
       if(val7==HIGH){
         tone(8,988,8);
      }
}





心得介紹:
  我們在家執行時,程式碼是可以執行的;但在學校卻不能執行,經過老師的指導才知道原來
  是程式碼的問題,我們把之前在家裡寫得很完整的有些程式碼註解掉了,導致程式在執行
  時,狀況一堆 。
  原本我們的構想是想在這次的期末作品中,利用二維陣列寫出錄音的功能,可以記錄時間、
  音樂,讓玩家可以儲存自己在彈奏的旋律,並加入播放的功能,聲音是由電腦發出剛剛輸入
  的聲音。希望之後可以完成這兩項功能。

影片:




組員分工:

  陳孟琳:主要負責processing、arduino的程式碼。

  紀詠心:主要負責電路連接。

Week16,HW12

將期末作品的進度寫出來~

目前進度:

processing程式碼:

import processing.serial.*;
Serial myPort;

PImage bg1,Do,Re,Mi,Fa,So,La,Si;

void setup() {
  size(800, 600);
  bg1 = loadImage("piano.jpg");  //載入圖檔
  Do = loadImage("piano-Do1.jpg");
  Re = loadImage("piano-Re1.jpg");
  Mi = loadImage("piano-Mi1.jpg");
  Fa = loadImage("piano-Fa1.jpg");
  So = loadImage("piano-So1.jpg");
  La = loadImage("piano-La1.jpg");
  Si = loadImage("piano-Si1.jpg"); 
  myPort = new Serial(this, "COM15", 9600);
}

void draw() {
  image(bg1, 0, 0, 800, 600);
  image(Do, 86, 82, 89, 333);
  image(Re, 169, 80, 89, 333);   
  image(Mi, 253, 81, 89, 333);;
  image(Fa, 338.5, 84, 89, 333);
  image(So, 425, 81, 89, 333);;
  image(La, 509, 82, 89, 333);
  image(Si, 593, 82, 89, 333);
}

----------------------------------------------------------------------------------------

arduino程式碼:

const int inPin1 = 1;
const int inPin2 = 2;
const int inPin3 = 3;
const int inPin4 = 4;
const int inPin5 = 5;
const int inPin6 = 6;
const int inPin7 = 7;

int val1 = 0, val2 = 0, val3 = 0, val4 = 0, val5 = 0, val6 = 0, val7 = 0;

void setup() {
   Serial.begin(9600);
  
   pinMode(inPin1, INPUT);
   pinMode(inPin2, INPUT);
   pinMode(inPin3, INPUT);
   pinMode(inPin4, INPUT);
   pinMode(inPin5, INPUT);
   pinMode(inPin6, INPUT);
   pinMode(inPin7, INPUT);
}

void loop() {
   val1 = digitalRead(inPin1);
   val2 = digitalRead(inPin2);
   val3 = digitalRead(inPin3);
   val4 = digitalRead(inPin4);
   val5 = digitalRead(inPin5);
   val6 = digitalRead(inPin6);
   val7 = digitalRead(inPin7);

      if(val1==HIGH){
         tone(8,524,8);
      }
      if(val2==HIGH){
         tone(8,588,8);
      }
      if(val3==HIGH){
         tone(8,660,8);
      }
      if(val4==HIGH){
         tone(8,698,8);
      }
      if(val5==HIGH){
         tone(8,784,8);
      }
       if(val6==HIGH){
         tone(8,880,8);
      }
       if(val7==HIGH){
         tone(8,988,8);
      }
}


----------------------------------------------------------------------------------------

找素材(圖片):




素材:一包冰棍、黑白色膠帶各一綑、一片珍珠板、
            七個方形按鈕、七個電阻、一個喇叭等。

----------------------------------------------------------------------------------------

心得:

  這次的期末作業,我們想要用冰棍來製作小型的鋼琴鍵。
  可以發出:Do、Re、Mi、Fa、So、La、Si的音階,並
  可以錄音由玩家彈奏的一段旋律,並有儲存、播放的功能。




2012年12月18日 星期二

Wee13,HW11

01.將Arduino做出的鋼琴錄影上傳到youtube,再貼回部落格


02.發揮你的創意做出最特別的音樂

~~音樂 : 小蜜蜂~~
03.貼上程式碼

const int inPin1 = 7;
const int inPin2 = 6;
const int inPin3 = 5;
const int inPin4 = 3;
const int inPin5 = 2;
int val1 = 0, val2 = 0, val3 = 0, val4 = 0, val5 = 0;
void setup() {
   pinMode(inPin1, INPUT);
   pinMode(inPin2, INPUT);
   pinMode(inPin3, INPUT);
   pinMode(inPin4, INPUT);
   pinMode(inPin5, INPUT);
}
void loop() {
   val1 = digitalRead(inPin1);
   val2 = digitalRead(inPin2);
   val3 = digitalRead(inPin3);
   val4 = digitalRead(inPin4);
   val5 = digitalRead(inPin5);

      if(val1==HIGH){
         tone(8,524,8);
      }
      if(val2==HIGH){
         tone(8,588,8);
      }
      if(val3==HIGH){
         tone(8,660,8);
      }
      if(val4==HIGH){
         tone(8,698,8);
      }
      if(val5==HIGH){
         tone(8,784,8);
      }
}

心得:
這次在課堂上做了"1 2 3 4 5 "五個音階,但是我們按"2"的按鈕,發出來的聲音聽起來有點分岔,不是很悅耳。電線經過幾次的調整後,"2"的音終於比較正常了,但是"3"的音卻怪怪的,索性我們跟別組借了按鈕,五個音階終於正常了。

影片中的音樂是"小蜜蜂"。

2012年11月27日 星期二

Weel12,HW10

1、霹靂燈之影片分享

   藉由調可變電阻改變閃爍頻率


影片一、快速閃爍的霹靂燈

影片二、閃爍較慢的霹靂燈

影片三、調整閃爍頻率之霹靂燈



2、

圖一
圖二


3、程式碼


void setup() {
  // declare the ledPin as an OUTPUT:
  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
  digitalWrite(13, HIGH);
  delay(sensorValue);
  digitalWrite(12, HIGH);
  delay(sensorValue);
  digitalWrite(11, HIGH);
  delay(sensorValue);
  digitalWrite(10, HIGH);
  delay(sensorValue);
  digitalWrite(9, HIGH);
  delay(sensorValue);
  digitalWrite(8, HIGH);
  delay(sensorValue);
  digitalWrite(7, HIGH);
  delay(sensorValue);
  // stop the program for <sensorValue> milliseconds:
  delay(sensorValue);        
  // turn the ledPin off:      
  digitalWrite(13, LOW);
  delay(sensorValue);
  digitalWrite(12, LOW);
  delay(sensorValue);
  digitalWrite(11, LOW);
  delay(sensorValue);
  digitalWrite(10, LOW);
  delay(sensorValue);
  digitalWrite(9, LOW);
  delay(sensorValue);
  digitalWrite(8, LOW);
  delay(sensorValue);
  digitalWrite(7, LOW);
  delay(sensorValue);
  // stop the program for for <sensorValue> milliseconds:
  delay(sensorValue);
  digitalWrite(13, HIGH);
  digitalWrite(12, HIGH);
  digitalWrite(11, HIGH);
  digitalWrite(10, HIGH);
  digitalWrite(9, HIGH);
  digitalWrite(8, HIGH);
  digitalWrite(7, HIGH);
  delay(sensorValue);
  digitalWrite(13, LOW);
  digitalWrite(12, LOW);
  digitalWrite(11, LOW);
  digitalWrite(10, LOW);
  digitalWrite(9, LOW);
  digitalWrite(8, LOW);
  digitalWrite(7, LOW);
  delay(sensorValue);
  digitalWrite(13, HIGH);
  digitalWrite(12, HIGH);
  digitalWrite(11, HIGH);
  digitalWrite(10, HIGH);
  digitalWrite(9, HIGH);
  digitalWrite(8, HIGH);
  digitalWrite(7, HIGH);
  delay(sensorValue);
  digitalWrite(13, LOW);
  digitalWrite(12, LOW);
  digitalWrite(11, LOW);
  digitalWrite(10, LOW);
  digitalWrite(9, LOW);
  digitalWrite(8, LOW);
  digitalWrite(7, LOW);
  delay(sensorValue);

  digitalWrite(7, HIGH);
  delay(sensorValue);
  digitalWrite(8, HIGH);
  delay(sensorValue);
  digitalWrite(9, HIGH);
  delay(sensorValue);
  digitalWrite(10, HIGH);
  delay(sensorValue);
  digitalWrite(11, HIGH);
  delay(sensorValue);
  digitalWrite(12, HIGH);
  delay(sensorValue);
  digitalWrite(13, HIGH);
  delay(sensorValue);
  // stop the program for <sensorValue> milliseconds:
  delay(sensorValue);        
  // turn the ledPin off:      
  digitalWrite(7, LOW);
  delay(sensorValue);
  digitalWrite(8, LOW);
  delay(sensorValue);
  digitalWrite(9, LOW);
  delay(sensorValue);
  digitalWrite(10, LOW);
  delay(sensorValue);
  digitalWrite(11, LOW);
  delay(sensorValue);
  digitalWrite(12, LOW);
  delay(sensorValue);
  digitalWrite(13, LOW);
  delay(sensorValue);
}

心得:

2012年11月20日 星期二

HW09, week11

01.思考可以用Processing + Arduino做些什麼?

  • 騎腳踏車:利用手的轉動,模擬腳的踩踏,並前進
  • 打桌球:可用水銀測量揮拍角度,但是速度部分我不知道如何測量及控制


02.貼一個Arduino相關的影片

Wireless Arduino Powered Chess

無線遠端一起玩西洋棋
西洋棋會自己動!!!!!
死掉的旗子也會自己跑出場哈哈

2012年11月13日 星期二

Midterm

期中作品

影片



截圖


一開始的畫面
滑鼠點選"開始遊戲"後,切換到"鐵板"的畫面

滑鼠點選"遊戲說明"後,切換到"遊戲說明"的畫面
 
製作章魚燒的鐵板


Time's up  &  Game Over的畫面
(滑鼠點選"離開遊戲"後,切換到這個畫面) 




 程式碼

float r=0.01;
int savedTime; //計時器時間
int bg=1;
PImage bg1, vv, pp, over, e, fff, tako1, all;
int state=0;
int ellipse1 = 0;


void setup() {
  size(800, 600);
  savedTime = millis();  //儲存遊戲開始的時間(只執行一次)
  bg1 = loadImage("bg1.jpg");
  vv = loadImage("vv.jpg");
  pp = loadImage("pp1.jpg");
  over = loadImage("bg4.jpg");
  e = loadImage("turtle.jpg");
  fff = loadImage("fff.jpg");
  tako1 = loadImage("tako1.jpg");
  all = loadImage("06.jpg");
}

void draw() {
  println(mouseY);
  if (bg==1) {
    image(bg1, 0, 0, 800, 600);  //一開始執行的畫面
    if (mousePressed && mouseX>=555 && mouseX<=794 && mouseY>=261 && mouseY<=396) {
      image(pp, 0, 0);
      bg=2;  //滑鼠點選"開始遊戲"後,切換到"鐵板"的畫面
    }
    else if (mousePressed && mouseX>=550 && mouseX<=800 && mouseY>=420 && mouseY<=550) {
      bg=3;  /滑鼠/點選"遊戲說明"後,切換到"遊戲說明"的畫面
    }
  }
  if (bg==3) {
    image(vv, 0, 0, 800, 600);  //"遊戲說明"的畫面
    if (mousePressed && mouseX>=255 && mouseX<=465 && mouseY>=498 && mouseY<=594) {
      image(pp, 0, 0, 800, 600);
      bg=2;  //滑鼠點選"開始遊戲"後,切換到"鐵板"的畫面
    }
  }

  if (bg==2) {  //鐵板的畫面
    int passedTime = (millis() - savedTime)/100; //經過的秒數
    if (passedTime<600) {
      image(e, 683, passedTime, 120, 98);
    }
    else if (passedTime>=600) image(over, 0, 0, 800, 600);
    println(passedTime);
    if (mousePressed && mouseX>=485 && mouseX<=645 && mouseY>=542 && mouseY<=584) {
      image(over, 0, 0);
      bg=4;  //遊戲結束的畫面
    }
    if (mousePressed && mouseX>50 && mouseX<90 && mouseY>500 && mouseY<540) { 
      state = 1;
    }
    if (mousePressed && mouseX>150 && mouseX<190 && mouseY>500 && mouseY<540) {
      state = 2;
    }
    if (mousePressed && mouseX>250 && mouseX<290 && mouseY>500 && mouseY<540) {
      state = 3;
    }
    if (mousePressed && mouseX>350 && mouseX<390 && mouseY>500 && mouseY<540) {
      state = 4;
    }
    if (state == 1) {
      if (mousePressed && mouseX>40 && mouseX<160 && mouseY>40 && mouseY<160) {
        if (passedTime<100) {
          fill(239, 228, 176);  //白
          ellipse(100, 100, 120, 120);
        }
        else if (passedTime>=100 && passedTime<150) {
          fill(235, 194, 102);  //黃
          ellipse(100, 100, 120, 120);
        }
        else if (passedTime>=150) {
          fill(223, 147, 51);  //熟
          ellipse(100, 100, 120, 120);
        }
      }
      else if (mousePressed && mouseX>40 && mouseX<160 && mouseY>190 && mouseY<310) {
        if (passedTime<100) {
          fill(239, 228, 176);  //白
          ellipse(100, 250, 120, 120);
        }
        else if (passedTime>=100 && passedTime<150) {
          fill(235, 194, 102);  //黃
          ellipse(100, 250, 120, 120);
        }
        else if (passedTime>=100) {
          fill(223, 147, 51);  //熟
          ellipse(100, 250, 120, 120);
        }
      }
      else if (mousePressed && mouseX>40 && mouseX<160 && mouseY>340 && mouseY<460) {
        if (passedTime<100) {       
          fill(239, 228, 176);  //白
          ellipse(100, 400, 120, 120);
        }
        else if (passedTime>=100 && passedTime<150) {
          fill(235, 194, 102);  //黃
          ellipse(100, 400, 120, 120);
        }
        else if (passedTime>=150) {
          fill(223, 147, 51);  //熟
          ellipse(100, 400, 120, 120);
        }
      }
      else if (mousePressed && mouseX>190 && mouseX<310 && mouseY>40 && mouseY<160) {
        if (passedTime<100) {
          fill(239, 228, 176);  //白
          ellipse(250, 100, 120, 120);
        }
        else if (passedTime>=100 && passedTime<150) {
          fill(235, 194, 102);  //黃
          ellipse(250, 100, 120, 120);
        }
        else if (passedTime>=150) {
          fill(223, 147, 51);  //熟
          ellipse(250, 100, 120, 120);
        }
      }
      else if (mousePressed && mouseX>190 && mouseX<310 && mouseY>190 && mouseY<310) {
        if (passedTime<100) {        
          fill(239, 228, 176);  //白
          ellipse(250, 250, 120, 120);
        }
        else if (passedTime>=100 && passedTime<150) {
          fill(235, 194, 102);  //黃
          ellipse(250, 250, 120, 120);
        }
        else if (passedTime>=150) {
          fill(223, 147, 51);  //熟
          ellipse(250, 250, 120, 120);
        }
      }
      else if (mousePressed && mouseX>190 && mouseX<310 && mouseY>340 && mouseY<460) {
        if (passedTime<100) {         
          fill(239, 228, 176);  //白
          ellipse(250, 400, 120, 120);
        }
        else if (passedTime>=100 && passedTime<150) {
          fill(235, 194, 102);  //黃
          ellipse(250, 400, 120, 120);
        }
        else if (passedTime>=150) {
          fill(223, 147, 51);  //熟
          ellipse(250, 400, 120, 120);
        }
      }
      else if (mousePressed && mouseX>340 && mouseX<460 && mouseY>40 && mouseY<160) {
        if (passedTime<100) { 
          fill(239, 228, 176);  //白
          ellipse(400, 100, 120, 120);
        }
        else if (passedTime>=100 && passedTime<150) {
          fill(235, 194, 102);  //黃
          ellipse(400, 100, 120, 120);
        }
        else if (passedTime>=150) {
          fill(223, 147, 51);  //熟
          ellipse(400, 100, 120, 120);
        }
      }
      else if (mousePressed && mouseX>340 && mouseX<460 && mouseY>190 && mouseY<310) {
        if (passedTime<100) { 
          fill(239, 228, 176);  //白
          ellipse(400, 250, 120, 120);
        }
        else if (passedTime>=100 && passedTime<150) {
          fill(235, 194, 102);  //黃
          ellipse(400, 250, 120, 120);
        }
        else if (passedTime>=150) {
          fill(223, 147, 51);  //熟
          ellipse(400, 250, 120, 120);
        }
      }
      else if (mousePressed && mouseX>340 && mouseX<460 && mouseY>340 && mouseY<460) {
        if (passedTime<100) { 
          fill(239, 228, 176);  //白
          ellipse(400, 400, 120, 120);
        }
        else if (passedTime>=100 && passedTime<150) {
          fill(235, 194, 102);  //黃
          ellipse(400, 400, 120, 120);
        }
        else if (passedTime>=150) {
          fill(223, 147, 51);  //熟
          ellipse(400, 400, 120, 120);
        }
      }//第三排
    }

    //手(加章魚至麵糊)
    if (state == 2) {
      if (mousePressed && mouseX>40 && mouseX<160 && mouseY>40 && mouseY<160) {
        image(tako1, 70, 70, 65, 65);
      }
      else if (mousePressed && mouseX>40 && mouseX<160 && mouseY>190 && mouseY<310) {
        image(tako1, 70, 220, 65, 65);
      }
      else if (mousePressed && mouseX>40 && mouseX<160 && mouseY>340 && mouseY<460) {
        image(tako1, 70, 370, 65, 65);
      }
      else if (mousePressed && mouseX>190 && mouseX<310 && mouseY>40 && mouseY<160) {
        image(tako1, 220, 70, 65, 65);
      }
      else if (mousePressed && mouseX>190 && mouseX<310 && mouseY>190 && mouseY<310) {
        image(tako1, 220, 220, 65, 65);
      }
      else if (mousePressed && mouseX>190 && mouseX<310 && mouseY>340 && mouseY<460) {
        image(tako1, 220, 370, 65, 65);
      }
      else if (mousePressed && mouseX>340 && mouseX<460 && mouseY>40 && mouseY<160) { 
        image(tako1, 370, 70, 65, 65);
      }
      else if (mousePressed && mouseX>340 && mouseX<460 && mouseY>190 && mouseY<310) { 
        image(tako1, 370, 220, 65, 65);
      }
      else if (mousePressed && mouseX>340 && mouseX<460 && mouseY>340 && mouseY<460) {
        image(tako1, 370, 370, 65, 65);
      }
    }
  
   //叉子   
    if (state == 3) {
      if (mousePressed && mouseX>40 && mouseX<160 && mouseY>40 && mouseY<160) {
        fill(43);
        ellipse(100, 100, 120, 120);
        image(fff, 510, 280, 50, 50);
      }
      else if (mousePressed && mouseX>40 && mouseX<160 && mouseY>190 && mouseY<310) {
        fill(43);
        ellipse(100, 250, 120, 120);
        image(fff, 560, 280, 50, 50);
      }
      else if (mousePressed && mouseX>40 && mouseX<160 && mouseY>340 && mouseY<460) {
        fill(43);
        ellipse(100, 400, 120, 120);
        image(fff, 560, 330, 50, 50);
      }
      else if (mousePressed && mouseX>190 && mouseX<310 && mouseY>40 && mouseY<160) {
        fill(43);
        ellipse(250, 100, 120, 120);
        image(fff, 510, 330, 50, 50);
      }
      else if (mousePressed && mouseX>190 && mouseX<310 && mouseY>190 && mouseY<310) {
        fill(43);
        ellipse(250, 250, 120, 120);
        image(fff, 510, 380, 50, 50);
      }
      else if (mousePressed && mouseX>190 && mouseX<310 && mouseY>340 && mouseY<460) {
        fill(43);
        ellipse(250, 400, 120, 120);
        image(fff, 560, 380, 50, 50);
      }
      else if (mousePressed && mouseX>340 && mouseX<460 && mouseY>40 && mouseY<160) { 
        fill(43);
        ellipse(400, 100, 120, 120);
        image(fff, 560, 430, 50, 50);
      }
      else if (mousePressed && mouseX>340 && mouseX<460 && mouseY>190 && mouseY<310) { 
        fill(43);
        ellipse(400, 250, 120, 120);
        image(fff, 510, 430, 50, 50);
      }
      else if (mousePressed && mouseX>340 && mouseX<460 && mouseY>340 && mouseY<460) {
        fill(43);
        ellipse(400, 400, 120, 120);
        image(fff, 535, 480, 50, 50);
      }
    }//state3
    if (state == 4) {
      //background(96,125,165);
      translate(400, 300);
      rotate(r);
      r+=0.01;
      image(all, 0, 0, 300, 383);
      //image(over, 0, 0, 800, 600);
    }
  }
}



心得及問題討論:

  我們這次的期中作業遇到了麵糊變換顏色跟時間倒數的問題,後來請教老師跟助教,
有了一點方向,經過不斷的嘗試跟調整,我們終於完成了麵糊可以從白色→黃色→褐色(時間約經過15秒),但是我們原本的想法是希望麵糊每經過10秒後會自己變色。
另外,我們了解到秒數的倒數計時程式不可以用second(),而是要用millis()千分之一秒。
  計時器部分,我們原本希望可以用兩個clock來紀錄不同的時間(烏龜的倒數計時,與麵糊改變顏色的計時),這是我們需要改進的地方。

  問題:我們目前只能完成一盒章魚燒,希望能繼續延伸製作第二盒甚至更多章魚燒。
物件及畫面可以再做調整,並需要加入更多限制使遊戲更完整、更有挑戰性。



2012年10月30日 星期二

Week08,HW08

1. 請寫下以下資料:
1.1. 你之前完成了什麼?
      
       我們之前完成了烤章魚燒的烤盤。

1.2. 你今天計畫要做什麼?

       我們今天計畫完成
       (1)切換畫面(從一開始的畫面→點選"開始遊戲" → 切換到烤章魚燒烤盤的畫面)。
       (2)工具列(麵糊、叉子、刷子、手)。 
       (3)章魚燒可以成功變色(漸層變色,變色是用計時器來控制)
            白色 → 黃色(麵糊開始變色)
                     → 褐色(章魚燒成功的顏色)
                     → 黑色(章魚燒失敗的顏色,焦掉)。 
       (4)用小烏龜的移動代表時間的倒數。

1.3. 可能會遇到的問題... (及可能的解決方法)

       我們在麵糊變色遇到了很大的困難,花了我們很多時間去調整RGB數值,但是都沒有很
      成功。
      後來我們請教助教,顏色終於比較像了,在助教的幫忙下,有了計時器和漸層的功能。
     

2. 請把你目前期中作品的進度貼出來
 
一開始的畫面

點選"遊戲開始"後切換的畫面
小烏龜代表時間的倒數(時間一點一滴的流逝~~)
倒入麵糊、麵糊變色(變色是用計時器來控制)、
小烏龜的移動(時間在倒數)的畫面

2012年10月29日 星期一

week7 視訊

//小葉老師最短的視訊
import processing.video.*;
Capture video;
void setup(){
  size(640,480,P2D);
  video = new Capture(this, width, height);
  video.start();
  loadPixels();
}
void draw(){
  if(video.available()){
    video.read();
    video.loadPixels();
    for(int i=0;i<640*480;i++){
      pixels[i]=video.pixels[i];      
    }
    updatePixels();
  }




我們可愛的組員及頭上長花反串同學 XD


臉臭臭的組員在認真上課中 

 

2012年10月16日 星期二

HW6,Week6

第一部分: "寫"作品建議, 讚美、寫賣點
雞蛋拋拋樂(蕭靖芸,黃慶華)
很像上樓梯一類的遊戲,但是我好想看到雞蛋破掉,或是孵出小雞
擠痘痘遊戲(林雨辰,王承安)
看起來很噁心又很有趣,很期待成品
踩地雷遊戲(潘若葳,黃培恩)
很好奇隨機出現的數字的產生


第二部分: 今天的進度: 做期中作品

(a) 素材
(b) 流程,很細地寫下步驟
我們需要(Backgroud)
  • 計時器,來推估製作進度 ( 麵糊白→黃→熟→→焦掉 ),與遊戲時間的限制
  • 烤盤
  • 盒子
  • 垃圾桶,將失敗的麵糊丟至此處
工具欄位包含了
  • 麵糊壺,於烤盤上倒入入麵糊
  • 叉子,利用滑鼠翻面與移動章魚燒
  • 內餡,麵糊上加入章魚、高麗菜等
  • 刷子,可於章魚燒上加入醬料
分數計算
於時間內所製作完整的章魚燒數量加以計算


延伸加強版
結合「撈金魚遊戲」
在遊戲一開始必須先撈適量的"章魚"放置於盤子上
而麵糊熟後必須加入「新鮮的」章魚才能獲得高分
或放置過久的章魚不能添加進去




(c) 試 code 看想法是否可行

2012年10月9日 星期二

HW5

作業1: 會自己動
void setup(){
 size(600,600);
}
int s=20;
float r=0.01;
void draw(){
  background(0,128,200);
  fill(255,255,255);
  quad(250,200,350,200,400,500,200,500);
  fill(127,127,127);
  triangle(300,150,450,300,150,300);

  translate(300,250);
  rotate(r);
  r+=0.01;
  for(int i=0;i<4;i++){
      fill(255,255,255,200);
      rotate(2*PI/4);
      rect(10,0,200,40);
      line(10,20,210,20);
      line(10,10,210,10);
      line(10,30,210,30);
  }
}
會轉動的風車


作業2: 會和你互動
加入  if,else條件 判斷是否按下按下滑鼠
使風車於按下滑鼠時停止轉動
   
if(!mousePressed){
      rotate(r);
      r+=0.01;
    }
    else      
    rotate(r);


作業3: 期中作品你想做什麼














製作章魚燒

玩家將滑鼠移動到烤盤上面游標會變成盛裝麵糊的容易,
點下去就可以將圓圈填滿,
麵糊會先變成淺褐色然後幾秒後便成褐色就代表已經熟了,
玩家必須馬上將滑鼠移動到章魚燒上面,
此時游標會變成叉子,
點下去後將章魚燒放置在右下角的盒子當中一個盒子必須裝滿八個章魚燒才算完整,
而當你的章魚燒在烤盤上放置太久則會燒焦,燒焦的就必須丟到左下角垃圾桶內,
這個遊戲就有時間限制跟數量限制了,
玩家必須在時間之內完成盒數章魚燒才算成功,


心得 :
看到大家的創意
很期待大家期中的作品ya

2012年10月3日 星期三

hw4,week4

作業 : 小畫家
製作了8種顏色方塊可選則顏色
右方有 "+" 與 "-" 可以調整畫筆粗細
下方
ave按鈕可以存取影像
load按鈕可以載入所存取的影像


void setup()
{
size(600,500);
background(172,255,255);
//background(0,125,63);
//選顏色方塊
fill(255,255,255);
rect(10,10,30,30,3);
fill(192,192,192);
rect(10,50,30,30,3);
fill(128,64,0);
rect(10,90,30,30,3);
fill(255,128,0);
rect(10,130,30,30,3);
fill(255,255,0);
rect(10,170,30,30,3);
fill(108,180,68);
rect(10,210,30,30,3);
fill(252,211,193);
rect(10,250,30,30,3);
fill(0,0,255);
rect(10,290,30,30,3);
fill(0,157,220);
rect(10,330,30,30,3);

//選筆粗
fill(255,255,255);
rect(560,10,30,30,3);
String w = "+";
fill(0);
text(w,572,30);

fill(255,255,255);
rect(560,50,30,30,3);
String d = "-";
fill(0);
text(d,572,70);


//button_save
fill(0,120,0);
rect(450,450,50,30,3);
String s = "save";
fill(255);
text(s,462,470);
//button_load
fill(128,64,64);
rect(507,450,50,30,3);
String l = "load";
fill(255);
text(l,520,470);


stroke(0,0,0);
strokeWeight(1);
}

int ha=5;
void draw()
{
  //筆觸大小
  if(mousePressed && mouseX>450 && mouseY<50){
    strokeWeight(++ha);
    if(ha>20)ha=20;
  }
  else if(mousePressed && mouseX>560 && mouseX<590 && mouseY>50 && mouseY<80){
    strokeWeight(--ha);
    if(ha<2)ha=2;
  }

  //button事件
  if(mousePressed && mouseX>450 && mouseX<500 && mouseY>450 && mouseY<480){
    save("pic_1.jpg");
  }
  else if(mousePressed && mouseX>507 && mouseX<557 && mouseY>450 && mouseY<480){
    PImage file = loadImage("pic_1.jpg");
    image(file, 0,0,600,500);
  }

  //顏色
  else if(mousePressed && mouseX<40 && mouseY>10 && mouseY<40)stroke(255,255,255);
  else if(mousePressed && mouseX<40 && mouseY>50 && mouseY<80)stroke(192,192,192);
  else if(mousePressed && mouseX<40 && mouseY>90 && mouseY<120)stroke(128,64,0);
  else if(mousePressed && mouseX<40 && mouseY>130 && mouseY<160)stroke(255,128,0);
  else if(mousePressed && mouseX<40 && mouseY>170 && mouseY<200)stroke(255,255,0);
  else if(mousePressed && mouseX<40 && mouseY>210 && mouseY<240)stroke(0,128,0);
  else if(mousePressed && mouseX<40 && mouseY>250 && mouseY<280)stroke(252,211,193);
  else if(mousePressed && mouseX<40 && mouseY>290 && mouseY<320)stroke(0,0,255);
  else if(mousePressed && mouseX<40 && mouseY>330 && mouseY<360)stroke(0,157,220);
  else if(mousePressed)line(mouseX,mouseY,pmouseX,pmouseY);
}





我是想要畫阿寶.........


心得
小畫家的介面製作好好玩
但是其實我還希望可以做出橡皮擦的功能(因為常常會不小心畫錯)
老師有提供一個方法,是多一個筆刷並設成背景顏色。
但是我想要的是四還原功能的筆刷~~
還有點選 + - 部分加大縮小筆刷大小
但是顏色都會殘留在上面

2012年9月25日 星期二

Week3,HW3

作業一 : 跟著滑鼠移動

void setup(){
  size(600,600);
  background(0,64,0);//背景顏色
  noStroke();//消除物件外框
}
void draw(){
  fill(255,255,255);
  rect(250,250,100,100);


  fill(255,255,0);
  ellipse(mouseX,mouseY,50,50);//物件位置改成mouseX、mouseY即可由滑鼠控制物件位置
}

作業二 : 多拉A夢追銅鑼燒

void setup(){
  size(800,600);
  //frameRate(1);
}
void dora(){
  //size(206,244);
  //noStroke();
  //頭
  fill(2,187,233);
  ellipse(100, 75, 150, 146);
  
  //身體
  fill(2,187,233);
  rect(47,140, 108, 76, 3);
  quad(17,165,47,143,48,173,32,185);
  quad(154,143,178,162,166,180,153,170);
  fill(255,255,255);
  ellipse(23,174,30,31);
  ellipse(178,173,30,31);
  ellipse(100, 165, 84, 84);//身體白處
  
  //臉
  fill(255,255,255);
  ellipse(100, 95, 126, 95);
  //眼睛
  fill(255,255,255);
  ellipse(82, 46, 35, 44);
  fill(255,255,255);
  ellipse(117, 46, 35, 44);
  //眼珠
  fill(0,0,0);
  ellipse(91, 55, 9, 9);
  fill(0,0,0);
  ellipse(111, 55, 9, 9);
  //鼻子
  fill(255,0,0);
  ellipse(100, 68, 19, 19);
  //嘴巴
  line(100,77,100,125);
  noFill();
  arc(100,88,84,77,PI/7.8,PI/1.2);
  //鬍鬚
  line(128,78,153,69);
  line(128,84,155,84);
  line(128,88,153,98);
  line(77,78,51,69);
  line(77,84,50,84);
  line(77,88,51,98);
  //項圈
  fill(207,36,12);
  rect(45,132,113,11,5);
  //鈴鐺
  fill(255,255,0);
  ellipse(100,146,22,23);
  line(91,143,109,143);
  line(90,146,111,146);
  fill(0,0,0);
  ellipse(100,149,2,2);
  line(100,150,100,157);
  //口袋
  fill(255,255,255);
  arc(100, 165, 50, 50, 0, PI);
  line(75,164,125,165);
  //腳
  fill(255,255,255);
  rect(38,215,60,16,10,5,5,5);
  rect(100,215,60,16,5,10,5,5);
}

float x=100,y=100;
void draw(){
  background(255,255,255);
//銅鑼燒
  PImage food;
  food=loadImage("http://demo.taipeitarget.ozchamp.com/images/x01.JPG");

//多拉A夢
  pushMatrix();
  translate(x-150,y-150);
  dora();//呼叫上面所畫的圖
  popMatrix();

//銅鑼燒位置跟大小
  translate(mouseX,mouseY);
  scale(0.1);
  image(food,0,0);

  x=x*0.9 + mouseX*0.1;
  y=y*0.9 + mouseY*0.1;
}



作業三 : 心得

我是利用第一周的作品來應用在此周的課程,
利用功課使我更熟悉寫法與用法,
利用老師的基礎範例與同學們的作品互相學習,
讓我寫的時候遇到的問題能有更多的資源,
謝謝老師、助教跟同學們囉:D









2012年9月18日 星期二

Week1,HW01

作業一:找尋使用processing製作的作品

Arduino iphone processing color mixer tutorial
混色器 ( 控制3個LED的Arduino連接到你的iPhone!)

9:25 ─ 9:50 與 13:10為 Demo 成果部分,
而9:50後有電路實作(接LED),
藉由mac作業系統設定控制並連接混色器(13:30)




作業二 : kitty程式碼


size(300,240);
PImage pic;
pic = loadImage("http://upload.wikimedia.org/wikipedia/zh/thumb/e/ef/P_and_F_Logo.jpg/260px-P_and_F_Logo.jpg");
image(pic, 20,20);




作業三:想用processing畫的圖

多拉A夢

size(206,244);
//noStroke();
//頭
fill(2,187,233);
ellipse(100, 75, 150, 146);

//身體
fill(2,187,233);
rect(47,140, 108, 76, 3);
quad(17,165,47,143,48,173,32,185);
quad(154,143,178,162,166,180,153,170);
fill(255,255,255);
ellipse(23,174,30,31);
ellipse(178,173,30,31);
ellipse(100, 165, 84, 84);//身體白處

//臉
fill(255,255,255);
ellipse(100, 95, 126, 95);
//眼睛
fill(255,255,255);
ellipse(82, 46, 35, 44);
fill(255,255,255);
ellipse(117, 46, 35, 44);
//眼珠
fill(0,0,0);
ellipse(91, 55, 9, 9);
fill(0,0,0);
ellipse(111, 55, 9, 9);
//鼻子
fill(255,0,0);
ellipse(100, 68, 19, 19);
//嘴巴
line(100,77,100,125);
noFill();
arc(100,88,84,77,PI/7.8,PI/1.2);
//鬍鬚
line(128,78,153,69);
line(128,84,155,84);
line(128,88,153,98);
line(77,78,51,69);
line(77,84,50,84);
line(77,88,51,98);
//項圈
fill(207,36,12);
rect(45,132,113,11,5);
//鈴鐺
fill(255,255,0);
ellipse(100,146,22,23);
line(91,143,109,143);
line(90,146,111,146);
fill(0,0,0);
ellipse(100,149,2,2);
line(100,150,100,157);
//口袋
fill(255,255,255);
arc(100, 165, 50, 50, 0, PI);
line(75,164,125,165);
//腳
fill(255,255,255);
rect(38,215,60,16,10,5,5,5);
rect(100,215,60,16,5,10,5,5);
我畫的





作業四 : 第一週上課心得
我是第二周才加選進此課程的,第一週沒有上到課,Processing 的介面和操作方式感覺不會很繁瑣複雜。
以Blogger學習和繳交作業的方式,可以直接看到其他同學的作品,可以互相激勵及切磋呢!