顯示具有 00160325張智棠 標籤的文章。 顯示所有文章
顯示具有 00160325張智棠 標籤的文章。 顯示所有文章

2014年1月12日 星期日

Week19 張智棠,陳奕汎

互動技術概論期末

Demo影片 :



Code:
 import ddf.minim.*;
import processing.serial.*;
AudioPlayer player,SE;
Minim minim;
Serial myPort;
int val;
int angle;
PImage img1,img2,img3,bg,win,copyright,copyright2;;
PImage imgMan,leftwalk,rightwalk;
PImage imgface,imgface2,imgface3,symbol;
int Alpha=255,Alpha2=255;

float z2=int(random(150)+50);
float z3=int(random(150)+80);
float z4=int(random(150)+100);
float ac=0.03;

int BuildingX,BuildingX2,BuildingX3;
int stage=4;
int N=6;
int []thingType = new int [6] ;
float []thingX = new float [6];
int BGX=0;

float Reac,Rez2,Rez3,Rez4;
boolean sw=false;
boolean left=false,right=false,start=true;
int a=3;
int Time=800;
float GameTime=0;
int Score=0;
int move=0;
int blood=100;
//stage1 run
//stage2 gameover
//stage3 win
//stage4 menu
void setup(){
  size(600,600);
  String [] all = Serial.list();
  String portName = all[all.length-1];
  myPort = new Serial(this, portName, 9600);
  img1=loadImage("monster1.png");
  img2=loadImage("monster2.png");
  img3=loadImage("monster3.png");
  imgface=loadImage("image1.png");
  imgface2=loadImage("image.png");
  imgface3=loadImage("image3.png");
  symbol = loadImage("symbol.png");
  imgMan=loadImage("start.png");
  leftwalk=loadImage("leftwalk.png");
  rightwalk=loadImage("rightwalk.png");
  bg=loadImage("bg.jpg");
  win=loadImage("");
  copyright = loadImage("copyright.bmp");
  copyright2 = loadImage("copyright2.bmp");
  imageMode(CENTER);
   for ( int i = 0 ; i < N ; i++)
  {
     newThing(i);
  }
  minim = new Minim(this);

  player = minim.loadFile("ST1.mp3");
  SE = minim.loadFile("ken.mp3");
}

