顯示具有 01160146_楊博凱 標籤的文章。 顯示所有文章
顯示具有 01160146_楊博凱 標籤的文章。 顯示所有文章

2015年1月18日 星期日

期末作品展示

原始模板:










面紙盒內部構造:



~期末作業~

Pressing:

import processing.serial.*;
Serial myPort;



int mapSizex=480;       //map x >>>
int mapSizey=480;       //map y ↓↓↓
//int posX=mapSizex/2, posY=mapSizey/2;  //player place at mid

int i=0;   //for

int maxWalkSpeed=2;         //move speed
float walkAccelx=0;         //x++ speed
float walkAccelxtmp=0;      //x++ speed tmp
float walkSpeedx=0;         //x start speed
float walkAccely=0;         //y++speed
float walkAccelytmp=0;      //y++speed temp
float walkSpeedy=0;         //y start speed

int maxConnon=5;           //max rock how many
float minConnonSpeed=0.1;   //rock move low speed
float maxConnonSpeed=1;     //rock move fast speed

float[] connonv= new float[maxConnon+1]; //
float[] connonx= new float[maxConnon+1]; //
float[] connonxv= new float[maxConnon+1]; //
float[] connony= new float[maxConnon+1]; //
float[] connonyv= new float[maxConnon+1]; //
float[] connonw= new float[maxConnon+1]; //

boolean gamestart=false; //pan duan start or not
boolean gameover=false;  //pan duan die or not
int score=0;             //score

PImage img, imgBG;
int posX=0;
int posY=0;

void setup()
{
  myPort=new Serial(this,"COM3",9600);
  size(255,200);
 
  size(mapSizex, mapSizey+6);          //+5 or can't see score
  img=loadImage("spaceship.png");        //
  imgBG=loadImage("starworld.jpg");    //picture
  imgBG.resize(mapSizex, mapSizey+6);  //+5 or can't see score
  imageMode(CENTER);                  
  posX=floor(mapSizex/2);         //player place reset
  posY=floor(mapSizey/2);         //same



  for (i=1;i<=maxConnon;i++)
  {
    switch(floor(random(1,5))) // random come out ball
    {  
    case 1: //<< x place -10 y random place
      connonx[i]=-10;                
      connony[i]=random(-10, mapSizey+10);
      break;
    case 2: //↑↑ y place -10 x random place
      connonx[i]=random(-10, mapSizex+10);
      connony[i]=-10;
      break;
    case 3: //>> x place +10 y random place
      connonx[i]=mapSizex+10;
      connony[i]=random(-10, mapSizey+10);
      break;
    case 4://↓↓ y place +10 x random place+10
      connonx[i]=random(-10, mapSizex+10);
      connony[i]=mapSizey+10;
      break;
    }
    connonv[i]=random(minConnonSpeed,maxConnonSpeed); //rock speed
    connonxv[i]=connonv[i]*((posX-connonx[i])/sqrt(sq(connonx[i]-posX)+sq(connony[i]-posY))); //x
    connonyv[i]=connonv[i]*((posY-connony[i])/sqrt(sq(connonx[i]-posX)+sq(connony[i]-posY))); // y
    connonw[i]=5;//ball big small
  }
}

void draw() {

  background(imgBG);
  image (img, posX,posY, 30,30);

  if (gamestart) {
    //gameStart();
    update();
    setConnon();
    scoreShow();
  }
  else {

    textSize(40);                        //big small
    fill(255,255,255);                   //colour
    text("PRESS HERE TO START", 30,100); //title
  }
}




void keyPressed()  //keyboard up down left right
{
  switch(keyCode)
  {
    case LEFT:          //<<
      walkAccelx=-0.2;  //speed  
      walkAccelxtmp=0;  //ship start 0 everytime then -0.15
      break;
     
    case RIGHT:          //>>
      walkAccelx=0.2;  
      walkAccelxtmp=0;
      break;
     
    case UP:             //^^
      walkAccely=-0.2;
      walkAccelytmp=0;
      break;
     
    case DOWN:          //↓↓
      walkAccely=0.2;
      walkAccelytmp=0;
      break;
   }
}


