顯示具有 00160131陳建勳 標籤的文章。 顯示所有文章
顯示具有 00160131陳建勳 標籤的文章。 顯示所有文章

2014年1月12日 星期日

第十九週期末報告

期末報告

主題:鋼鋼好朋友
介紹:鋼鐵超人要利用手上的武器診拯救好朋友。
Arduino程式碼:
int switchStateRed = 0; int switchStateBlue = 0; int switchStateB = 0; int switchStateW = 0; int switchStateA = 0; const int ledPin = 13; // led connected to digital pin 13 const int knockSensor = A0; // the piezo is connected to analog pin 0 const int threshold = 100; int sensorReading = 0; // variable to store the value read from the sensor pin int ledState = LOW; void setup(){ pinMode(ledPin, OUTPUT); pinMode(2,INPUT); pinMode(3,INPUT); pinMode(4,INPUT); pinMode(5,INPUT); pinMode(6,INPUT); Serial.begin(9600); } //int a=0,b=0; void loop(){ sensorReading = analogRead(knockSensor); switchStateRed = digitalRead(2); switchStateBlue = digitalRead(3); switchStateW = digitalRead(4); switchStateA = digitalRead(5); switchStateB = digitalRead(6); // if the sensor reading is greater than the threshold: if (sensorReading >= threshold) { // toggle the status of the ledPin: ledState = !ledState; // update the LED pin itself: digitalWrite(ledPin, ledState); // send the string "Knock!" back to the computer, followed by newline } if(switchStateRed == HIGH) {Serial.write('1');} if(switchStateBlue == HIGH) {Serial.write('2');} if(switchStateW == HIGH) {Serial.write('3');} if(switchStateA == HIGH) {Serial.write('4');} if(switchStateB == HIGH) {Serial.write('5');} delay(33); }
Processing程式碼:
PImage img; PImage img1; PImage img2; PImage img3; PImage img4; PImage img5; PImage img6; PImage img7; PImage img8; PImage img9; PImage img0; PImage img10; PImage img11; PImage img12; PImage img13; PImage img14; PImage img15; PImage img16; import processing.serial.*;// Serial serial;// import ddf.minim.*; AudioPlayer player; AudioPlayer player1; AudioPlayer player2; AudioPlayer player3; AudioPlayer player4; AudioPlayer player5; Minim minim;//audio context char c=' '; float z; int ss; int btime; int [] start = new int[50]; float [] bulletX=new float[50]; float [] bulletY=new float[50]; int [] mstart = new int[50]; float [] monsterX=new float[50]; float [] monsterY=new float[50]; int bo; int top=0; int i; int a; int b; int m=0; int s; int ba; int bc; int hl; int ml; int f; float bl; int ud; int bossY; float []thingAA = new float[50]; float mt; float md; void setup() { mt=150; size(1000, 300); btime=1800; ss=0; i=0; a=0; b=0; s=0; ba=0; bo=15; bc=100; f=0; z=15; img = loadImage("01.png"); img1 = loadImage("pic4.bmp"); img2 = loadImage("dragon.png"); img3 = loadImage("a.png"); img4 = loadImage("b.png"); img5 = loadImage("c.png"); img6 = loadImage("d.png"); img7 = loadImage("e.png"); img8 = loadImage("f.png"); img9 = loadImage("g.png"); img0 = loadImage("h.png"); img10 = loadImage("02.png"); img11 = loadImage("blood.png"); img12 = loadImage("magic.png"); img13 = loadImage("1.png"); img14 = loadImage("blood2.png"); img15 = loadImage("win.jpg"); img16 = loadImage("lose.jpg"); m=0; bl=600; bossY=int(random(85, 185)); imageMode(CENTER); hl=400; ml=0; minim = new Minim(this); player = minim.loadFile("file.mp3", 2048); player1 = minim.loadFile("01.wav", 2048); player2 = minim.loadFile("02.wav", 2048); player3 = minim.loadFile("03.wav", 2048); player4 = minim.loadFile("winner.wav", 2048); player5 = minim.loadFile("loser.WAV", 2048); serial=new Serial(this, "COM3", 9600); player.play(); } void draw() { if (serial.available()>0) { c=(char)serial.read(); if (c=='1')mt=mt+10; if (c=='2')mt=mt-10; if (c == '3') { if (bc==100) { if (bo!=0) { bulletX[top]=120; bulletY[top]=mt-25; start[top]=1; top++; if (top>=50) top=0; bo--; player1 = minim.loadFile("01.wav"); player1.play(); } } z--; } if (c == '4') { ba=1; z=0; } if (c=='5') if (a==0&&ml==300) { a=1; } } if (ss==0) { background(img1); image(img, 70, mt, 63, 80); image(img11, 0, 0, hl, 30); image(img12, 0, 25, ml, 15); if (a==0)i=0; if (a==1&&i<=60) { i=i+1; } if (a==1&&i==61) i=31; if (a==2&&i<=160) i=i+1; if (i>0&&i<=30) { image(img3, 1600, mt, 3000, 100); player3 = minim.loadFile("03.wav"); player3.play(); } if (i>30&&i<=40) { image(img4, 1600, mt, 3000, 100); } if (i>40&&i<=50) { image(img5, 1600, mt, 3000, 100); } if (i>50&&i<=60) { image(img6, 1600, mt, 3000, 100); } if (i>60&&i<=100) { image(img7, 1600, mt, 3000, 100); } if (i>100&&i<=120) { image(img0, 1600, mt, 3000, 100); } if (i>120&&i<=140) { image(img8, 1600, mt, 3000, 100); } if (i>140&&i<=160) { image(img9, 1600, mt, 3000, 100); } if (a==1&&ml>0) ml=ml-2; if (btime>0)s=int(random(0, 15)); else { s=int(random(0,10)); } if ( s == 5) { monsterX[m]=900; monsterY[m]=random(50, 950); mstart[m]=1; m++; if (m>=50)m=0; } for (int i=0;i<50;i++) { if (mstart[i]==1) { image(img2, monsterX[i], monsterY[i], 64, 64); monsterX[i]-=3; if (monsterY[i]>500) { monsterY[i]=0; mstart[i]=0; } } } for (int i=0;i<50;i++) { if (start[i]==1) { image(img10, bulletX[i], bulletY[i]+30, 30, 10); bulletX[i]+=3; if (bulletY[i]>500) { bulletY[i]=0; start[i]=0; } } } for (int k=0;k<50;k++) for (int j=0;j<50;j++) { if (monsterY[j]<=bulletY[k]+50 && monsterY[j]>=bulletY[k]-50) if (monsterX[j]<=bulletX[k]+10&& monsterX[j]>=bulletX[k]-10 && mstart[j]==1) { start[k]=0; mstart[j]=0; monsterY[j]=0; bulletY[k]=0; if (ml<300) ml=ml+10; } if (btime<=0) { if (bossY<=bulletY[k]+85 && bossY >=bulletY[k]-85) if (800<=bulletX[k]+10&& 800>=bulletX[k]-10) { start[k]=0; bl=bl-0.0025; } } } for (int k=0;k<50;k++) { if (a==1) { if (monsterY[k]<= mt +50&&monsterY[k]>= mt-50) { mstart[k]=0; monsterY[k]=0; } if (bossY <= mt+150&&bossY>= mt-150) bl=bl-0.025; } } if (ba==1) { if (bc!=0) { bc--; } else { bo=15; bc=100; ba=0; } if (z<15) { z=z+0.15; } } if (a==1&&ml==0) { a=0; } for (int j=0;j<50;j++) if (monsterY[j]<=mt+50 && monsterY[j]>=mt-50) if (monsterX[j]<=70+10 && mstart[j]==1) { hl=hl-50; mstart[j]=0; } for (int i=0;i<=z;i++) image(img13, 940, 10+i*10, 30, 10); if (z>15) z=15; if (btime>0) btime--; if (btime==0) { image(img14, 980, 300, 20, bl); image(img2, 800, bossY, 240, 240); if (bossY<=185&&bossY>=85) { if (ud==0)bossY++; if (ud==1)bossY--; if (bossY>=185)ud=1; if (bossY<=85)ud=0; } else { if (bossY==84) bossY=85; if (bossY==186) bossY=185; } } if (bl<=0) { ss=1; player4 = minim.loadFile("winner.wav"); player4.play(); } if (hl<=0) { ss=2; player5 = minim.loadFile("loser.WAV"); player5.play(); } } if (ss==1) image(img15,500,150,1000,300); if (ss==2) image(img16,500,150,1000,300); } void keyPressed() { if (key=='q') ml=300; if (key == 'p') btime=0; if (key == 'o') bl=0; } void stop() { player.close(); minim.stop(); super.stop(); }