float newH;
float newH2;
float newH3;
float newH4=50;
int b;
void draw(){

  if ( myPort.available() > 0)
  {
    val = myPort.read(); //Arduino Control
    //angle = myPort.read();
    println("val "+val);
    println("ac "+ac);
   // println("angle "+angle);
  }
  if (stage==3)
  {
    if (val==180) stage=4;
  }
  if (stage==4)
  {
    if (val==180) stage=1;
  }
  if (stage==1)
  {
 
    if (val==181)
    {
      if (sw==false)
      {
         z2-=ac;
        ac+=0.001;
        if (ac>0.88) ac=0.88;
      }
    }
   /* if (val==179)
    {
      if (sw==false)
      {
        textSize(32);
        fill(255,128,0);
        text("PAUSE",250,300);
        Reac = ac;
        Rez2 = z2;
        Rez3 = z3;
        Rez4 = z4;
        z2+=ac;
        ac=0;
        sw = true;
      }
    }
    if (sw ==true)
    {
      if (val==181)
      {
        sw = false;
        ac = Reac;
        z2 = Rez2;
        z3 = Rez3;
        z4 = Rez4;
      }
    }*/
    else z2-=ac;
 
    if (val>79 && val<180)
    {
      if (sw==false)
      {
          if (val%79<10){thingX[0]-=val%79; thingX[1]-=val%79; thingX[2]-=val%79;thingX[3]-=val%79;thingX[4]-=val%79; thingX[5]-=val%79;}
          if (val%79>10){thingX[0]-=10; thingX[1]-=10; thingX[2]-=10;thingX[3]-=10; thingX[4]-=10; thingX[5]-=10;}
          right=true;
          left=false;
          start=false;
      }
    }
   if (val>0 && val<79)
    {
      if (sw==false)
      {
        if (val%79<10) {thingX[0]+=val%79; thingX[1]+=val%79; thingX[2]+=val%79;thingX[3]+=val%79; thingX[4]+=val%79; thingX[5]+=val%79;}
        if (val%79>10){ thingX[0]+=10; thingX[1]+=10; thingX[2]+=10;thingX[3]+=10; thingX[4]+=10; thingX[5]+=10;}
        left=true;
        right=false;
        start=false;
      }
    }
  }



  if (stage==1&&sw==false)//stage01 runnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnn
  {
    if (a==1)
    {
       player.close();
       player=minim.loadFile("ST1.mp3");
       player.setGain(-20);
       player.play();
       player();
       ac=0.03;
       z2=int(random(150)+50);
       z3=int(random(150)+80);
       z4=int(random(150)+100);
       blood=100;
       Time=1000;
       GameTime=0;
       Score=0;
       newH= 1360*atan(10/z2)/PI;
       newH2= 1360*atan(10/z3)/PI;
       newH3= 1360*atan(10/z4)/PI;
    }
    a=2;
    GameTime+=0.5;
    background(255);
    image(bg,300,300,600,600);
    fill(255,0,0);
    rect(100,500,blood+GameTime*0.05-Score*20,50);
    fill(255);
    textSize(15);
    text("HP "+(int)(blood+GameTime*0.05-Score*20),100,580);
    text("GameTime"+GameTime,400,580);
    fill(255,255,0);
    textSize(15);
    text("Press S To PAUSE",100,100);
    text("Press R To Continue",100,150);
    text("Press A To Access",400,100);
    text("Press X or x To Move",400,150);
    if ((blood+GameTime*0.05-Score*20)<0) stage=2;
    //if (GameTime>3000) stage=3;
    for ( int i = 0 ; i < N ; i++)
    {
      if (thingType[i]%6==1)
      {
        draw1(i);
        if (z2<5&&(newH4-newH)<30)
        {
          Score++;
          SE.close();
          SE = minim.loadFile("ken.mp3");
          SE.setGain(-20);
          SE.play();
        }
      }
      if (thingType[i]%6==2)
      {
        draw2(i);
        if (z3<5&&(newH4-newH2)<30)
        {
           Score++;
           SE.close();
           SE = minim.loadFile("ken.mp3");
           SE.setGain(-20);
           SE.play();

        }
      }
      if (thingType[i]%6==3)
      {
        draw3(i);
        if (z4<5&&(newH4-newH3)<30)
        {
           Score++;
           SE.close();
           SE = minim.loadFile("ken.mp3");
           SE.setGain(-20);
           SE.play();
        }
     
      }
 
      drawMan();
   
      newH= 1360*atan(10/z2)/PI;
      newH2= 1360*atan(10/z3)/PI;
      newH3= 1360*atan(10/z4)/PI;
   
     if(z2<5||thingX[i]<0 ||thingX[i]>600)
      {
        z2=int(random(150)+50);
        newH= 1360*atan(10/z2)/PI;
        newThing(i);
      }
     if(z3<5||thingX[i]<0 ||thingX[i]>600)
      {
        z3=int(random(150)+80);
        newH2= 1360*atan(10/z3)/PI;
        newThing(i);
      }
     else if(z4<5||thingX[i]<0||thingX[i]>600)
      {
        z4=int(random(150)+100);
        newH3= 1360*atan(10/z4)/PI;
        newThing(i);
      }
    }
     
    z2-=ac;
    z3-=ac;
    z4-=ac;
    if (GameTime>1000){ stage=3;a=4;}
  }
    if (stage==2)//stage02 game overrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrr
    {
      if(a==2)
      {
        player.close();
        player=minim.loadFile("ending.mp3");
        player.setGain(-20);
        player();
      }
      a=3;
      background(255,0,0);
      fill(0);
      textSize(32);
      text("Game Over", 200, 300);
      text("ReStart Time :"+Time,200,400);
      Time--;
      line(230,150,215,180);
      line(215,180,230,210);
      line(230,210,400,210);
      line(400,210,400,150);
      line(400,150,230,150);
      if (Time<800 && Time>600)
      {
        image(imgface,200,200,50,50);
        textSize(16);
        text("outch!",250,180);
      }
      if (Time<600 && Time>300)
      {
        image(imgface2,200,200,50,50);
        textSize(16);
        text("It's Really Hurt..",250,180);
      }
      if (Time<300)
     {
       image(imgface3,200,200,50,50);
       textSize(16);
       text("I Can Do Again!",250,180);
     }
      if (Time<0) stage=4;
    }
    if (stage==3) //stage03 winnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnn
    {
      if(a==4)
      {
        player.close();
        player=minim.loadFile("win.mp3");
        player.setGain(-10);
        player();
      }
      background(0);
      fill(255);
      textSize(32);
      text("You Make It! ", 200, 100);
      text("Thanks For Your Playing!",100,200);
      text("   This Game Design by↓",100,300);
      text("&",285,360);
      image(copyright,250,350,39,33);
      image(copyright2,350,350,39,33);
      text("Press W To ReStart Game",110,500);
      a=3;
    }
    if (stage==4) //stage04 menuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuu
    {
   
      background(0);
      if(a==3)
      {
        player.close();
        player=minim.loadFile("start.mp3");
        player.setGain(-10);
        player();
      }

        textSize(16);
        fill(255,0,0,Alpha);
        text("run for life",250,80);
        textSize(64);
        stroke(50);
        text("Monster Run",100,120);
        if (Alpha>0) Alpha--;
        if (Alpha==0) Alpha=255;
        fill(255);
        textSize(16);
        text("Do Your Best To Avoid Monster",180,200);
        text("Press Q To Start Game",200,300);
        textSize(8);
        text("TW",95,545);
        text("Monster Run   @2013 From Software",50,550);
        image(symbol,300,450,200,200);
        text("Tang Fan Gaming House @2013",430,550);
        a=1;
   
   
   
   
    }
}