void keyReleased() //put out
{
  switch(keyCode)
  {
    case LEFT:                      
      walkAccelxtmp=walkAccelx;      //orginal speed switch
      walkAccelx=0;                  //restar 0
      break;
     
    case RIGHT:
      walkAccelxtmp=walkAccelx;
      walkAccelx=0;
      break;
     
    case UP:
      walkAccelytmp=walkAccely;
      walkAccely=0;
      break;
     
    case DOWN:
      walkAccelytmp=walkAccely;
      walkAccely=0;
      break;
     
    case ' ':                 //space bar
      if (gameover==true)
      {  
         score=0;
         gameover=false;
         frameCount=0;
         walkAccelytmp=0;
         setup();
        //redraw();          
       }
       break;
    }
}

void mouseClicked()  
{
  if (gameover==true)
  {
    score=0;
    gameover=false;
    frameCount=0;
    setup();
    //redraw();
  }
  if (gamestart==false)
  {
    gamestart=true;
  }
}       // see dao zhe bian

void update()
{
  if (posY>=10 && posY<=mapSizey-10)
  {
    posY+=walkSpeedy;
    if (walkAccely!=0)
    {
      if (abs(walkSpeedy)<maxWalkSpeed)
      {
        walkSpeedy+=walkAccely;
      }
      else
      {
        if (walkSpeedy>0)
        {
          walkSpeedy=maxWalkSpeed;
        }
        else
        {
          walkSpeedy=-maxWalkSpeed;
        }
      }
    }
    else
    {
      if (abs(walkSpeedy)>0.2)
      {
        walkSpeedy-=walkAccelytmp;
      }
      else
      {
        walkSpeedy=0;
        walkAccelytmp=0;
      }
    }
  }
  else
  {
    if (posY<10)
    {
      walkSpeedy=0;
      posY=10;
      walkAccely=0;
    }
    if (posY>mapSizey-10)
    {
      walkSpeedy=0;
      posY=mapSizey-10;
      walkAccely=0;
    }
  }
  if (posX>=10&&posX<=mapSizex-10)
  {
    posX+=walkSpeedx;
    if (walkAccelx!=0)
    {
      if (abs(walkSpeedx)<maxWalkSpeed)
      {
        walkSpeedx+=walkAccelx;
      }
      else
      {
        if (walkSpeedx>0)
        {
          walkSpeedx=maxWalkSpeed;
        }
        else
        {
          walkSpeedx=-maxWalkSpeed;
        }
      }
    }
    else
    {
      if (abs(walkSpeedx)>0.2)
      {
        walkSpeedx-=walkAccelxtmp;
      }
      else {
        walkSpeedx=0;
        walkAccelxtmp=0;
      }
    }
  }
  else
  {
    if (posX<10)          //dun give aloplant go outside
    {
      walkSpeedx=0;
      posX=10;
      walkAccelx=0;
    }
    if (posX>mapSizex-10)
    {
      walkSpeedx=0;
      posX=mapSizex-10;
      walkAccelx=0;
    }
  }
  int a=0;
 
  if(myPort.available()>0) a =myPort.read();
  if( (a&0x01)==0x01)posY+=10;///{println("up");}else println("no up");
  if( (a&0x02)==0x02)posY-=10;
  if( (a&0x04)==0x04)posX+=10;
  if( (a&0x08)==0x08)posX-=10;

       
 
  noStroke();
  fill(0,255,0,1);
  ellipse(posX,posY, 10, 10);   //mid xiao dian
}



