顯示具有 99160273程柔淇 標籤的文章。 顯示所有文章
顯示具有 99160273程柔淇 標籤的文章。 顯示所有文章

2013年1月19日 星期六

Week19,final

1.作品名稱:撈漁撈不完
2.影片:

















3.程式碼:
(1)arduino:
int buttonPin2 = 4;
int buttonPin3 = 3;
int buttonState2 = 0;
int buttonState3 = 0;

void setup() {

pinMode(buttonPin2, INPUT);
pinMode(buttonPin3, INPUT);
Serial.begin(9600);

}
void loop() {
buttonState2 = digitalRead(buttonPin2);
buttonState3 = digitalRead(buttonPin3);


if (buttonState2 == HIGH) {
Serial.print('A');
}

else if (buttonState3== HIGH) {
Serial.print('S');
}

else {
Serial.print('H');
}
delay(500);
}

(2)processing:
import processing.serial.*;
Serial myPort;
PImage fish, fisher,background;
float []fishX=new float[10];
float []fishY=new float[10];
int []fishLive =new int[10];
float []fishSpeed = new float[10];
int key;
int x,y=300,level=0;
void setup(){
size(900,600);
myPort = new Serial(this, "COM6", 9600);
fish=loadImage("fish.png");
fisher=loadImage("fisher.png");
background=loadImage("ocean.jpg");
for(int i=0;i<5;i++){
fishX[i]=i*-200;
fishY[i]=300+random(200);
fishLive[i]=1;
fishSpeed[i]=random(2) + 2;
}
}
int a=0,live=100,end=0;
int shift=4;
void draw(){
if(myPort.available()>0){
key = myPort.read();
println(key);

}
if(end==1){
background(255,0,255);
shift=0;a=100;}
background(225);
image(background, 0, 0);
if(a>0){
a--;
background(255,0,0);
live--;
if(live<0) live=0; }
if(live<=0) end=1;
textSize(80);
text("Life: "+live,100,100);
for(int i=0;i<5;i++){
if(fishX[i]+100>400 && fishX[i]<400+100 && fishY[i]+100>y && fishY[i]<y+100)
{fishLive[i]=0; }
if(fishLive[i]==1) image(fish,fishX[i],fishY[i]);
fishX[i]+=fishSpeed[i];;
if(fishX[i]>900){
fishX[i]-=1000;
fishY[i]=300+random(200);
if(fishLive[i]==1){ a=10; }
fishLive[i]=1;
} }
if(key=='A')
{y+=5;}
else if(key=='S')
{ y-=5;}
else if(key=='H')
{y+=0; }
image(fisher, 400,y,100,100);
if(end==1){
text("sorry,fisher is broken ", 60,300);
}
}

4.心得:
這次的作業從一開始不懂到問了同學,也請教很多學長姊,得到很多人的幫助之後理解,但是也花了我們很多的時間,因為基礎沒有很好,但是我們也盡力去理解程式碼,雖然說可能很多都是老師上課講解過或者是同學教過的東西,但是我們不懂也有去問他們,最後雖然沒有很精緻,但是也努力去完成它了,上完老師的課,讓我收穫十足,但要是回家沒複習,下次要在連接上就會困難重重,這是我們這組要改進的部分,期待下次能再做得更好,讓大家更欣賞我們的作品

5.組員分工狀況 :
寫部落格:賴冠戎,程柔淇
撰寫processing遊戲主要程式:賴冠戎
將processing遊戲作修改:程柔淇
撰寫arduion程式:程柔淇
找素材:賴冠戎,程柔淇
電路板之連結:賴冠戎,程柔淇
拍攝影片:賴冠戎

Week14,hw12

1.這周進度:
(1).討論出主題
(2).更改processing(細修,方便接上Arduino)
(3).將Arduino程式碼完成
(4).電路板都接上並也能執行


2.心得
processing需要配合Arduino,所以要更改的地方很多,目前進度在processing,還有很多不了解的地方,但是有在問會的人,會盡力搞懂並且用好程式碼,等搞懂後arduino就可以很快地打出來了,電路也可以快速地接好,雖然說很多地方不懂,但是會積極去問別人並且理解程式碼的意思.因次把之前做的processing都修了一遍,組內討論時間允許的話,要在期末發表前把電路版加上更多花樣,例如將寶麗容求切一半貼於按鍵上,或是製作一個盒子,如此能更吸引大家遊戲,也能更高分,希望大家會喜歡

3.Arduino程式碼

int buttonPin2 = 4;
int buttonPin3 = 3;
int buttonState2 = 0;
int buttonState3 = 0;