void keyPressed()
{
  if (stage==3)
  {
    if (key=='w' ||key=='W') stage=4;
  }
  if (stage==4)
  {
    if (key=='q' ||key=='Q') stage=1;
  }
  if (stage==1)
  {
 
    if (key=='a'||key=='A')
    {
      if (sw==false)
      {
         z2-=ac;
        ac+=0.01;
        if (ac>0.88) ac=0.88;
      }
    }
    if (key=='s' ||key=='S')
    {
      if (sw==false)
      {
        textSize(32);
        fill(255,128,0);
        text("PAUSE",250,300);
        Reac = ac;
        Rez2 = z2;
        Rez3 = z3;
        Rez4 = z4;
        z2+=ac;
        ac=0;
        sw = true;
      }
    }
    if (key=='r' || key=='R')
    {
      if (sw ==true)
      {
        sw = false;
        ac = Reac;
        z2 = Rez2;
        z3 = Rez3;
        z4 = Rez4;
      }
    }
    else z2-=ac;
 
    if (key=='x')
    {
      if (sw==false)
      {
          thingX[0]-=20; thingX[1]-=20; thingX[2]-=20;
          right=true;
          left=false;
          start=false;
      }
    }
    if (key=='X')
    {
      if (sw==false)
      {
        thingX[0]+=20; thingX[1]+=20; thingX[2]+=20;
       left=true;
       right=false;
       start=false;
      }
    }
  }
}

void newThing(int i )
{
  thingType[i] = int (random(3)+1) ;
  thingX[i] = int(random(600)+1)  ;
}

void draw1(int i)
{

  if(newH>0)
  {
    tint(255, 255-z2);
    image(img1,thingX[i],300, newH, newH);
  }
}
void draw2(int i)
{
  if(newH2>0)
  {
    tint(255, 255-z3);
    image(img2,thingX[i],300, newH2, newH2);
  }
}
void draw3(int i)
{
  if(newH3>0)
  {
    tint(255, 255-z4);
    image(img3,thingX[i],300, newH3, newH3);
  }
}
void stop()
{
  player.close();
  minim.stop();
  super.stop();
}

