顯示具有 04211021_馬紹芸 標籤的文章。 顯示所有文章
顯示具有 04211021_馬紹芸 標籤的文章。 顯示所有文章

2019年1月3日 星期四

WEEK16 04211021 馬紹芸

程式改顏色+音樂
import processing.sound.*;
SoundFile sound;

import processing.serial.*;
Serial serial;
int handX=500, handY=500;
float handVX=0, handVY=0;//add

int score=0;
float[] eggX=new float[200];
float[] eggY=new float[200];
boolean[] eggDie=new boolean[200];

void setup() {
  sound = new SoundFile(this, "m.mp3");
  sound.play();
  size(1200, 600);
  serial = new Serial(this, "COM7", 9600);
  for (int i=0; i<200; i++) {
    eggX[i]=random(100, 1100);
    eggY[i]=-random(800);   
    eggDie[i]= false;
  }
}

void draw() {
  background(255, 255, 191);
 
  stroke(255);
  fill(230,26,100);
  rect(handX-200/2, handY-10/2, 200,10);
 
  fill(255);
  handX += handVX;
  getData();//add
  for (int i=0; i<200; i++) {
    if(i%10 == 0){
    if (eggDie[i]==true)
      continue;
    ellipse(eggX[i], eggY[i], 70, 100);
    eggY[i]+=15;
    if (eggY[i]>700)
      eggY[i]=-400;
    if (dist(handX, handY, eggX[i], eggY[i])<70) {
      eggDie[i]=true;
      score+=500;
      }
    }
  fill(230,26,100);
  if(score == 10000){
   textMode(CENTER);
   text("well done",490,200);}
  else{text("Score "+score, 450, 200);} 
}
 
  textSize(50);
  noFill();
}

void getData(){
  if(serial.available()>0){
    int val = serial.read();
    println(val);
    handVX = (val-63)/8.0;
  }
  //if(keyPressed && keyCode==LEFT) handVX= -2;
  //if(keyPressed && keyCode==RIGHT)handVX= +2;
}