void setup() {

pinMode(buttonPin2, INPUT);
pinMode(buttonPin3, INPUT);
Serial.begin(9600);

}
void loop() {
buttonState2 = digitalRead(buttonPin2);
buttonState3 = digitalRead(buttonPin3);


if (buttonState2 == HIGH) {
Serial.print('A');
}

else if (buttonState3== HIGH) {
Serial.print('S');
}

else {
Serial.print('H');
}
delay(500);
}


2012年12月4日 星期二

week13,HW11

1. 程式碼

int speakerPin = 9;

int length = 15; // the number of notes
char notes[] = "ccggaagffeeddc "; // a space represents a rest
int beats[] = { 1, 1, 1, 1, 1, 1, 2, 1, 1, 1, 1, 1, 1, 2, 4 };
int tempo = 300;

void playTone(int tone, int duration) {
  for (long i = 0; i < duration * 1000L; i += tone * 2) {
    digitalWrite(speakerPin, HIGH);
    delayMicroseconds(tone);
    digitalWrite(speakerPin, LOW);
    delayMicroseconds(tone);
  }
}

void playNote(char note, int duration) {
  char names[] = { 'c', 'd', 'e', 'f', 'g', 'a', 'b', 'C' };
  int tones[] = { 1915, 1700, 1519, 1432, 1275, 1136, 1014, 956 };

  // play the tone corresponding to the note name
  for (int i = 0; i < 8; i++) {
    if (names[i] == note) {
      playTone(tones[i], duration);
    }
  }
}

void setup() {
  pinMode(speakerPin, OUTPUT);
}

void loop() {
  for (int i = 0; i < length; i++) {
    if (notes[i] == ' ') {
      delay(beats[i] * tempo); // rest
    } else {
      playNote(notes[i], beats[i] * tempo);
    }

    // pause between notes
    delay(tempo / 2);
  }
}

2012年11月20日 星期二

Week11,HW09


01.思考可以用Arduino做些什麼?
想利用Arduino和processing的程式做成一台賽車(貼電路板在賽車上)
可以做出避障﹑循跡﹑防跌落的功能


02.貼一個Arduino應用的影片

2012年11月12日 星期一

Midtern

1.圖片說明
 (1)開始畫面 按PLAY按紐
 (2)第一關
 (3)共有五個相異點 點出即會框出來
(4)找出五個就過關 按NEXT 
 (5)共有五個相異點 點出即會框出來
 (6)過關 即結束
2.程式碼
PImage img1, img2, img3,img4,img5; //宣告畫面
int now=1;
int a01=0,a02=0,a03=0,a04=0,a05=0,z01=0,e01=0,b01=0,b02=0,b03=0,b04=0,b05=0;
int x,y,z,c;
import ddf.minim.*;  //音樂
AudioPlayer player;
Minim minim;