void drawMan()
{
  if (start==true)
  {
    tint(255, 255);
    image(imgMan, 300,450,newH4,newH4);
  }
   if (right==true)
  {
    tint(255, 255);
    image(rightwalk, 300,450,newH4,newH4);
  }
   if (left==true)
  {
    tint(255, 255);
    image(leftwalk, 300,450,newH4,newH4);
  }
}
void player()
{
  player.loop();
}

2013年12月1日 星期日

Week13 張智棠

Arduino 實作 :

CH5 MOOD CUE

CODE :
#include <Servo.h>
Servo myServo ;
int const potPin = A0;
int potVal;
int angle;
void setup()
{
  myServo.attach(9);
  Serial.begin(9600);
}
void loop()
{
  potVal = analogRead(potPin);
  Serial.print("potVal :");
  Serial.print(potVal);
  angle = map(potVal,0,1023,0,179);
  Serial.print(", angle: ");
  Serial.println(angle);
  myServo.write(angle);
  delay(15);
}

CH6 Light Theremin 

CODE :

int sensorValue;
int sensorLow = 1023;
int sensorHigh = 0;
const int ledPin = 13;

void setup()
{
  pinMode(ledPin,OUTPUT);
  digitalWrite(ledPin,HIGH);
  while(millis()<5000)
  {
    sensorValue = analogRead(A0);
    if (sensorValue > sensorHigh)
    {
      sensorHigh = sensorValue;
    }
    if (sensorValue < sensorLow)
    {
      sensorLow = sensorValue;
    }
  }
  digitalWrite(ledPin,LOW);
}

void loop()
{
  sensorValue = analogRead(A0);
  int pitch = map(sensorValue,sensorLow,sensorHigh,50,4000);
  tone(8,pitch,20);
  delay(10);
}

CH7 Keybpard instrument

CODE :


int notes[] = {262,294,330,349};

void setup()
{
  Serial.begin(9600);
}

void loop()
{
  int keyVal = analogRead(A0);
  Serial.println(keyVal);
  if (keyVal == 1023)
  {
    tone(8,notes[0]);
  }
  else if (keyVal >=900 && keyVal <=1010)
  {
    tone(8,notes[1]);
  }
  else if (keyVal>=505 && keyVal <=515)
  {
    tone(8,notes[2]);
  }
  else if (keyVal>=5 && keyVal<= 10)
  {
    tone(8,notes[3]);
  }
  else
  {
    noTone(8);
  }
}



實作影片 :
CH5

CH6



CH7


2013年11月24日 星期日

Week12 張智棠 陳奕汎

實作Arduino Book CH3,CH4

CH3 LOVE-O- METER

Code :

const int sensorPin = A0;
const float baselineTemp = 90.0;

void setup()
{
  
  Serial.begin(9600);
  
  for (int pinNumber = 2; pinNumber < 5; pinNumber++)
  {
    pinMode(pinNumber, OUTPUT);
    digitalWrite(pinNumber, LOW);
  }
}

void loop()
{
  int sensorVal = analogRead(sensorPin);
  
  Serial.print("Sensor Value: ");
  Serial.print(sensorVal);
  
  float voltage = (sensorVal/1024.0) * 5.0;
  
  Serial.print(", Volts:");
  Serial.print(voltage);
  
  Serial.print(", degrees C: ");
  float temperature = (voltage - .5) * 100;
  Serial.println(temperature); 
  
  if (temperature < baselineTemp)
  {
    digitalWrite(2, LOW);
    digitalWrite(3, LOW);
    digitalWrite(4, LOW);
  }
  
  else if (temperature >= baselineTemp + 2 && temperature < baselineTemp + 4)
  {
    digitalWrite(2, HIGH);
    digitalWrite(3, LOW);
    digitalWrite(4, LOW);
  }
  
  else if (temperature >= baselineTemp + 4 && temperature < baselineTemp + 6)
  {
    digitalWrite(2, HIGH);
    digitalWrite(3, HIGH);
    digitalWrite(4, LOW);
  }
  
  else if (temperature > baselineTemp + 6)
  {
    digitalWrite(2, HIGH);
    digitalWrite(3, HIGH);
    digitalWrite(4, HIGH);
  }
  
  delay(1); 
  
}

CH4 COLOR MIXING LEMP

Code :

