顯示具有 04372600_吳宇凡 標籤的文章。 顯示所有文章
顯示具有 04372600_吳宇凡 標籤的文章。 顯示所有文章

2018年12月6日 星期四

Week_13 吳宇凡


1.



2.processing/文件/範例程式



3.Libraries/Serial/SimpleRead



4.void setup(){
    pinMode(2,INPUT_PULLUP);
    Serial.begin(9600);
}
void loop(){
    if(digitalRead(2) == HIGH){ 
    Serial.write(1);
    }
    else{
      Serial.write(0);
    } 
    delay(100);
}


2018年11月22日 星期四

Week_11 吳宇凡





1.


2.
void setup() {
  // initialize digital pin LED_BUILTIN as an output.
  pinMode(LED_BUILTIN, OUTPUT);
}

// the loop function runs over and over again forever
void loop() {
  digitalWrite(LED_BUILTIN, HIGH);   // turn the LED on (HIGH is the voltage level)
  delay(1000);                       // wait for a second
  digitalWrite(LED_BUILTIN, LOW);    // turn the LED off by making the voltage LOW
  delay(1000);                       // wait for a second
}


3.









2018年10月25日 星期四

Week_7 吳宇凡

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;
}


2.計時
  int state=0;
int remainTime=0;
void setup(){
  size(800,600);
}
void draw(){
  if(state==0){
    drawOP();
    if(key=='1'){
      state=1;
      remainTime=5*60;
    }
  }else if(state==1){
    drawPlayer();
  }else if(state==2){
    drawED();
  }
}
void drawED(){
  background(0);
  fill(#F0D90C);
  textSize(30);text("Game Over",100,100);
}
void drawPlayer(){
  background(#F0D90C);
  fill(#161FF2);
  textSize(30);text("Playing.. You can press 2 to End",10,100);
  text("remail: "+remainTime,10,200);
  remainTime--;
  if(remainTime<=0) state=2;
}
void drawOP(){
  background(0);
  fill(#F5DE07);
  textSize(30);text("Opening.. You can press 1 to play",10,100);
}


2018年10月18日 星期四

Week_06 吳宇凡

1.
import ddf.minim.*;
Minim minim;
AudioPlay player;
void setup(){
minim = new Minim(this);
player=minim.loadFile("groove.mp3");
player.play();
}

2.
float fruitX, fruitY, fruitVX, fruitVY;
void setup() {
  size(800, 600);
  fruitX=30;    fruitVX=3;
  fruitY=700;   fruitVY=-35;
}
void draw(){
  background(0);
  ellipse(fruitX,fruitY,100,100);
  fruitX+=fruitVX;
  fruitY+=fruitVY;
  fruitVY+=0.98;
}

3.
float [] fruitX=new float[20];
float [] fruitVX=new float[20];
float [] fruitY=new float[20];
float [] fruitVY=new float20];
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;
  }
}

4.
float [] fruitX=new float[20];
float [] fruitVX=new float[20];
float [] fruitY=new float[20];
float [] fruitVY=new float20];
void reborn(int i) {
  fruitX[i]=random(800);      fruitVX[i]=random(6)-3;
  fruitY[i]=700;              fruitVY[i]=-35;
}
void setup() {
  size(800, 600);
  for (int i=0; i<20; i++) {
    reborn(i);
  }
}
void draw() {
  background(0);
  for (int i=0; i<20; i++) {
    if (dist(mouseX, mouseY, fruitX[i], fruitY[i])<=50) {
      reborn(i);      continue;
    }
    ellipse(fruitX[i], fruitY[i], 100, 100);
    fruitX[i]+=fruitVX[i];
    fruitY[i]+=fruitVY[i];
    fruitVY[i]+=0.98;
    if (fruitY[i]>700)reborn(i);
  }
}

