2018年11月15日 星期四

week10_焦焦焦

課堂(1):

到臉書社團 https://makeruno.com.my/getting-started/

 Download the CH341 Driver for Mac here.

開啟Arduino 



到電腦(左上"系統內容"裡的"裝置管理員")




找到裝置(COM7)



開啟Arduino

到工具列(開發板找到所需的裝置)



到工具列(序列找到裝置對應的內容"COM7")



課堂(2)

修改同學期中的作品(原始)

import ddf.minim.*;
Minim minim;
AudioPlayer player;
PImage imgBullet, imgBG, imgB;
float []ballX=new float[2000];
float []ballY=new float[2000];
float []ballVX=new float[2000];
float []ballVY=new float[2000];
float a, b;
int score=0, state=0;
int Time=3600;
void setup() {
  size(480, 800);
  imgBG=loadImage("out.png");
  imgBullet=loadImage("ball.png");
  imgB=loadImage("BG.jpg");
  imageMode(CENTER);
  a=240;
  b=300;
  minim=new Minim(this);
  player=minim.loadFile("music.mp3");
  player.play();
}
void draw() {

  image(imgB, width/2, height/2, width, height);
  ///we draw the stick
  if (score>=10)
    a++;
  if (a>=400)
    a= random(width - 10);
  image(imgBG, a, b, 300, 300);
  for (int i=0; i<2000; i++) {
    if (dist(ballX[i], ballY[i], a, b)<=10&&sco[i]==true) {
      sco[i]=false;
      score++;
    }
    if (ball[i]) {
      image(imgBullet, ballX[i], ballY[i], 100, 100);
      ballY[i]+=ballVY[i];
      ballVY[i]+=.98;
    }
  }
  Time--;
  image(imgBullet, mouseX, mouseY, 100, 100);
  fill(255, 0, 0);
  textSize(40);
  text(+(Time+59)/60, 320, 135);
  fill(255, 0, 0);
  textSize(40);
  text(+score, 120, 135);
  ellipse(190, 310, 10, 10);
  ellipse(300, 310, 10, 10);
}
int i=0;
boolean []ball=new boolean[2000];
boolean []sco=new boolean[2000];
void mousePressed() {
  ball[i]=true;
  sco[i]=true;
  ballX[i]=mouseX; ///ballVX[i]=random(3);
  ballY[i]=mouseY;
  ballVY[i]=-35;
  i++;
}

到速寫本添加新元件(minim)




即可開啟



import ddf.minim.*;
Minim minim;
AudioPlayer player;
PImage imgBullet, imgBG, imgB;
float []ballX=new float[2000];
float []ballY=new float[2000];
float []ballVX=new float[2000];
float []ballVY=new float[2000];
float a, b;
int score=0, state=0;
int Time=3600;
void setup() {
  size(480, 800);
  imgBG=loadImage("out.png");
  imgBullet=loadImage("ball.png");
  imgB=loadImage("BG.jpg");
  imageMode(CENTER);
  a=240;
  b=300;
  minim=new Minim(this);
  player=minim.loadFile("music.mp3");
  player.play();
}
void draw() {

  image(imgB, width/2, height/2, width, height);
  ///we draw the stick
  if (score>=10)
    a++;
  if (a>=400)
    a= random(width - 10);
  image(imgBG, a, b, 300, 300);
  for (int i=0; i<2000; i++) {
    if (dist(ballX[i], ballY[i], a, b)<=10&&sco[i]==true) {
      sco[i]=false;
      score++;
    }
    if (ball[i]) {
      image(imgBullet, ballX[i], ballY[i], 100, 100);
      if( dist(ballX[i], ballY[i], 190,310)<50 && ballVY[i]>0 ) ballVY[i] =- ballVY[i];
      ballY[i]+=ballVY[i];
      ballVY[i]+=.98;
    }
  }
  Time--;
  image(imgBullet, mouseX, mouseY, 100, 100);
  fill(255, 0, 0);
  textSize(40);
  text(+(Time+59)/60, 320, 135);
  fill(255, 0, 0);
  textSize(40);
  text(+score, 120, 135);
  ellipse(190, 310, 10, 10);
  ellipse(300, 310, 10, 10);
}
int i=0;
boolean []ball=new boolean[2000];
boolean []sco=new boolean[2000];
void mousePressed() {
  ball[i]=true;
  sco[i]=true;
  ballX[i]=mouseX; ///ballVX[i]=random(3);
  ballY[i]=mouseY;
  ballVY[i]=-35;
  i++;
}





沒有留言:

張貼留言