const int greenLEDPin = 9;
const int redLEDPin = 11;
const int blueLEDPin = 10;

const int redSensorPin = A0;
const int greenSensorPin = A1;
const int blueSensorPin = A2;
int redValue = 0;
int greenValue = 0;
int blueValue = 0;
int redSensorValue = 0;
int greenSensorValue = 0;
int blueSensorValue = 0;

void setup()
{
  Serial.begin(9600);
  pinMode(greenLEDPin,OUTPUT);
  pinMode(redLEDPin,OUTPUT);
  pinMode(blueLEDPin,OUTPUT);
}
void loop()
{
  redSensorValue = analogRead(redSensorPin);
  delay(5);
  greenSensorValue = analogRead(greenSensorPin);
  delay(5);
  blueSensorValue = analogRead(blueSensorPin);

  Serial.print("Raw Sensor Values \t Red : ");
  Serial.print(redSensorValue);
  Serial.print("\t Green:  ");
  Serial.print(greenSensorValue);
  Serial.print("\t Blue: ");
  
  redValue = redSensorValue/4;
  greenValue = greenSensorValue/4;
  blueValue = blueSensorValue/4;
  
  Serial.print("Mapped Sensor Values \t Red: ");
  Serial.print(redValue);
  Serial.print("\t Green: ");
  Serial.print(greenValue); 
  Serial.print("\t Blue: ");
  Serial.print(blueValue);
  
  analogWrite(redLEDPin, redValue);
  analogWrite(greenLEDPin, greenValue);
  analogWrite(blueLEDPin, blueValue);

}
實作 :
ch3

ch4

2013年11月17日 星期日

Week11 張智棠

本周進度: 
1 . 拿到Arduino的各設備
2. 測試版子
3. 試利用板子實作 如下


2013年11月10日 星期日

Week10 張智棠,期中作品展示

期中作品展示


程式碼 :

import ddf.minim.*;
AudioPlayer playerDead,playerST1,playerending,playerST2;
Minim minim;
float loc = 0 ;
int  N = 10 ,score = 0,blood=100;
int PX=100,PY=701;
PImage coin , cone , fire,stageBG2,stageBG4,stageBG5,people,copyright,copyright2;
int []thingType = new int [10] ;
float []thingY = new float [10];
float []thingX = new float [10];
float HeadX=200,HeadY=600;
int stage = 1;
int shoes = 0,jumper=0;