5.
float [] fruitX=new float[20];
float [] fruitVX=new float[20];
float [] fruitY=new float[20];
float [] fruitVY=new float20];
void reborn(int i) {
  fruitX[i]=random(800);      fruitVX[i]=random(6)-3;
  fruitY[i]=700;              fruitVY[i]=-35;
}
void setup() {
  size(800, 600);
  for (int i=0; i<20; i++) {
    reborn(i);
  }
  for (int i=0; i<10; i++)sword[i]=new PVector();
}
PVector [] sword = new PVector[10];
void draw() {
  background(255);
   for (int i=0; i<20; i++) {
     if (dist(mouseXmouseY, fruitX[i], fruitY[i])<=50) {
      reborn(i);   
      continue;
    }
    ellipse(fruitX[i], fruitY[i], 100, 100);
    fruitX[i]+=fruitVX[i];
    fruitY[i]+=fruitVY[i];
    fruitVY[i]+=0.98;
    if (fruitY[i]>700)reborn(i);
  }
   for (int i=9; i>0; i--) {
    sword[i].x=sword[i-1].x;
    sword[i].y=sword[i-1].y;
  }
  sword[0].x=mouseX;
  sword[0].y=mouseY;
   for (int i=1; i<10; i++) {
    line(sword[i].x, sword[i].y, sword[i-1].x, sword[i-1].y);
  }
}

2018年10月11日 星期四

Weel_05 吳宇凡

1.PImage [] imgN=new PImage[10];
PImage egg;
float[] eggX=new float[100];
float[] eggY=new float[100];
boolean[] eggDie=new boolean[100];
void setup() {
  size(800, 600);
  egg = loadImage("egg.png");
  for (int i=0; i<9; i++) imgN[i] = loadImage(i+".png");
  for (int i=0; i<100; i++) {
    eggX[i]=random(100, 700);
    eggY[i]=-random(2000);
    eggDie[i]=false;
  }
}
int score =0;
void draw() {
  background(255);
  fill(255);
  rect(mouseX-50, mouseY-25, 100, 50);
  for (int i=0; i<100; i++) {
    if (eggDie[i])continue;
    image(egg, eggX[i], eggY[i], 80, 100);
    eggY[i]+=5;
    if (eggY[i]>700)eggY[i]=-2000+600;
    if (dist(mouseX-50, mouseY-25, eggX[i], eggY[i])<50) {
      eggDie[i]=true;
      score+=100;
    }
  }
  //fill(255, 0, 0);textSize(80);text("Score:"+score, 100, 100);
  int now=score;
  for (int i=0; i<7; i++) {
    image(imgN[(now%10)], 400-i*100, 100, 100, 150);
    now/=10;
  }
}
2.

3.

4.

5.

6.

7.
PImage []img=new PImage[8];
//float cherryX=0, cherryY=700;
//float cherryVX=6, cherryVY=-40;
float [] cherryX=new float[8];
float [] cherryY=new float[8];
float [] cherryVX=new float[8];
float [] cherryVY=new float[8];
void setup() {
  size(800, 600);
  for (int i=0; i<8; i++)img[i]=loadImage("cherry.png");
  for (int i=0; i<10; i++)sword[i]=new PVector();
  for (int i=0; i<8; i++) {
    cherryX[i]=random(3, 4);
    cherryY[i]=-random(8);
  }
}
PVector [] sword=new PVector[10];
void draw() {
  background(255);
  for (int i=0; i<8; i++) {
    image(img[i], cherryX[i], cherryY[i], 150, 150);
    cherryX[i]=random(3, 4);
    cherryY[i]=-random(8);
    cherryX[i]+=cherryVX[i];
    cherryY[i]+=cherryVY[i];
    cherryVY[i]+=0.98;
  }
  for (int i=9; i>0; i--) {
    sword[i].x=sword[i-1].x;
    sword[i].y=sword[i-1].y;
  }
  sword[0].x=mouseX;
  sword[0].y=mouseY;
  for (int i=1; i<10; i++) {
    line(sword[i].x, sword[i].y, sword[i-1].x, sword[i-1].y);
  }
}


2018年10月4日 星期四

Week_03 吳宇凡









1.size(500,500);
  ellipse(250,250,480,480);
  triangle(250,250,250,10,80,150);
2.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));


3.for(floatangle=0; angle<PI*2; angle+=PI/3){
    for(int R=0;R<=240;R+=30){
      noFill();
      triangle(250,250,
      250+240*cos(angle),         250+240*sin(angle),
      250+240*cos(angle+PI/3),250+240*sin(angle+PI/3));
    }
4. for(int R=0;R<=240;R+=20)

5.background(255);
     for(int cx=10;cx<800;cx+=40){
      for(int cy=10;cy<400;cy+=40){
        ellipse(cx,cy,30,30);
    } 
 }

 6.void myTriangle(int cx,int cy){
      float R=25, a=PI/2;
        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));
}
background(255);
      for(int cx=10;cx<800;cx+=40){
        for(int cy=10;cy<400;cy+=40){
         myTriangle(cx,cy);
    }
 }