void setup(){
minim=new Minim(this);
player=minim.loadFile("159.mp3", 2048);
player.play();

size(700,500);  //畫面大小
img1=loadImage("img1.jpg");
img2=loadImage("img2.jpg");
img3=loadImage("img3.jpg");
img4=loadImage("img4.jpg");
img5=loadImage("img5.jpg");
}
void show1()
{image(img1,0,0);}
void show2()
{image(img2,0,0);}
void show3()
{image(img3,0,0);}
void show4()
{image(img4,0,0);}
void show5()
{image(img5,0,0);}
void draw(){
if(now==1){
show1();
if(mouseX>53 && mouseX<353 && mouseY>163 && mouseY<259 && mousePressed){
now=2;
}}
if(now==2){
background(0);
show2();
if(mouseX>475 && mouseX<495 && mouseY>75 && mouseY<97 && mousePressed)
{a01=1;}
if(mouseX>488 && mouseX<512 && mouseY>131 && mouseY<150 && mousePressed)
{a02=1;}
if(mouseX>590 && mouseX<635 && mouseY>178 && mouseY<202 && mousePressed)
{a03=1;}
if(mouseX>400 && mouseX<427 && mouseY>200 && mouseY<255 && mousePressed)
{a04=1; }
if(mouseX>533 && mouseX<554 && mouseY>290 && mouseY<305 && mousePressed)
{a05=1;}

if(a01==1)
{line(475,75,495,75);
line(475,75,475,97);
line(475,97,495,97);
line(495,97,495,75);
strokeWeight(4);
stroke(0,0,0);}

if(a02==1)
{line(488,131,512,131);
line(488,131,488,150);
line(488,150,512,150);
line(512,150,512,131);
strokeWeight(4);
stroke(0,0,0);}

if(a03==1)
{line(590,178,635,178);
line(590,178,590,202);
line(590,202,635,202);
line(635,202,635,178);
strokeWeight(4);
stroke(0,0,0);}

if(a04==1)
{line(400,200,427,200);
line(400,200,400,255);
line(400,255,427,255);
line(427,255,427,200);
strokeWeight(4);
stroke(0,0,0);}

if(a05==1)
{line(533,290,554,290);
line(533,290,533,305);
line(533,305,554,305);
line(554,305,554,290);
strokeWeight(4);
stroke(0,0,0);}


if(a01==1 && a02==1 && a03==1 && a04==1 && a05==1 )
{now=3; }
}


if(now==3){
show3();
if(mouseX>519 && mouseX<673 && mouseY>123 && mouseY<188 && mousePressed)
{z01=1;}
if(z01==1)
{now=4;}
}

if(now==4){
show4();
if(mouseX>434 && mouseX<464 && mouseY>103 && mouseY<128 && mousePressed)
{b01=1;}
if(mouseX>391 && mouseX<432 && mouseY>184 && mouseY<223 && mousePressed)
{b02=1;}
if(mouseX>380 && mouseX<400 && mouseY>355 && mouseY<384 && mousePressed)
{b03=1;}
if(mouseX>355 && mouseX<379 && mouseY>405 && mouseY<432 && mousePressed)
{b04=1;}
if(mouseX>441 && mouseX<457 && mouseY>480 && mouseY<498 && mousePressed)
{b05=1;}

if(b01==1)
{line(434,103,464,103);
line(434,103,434,128);
line(434,128,464,128);
line(464,128,464,103);
strokeWeight(4);
stroke(255,0,0);}

if(b02==1)
{line(391,184,432,184);
line(391,184,391,223);
line(391,223,432,223);
line(432,223,432,184);
strokeWeight(4);
stroke(255,0,0);}

if(b03==1)
{line(380,355,400,355);
line(380,355,380,384);
line(380,384,400,384);
line(400,384,400,355);
strokeWeight(4);
stroke(255,0,0);}

if(b04==1)
{line(355,405,379,405);
line(355,405,355,432);
line(355,432,379,432);
line(379,432,379,405);
strokeWeight(4);
stroke(255,0,0);}

if(b05==1)
{line(441,480,457,480);
line(441,480,441,498);
line(441,498,457,498);
line(457,498,457,480);
strokeWeight(4);
stroke(255,0,0);}

if(b01==1 && b02==1 && b03==1 && b04==1 && b05==1)
{now=5; }
}
if(now==5){
show5();
if(mouseX>36 && mouseX<149 && mouseY>94 && mouseY<152 && mousePressed)
{e01=1;}

if(e01==1)
{exit();}

}}

4.影片

5.心得感想
這次期中作業,可以把以前到現在老師所教的程式做結合
不是單單的一個大作業,因為除了老師在課堂上教的以外
還需自己找程式,或是組上討論,問同學
這個作業會讓我一直想繼續做下去,想改到最好
跟以前的情況不一樣
很喜歡老師教的風格、方法
這個作業可以因增加難度、程式一直延續下去
關卡、介面風格等等都可以更精進

Week08,HW08

1. 你之前完成了什麼把所有的素材都找齊
並計算出大小(位置)

2. 你今天計畫完成什麼
查出所有相對應的程式
但發現有很多程式太複雜
---------------------------
找出第二個遊戲(海綿寶寶-大家來找碴)的原件
以及相對應的程式


3.可能會遇到的問題
所以小組討論完後決定找另一個遊戲
此遊戲為大家來找碴
並設定主題是海綿寶寶 

2012年10月23日 星期二

Week07,HW07

1.期中作業
期中考作業目前進度:
先把素材大致上都準備完成
程式有先大概把素材要擺放的位置算出來
還有一些移動和點選的程式還沒打處理完畢

2.課堂視訊作業

2012年10月16日 星期二

Week06,HW06

1. 寫作品建議
我覺得林雨辰他們那組想做的遊戲,可以讓大家玩得很開心
而李之寧他們那組射擊酒瓶很刺激,也可以順便考驗自己手眼的準度

2.做期中作品
(a)素材
人臉,衣服,鞋子,褲子,配件
(b)想流程解詳細的寫下步驟
幫小女孩搭配衣服
(c)是code 看想法是否可行

3.心得
發現要打出一個遊戲真的不容易,程式碼會很常有錯誤,需要更多時間克服

2012年10月9日 星期二

Week05,HW05


1.
void setup()
{
  size(600,600);
}
  float r=0.01;
void draw()
{
  background(250,0,150);
  translate(300,300);
  rotate(r);
  r+=0.001;
  fill(255,255,0);
  for(int i=0;i<36;i++)
  {
    rotate( PI/6);
    ellipse(100,0,200,55);
  }
  fill(100,250,100);
  ellipse(0,0,50,50);
} 

 



















