顯示具有 05161040_黃玟褱 標籤的文章。 顯示所有文章
顯示具有 05161040_黃玟褱 標籤的文章。 顯示所有文章

2018年12月20日 星期四

Week15

為期末作品做搖桿的測試

找出如何控制上下左右,以及如何接杜邦線
準備開始做遊戲內容的程式碼

2018年12月13日 星期四

WEEK14


寫入旋鈕程式
之後可以用在控制滑鼠屬標
int sensorPin = A0;    // select the input pin for the potentiometer
int ledPin = 13;      // select the pin for the LED
int sensorValue = 0;  // variable to store the value coming from the sensor

void setup() {
  // declare the ledPin as an OUTPUT:
  pinMode(ledPin, OUTPUT);
}

void loop() {
  // read the value from the sensor:
  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);
}

2018年11月29日 星期四

WEEK12

戶外教學
學習怎麼製作光劍




焊接LED燈



有問題旁邊的同學們也都很熱於幫忙




















後來因為一些材料的問題我們是最後一組走的,我們很努力地克服所有障礙後,終於拿到光劍大家都很開心也謝謝老師陪著我們還有材料費用的部分,我們去繳少少的錢有很大的成就感以及收穫,很棒的戶外教學

2018年11月22日 星期四

WEEK11

瀏覽電腦上的驅動程式

前往此網址下載驅動程式:

https://makeruno.com.my/getting-started/

更改工具列的序列埠(每個人的不一樣,我的是COM9)
複製程式碼:
https://makeruno.com.my/playing-melody-using-only-maker-uno/?fbclid=IwAR0tZ_KdYKtJw9aii5Foj-eNHvXMWCRF7SSoir2nivJAez7VqyK8293UdHo

程式會播放音樂藉由蜂鳴器

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

week08

期中作品:閃電俠
連結:https://www.youtube.com/watch?v=3yH-vp-ZOUQ
玩法:從起點走到END終點,要走最少的格子,不能採到炸彈,並且在時間內抵達,如果時間到了還沒抵達則GAMEOVER,踩到炸彈則GAMEOVER,不是走最少格子則GAMEOVER

2018年11月15日 星期四

WEEK10

使用Aruino Maker Uno

前往下列網址:
https://makeruno.com.my/getting-started/?fbclid=IwAR2eFAh0fqWqNJjFLbzTYBV9VI42uael8ZatyZLvERZHnb7MYFMk5pmiSxY

下載Arduino IDE Software
並安裝CH341 Driver for Windows

2018年10月18日 星期四

week06


水果忍者,畫水果 讓水果墜落地平線會自行重生 被滑鼠點掉也會自行重生
只差幫水果做貼圖就是真的水果忍者

2018年10月11日 星期四

WEEK5

接雞蛋

先做從天而降的雞蛋

float[] eggX=new float[100];
float[] eggY=new float[100];
void setup(){
  size(800,600);
  for(int i=0;i<100;i++){
    eggX[i]=random(100,700);
    eggY[i]=-random(2000);
  }
}
void draw(){
  background(255);
  for(int i=0;i<100;i++){
    ellipse(eggX[i], eggY[i],80,100);
    eggY[i]+=5;
  }
}


開始接雞蛋

float[] eggX=new float[100];float[] eggY=new float[100];                          
boolean[] eggDie=new boolean[100];
void setup(){  size(800,600);  
for(int i=0;i<100;i++){
    eggX[i]=random(100,700);
    eggY[i]=-random(2000);
               eggDie[i]=false;  }
}
void draw(){
  background(255);
  rect(mouseX-50, mouseY-25,100,50);
  for(int i=0;i<100;i++){//for all eggs
    if(eggDie[i])continue;//continue to for loop
    ellipse(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;  }
}
}


2018年9月27日 星期四

WEEK4

子彈
按鍵盤射出子彈


void setup(){
size(800,600); } void draw(){ background(255); fill(255,0,0);rect(100,100,100,100); 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]; int bulletn=0; boolean []bulletflying=new boolean[100]; void keyPressed(){ bulletflying[bulletn]=true; bulletx[bulletn]=100; bullety[bulletn]=100; bulletn++; }

week03

畫出三角形,畫出角度,使用迴圈讓他重覆執行畫出迷幻園行中的三角形

void setup(){ size (500,500); } 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)); } } }












畫出會彈跳的mairo,慢慢彈跳變低,碰到邊界就反彈很酷

PImage imgmario; float marioX=0,marioY=0,marioVX=0.5,marioVY=0,marioAX=0,marioAY=0.1; void setup(){ size (400,600); imgmario=loadImage("mario.png"); } void draw(){ background(255); image (imgmario,marioX,marioY,100,150); marioX+=marioVX; marioVX+=marioAX; marioY+=marioVY; marioVY+=marioAY; if(marioY>600-150)marioVY*=-0.9; if(marioX>400-100)marioVX*=-1; if(marioY<0)marioVY*=-0.9; if(marioY<0)marioVX*=-1; if(marioX<300)marioVX=-marioVX; if(marioX>0)marioVX=-marioVX; } void keyPressed(){ if(keyCode==UP){marioY-=5;} if(keyCode==DOWN){marioY+=5;} if(keyCode==LEFT){marioX-=5;} if(keyCode==RIGHT){marioX+=5;} }

2018年9月20日 星期四

WEEK2

接龍

void setup(){
 size(400,400); 
}
int R=30; 
void draw(){
 ellipse(mouseX,mouseY,R,R);
 if(R<0) R=30;
}



幫接龍加點顏色
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;
}

2018年9月13日 星期四

WEEK1

下載https://processing.org/ 















簡單程式碼

點擊滑鼠改變背景顏色

void setup(){
 size(800,600);
}
void draw(){
 if(mousePressed) background(150,0,0);
    else background(0,250,0);
}


小畫家



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


void draw(){

  line(mouseX,mouseY,pmouseX,pmouseY);
}