void setup() { pinMode(2,INPUT); digitalWrite(2,HIGH); Serial.begin(9600); delay(100); } void loop() { int val = analogRead(A0);//x: 0...1023 Serial.write(val/8); delay(50); }

WEEK15 04211021 馬紹芸

P
import processing.sound.*;
SoundFile sound;

import processing.serial.*;
Serial serial;
int handX=500, handY=500;
float handVX=0, handVY=0;//add

int score=0;
float[] eggX=new float[200];
float[] eggY=new float[200];
boolean[] eggDie=new boolean[200];

void setup() {
  sound = new SoundFile(this, "m.mp3");
  sound.play();
  size(1200, 600);
  serial = new Serial(this, "COM7", 9600);
  for (int i=0; i<200; i++) {
    eggX[i]=random(100, 1100);
    eggY[i]=-random(800);   
    eggDie[i]= false;
  }
}

void draw() {
  background(255, 255, 191);
 
  stroke(255);
  fill(230,26,100);
  rect(handX-200/2, handY-10/2, 200,10);
 
  fill(255);
  handX += handVX;
  getData();//add
  for (int i=0; i<200; i++) {
    if(i%10 == 0){
    if (eggDie[i]==true)
      continue;
    ellipse(eggX[i], eggY[i], 70, 100);
    eggY[i]+=15;
    if (eggY[i]>700)
      eggY[i]=-400;
    if (dist(handX, handY, eggX[i], eggY[i])<70) {
      eggDie[i]=true;
      score+=500;
      }
    }
  fill(230,26,100);
  if(score == 10000){
   textMode(CENTER);
   text("well done",490,200);}
  else{text("Score "+score, 450, 200);} 
}
 
  textSize(50);
  noFill();
}

void getData(){
  if(serial.available()>0){
    int val = serial.read();
    println(val);
    handVX = (val-63)/8.0;
  }
  //if(keyPressed && keyCode==LEFT) handVX= -2;
  //if(keyPressed && keyCode==RIGHT)handVX= +2;
}

A
void setup() { pinMode(2,INPUT); digitalWrite(2,HIGH); Serial.begin(9600); delay(100); } void loop() { int val = analogRead(A0);//x: 0...1023 Serial.write(val/8); delay(50); }

WEEK9 04211021 馬紹芸

2018年12月13日 星期四

WEEK14 04211021 馬紹芸


1.閃爍
int sensorPin = A0;   
int ledPin = 13;     
int sensorValue = 0;  
void setup() {
  pinMode(ledPin, OUTPUT);
}

void loop() {

  sensorValue = analogRead(sensorPin);
  // turn the ledPin on
  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);
}

WEEK13 04211021 馬紹芸

期末作業
接雞蛋+搖桿

做了什麼?
接雞蛋小遊戲。


如何操作?
接雞蛋,接到10000點達成任務!加入手動搖桿增加趣味性。


賣點是什麼?
活潑趣味的療癒小遊戲,遊戲時間非常短,在現在節奏如此快速的社會中提供一個快速得到成就感並舒壓的小遊戲。


困難點是什麼?
身為設計系學生對程式不熟,即使對資傳系來說很簡單基礎的技術和知識對我來說都很困難,更多的是心理上的障礙,最困難的應該是克服想要放棄和覺得自己還是好好做設計的認知吧!

2018年11月22日 星期四

WEEK8 04211021 馬紹芸


YOUTUBE
https://youtu.be/Zs8clSaX3y4



做了什麼?
畫面簡潔的接雞蛋小遊戲。


如何操作?
接雞蛋,接到10000點達成任務!


賣點是什麼?
簡單乾淨的療癒小遊戲,遊戲時間非常短,在現在節奏如此快速的社會中提供一個快速得到成就感並舒壓的小遊戲。



int score=0;
float[] eggX=new float[200];
float[] eggY=new float[200];
boolean[] eggDie=new boolean[200];

void setup() {
  size(1200, 600);
  for (int i=0; i<200; i++) {
    eggX[i]=random(100, 1100);
    eggY[i]=-random(800);   
    eggDie[i]= false;
  }
}

void draw() {
  background(255, 191, 191);
  rectMode(CENTER);
  rect(mouseX, mouseY, 200, 10);

  for (int i=0; i<200; i++) {
    if(i%10 == 0){
    if (eggDie[i]==true)
      continue;
    ellipse(eggX[i], eggY[i], 70, 100);
    eggY[i]+=15;
    if (eggY[i]>700)
      eggY[i]=-400;
    if (dist(mouseX, mouseY, eggX[i], eggY[i])<70) {
      eggDie[i]=true;
      score+=500;
      }
    }
  if(score == 10000){textMode(CENTER); text("well done",450,200);}
  else{text("Score "+score, 450, 200);} 
}
 
  fill(255);
  textSize(50);
  textMode(CENTER);
 
}

WEEK11 04211021 馬紹芸

1.如何播歌、切歌

void setup() {
  for(int i=2;i<=13;i++){
    pinMode(i, OUTPUT);
  }
}

void loop() {
  for(int i=2;i<=13;i++){
    digitalWrite( i, HIGH);
    delay(300);
  }
  for(int i=2;i<=13;i++){
    digitalWrite( i, LOW);
  }
}

2.
https://makeruno.com.my/playing-melody-using-only-maker-uno/

3.


int piezoPin = 8;
int length = 15;
char notes[] = "ccggaag ffeeddc ggffeed ggffeed ccggaag ffeeddc ";      // 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(piezoPin, HIGH);
    delayMicroseconds(tone);
    digitalWrite(piezoPin, 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 };
  for (int i = 0; i < 8; i++)
  {
    if (names[i] == note)
    {
      playTone(tones[i], duration);
    }
  }
}

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

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



int piezoPin = 8;
int button = 2;
int lengths = 26;
char jbnotes[] = "eeeeeeegcde fffffeeeeddedg";
int jbbeats[] = { 1, 1, 2, 1, 1, 2, 1, 1, 1, 1, 4, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 2};
int length = 15;
char ttlsnotes[] = "ccggaag ffeeddc ggffeed ggffeed ccggaag ffeeddc ";
int ttlsbeats[] = { 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(piezoPin, HIGH);
    delayMicroseconds(tone);
    digitalWrite(piezoPin, 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 };
  for (int i = 0; i < 8; i++)
  {
    if (names[i] == note)
    {
      playTone(tones[i], duration);
    }
  }
}

void setup()
{
  pinMode(piezoPin, OUTPUT);
  pinMode(button, INPUT_PULLUP);
}

void loop()
{
  int sensorVal = digitalRead(button);
  if (sensorVal == HIGH)
  {
    for (int i = 0; i < length; i++)
    {
      if (ttlsnotes[i] == ' ')
      {
        delay(ttlsbeats[i] * tempo);
      }
      else
        playNote(ttlsnotes[i], ttlsbeats[i] * tempo);
      delay(tempo / 2);
    }
  }
  else
  {
    for (int i = 0; i < lengths; i++)
    {
      if (jbnotes[i] == ' ')
      {
        delay(jbbeats[i] * tempo);
      }
      else
        playNote(jbnotes[i], jbbeats[i] * tempo);
      delay(tempo / 2);
    }
  }
}



2018年11月15日 星期四

WEEK10 04211021 馬紹芸