2.背景跟花瓣可以隨著滑鼠移動變色
void setup()
{
  size(600,600);
}
  float r=0.01;
void draw()
{
  background(125,mouseX*1/2,mouseY*1/3);
  translate(mouseX,mouseY);
  fill(65,0,0);
  rect(-25,0,50,300);
  rotate(r);
  r+=0.001;
  for(int i=0;i<36;i++)
  {
    fill(mouseX*1/3,mouseY*1/10,0);
    rotate( PI/6);
    ellipse(100,0,200,55);
  }
  fill(100,250,100);
  ellipse(0,0,50,50);
} 

 


















3.接蘋果 不能接到蘑菇 時間越久速度越快 滑鼠左右鍵移動

2012年10月2日 星期二

Week04,HW04

void setup(){
  size(500,400);
  fill(255,0,0);
  rect(0,0,50,50);
  fill(0,255,0);
  rect(0,50,50,50);
  fill(0,0,255);
  rect(0,100,50,50);
  fill(255,255,255);
  rect(0,150,50,50);
  fill(0,0,0);
  rect(0,200,50,50);
  fill(255,255,255);
  rect(0,250,50,50);
  rect(0,300,50,50);
  rect(450,0,50,50);
  rect(450,50,50,50);
}
int www=5;
void draw(){
  if(mousePressed && mouseX<50 && mouseY<50) stroke(255,0,0);
  else if(mousePressed && mouseX<50 && mouseY<100) stroke(0,255,0);
  else if(mousePressed && mouseX<50 && mouseY<150) stroke(0,0,255);
  else if(mousePressed && mouseX<50 && mouseY<200) stroke(255,255,255);
  else if(mousePressed && mouseX<50 && mouseY<250) stroke(0,0,0);
  else if(mousePressed && mouseX<50 && mouseY<300) save("123.png");
  else if(mousePressed && mouseX<50 && mouseY<350){ 
    PImage file = loadImage("123.png");
    image(file, 0,0,500,400);
  
  }else if(mousePressed && mouseX&rt;450 && mouseY<50){
    strokeWeight(++www);
  }
  else if(mousePressed && mouseX&rt;450 && mouseY<1000){
    strokeWeight(--www);
    if(www<2)www=2;
  }
  else if(mousePressed)  line(mouseX, mouseY, pmouseX, pmouseY);
} 

2012年9月25日 星期二

Week03,HW03

1.
void setup(){
  size(600,600);
}

void draw(){
  fill(150,0,50);
  rect(250,250,120,280);

  fill(150,255,0);
  ellipse(mouseX,mouseY,150,100);
}

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
2.
void setup(){
  size(600,600);
  //frameRate(1);
}
float x=100,y=100;
void draw(){
  background(150,50,50);

  fill(0,35,255);
  ellipse(x,y,100,200);

  fill(70,200,75);
  rect(mouseX,mouseY,200,100);
 
  x=x*0.85 + mouseX*0.1;
  y=y*0.85 + mouseY*0.1;
}





















3.
最後的眼睛程式
看了看還是看不太懂
但是今天的一二課堂作業還可以理解
只不過要做多一點改變的話
還需要多一些時間才可以完成











2012年9月18日 星期二

Week02,HW02

1.
size(600,600);
for(int i=0;i<50;i++){
  fill(random(750),random(600),random(505));
  rect(random(300),random(260),random(250),random(350));
}























2.


size(600,600);
for(int i=0;i<60;i++){
  for(int k=0;k<60;k++){
    fill(i*300/60,k*250/60,250);
    rect(i*10,k*10,  10,10);
  }
}























3.


size(500,300);
for(int i=0;i<5;i++){
  for(int k=0;k<3;k++){
    fill(i*200/5,k*255/3,100);
    ellipse(i*100+50,k*100+50,  100,random(100));
    fill(i*750/5,k*955/3,100);
    ellipse(i*100+50,k*100+50,  100,random(100));
    fill(i*500/5,k*600/3,100);
    ellipse(i*100+50,k*100+50,  100,random(100));

  }
}
for(int j=0;j<5;j++){
  for(int h=0;h<3;h++){
    fill(j*600/10,h*900/3,500);
    ellipse(j*100+50,h*100+50, 50,50);
  }
}





心得:
今天上課用了一點點程式就可以變出好幾個東西
只不過還要再熟悉一點才可以畫出更完整的圖

2012年9月11日 星期二

Week01,HW01

1.



2.
size(450,350);
PImage kitty;
kitty = loadImage("http://www.anime.com/Hello_Kitty/images/kitty-wallpaper.jpg");
image(kitty, 20, 20);




3.














4.
e