void setup ()
{
  size (600, 800) ;
  coin = loadImage("coin.jpg") ;
  cone = loadImage("cone.jpg") ;
  fire = loadImage("image.jpg");
  stageBG4 = loadImage("gameover.jpg");
  stageBG2 = loadImage("stageBG2.bmp");
  people = loadImage("people.jpg");
  copyright = loadImage("copyright.bmp");
  copyright2 = loadImage("copyright2.bmp");
  for ( int i = 0 ; i < N ; i++)
  {
     newThing(i);
  }
  minim = new Minim(this);
  playerDead = minim.loadFile("warawa.mp3");
  playerST1 = minim.loadFile("ST1.mp3");
  playerST2 = minim.loadFile("ST2.mp3");
  playerending = minim.loadFile("ending.mp3");
 
}
int now = 0 ;
void draw ()
{
 
 if (stage==1)
 {
   playerST1.pause();
   playerDead.pause();
   background(255,255,255);
   image(people,150,450,30,58);
   fill(#1A1717);
   textSize(12);
   text("Matchstick Men are suffering from the strange thing!",100,100);
   text("He want to find he's friend to help him",100,200);
   textSize(25);
   text("Rule :",100,250);
   textSize(12);
   text("Catch TEN COIN can stop the strange thing for a while",100,300);
   text("Catech the other thing may cause a damage from himself",100,400);
   textSize(32);
   text("Press S or s to Play ", 150, 700);
 }
  if (stage==2)
  {
    background(255);
    playerST1.pause();
    playerST2.setGain(-20);
    playerST2.play();
   
    score = 0;
    blood = 100;

    image(stageBG2,0,0,600,800);
    image(people,PX,PY,30,58);
   
    if (150<PX&&PX<250&&550<PY&&PY<650)
    {
      shoes=1;
      textSize(25);
      text("You Get a shoes!",200,500);
      text("Triple MoveSpeed!",200,600);
    }
    if (300<PX&&PX<450&&400<PY&&PY<500) PY-=200;
    if (500<PX&&PX<600&&0<PY&&PY<100) stage=5;
   
   
    if (PY%80==0) stage=3;

  }
  if (stage==5)
  {
    playerST2.pause();
    background(0,0,0);
    playerending.setGain(-20);
    playerending.play();
    textSize(35);
    text("Matchstick Men Finally ",100,100);
    text("arrival His Friends Side!",100,150);
    text("You Made It!",100,200);
    text("Thanks For Your Playing!",100,400);
    text("   This Game Done by↓",100,500);
    text("&",310,580);
    image(copyright,250,550,39,33);
    image(copyright2,350,550,39,33);
  }
  if (stage == 4)
  {
    playerST1.pause();
    playerST2.pause();
    image(stageBG4,0,0,600,800);
    fill(0,255,0);
    textSize(32);
    text("Game Over", 200, 350);
    playerDead.play();

  }
  if (stage ==3)
  {
    background(255);
    fill(0,0,255);
    textSize(32);
    text("Life",100,800);
    fill(255,0,0);
    rect(100,700,blood,50);
    playerST2.pause();
   
    playerST1.setGain(-20);
    playerST1.play();
    textSize(12);
    text("Use",545,760);
    text("← → ",545,780);
    text("to Move",545,800);
    textSize(25);
    text("coin : "+score,400,760);
   
   
    for ( int i = 0 ; i < N ; i++)
    {
      if (thingType[i] == 1 )
      {
         drawcoin(i) ;
         if ( dist(thingX[i],thingY[i],HeadX,HeadY)<50)
        {
          score++;
          if (blood<100) blood+=5;
          thingY[i] =620;
        }
      }
      else if (thingType[i] == 2 )
     {
       drawcone(i) ;
        if ( dist(thingX[i],thingY[i],HeadX,HeadY)<50)
        {
          blood-=10;
          thingY[i] =620;
        }
     }
      else if (thingType[i] == 3 )
      {
        drawfire(i) ;
         if ( dist(thingX[i],thingY[i],HeadX,HeadY)<50)
         {
          blood-=20;
          thingY[i] =620;
         }
      }
      thingY[i] += 4 ;
      if (score>2) thingY[i] += 5 ;
      if (score>6) thingY[i] += 7 ;
      if (thingY[i] > 600 ) newThing(i) ;  
     
    }
    people(loc) ;
    if (blood <1) stage = 4;
    if (score ==10) 
    {
      PY-=1;
      stage = 2;
    }
  }
}

void people (float x) {
    noFill();
    ellipse (225+x, 600, 30, 30) ;
    line ( 225+x, 615, 225+x, 660 );
    line ( 225+x, 625, 205+x, 640) ;
    line ( 225+x, 625, 245+x, 640) ;
    line ( 225+x, 660, 205+x, 680) ;
    line ( 225+x, 660, 245+x, 680) ;
}
void keyPressed()
{
  if (stage==1)
  {
    if (key=='s' || key =='S') stage=2;
  }
  else if (stage==2)
  {
    if(shoes==1)
    {
      if (keyCode==UP) PY-=3;
      if (keyCode==LEFT) PX-=3;
      if (keyCode==RIGHT)PX+=3;
      if (keyCode==DOWN) PY+=3;
    }
    else
    {
      if (keyCode==UP) PY-=1;
      if (keyCode==LEFT) PX-=1;
      if (keyCode==RIGHT)PX+=1;
      if (keyCode==DOWN) PY+=1;
    }
   
  }
  else if (stage==3)
  {
    if (key=='s' || key =='S') stage=2;
    if ( keyCode ==RIGHT)
    {
      loc += 200;
      if (loc >200) loc = 200;
      HeadX = loc+225;
    }
    if ( keyCode ==LEFT)
    {  
      loc -= 200;
      if (loc < -200 ) loc = -200;
      HeadX = loc+225;
    }
  }
}

void newThing(int i )

  thingY[i] = -random(300) ;
  thingX[i] = int(random(10)) * 200  ;
  thingType[i] = int (random(3)+1) ;
}