7.float R=25, a=-PI/2;

8.float a=-PI/2;
    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));
  }

9.size(400,600);
 background(255);
  
  PImage imgMario = loadImage("mario.png");
  image(imgMario, 0,0, 150,150);
10.PImage imgMario;
float marioX=0, marioY=0,
  if (keyCode==UP)          { marioY-=5; }
  if (keyCode==DOWN)   { marioY+=5;}
  if (keyCode==LEFT)      { marioX-=5;}
  if (keyCode==RIGHT)   { marioX+=5;}
11.
float marioX=0, marioY=100, marioVX=1, marioVY=0, marioAX=0, marioAY=0.1;
marioX+=marioVX;   marioVX+=0;
  marioY+=marioVY;   marioVY+=0.98;
  if (marioY>500) marioVY = -marioVY*0.9;
12.
if (marioY>500) {
    marioVY = -marioVY*0.8;
    marioY=500;
  }
  if (marioX>300)marioX =-marioVX;
  if (marioX<0)marioVX =-marioVX;





2018年9月27日 星期四

Week_04 吳宇凡

1.
size(800,600);
text("Start!",100,100);

2.
fill(255,0,0); rect(100,100,100,100);
  fill(0,0,0);   text("Start!",100,100);

3.
rect(mouseX,mouseY,100,100); text("Start!",mouseX,mouseY);
textSize(80);

4.
 background(255);
  fill(255, 0, 0); 
  rect(100, 100, 100, 100);
  if (bulletFlying) {
    ellipse(bulletX, bulletY, 50, 50);
    bulletX+=3;
  }
}
float bulletX=100, bulletY=100;
boolean bulletFlying=false;
void keyPressed() {
  bulletFlying=true;
}

5.
  for (int i=0; i<bulletN; i++) {
    if  (bulletFlying[i]) {
     ellipse(bulletX[i], bulletY[i], 50, 50);
      bulletX[i]+=3;
    }
  }
float []bulletX=new float[100];
float []bulletY=new float[100];
boolean []bulletFlying= new boolean[100];
int bulletN=0;
void keyPressed() {
  bulletFlying[bulletN]=true;
  bulletX[bulletN]=100; bulletY[bulletN]=100;
  bulletN++;
}

6.
PImage imgBullet;
void setup(){
size(800,600);
imgBullet = loadImage("bullet.png");
}
void draw(){
image(imgBullet,mouseX,mouseY,100,100);
}

7.
PImage imgBullet, imgBG;
void setup() {
  size(800, 600);
  imgBG=loadImage("BG.png");
  imgBullet = loadImage("bullet.png");
  imageMode(CENTER);
}
void draw() {
  image(imgBG, width/2, height/2, width, height);
  image(imgBullet, mouseX, mouseY, 100, 100);
  for (int i=0; i<bulletN; i++) {
    if (bulletFlying[i]) {
      image(imgBullet, 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 keyPressed() {
  bulletFlying[bulletN]=true;
  bulletX[bulletN]=mouseX;
  bulletY[bulletN]=mouseY;
  bulletN++;
  println(bulletN);
}
8.
bulletY[i]+=bulletVY[i];
    bulletVY[i] +=0.98;
float []bulletVY=new float[100];


2018年9月20日 星期四

Week_02 吳宇凡





1.ellipse(200,200,30,30);
2.int R=30;//大小30
  ellipse(mouseX,mouseY,R,R);

3.fill(255,0,0);//顏色
 R= -3
 if(R<0) R=30;
4.工具 顏色選擇器

5.colorMode(HSB,100)
 int R=30,H=50;
6.H++
  if(H>=100) H=0;
7.int CircleX=200,CircleY=200;
  ellipse(CircleX,CircleY,R,R);
  CircleX+=random(10);
  CircleY+=random(10);
 if(R<0){ 
 R=50;
 CircleX=200;
 CircleY=200;
 }
8.CircleX+=random(30)-15;
 CircleY+=random(30)-15;

9.
10.
11.
12.