1.https://makeruno.com.my/getting-started/
接/下載


2
.



uno板子接到電腦,下載好程式
audrino是和processing買程式介面,所以很相像
接電線~

2018年10月25日 星期四

WEEK7 04211021 馬紹芸

1——減少血

int life=10;
boolean gameOver=false;
void setup(){
 size(500,500);
}
void draw(){
 background(0,0,205);
 fill(255);rect(50,50,100,20);
 fill(255,0,0);rect(50,50,life*10,20);
 if(gameOver){
   textSize(40);
   text("Game Over",150,150);
 }
}
void mousePressed(){
 life--;
 if(life<=0)gameOver=true;
}

期末規劃
延續期中程式+搖桿,更新視覺設計,增加背景音樂,
使之更為有趣、活潑。



2018年10月18日 星期四

WEEK6 04211021 馬紹芸

1.



2.


float[] fruitX=new float[20];
float[] fruitY=new float[20];
float[] fruitVX=new float[20];
float[] fruitVY=new float[20];

void setup(){
  size(800,600);
  for(int i=0;i<20;i++){
  fruitX[i]=random(800);  fruitVX[i]=3;
  fruitY[i]=700; fruitVY[i]=-35;
  }
}

void draw(){
  background(0);
  for(int i=0;i<20;i++){
  ellipse(fruitX[i],fruitY[i], 100,100);
  fruitX[i]+=fruitVX[i];
  fruitY[i]+=fruitVY[i];
  fruitVY[i]+=0.98;
  }
}



2018年10月4日 星期四

WEEK4 04211021 馬紹芸

第八周 期中作業

(期中先不做)內容規劃
做一個色感傳遞裝置  "ex:紅色=壓迫感/熱情/愛....."
透過抽象畫體現出顏色的各種感覺,並增加不同聲調的音樂(康定斯基認為顏色是有對應的聲調),這個裝置可以增加小朋友對顏色的感知能力.



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

void draw(){
  fill(255,0,0); rect(200,200,100,100);
  fill(0,0,0); textSize(100); text("HAHAHA",200,200);
}




2.
void setup(){
size(800,600);
}

void draw(){
  background(255);
  fill(255,0,0); rect(200,200,100,100);
  if(bulletFlying){
    ellipse(bulletX,bulletY, 20,20);
    bulletX+=3; bulletY+=3;
  }
}
float bulletX=100, bulletY=100;
boolean bulletFlying=false;

void keyPressed(){
bulletFlying=true;
bulletX=100;
}




3.好幾個子彈咻咻咻
void setup(){
size(800,600);
}

void draw(){
  background(255);
  fill(255,0,0); rect(200,200,100,100);
  for(int i=0; i<bulletN; i++){
  if(bulletFlying[i]){
    ellipse(bulletX[i],bulletY[i], 20,20);
    bulletX[i]+=3; bulletY[i]+=3;
  }
 }
}
float []bulletX=new float[100];
float []bulletY=new float[100];
int bulletN=0;
boolean[] bulletFlying=new boolean[100];

void keyPressed(){
bulletFlying[bulletN]=true;
bulletX[bulletN]=100;
bulletY[bulletN]=100;

bulletN++;

}



4
BOOK
https://www.facebook.com/media/set/?set=oa.144052536243519&type=3
http://www.flag.com.tw/books/product/FT702

TEACHER:


MINE:
PImage imgBG, imgZD;
void setup(){
 size(800,600);
 imgBG=loadImage("BG.png");
 imgZD=loadImage("ZD.png");
 imageMode(CENTER);
}

void draw(){
  image(imgBG,width/2,height/2, width,height);
  image(imgZD, mouseX,mouseY, 100,100);
  for(int i=0; i<bulletN; i++){
    if(bulletFlying[i]){
    image(imgZD, bulletX[i], bulletY[i], 100,100);
    bulletX[i]+=3;
  }
 }
}
float []bulletX=new float[100];
float []bulletY=new float[100];
boolean[] bulletFlying=new boolean[100];
int bulletN=0;

void mousePressed(){
bulletFlying[bulletN]=true;
bulletX[bulletN]=mouseX;
bulletY[bulletN]=mouseY;
bulletN++;
}
ZD
BG



5.
TEACHER:


MINE:

PImage imgBG, imgZD;
void setup(){
 size(800,600);
 imgBG=loadImage("BG.png");
 imgZD=loadImage("ZD.png");
 imageMode(CENTER);
}