void drawcoin(int i)
{
  image(coin , thingX[i],thingY[i], 60,60) ;
}

void drawcone(int i)
{
  image(cone , thingX[i] , thingY[i] , 60 , 60) ;
}

void drawfire (int i )
{
  image(fire , thingX[i] , thingY[i] , 60 , 60) ;
}


void stop()
{
  playerDead.close();
  playerST1.close();
  playerending.close();
  minim.stop();
  super.stop();
}


2013年10月21日 星期一

Week07 張智棠

1. 請列出你今天三個小時,要完成的事
2. 你在期中作品要做到什麼程度
3. Why? 你為什麼要做它

1. 做到火柴人能吃到硬幣

2. 做到可以有基本紅白機時代的美工程度

3. 想玩玩自己仿作的知名遊戲 想體驗這種感覺

2013年10月14日 星期一

Week06 張智棠

本周期中作業進度

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

void draw () 
{
  camera(100.0, 0.0, 200.0, 50.0, 50.0, 0.0, 1.0, 0.0, 0.0);
  translate(50, 50, 0);
  rotateX(-PI/6);
  rotateY(PI/3);
  box(45);
  people() ;
}

void people () {
  ellipse (280, 600, 30, 30) ;
  line ( 280, 615, 280, 660 ) ;
  line ( 280, 625, 260, 640) ;
  line ( 280, 625, 300, 640) ;
  line ( 280, 660, 260, 680) ;
  line ( 280, 660, 300, 680) ;
}

平面障礙遊戲之人物製作與攝影機角度之測試

2013年10月6日 星期日

Week05 張智棠

1. 轉動一個橢圓 每次轉動六分之一
1.1 改良上述程式碼 增加變化
1.2 再次改良
1.3 滑鼠點一下就在畫一個
期中作業構思:
                         橫向卷軸的障礙遊戲 視情況變更內容或者大洗牌


2013年9月29日 星期日

Week04 張智棠

1. 利用Processing 實作小畫家的鉛筆
2. 換顏色
3. 換顏色改成調色盤

4. 把筆畫改粗
5. 成品展示(把滑鼠圖示改成鉛筆, 改顏色, 調色盤, 不寫死的改筆粗細)