void setConnon() {

  for (i=1;i<=maxConnon;i++) {

    if (abs(connonx[i]-posX)<connonw[i]&&abs(connony[i]-posY)<connonw[i]) {
      gameover=true;
    }
    else {
      if ((connonx[i]>mapSizex+10)||(connonx[i]<-10)||(connony[i]<-10)||(connony[i]>mapSizey+10)||gameover) {

        switch(floor(random(1, 4.99))) {
        case 1: //左
          connonx[i]=-10;
          connony[i]=random(-10, mapSizey+10);
          break;
        case 2: //上
          connonx[i]=random(-10, mapSizex+10);
          connony[i]=-10;
          break;
        case 3: //右
          connonx[i]=mapSizex+10;
          connony[i]=random(-10, mapSizey+10);
          break;
        case 4: //下
          connonx[i]=random(-10, mapSizex+10);
          connony[i]=mapSizey+10;
          break;
        }
        connonv[i]=random(0.1, 5);
        connonxv[i]=connonv[i]*((posX-connonx[i])/sqrt(sq(connonx[i]-posX)+sq(connony[i]-posY)));
        connonyv[i]=connonv[i]*((posY-connony[i])/sqrt(sq(connonx[i]-posX)+sq(connony[i]-posY)));


        if (!gameover) {
          score+=1;
        }

        if (frameCount>=1000&&frameCount<2000) {
          connonw[i]=floor(random(3, 15));
        }
        if (frameCount>=2000&&frameCount<4000) {
          connonw[i]=floor(random(3, 30));
        }
        if (frameCount>=4000) {
          connonw[i]=floor(random(3, 80));
        }
      }


      else {
        connonx[i]+=connonxv[i];
        connony[i]+=connonyv[i];
        noStroke();
        fill(250, 20, 0);
        ellipse(connonx[i], connony[i], connonw[i], connonw[i]);
      }
    }
  }
}

void scoreShow() //show score
{
  if (gameover)
  {
    textSize(15);
    fill(255, 255, 255);
    text("Game Over\nYour Score: "+score+"\nPress space bar to continue", floor(mapSizex/4), floor(mapSizey/2));
  }
  else
  {
    textSize(10);    
    fill(240, 220, 0);
    text("Your Score: "+score, 10, mapSizey+5); //left botton score
  }
}

arduino:

void setup(){
  Serial.begin(9600);
  pinMode(12, INPUT_PULLUP);
  pinMode(5, INPUT_PULLUP);
  pinMode(3, INPUT_PULLUP);
  pinMode(0, INPUT_PULLUP);
  pinMode(8,INPUT_PULLUP);

}
void loop(){
  int a=0;
  if(digitalRead(12)==LOW)a|=0x01;//Serial.println("up  ");
  if(digitalRead(5)==LOW) a|=0x02;//Serial.println("down");
  if(digitalRead(3)==LOW) a|=0x04;//Serial.println("left");
  if(digitalRead(0)==LOW) a|=0x08;//Serial.println("right");

  Serial.write(a);

  delay(20);
}

2014年12月22日 星期一

重點程式

void setup(){
  Serial.begin(9600);
  pinMode(12, INPUT_PULLUP);
  pinMode(5, INPUT_PULLUP);
  pinMode(3, INPUT_PULLUP);
  pinMode(0, INPUT_PULLUP);
  pinMode(13,OUTPUT);

}
void loop(){
  int a=0;
  if(digitalRead(12)==LOW)a|=0x01; // Serial.println("up");
  if(digitalRead(5)==LOW) a|=0x02;//Serial.println("down");
  if(digitalRead(3)==LOW) a|=0x04;//Serial.println("left");
  if(digitalRead(0)==LOW) a|=0x08;//Serial.println("right");
  Serial.write(a);

  if(millis()%1000<500) digitalWrite(13, HIGH);
  else digitalWrite(13,LOW);
  delay(20);
}



if(int  now==0 &按按鈕)
{
now=1;
Serial.write('A');
}
if(now=1 & 按鈕沒按)
{
now=0;
} Serial.write('a');

2014年12月15日 星期一

程式碼

aduino



void setup(){
  Serial.begin(9600);
  pinMode(12, INPUT_PULLUP);
  pinMode(5, INPUT_PULLUP);
  pinMode(3, INPUT_PULLUP);
  pinMode(0, INPUT_PULLUP);
  pinMode(13,OUTPUT);
 
}
void loop(){
  int a=0;
  if(digitalRead(12)==LOW)a|=0x01; // Serial.println("up");
  if(digitalRead(5)==LOW) a|=0x02;//Serial.println("down");
  if(digitalRead(3)==LOW) a|=0x04;//Serial.println("left");
  if(digitalRead(0)==LOW) a|=0x08;//Serial.println("right");
  Serial.write(a);
 
  if(millis()%1000<500) digitalWrite(13, HIGH);
  else digitalWrite(13,LOW);
  delay(20);
}






processing.