void draw(){
  image(imgBG,width/2,height/2, width,height);
  ellipse(mouseX,mouseY, 100,100);
  for(int i=0; i<bulletN; i++){
    if(bulletFlying[i]){
    ellipse(bulletX[i],bulletY[i], 100,100);
    bulletY[i]+=bulletVY[i];
    bulletVY[i] +=0.98;
  }
 }
}
float []bulletX=new float[100];
float []bulletY=new float[100];
float []bulletVY=new float[100];
boolean[] bulletFlying=new boolean[100];
int bulletN=0;

void mousePressed(){
bulletFlying[bulletN]=true;
bulletX[bulletN]=mouseX;
bulletY[bulletN]=mouseY;
bulletVY[bulletN]=-20;
bulletN++;
}


2018年9月27日 星期四

WEEK3 04211021 馬紹芸

1. san jiao han shu


void setup(){
 size(500,500);
}
void draw(){
   ellipse(250,250, 480,480);      //480shi zhi jing
   for(float angle=0; angle<PI*2; angle+=PI/3){
     triangle(250,250,
             250+240*cos(angle), 250+240*sin(angle),
             250+240*cos(angle+PI/3),250+240*sin(angle+PI/3));
}
}



2.

void draw(){
   ellipse(250,250, 480,480);
   for(float angle=0; angle<PI*2; angle+=PI/3){
     for(int R=0; R<=240; R+=20){
       noFill();
       triangle(250,250,
             250+R*cos(angle),     250+R*sin(angle),
             250+R*cos(angle+PI/3),250+R*sin(angle+PI/3));
     }}
   }



3.
https://www.facebook.com/…/vb.10000008496…/1310952318917588/


4.
teacher:


mine


for(int R=15; R>0; R-=5){
    triangle( cx+R*cos(a), cy+R*sin(a),
             cx+R*cos(a+2*PI/3), cy+R*sin(a+2*PI/3),
             cx+R*cos(a-2*PI/3), cy+R*sin(a-2*PI/3));
  }
}
           
void draw(){
  background(255);
  for (int cx=20; cx<800; cx+=40) {
    for(int cy=20; cy<400; cy+=40) {
   //ellipse(cx,cy, 30,30);
   myTriangle(cx, cy);
     }
   }}



5.mario game(shang xia zuo you)




6.""newton}} VX=su du AX =jia su du(tan tiao gan)
teacher

mine

PImage imgMario;
float marioX=0, marioY=0, marioVX=2, marioVY=0, marioAX=0, marioAY=0.1;

void setup(){
  size(400, 600);
  imgMario= loadImage("mario.png");//Only Once!!
}

void draw(){
  //background(255);
  image(imgMario, marioX,marioY, 100,150);
  marioX += marioVX; marioY += marioVY;
  marioVX+= marioAX; marioVY+= marioAY;
//Don't load any image in draw()
}

void keyPressed(){
  if(keyCode==UP)   {marioY-=5;}
  if(keyCode==DOWN) {marioY+=5;}
  if(keyCode==LEFT) {marioX-=5;}
  if(keyCode==RIGHT){marioX+=5;}
}


7.http://www.cmlab.csie.ntu.edu.tw/…/process…/angryBirdsBrick/

2018年9月20日 星期四

WEEK2 04211021 馬紹芸

1。




2。
void setup(){
  size(400,400);
  colorMode(HSB,100);
}
int R=30, H=0;
void draw(){
  fill(H,100,100);
  ellipse(mouseX,mouseY, R,R);
  R-=3;
  if(R<0) R=30;
  H++;
  if(H>=100) H=0;





3。
void setup(){
  size(400,400);
  colorMode(HSB,100);
}
int R=30, H=0;
int CircleX=200,CircleY=200;
void draw(){
  fill(H,100,100);
  ellipse(CircleX,CircleY, R,R);
  R-=2;
  CircleX+=random(30)-15;
  CircleY+=random(30)-15;
  if(R<0){
    R=50;
  CircleX=200; CircleY=200;
 }
 H++;
 if(H>=100) H=0;
}



4。




5。



2018年9月13日 星期四

WEEK1 04211021 馬紹芸

A

Processing
size(800,600);
line(0,0,100,100);
rect( 100,100, 300,300);
///Ctrl-R can run it



互動
//void Setup()//Unity uses it
void setup(){
  size(800,600);
}
//void Update()//Unity uses it
void draw(){
  if(mousePressed) background(255,0,0);
  else background(0,255,0);
}




void setup(){
  size(800,600);
}
void draw(){
  if(mousePressed) line(mouseX,mouseY, pmouseX, pmouseY);
}




  if(mousePressed) line(mouseX,mouseY, pmouseX, pmouseY);
}
void keyPressed(){
  if(key=='1') strokeWeight(1);
  if(key=='2') strokeWeight(2);
  if(key=='9') strokeWeight(9);
  if(key=='r') stroke(255,0,0);
}