PImage img;
void setup()
{

  size(800, 800);
  background(255);
  img = loadImage("https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjNQqRHoE1MEuEuUq6JydjuRPRc1BVlVodGOSQ4IlXhIgUznEqeEQBn1JdTQb3DtalxXklR0LMnsuiy2hdTaVFNsV3SvvBNQjKeC5jrBW97tj0WcV1KoB1Zt68rBWhGnwx7bx8-Jp_Z3pBI/s1600/pencil.gif");
  cursor(img);
  
  fill(0,0,255);
  rect(0,100,100,100);
  
  fill(255,0,0);
  rect(0,200,100,100);
  
  fill(255);
  rect(700,0,100,100);
  fill(255);
  rect(700,100,100,100);
  noStroke();
  colorMode(RGB, 100);
  for (int i=0; i<100;i++)
  {
    for (int j = 0 ; j < 100; j++)
    {
      stroke(i,j,0);
      point(i,j);
    }
  }

  strokeWeight(30);
  stroke(#000000);
  point(750,50);
  strokeWeight(15);
  point(750,150);
}
void draw()
{

}
void keyPressed()
{
  if (key=='s') save("image.jpg");
}
void mouseDragged()
{
  line(mouseX, mouseY, pmouseX, pmouseY);
}

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

本周心得:
這一周的成品雖然是參考學長姐去年的作品
但我自己寫了幾個小功能
看似簡單的功能寫起來卻不如自己想的困難
感到有一點點的成就感

2013年9月22日 星期日

Week03 張智棠

1. 看完老師示範後先試著畫出棋盤
void setup()
{
  size(800, 800);
}

void draw()
{
  background(247,247,135);
  noFill();
  strokeWeight(5);
  rect(50,50,700,700);
  strokeWeight(1);
  for (int i = 0; i < 10 ; i++)
  {
    line(50,50+i*70, 750 , 50+i*70);
    line(50+i*70, 50, 50+i*70, 750);
  }
}

2. 擺棋子
3. 運用滑鼠事件來達到 點一下在畫的功能(放棋子)
int nowX, nowY;
int [][]array = new int [10][10]; //宣告陣列 將棋盤方格化
void setup()
{
  size(800, 800);
}

void draw()
{
  background(247, 247, 135);
  noFill();
  strokeWeight(5);
  rect(50, 50, 700, 700);
  strokeWeight(1);
  for (int i = 0; i < 10 ; i++)
  {
    line(50, 50+i*70, 750, 50+i*70);
    line(50+i*70, 50, 50+i*70, 750);
  }
  fill(255, 255, 255, 80);
  rect(nowX*70+85, nowY*70+85, 70, 70);
  fill(0);
  for (int i = 0 ; i < 10; i++)
  {
    for (int j = 0; j < 10 ;j++)
    {
      if (array[i][j] == 1)
      { 
        rect(i*70+85, j*70+85, 70, 70);
      }
    }
  }
}

void mousePressed()
{
  array[nowX][nowY]=1;
}

void mouseMoved()
{
  nowX = (mouseX-50)/70;
  nowY = (mouseY-50)/70;
}
3.1 把格子修改成棋子 並切換顏色

int nowX, nowY,nowcolor=1;
int [][]array = new int [10][10]; //宣告陣列 將棋盤方格化
void setup()
{
  size(800, 800);
}

void draw()
{
  background(247, 247, 135);
  noFill();
  strokeWeight(5);
  rect(50, 50, 700, 700);
  strokeWeight(1);
  for (int i = 0; i < 10 ; i++)
  {
    line(50, 50+i*70, 750, 50+i*70);
    line(50+i*70, 50, 50+i*70, 750);
  }
  fill(255, 255, 255, 80);
  ellipse(nowX*70+120, nowY*70+120, 70, 70);
  fill(0);
  for (int i = 0 ; i < 10; i++)
  {
    for (int j = 0; j < 10 ;j++)
    {
      if (array[i][j] == 1){fill(0); ellipse(i*70+120, j*70+120, 70, 70);  }
      else if (array[i][j]==2){fill(255); ellipse(i*70+120, j*70+120, 70, 70); }
    }
  }
}

void mousePressed()
{
  array[nowX][nowY]=nowcolor;
  if (nowcolor==1) nowcolor=2;
  else if (nowcolor==2) nowcolor=1;
}

void mouseMoved()
{
  nowX = (mouseX-50)/70;
  nowY = (mouseY-50)/70;
}

4. 貼你覺得有意思的影片, 使用youtube 的分享, Blogger 分享, 兩邊都改成 HTML, 貼上 HTML 



2013年9月15日 星期日

Week02 張智棠

1. 啟動Processing
2. 在600x400 的視窗畫格子
3. 在格子中在畫其它
4. 先畫紅色方格 在畫色的類菱形物
5. 類菱形物的顏色後面加上Alpha值
6. 利用滑鼠的位置來改變圖片的透明度
7. 亂數決定方格的顏色 


本周心得 : 從開學到現在是第二次上課,老師每個步驟都講解的很詳細,而且還會帶著我們做,會講說每個步驟的想法是什麼在講解




2013年9月8日 星期日

week01 張智棠

    0. 課程準備
    0.1. 加入 課程FB社團
    0.2. Google文件 填寫修課資料 (學號姓名,email,電話)
    0.3. 加入 Blog, 設定

*編交作業方式: 
tag: 000葉正聖老師, Week01, 00160011葉大明
(逗號隔開, 學號姓名間不要有空格)
1. 使用Processing寫出第一個程式

2. 編譯老師示範
 

 2.1 程式碼改成比較正式的函式類型
 2.2 將鳥畫在滑鼠位置 但會造成殘影,如圖
 2.3 解決2.2的問題 修改程式碼 改成先畫背景在畫鳥
 2.4 但2.3中滑鼠的位置不是在圖片中心 再次修改