import processing.serial.*;
Serial myPort;
void setup(){
  size(255+80,200);
  myPort=new Serial(this,"COM4",9600);
  
}

int posX=0;
int posY=0;
void draw(){
  background (255);
  int a=0;
  if(myPort.available()>0) a =myPort.read();
  if( (a&0x01)==0x01)posY+=10;///{println("up");}else println("no up");
  if( (a&0x02)==0x02)posY-=10;
  if( (a&0x04)==0x04)posX+=10;
  if( (a&0x08)==0x08)posX-=10;
  fill(#ff0000);rect(posX,posY,80,50);
  
}





...

void setup(){
  Serial.begin(9600);
  pinMode(12, INPUT_PULLUP);
  pinMode(5, INPUT_PULLUP);
  pinMode(3, INPUT_PULLUP);
  pinMode(0, INPUT_PULLUP);
 
}
void loop(){
  while(Serial.available()>0){
    char data = Serial.read();
    Serial.print(data);
  }
  {if(digitalRead(12)==LOW)Serial.println("up");
  else (digitalRead(12)==0);}
  {if(digitalRead(5)==LOW)Serial.println("down");
  else (digitalRead(5)==0);}
  {if(digitalRead(3)==LOW)Serial.println("left");
   else (digitalRead(3)==0);}
  {if(digitalRead(0)==LOW)Serial.println("right");
   else (digitalRead(0)==0);}
}



import processing.serial.*;
Serial myPort;
void setup(){
  size(255+80,200);
  myPort=new Serial(this,"COM4",9600);
}
int posX=0;
int posY=0;
void draw(){
  background (255);
  fill(#ff0000);rect(posX,posY,80,50);
    posY=myPort.read();
    posX=myPort.read();
    println(posX);
  }

2014年11月24日 星期一

arduino霹靂燈


arduino~霹靂燈~
/*
Blink
Turns on an LED on for one second, then off for one second, repeatedly.

This example code is in the public domain.
*/

// Pin 13 has an LED connected on most Arduino boards.
// give it a name:
int led1 = 13;
int led2 = 11;
int led3 = 9;
int led4 = 12;
int led5 = 10;
int led6 = 7;

// the setup routine runs once when you press reset:
void setup() {
// initialize the digital pin as an output.
pinMode(led1, OUTPUT);
pinMode(led2, OUTPUT);
pinMode(led3, OUTPUT);
pinMode(led4, OUTPUT);
pinMode(led6, OUTPUT);
}

// the loop routine runs over and over again forever:
void loop() {
digitalWrite(led1, HIGH); // turn the LED on (HIGH is the voltage level)
delay(200); // wait for a second
digitalWrite(led1, LOW); // turn the LED off by making the voltage LOW
delay(200); // wait for a second

digitalWrite(led2, HIGH); // turn the LED on (HIGH is the voltage level)
delay(100); // wait for a second
digitalWrite(led2, LOW); // turn the LED off by making the voltage LOW
delay(100);

digitalWrite(led3, HIGH); // turn the LED on (HIGH is the voltage level)
delay(50); // wait for a second
digitalWrite(led3, LOW); // turn the LED off by making the voltage LOW
delay(50);

digitalWrite(led6, HIGH); // turn the LED on (HIGH is the voltage level)
delay(10); // wait for a second
digitalWrite(led6, LOW); // turn the LED off by making the voltage LOW
delay(10);

digitalWrite(led6, HIGH); // turn the LED on (HIGH is the voltage level)
delay(200); // wait for a second
digitalWrite(led6, LOW); // turn the LED off by making the voltage LOW
delay(200); // wait for a second

digitalWrite(led3, HIGH); // turn the LED on (HIGH is the voltage level)
delay(100); // wait for a second
digitalWrite(led3, LOW); // turn the LED off by making the voltage LOW
delay(100);

digitalWrite(led2, HIGH); // turn the LED on (HIGH is the voltage level)
delay(50); // wait for a second
digitalWrite(led2, LOW); // turn the LED off by making the voltage LOW
delay(50);

digitalWrite(led1, HIGH); // turn the LED on (HIGH is the voltage level)
delay(10); // wait for a second
digitalWrite(led1, LOW); // turn the LED off by making the voltage LOW
delay(10);
}

第8週業界雙師授課心得報告

   這次業界講師授課,很可惜我沒有聽到,因為身體不舒服的關係,所以只能從同學的文字中得知,這次請到的是叁式的創辦人,曾煒傑先生來跟我們分享,真得是很可惜,從同學的文章中,曾煒傑先生是一個非常害的人,擁有夢想實踐力和勇往直前的決心,但是光從文字上,我真的無法去完全體會到,因此我選擇以網路肉搜的方式,把曾煒傑先生找出來,看看他是不是真的相當厲害。

   網路上有許多資料,許多同學都有寫到”第七感官(Seven Sence)”這個東西,由於我沒有聽到講師的講解,因此我只能自己從視頻上來體會,我也查到某的平台訪問曾煒傑,關於第七感官創作理念,以及使用科技結合藝術所遇到的困難點,曾煒傑在因緣際會下,認識了一位編舞家,編舞家希望打造處一個連續性的空間,又希望做出有點不太一樣的創新,後來才有了希望由觀眾們來互動,來改變表演的性質,讓這個表演有更好玩的呈現方式。

  互動可以做成這樣,真的相當佩服他,從網站上訪問曾煒傑,得知他們也是台灣第一個以這種方式呈現的,還有相當多作品,讓我大開眼界,雖然沒能聽到曾煒傑親口的述說,但是從網路上的視頻,讓我真的學到很多。

第10週業界雙師授課心得報告-愛迪斯胡啟彥先生

第10週業界雙師授課心得報告-愛迪斯胡啟彥先生

今天老師請到是愛迪斯的胡啟彥先生來和我們分享有關互動技術的相關作品,愛迪斯是一個是一家專業的虛擬仿真整體解決方案應用代理商和服務商,擅長虛擬實境、動作捕捉、擴增實境、多平台開發等多方向,愛迪斯以創新的點子和專業的技術,是讓很多客戶喜愛。
  今天胡啟彥先生,介紹了相當多的作品,有很多都是跟Unity相關的作品,Unity是一個輕鬆就能建立3D影像遊戲、建築視覺化、即時3D動畫等類型互動內容的多平台綜合型遊戲開發工具,Unity開發應用範圍廣泛,從手機遊戲到網路的大型遊戲,甚至是大型的比賽上,也是用得到Unity的技術,曾經在英雄聯盟比賽會場上,就是使用這種技術,讓一般民眾體會到視覺和聽覺上的特殊感受,在遊戲以及電影上,Unity的技術,會讓人更能清楚體會到真人的感覺。

  在房屋業者上,虛擬居家系統,會讓民眾能模擬房屋內的感覺,能假裝一個視角從房屋裡頭,全部一目瞭然,不管是從裡到外,從上到下,就算是在二樓也能到達,我們還看了愛迪斯跟核能電廠合作,有幾項附有教學意義的小遊戲,從中和遊戲的互動,讓民眾和小朋友都能知道能源的來源,不但非常有教學的用處,更讓一般民眾清楚,而且互動的遊戲都相當好玩,會讓人有想實地踏進去玩的感覺,很感謝老師讓我們有那麼好的機會,讓我們能更清楚知道互動技術的科技和使用工具。

2014年10月6日 星期一

week04



void setup() {
  size(600, 400);
}
void draw() {
  background(0);
  translate(mouseX, mouseY);
  rotate(0.01*frameCount);
  for(int i=0;i<20;i++){
  fill(#FF6464); ellipse(0, 0, 18, 180);
  rotate(PI/4);
  }

  fill(#FF7C17);  ellipse(0, 0, 80, 80);

}





void setup() {
  size(600, 400);
  colorMode(HSB,600,400,400);
}
void draw() {

  fill(mouseX,mouseY,400);
  translate(mouseX, mouseY);
  rotate(0.01*frameCount);
  for(int i=0;i<20;i++){
  ellipse(0, 0, 18, 180);
  rotate(PI/4);
  }

   fill(mouseX,mouseY,400); ellipse(0, 0, 80, 80);

}


期中作品分析
遊戲名字:特訓99
1.1中間為玩家
1.2周圍會有無數的砲彈攻擊玩家
1.3當砲彈觸碰到玩家,遊戲則結束
1.4分數會顯示在左下角   



期中作品







2014年9月29日 星期一

week03




PImage img;
void setup(){
size (600,600);
img=loadImage("main.png");
imageMode(CENTER);
}

void draw(){
   background(255,255,0);
   image (img,mouseX,mouseY,300,300);
}



蛋蛋攻擊~

PImage img,imgBG;
float eggX=750,eggY=550,eggVX,eggVY,flying=0;
void setup(){
size (800,600);
img=loadImage("main.png");
imgBG=loadImage("greenground.jpg");
imgBG.resize(800,600);
imageMode(CENTER);
}

void draw(){
   background(imgBG);
   image (img,mouseX,mouseY,300,300);
   if(flying>0){
     ellipse(eggX,eggY,50,50);
     eggX+= eggVX;eggY+= eggVY;flying--;
   }
}
void mousePressed(){
  eggX=550;eggY=450;flying=30;
  eggVX=(mouseX-eggX)/30;
  eggVY=(mouseY-eggY)/30;
}

2014年9月22日 星期一

Week2



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

void draw(){
   background(250,252,150);
   rect(mouseX,mouseY,100,100);
 }


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




void setup (){
  size(800,600);
  background(250,252,150);
  fill(255,0,0);rect(0,0,100,100);
  fill(0,255,0);rect(0,100,100,100);
  fill(0,0,255);rect(0,200,100,100);
  fill(0);rect(0,300,100,100);
  }
 void draw(){
   if(mousePressed)
   line(mouseX,mouseY,pmouseX,pmouseY);
   
 }
 void mousePressed(){
   if(mouseX<100 && mouseY<100) stroke(255,0,0);
   else if(mouseX<100 && mouseY<200) stroke(0,255,0);
   else if(mouseX<100 && mouseY<300) stroke(0,0,255);
   else if(mouseX<100 && mouseY<400) stroke(0);
 }


void setup (){
  size(800,600);
  background(250,252,150);
  rect(0,550,100,100);ellipse(750,50,5,5);
  rect(,100,100,100);ellipse(750,150,10,10);
  rect(700,200,100,100);ellipse(750,250,15,15);
  
  
  
  
  fill(255,0,0);rect(0,0,100,100);
  fill(0,255,0);rect(0,100,100,100);
  fill(0,0,255);rect(0,200,100,100);
  fill(0);rect(0,300,100,100);

}



 void draw(){
   if(mousePressed &&mouseX>100 &&mouseY<700)
   line(mouseX,mouseY,pmouseX,pmouseY);}
   

 void mousePressed(){
   if(mouseX<100 && mouseY<100) stroke(255,0,0);
   else if(mouseX<100 && mouseY<200) stroke(0,255,0);
   else if(mouseX<100 && mouseY<300) stroke(0,0,255);
   else if(mouseX<100 && mouseY<400) stroke(0);
   else if(mouseX>700 && mouseY<100) strokeWeight(5);
   else if(mouseX>700 && mouseY<200) strokeWeight(10); 
   else if(mouseX>700 && mouseY<300) strokeWeight(15);  
 }



2014年9月15日 星期一

week01


size (600,300);
background (9,39,20);
fill (255,255,255);
rect (0,100,600,15);

fill (255,255,255);
rect (0,200,600,15);

fill (255,255,255);
rect (0,300,600,15);

fill (255,255,255);
rect (200,0,15,600);

fill (255,255,255);
rect (400,0,15,600);

fill (255,255,255);
ellipse (100,50,50,50);//circle1

fill (255,255,255);
ellipse (300,50,50,50);//circle2

fill (255,0,0);
ellipse (500,50,50,50);//circle3

fill (255,0,0);
ellipse (100,150,50,50);//circle4

fill (255,255,255);
ellipse (300,150,50,50);//circle5

fill (255,0,0);
ellipse (500,150,50,50);//circle6

fill (255,255,255);
ellipse (100,250,50,50);//circle7

fill (255,0,0);
ellipse (300,250,50,50);//circle8

fill (255,0,0);
ellipse (500,250,50,50);//circle9

stroke(0,0,0);
strokeWeight(4);
line(500,0,500,500);//line

Week01