2013年12月16日 星期一

第十五週


這是我們的遊戲畫面以及程式碼,已經可以集氣和攻擊怪獸了。
之後會再增加大魔王關。


2013年12月9日 星期一

2013年12月1日 星期日

第十三週作業

Project 5
void setup() { pinMode(ledPin, OUTPUT); digitalWrite(ledPin, HIGH); //程式一開始的五秒內是校正用的,這時候要趕快遮住/打開光敏電阻,讓程式修正最大和最小值 while (millis() < 5000) { sensorValue = analogRead(A0); if (sensorValue > sensorHigh) { sensorHigh = sensorValue; } if (sensorValue < sensorLow) { sensorLow = sensorValue; } } //等到燈熄滅,就開始進入 loop digitalWrite(ledPin, LOW); } void loop() { sensorValue = analogRead(A0); //這裡也使用了 map 函示來對應最高和最低的數值,對應為 50~4000 hz int pitch = map(sensorValue, sensorLow, sensorHigh, 50, 4000); tone(8, pitch, 20); delay(10); } #include <Servo.h> Servo myServo; int const potPin =A0; int potVal; int angle; void setup(){ myServo.attach(9); Serial.begin(9600); } void loop(){ potVal = analogRead(potPin); Serial.print("potVal: "); Serial.print(potVal); //這裡的 map function 可以把 0~1023 轉換到 0~179度 //很方便的函示 angle=map(potVal, 0, 1023, 0, 179); Serial.print(", angle: "); Serial.print(angle); myServo.write(angle); delay(15); }
Project 6
int sensorValue;
int sensorLow = 1023;
int sensorHigh = 0;
const int ledPin = 13;

void setup() {
  pinMode(ledPin, OUTPUT);
  digitalWrite(ledPin, HIGH);
  //程式一開始的五秒內是校正用的,這時候要趕快遮住/打開光敏電阻,讓程式修正最大和最小值
  while (millis() < 5000) {
    sensorValue = analogRead(A0);
    if (sensorValue > sensorHigh) {
      sensorHigh = sensorValue;
    }
    if (sensorValue < sensorLow) {
      sensorLow = sensorValue;
    }
  }
  //等到燈熄滅,就開始進入 loop
  digitalWrite(ledPin, LOW);
}

void loop() {
  sensorValue = analogRead(A0);
  //這裡也使用了 map 函示來對應最高和最低的數值,對應為 50~4000 hz
  int pitch = map(sensorValue, sensorLow, sensorHigh, 50, 4000);
  tone(8, pitch, 20);
  delay(10);
}
Project 7
int buttons[6];
int notes[]={262,294,330,349};
void setup(){
buttons[0]=2;
 Serial.begin(9600); 
}
void loop(){
 int keyVal=analogRead(A0);
 Serial.println(keyVal);
if(keyVal==1023){
tone(8,notes[0]);
}
else if(keyVal >= 990 && keyVal <= 1010){
tone(8,notes[1]);
}
else if(keyVal >= 505 && keyVal <= 515){
tone(8,notes[2]);
}
else if(keyVal >= 950 && keyVal <= 980){
tone(8,notes[3]);
}
else{
noTone(8);
}
}

2013年11月24日 星期日

第十二週作業



const int sensorPin = A0; const float baselineTemp = 22.0; void setup(){ Serial.begin(9600); for(int pinNumber = 2; pinNumber < 5; pinNumber++){ pinMode(pinNumber, OUTPUT); digitalWrite(pinNumber, LOW); } } void loop(){ int sensorVal = analogRead(sensorPin); Serial.print("Sensor Value: "); Serial.print(sensorVal); float voltage = (sensorVal/1024.0)*5.0; Serial.print(", Volts: "); Serial.print(voltage); Serial.print(", Degrees: "); float temperature = (voltage - .5)*100; Serial.println(temperature); if(temperature < baselineTemp){ digitalWrite(2, LOW); digitalWrite(3, LOW); digitalWrite(4, LOW); } else if(temperature >= baselineTemp+2 && temperature < baselineTemp+4){ digitalWrite(2, HIGH); digitalWrite(3, LOW); digitalWrite(4, LOW); } else if(temperature >= baselineTemp+4 && temperature < baselineTemp+6){ digitalWrite(2, LOW); digitalWrite(3, HIGH); digitalWrite(4, HIGH); } else if(temperature >= baselineTemp +6){ digitalWrite(2, HIGH); digitalWrite(3, HIGH); digitalWrite(4, HIGH); } delay(100); }


const int Brightness = 20; // set overall brightness, use lower value in darkroom to protect your eyes (0-255) const int greenLEDPin = 9; // LED connected to digital pin 9 const int redLEDPin = 10; // LED connected to digital pin 10 const int blueLEDPin = 11; // LED connected to digital pin 11 const int redSensorPin = A0; // pin with the photoresistor with the red gel const int greenSensorPin = A1; // pin with the photoresistor with the green gel const int blueSensorPin = A2; // pin with the photoresistor with the blue gel int redSensorValue = 0; // variable to hold the value from the red sensor int greenSensorValue = 0; // variable to hold the value from the green sensor int blueSensorValue = 0; // variable to hold the value from the blue sensor int redSensorHigh = 0; //High and low value for mapping. Notice that 'High' value were set low at 0, so that during calibration, its value would be be pushed up. See project 6. int greenSensorHigh = 0; int blueSensorHigh = 0; int redSensorLow = 1023; // the opposite is true for 'Low' value int greenSensorLow = 1023; int blueSensorLow = 1023; void setup() { Serial.begin(9600); pinMode(greenLEDPin,OUTPUT); pinMode(redLEDPin,OUTPUT); pinMode(blueLEDPin,OUTPUT); analogWrite(redLEDPin, Brightness); analogWrite(greenLEDPin, Brightness); analogWrite(blueLEDPin, Brightness); while (millis() < 10000) { redSensorValue = analogRead(redSensorPin); if (redSensorValue > redSensorHigh) { redSensorHigh = redSensorValue; } if (redSensorValue < redSensorLow) { redSensorLow = redSensorValue; } delay(5); greenSensorValue = analogRead(greenSensorPin); if (greenSensorValue > greenSensorHigh) { greenSensorHigh = greenSensorValue; } if (greenSensorValue < greenSensorLow) { greenSensorLow = greenSensorValue; } delay(5); blueSensorValue = analogRead(blueSensorPin); if (blueSensorValue > blueSensorHigh) { blueSensorHigh = blueSensorValue; } if (blueSensorValue < blueSensorLow) { blueSensorLow = blueSensorValue; } delay(5); } } void loop() { redSensorValue = analogRead(redSensorPin); delay(5); greenSensorValue = analogRead(greenSensorPin); delay(5); blueSensorValue = analogRead(blueSensorPin); Serial.print("raw sensor Values \t red: "); Serial.print(redSensorValue); Serial.print("\t green: "); Serial.print(greenSensorValue); Serial.print("\t Blue: "); Serial.println(blueSensorValue); int redValue = map(redSensorValue,redSensorLow,redSensorHigh,0,Brightness); redValue = constrain(redValue,0,255); int greenValue = map(greenSensorValue,greenSensorLow,greenSensorHigh,0,Brightness); greenValue = constrain(greenValue,0,255); int blueValue = map(blueSensorValue,blueSensorLow,blueSensorHigh,0,Brightness); blueValue = constrain(blueValue,0,255); Serial.print("Mapped sensor Values \t red: "); Serial.print(redValue); Serial.print("\t green: "); Serial.print(greenValue); Serial.print("\t Blue: "); Serial.println(blueValue); analogWrite(redLEDPin, redValue); analogWrite(greenLEDPin, greenValue); analogWrite(blueLEDPin, blueValue); }

2013年11月17日 星期日

陳建勳的第十一週作業

0. 發 Arduino Starter Kit、Arduino Mega2560、Arduino Project Book, 每個人手上都有一個板子

1. 練習第一個範例 File-Examples-Basic-Blink

2. 修改程式,變成展得比較特別的作法

3.
void setup() {              
  // initialize the digital pin as an output.
  pinMode(11, OUTPUT);
  pinMode(12, OUTPUT);
  pinMode(13, OUTPUT);  
}
void loop() {
  digitalWrite(13, HIGH);   // turn the LED on (HIGH is the voltage level)
  delay(300);               // wait for a second
  digitalWrite(13, LOW);    // turn the LED off by making the voltage LOW
  delay(200);    // wait for a second

  digitalWrite(12, HIGH);   // turn the LED on (HIGH is the voltage level)
  delay(200);
  digitalWrite(12, LOW);   // turn the LED on (HIGH is the voltage level)
  delay(200);

  digitalWrite(12, HIGH);   // turn the LED on (HIGH is the voltage level)
  delay(100);
  digitalWrite(12, LOW);   // turn the LED on (HIGH is the voltage level)
  delay(200);
}


void setup() { // initialize the digital pin as an output. pinMode(13, OUTPUT); pinMode(12, OUTPUT); pinMode(11, OUTPUT); } // the loop routine runs over and over again forever: void loop() { digitalWrite(12, HIGH); // turn the LED on (HIGH is the voltage level) delay(2000); // wait for a second digitalWrite(12, LOW); // turn the LED off by making the voltage LOW delay(200); // wait for a second digitalWrite(13, HIGH); // turn the LED on (HIGH is the voltage level) delay(10); // wait for a second digitalWrite(13, LOW); // turn the LED off by making the voltage LOW delay(100); digitalWrite(11, HIGH); // turn the LED on (HIGH is the voltage level) delay(110); // wait for a second digitalWrite(11, LOW); // turn the LED off by making the voltage LOW delay(1010); }


2013年11月10日 星期日

第十週期中作品展示

黃敦群與陳建勳的作品
我們是要照順序接漢堡素材,若接錯順序或是時間內沒有接完就會GameOver!!

PImage img;
PImage img2;
PImage img3;
int N=20;
PImage img4;
PImage img5;
PImage img6;
PImage img7;
PImage img8;
PImage img9;
PImage img10;
float a, b, c, d, e;
int A1=0;
int A2=0;
int A3=0;
int A4=0;
int A5=0;
int G1=0;
int G2=0;
int G3=0;
int G4=0;
int G5=0;
float B1=0;
float B2=0;
float B3=0;
float B4=0;
float B5=0;
int C1, C2, C3, C4, C5;
int L=330;
int I1, I2, I3, I4, I5;
float []thingAA = new float[N];
float []thingBB = new float[N];
float []thingCC = new float[N];
float []thingDD = new float[N];
float []thingEE = new float[N];

float x=random(0, 600);
float y=random(0, 600);
float z=random(0, 600);
float w=random(0, 600);
float v=random(0, 600);

int R=0;
import ddf.minim.*;

AudioPlayer player;
AudioPlayer player1;
AudioPlayer player2;

Minim minim;//audio context

void setup() {
  size(600, 400);
  I1=0;
  I2=0;
  I3=0;
  I4=0;
  I5=0;
  thingAA[0]=int(random(5, 7));
  thingBB[0]=int(random(5, 7));
  thingCC[0]=int(random(5, 7));
  thingEE[0]=int(random(5, 7));
  thingDD[0]=int(random(5, 7));
  img = loadImage("01.jpg");
  img2 = loadImage("down.jpg");
  img3 = loadImage("meet.jpg");
  img4 = loadImage("cheese.jpg");
  img5 = loadImage("vegetable.jpg");
  img6 = loadImage("top.jpg");
  img7 = loadImage("dish.jpg");
  img8 = loadImage("win.jpg");
  img9 = loadImage("lose.jpg");
  img10= loadImage("start.jpg");
  minim = new Minim(this);
  player = minim.loadFile("file.mp3", 2048);
  player1 = minim.loadFile("winner.wav", 2048);
  player2 = minim.loadFile("loser.WAV", 2048);
}
void draw() {

  if (R==0) {
    background(img10);
    A1=0;
    A2=0;
    A3=0;
    A4=0;
    A5=0;
    G1=0;
    G2=0;
    G3=0;
    G4=0;
    G5=0;
    B1=0;
    B2=0;
    B3=0;
    B4=0;
    B5=0;

    L=330;

    x=random(0, 600);
    y=random(0, 600);
    float z=random(0, 600);
    float w=random(0, 600);
    float v=random(0, 600);

    I1=0;
    I2=0;
    I3=0;
    I4=0;
    I5=0;
    thingAA[0]=int(random(5, 7));
    thingBB[0]=int(random(5, 7));
    thingCC[0]=int(random(5, 7));
    thingEE[0]=int(random(5, 7));
    thingDD[0]=int(random(5, 7));
  }
  if (I1<=10 && I2<=10 && I3<=10 && I4<=10. && I5<=10 && L!=230 && R==1) {
    background(img);
    image(img7, mouseX, 350, 80, 60);

    if (thingAA[I1]==5) {
      a=a+5;
      image(img2, x, a, 60, 40);
    }
    if (thingAA[I1]!=5)
    {
      thingAA[I1]=int(random(5, 25));
    }

    if (thingBB[I2]==5) {
      b=b+5;
      image(img3, y, b, 60, 40);
    }
    if (thingBB[I2]!=5)
    {
      thingBB[I2]=int(random(5, 25));
    }

    if (thingCC[I3]==5) {
      c=c+5;
      image(img4, z, c, 60, 40);
    }
    if (thingCC[I3]!=5)
    {
      thingCC[I3]=int(random(5, 25));
    }

    if (thingDD[I4]==5) {
      d=d+5;
      image(img5, w, d, 60, 40);
    }
    if (thingDD[I4]!=5)
    {
      thingDD[I4]=int(random(5, 25));
    }

    if (thingEE[I5]==5) {
      e=e+5;
      image(img6, v, e, 60, 40);
    }
    if (thingEE[I5]!=5)
    {
      thingEE[I5]=int(random(5, 25));
    }

    if (a==400) {
      I1=I1+1;
      thingAA[I1]=int(random(5, 8));
    }
    if (b==400) {
      I2=I2+1;
      thingBB[I2]=int(random(5, 8));
    }
    if (c==400) {
      I3=I3+1;
      thingCC[I3]=int(random(5, 8));
    }
    if (d==400) {  
      I4=I4+1;
      thingDD[I4]=int(random(5, 8));
    }
    if (e==400) {
      I5=I5+1;
      thingEE[I5]=int(random(5, 8));
    }


    if (a==400) {
      a=0;
      x = random(0, 600);
    }

    if (b==400) {
      b=0;
      y = random(0, 600);
    }

    if (c==400) {
      c=0;
      z = random(0, 600);
    }

    if (d==400) {
      d=0;
      w = random(0, 600);
    }

    if (e==400) {
      e=0;
      v = random(0, 600);
    }

    if (a==L && x <= mouseX+20 && x>= mouseX-20 && G1==0)
    {
      A1=1;
      B1=mouseX-x;
      C1=L;
      L=L-20;
      G1=1;
    }
    if (A1==1&&G1==1) {
      image(img2, mouseX+B1, C1, 60, 40);
    }

    if (b==L && y <= mouseX+20 && y>= mouseX-20 && G2==0)
    {
      A2=1;
      B2=mouseX-y;
      C2=L;
      L=L-20;
      G2=1;
    }
    if (A2==1&&G2==1) {
      image(img3, mouseX+B2, C2, 60, 40);
    }

    if (c==L && z <= mouseX+20 && z>= mouseX-20 && G3==0)
    {
      A3=1;
      B3=mouseX-z;
      C3=L;
      L=L-20;
      G3=1;
    }
    if (A3==1&&G3==1) {
      image(img4, mouseX+B3, C3, 60, 40);
    }


    if (d==L && w <= mouseX+20 && w>= mouseX-20 && G4==0)
    {
      A4=1;
      B4=mouseX-w;
      C4=L;
      L=L-20;
      G4=1;
    }
    if (A4==1&&G4==1) {
      image(img5, mouseX+B4, C4, 60, 40);
    }

    if (e==L && v <= mouseX+20 && v>= mouseX-20 && G5==0)
    {
      A5=1;
      B5=mouseX-v;
      C5=L;
      L=L-20;
      G5=1;
    }
    if (A5==1&&G5==1) {
      image(img6, mouseX+B5, C5, 60, 40);
    }
  }
  else {
    if (R!=0) {
      if (C1==330&&C2==310&&C3==290&&C4==270&&C5==250) {
        background(img8);
        R=2;
     
        player1.play();
      }
      else
      {
        background(img9);
        R=3;
        player2.play();
      }
    }
  }
 }

void mouseClicked()
{
  if (R==0) {
    player.play();
    R=1;
  }
  if (I1==10 || I2==10 || I3==10 || I4==10 || I5==10 || L==230 )
    R=0;
}

void stop()
{
 player.close();
 minim.stop();
 super.stop();
}


2013年10月21日 星期一

第七周作業

兩個人交一份沒關係, 標注你的學號姓名

1. 請列出你今天三個小時,要完成的事

背景以及食材,食材掉落

之後會有一個盤子來接食物

2. 你在期中作品要做到什麼程度
使用一個盤子來接一些漢堡的配料,總共有四種配料,依序接下食材,只要在指定的順序下接好一個漢堡就有一分。
3. Why? 你為什麼要做它
因為遊戲好玩。

2013年10月6日 星期日

陳建勳的第五周作業









2. 想做的期中作品:我的其中作品目前暫定是一個電花扇的遊戲,目前沒有圖例,因為是原創,利用電風扇達成一些成就,YA。



2013年9月22日 星期日

陳建勳的第三周作業



1. 今天目標: 畫出一個五子棋
1.1. 使用 Tool- Color Selector, 挑出你要的顏色, 可用 R,G,B 來描述,也可用 #0B33FF 之類的像亂碼的數字來設定顏色
1.2. 要畫外框,可以用 rect()來畫, 要修改填充的顏色可以用fill(), 要讓畫的內部不要填充, 可以查看 Help-Reference 後,在 fill()樓上樓下相關的地方找到你要的功能 (ex. noFill() )
1.3. 使用 stroke() 來調畫線stroke的顏色, 在 Help-Reference 裡面可以找 stroke 相關的功能,像是比較粗的 stroke 可以用 strokeWeight() 來設定權重粗細
1.4. 想要畫裡面的細黑線,可以用 line() 來畫,配上不同的 strokeWeight() 粗細



int nowX, nowY;
int [][] array = new int [8][8];
void setup(){
 size(800,800); 
}
void draw(){
 background(#F0D079); 
  noFill();
  strokeWeight(6);
  rect(50,50,700,700);
  strokeWeight(1);
  for(int i=0;i<9;i++){
   line(50 ,50+i*80, 750, 50+i*80); 
   line(50+i*80, 50, 50+i*80, 750);
  }
  fill(255,0,0);
  rect(nowX*80+50, nowY*80+50, 80,80);
  fill(0);
  for(int i=0;i<8;i++){
   for(int j=0;j<8;j++){
    if(array[i][j]==1) rect(i*80+50, j*80+50, 80, 80);
   } 
  }
}

void mousePressed(){
 array[nowX][nowY]=1; 
}

void mouseMoved(){
 nowX = (mouseX-50)/80; 
 nowY = (mouseY-50)/80;
println("mouseX: "+ mouseX + "mouseY:" +mouseY +"nowX:" +nowX + "nowY:"+nowY); 
}

int nowColor=1;
int nowX, nowY;
int [][] array = new int [10][10];
void setup(){
 size(800,800); 
}
void draw(){
 background(#F0D079); 
  noFill();
  strokeWeight(6);
  rect(50,50,720,720);
  strokeWeight(1);
  for(int i=0;i<10;i++){
   line(50 ,50+i*80, 765, 50+i*80); 
   line(50+i*80, 50, 50+i*80, 765);
  }
  fill(255,0,0);  ellipse(nowX*80+50, nowY*80+50, 80,80);
  for(int i=0;i<10;i++){
   for(int j=0;j<10;j++){
    if(array[i][j]==1){fill(0); ellipse(i*80+50, j*80+50, 80, 80);}
    if(array[i][j]==2){fill(255); ellipse(i*80+50, j*80+50, 80, 80);}
   } 
  }
}

void mousePressed(){
 array[nowX][nowY]=nowColor; 
 if(nowColor==1)nowColor=2;
 else if(nowColor==2)nowColor=1;
}

void mouseMoved(){
 nowX = (mouseX-50)/80; 
 nowY = (mouseY-50)/80;
println("mouseX: "+ mouseX + "mouseY:" +mouseY +"nowX:" +nowX + "nowY:"+nowY); 
}

1. Google 美女工程師, 程式語言用 Ruby, C++, Processing 
1.1. TODO: 請去找一下 Processing 寫出來的作品 
1.2. TODO: 用 Youtube 分享,按Blogger 把 HTML的 <iframe...> 貼在你的作業中
1.3. 下載 Processing 
2. TODO: 寫出你的第一個Processing 程式碼: Hello World 變 Hello Kitty
3. TODO: 請找一張圖,用小畫家(mspaint)輔佐你,畫出你的 Processing 圖, 並都貼出來。
4. TODO: 請寫下你的心得 (1) 你學了什麼東西, (2) 有什麼東西不懂, (3) , 還想學什麼

貼你覺得有意思的影片, 使用youtube 的分享, Blogger 分享, 兩邊都改成 HTML, 貼上 
HTML 



2013年9月15日 星期日

陳建勳的第二周作業

1. Processing 啟動, 有問題的同學請再下載download
http://processing.org

2. 試 for迴圈
3. 試用 Processing-Help-Reference
3.1. 找 rect() 函式
3.2. 看看 rect() 樓上樓下的相關函式, 並嘗試畫出和老師不同的圖  [課堂作業1]
4. 那想要改變顏色呢?
4.1. fill() 是填充的顏色, stroke()是筆的顏色
4.2. 透明的顏色(alpha),其實也是顏色(color)
5. 加一點點滑鼠的互動吧! 可以使用 mouseX 及 mouseY 的值,來進行色彩繽紛的運算



6. 亂數 random(數字上界) 來設定初始的亂數值 [課堂作業3] 利用mouseX,mouseY,random()做設計


[課堂作業4] 請大家寫一下到現在的心得 (ex. 速度, 內容, 想學的東西, 期待、希望、夢想..)

老師上課的速度很OK,教的也很清楚,謝謝老師。



2013年9月9日 星期一

陳建勳的第一周作業

0.1. 加入 課程FB社團
0.2. Google文件 填寫修課資料 (學號姓名,email,電話)
0.3. 加入 Blog, 設定
size(600,600);
background(255, 0, 0);
rect(100,100, 200,200);
PImage imgBird=loadImage("http://www.cmlab.csie.ntu.edu.tw/~jsyeh/processing/angryBirdsBrick/bird.png");
PImage imgPig =loadImage("http://www.cmlab.csie.ntu.edu.tw/~jsyeh/processing/angryBirdsBrick/pig.gif");
image(imgBird, 0,0);
image(imgPig, 200,200,  100,100);
PImage imgBird, imgPig;

void setup() {
  size(600, 600);
  imgBird=loadImage("http://www.cmlab.csie.ntu.edu.tw/~jsyeh/processing/angryBirdsBrick/bird.png");
  imgPig =loadImage("http://www.cmlab.csie.ntu.edu.tw/~jsyeh/processing/angryBirdsBrick/pig.gif");
  imageMode(CENTER);
}

void draw() {
  background(255, 0, 0);
  image(imgBird, mouseX, mouseY);
  image(imgPig, 200, 200, 100, 100);
}