顯示具有 98160204楊子儀 標籤的文章。 顯示所有文章
顯示具有 98160204楊子儀 標籤的文章。 顯示所有文章

2012年12月25日 星期二

final


1.processing

import processing.serial.*;
Serial myPort;
int val;
void setup() {
  size(400, 200);
  background(255);
  noStroke();
 // frameRate(30);
  fill(102);
 myPort = new Serial(this, "COM4", 9600);
}
int d=0,r=0,m=0,f=0,s=0;
void draw() {
  if(myPort.available()>0){
    val = myPort.read();//第三個重點:如果讀到數字就拿出來用
    //rect(20, 20, 72, 160);
  }
 
  fill(255, 255, 255);
  stroke(0, 0, 0);
  strokeWeight(2);
  if(val=='G'){
   d=1;
  }
  else if(val=='B'){
   d=0;
  }
  if(val=='F'){
   r=1;
  }
  else if(val=='V'){
   r=0;
  }
  if(val=='D'){
   m=1;
  }
  else if(val=='C'){
   m=0;
  }
  if(val=='S'){
   f=1;
  }
  else if(val=='X'){
   f=0;
  }
  if(val=='A'){
   s=1;
  }
  else if(val=='Z'){
   s=0;
  }
  if(val=='H'){
    d=0;
    r=0;
    m=0;
    f=0;
    s=0;
  }
 
 //println(doo);
  if(s==1){
    fill(255,0,0);
   rect(20, 20, 72, 160);
  }
  else if(s==0){
    fill(255);
   rect(20, 20, 72, 160);
  }
 
   if(f==1){
    fill(255,0,0);
    rect(92, 20, 72, 160);
  }
  else if(f==0){
    fill(255);
   rect(92, 20, 72, 160);
  }
   if(m==1){
    fill(255,0,0);
     rect(164, 20, 72, 160);
  }
  else if(m==0){
    fill(255);
     rect(164, 20, 72, 160);
  }
   if(r==1){
    fill(255,0,0);
    rect(236, 20, 72, 160);
  }
  else if(r==0){
    fill(255);
    rect(236, 20, 72, 160);
  }
   if(d==1){
    fill(255,0,0);
    rect(308, 20, 72, 160);
  }
  else if(d==0){
    fill(255);
    rect(308, 20, 72, 160);
  }
  fill(0);
  rect(74, 20, 36, 80);
  rect(146, 20, 36, 80);
  rect(290, 20, 36, 80);
  rect(362, 20, 18, 80);
}

2.arduinno

int buttonPin = 2;
int buttonPin3 = 3;
int buttonPin4 = 4;
int buttonPin5 = 5;
int buttonPin6 = 6;
int buttonState = 0; 
int buttonState3 = 0; 
int buttonState4 = 0; 
int buttonState5 = 0; 
int buttonState6 = 0; 
void setup() {

  pinMode(buttonPin, INPUT);    
  pinMode(buttonPin3, INPUT);    
  pinMode(buttonPin4, INPUT);    
  pinMode(buttonPin5, INPUT);    
  pinMode(buttonPin6, INPUT);    
    Serial.begin(9600);

}
void loop() {
  buttonState = digitalRead(buttonPin);
  buttonState3 = digitalRead(buttonPin3);
  buttonState4 = digitalRead(buttonPin4);
  buttonState5 = digitalRead(buttonPin5);
  buttonState6 = digitalRead(buttonPin6);
 
  if (buttonState == HIGH) {    
   tone(8, 131, 300);
   Serial.write('A');
  } 
  else if (buttonState == LOW) {
   Serial.write('Z');
  }
 
  if (buttonState3== HIGH) {    
   tone(8, 147 , 300);
   Serial.print('S');
  }
  else if (buttonState3 == LOW) {
   Serial.write('X');
  }
  if (buttonState4 == HIGH) {    
   tone(8, 165 , 300);
   Serial.print('D');
  }
   else if (buttonState4 == LOW) {
   Serial.write('C');
  }
  if (buttonState5 == HIGH) {    
   tone(8, 175 , 300);
   Serial.print('F');
  }
   else if (buttonState5 == LOW) {
   Serial.write('V');
  }
  if (buttonState6 == HIGH) {    
   tone(8, 196, 300);
   Serial.print('G');
  }
   else if (buttonState6 == LOW) {
   Serial.write('B');
  }
 else {
   Serial.print('H');
  }
   delay(100);
}

3.展示歌曲 火車快飛

5531 5531 2344 3455

5353 231

4222 3111

2342111

week15,hw12

1.void setup() {
  size(400, 200);
  background(255);
  noStroke();
  fill(102);
}
void draw() {
  fill(255, 255, 255);
  stroke(0, 0, 0);
  strokeWeight(2);
  rect(20, 20, 72, 160);
  rect(92, 20, 72, 160);
  rect(164, 20, 72, 160);
  rect(236, 20, 72, 160);
  rect(308, 20, 72, 160);
  fill(0);
  rect(74, 20, 36, 80);
  rect(146, 20, 36, 80);
  rect(290, 20, 36, 80);
  rect(362, 20, 18, 80);
 
}



畫出一個鋼琴鍵盤,之後再跟arduino結合,按出一個音,鋼琴鍵盤就會變紅色。

2012年12月18日 星期二

hw11,week13

1.

2.小蜜蜂
   533
   422
   1234555
   533
   422
   13551

3.int buttonPin = 2;
int buttonPin3 = 3;
int buttonPin4 = 4;
int buttonPin5 = 5;
int buttonPin6 = 6;
int buttonState = 0; 
int buttonState3 = 0; 
int buttonState4 = 0; 
int buttonState5 = 0; 
int buttonState6 = 0; 
void setup() {
  pinMode(buttonPin, INPUT);    
  pinMode(buttonPin3, INPUT);    
  pinMode(buttonPin4, INPUT);    
  pinMode(buttonPin5, INPUT);    
  pinMode(buttonPin6, INPUT);    
}
void loop() {
  buttonState = digitalRead(buttonPin);
  buttonState3 = digitalRead(buttonPin3);
  buttonState4 = digitalRead(buttonPin4);
  buttonState5 = digitalRead(buttonPin5);
  buttonState6 = digitalRead(buttonPin6);
 
  if (buttonState == HIGH) {    
   tone(8, 131, 10);
  }

  if (buttonState3== HIGH) {    
   tone(8, 147 , 10);
  }

  if (buttonState4 == HIGH) {    
   tone(8, 165 , 10);
  
  }

  if (buttonState5 == HIGH) {    
   tone(8, 175 , 10);
  }

  if (buttonState6 == HIGH) {    
   tone(8, 196, 10);
  }
}

2012年11月27日 星期二

HW10, week12


1.影片

3.程式碼
/*
  Analog Input
 Demonstrates analog input by reading an analog sensor on analog pin 0 and
 turning on and off a light emitting diode(LED)  connected to digital pin 13.
 The amount of time the LED will be on and off depends on
 the value obtained by analogRead().

 The circuit:
 * Potentiometer attached to analog input 0
 * center pin of the potentiometer to the analog pin
 * one side pin (either one) to ground
 * the other side pin to +5V
 * LED anode (long leg) attached to digital output 13
 * LED cathode (short leg) attached to ground

 * Note: because most Arduinos have a built-in LED attached
 to pin 13 on the board, the LED is optional.


 Created by David Cuartielles
 modified 30 Aug 2011
 By Tom Igoe

 This example code is in the public domain.

 http://arduino.cc/en/Tutorial/AnalogInput

 */
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
int s=0;
void setup() {
// declare the ledPin as an OUTPUT:
for(int i =0;i<=7;i++){
pinMode( i, OUTPUT);
}
// pinMode(ledPin, OUTPUT);
Serial.begin(9600);
}
void loop() {
// read the value from the sensor:
sensorValue = analogRead(sensorPin);
// turn the ledPin on();
Serial.println("Hello World!!");
for(int i =0;i<=7;i++){
if(s==i||s==i+1){
digitalWrite(i, HIGH);}
else digitalWrite(i, LOW);
}
// stop the program for <sensorValue> milliseconds:
delay(sensorValue);

 s++;
if(s>=8)s=0;
//++s;
}

2012年11月20日 星期二

hw09 week11

01.思考可以用Arduino做些什麼?

可以利用感應來左右移動,防止跌倒
也可以利用手機來控制方向
像是影片中利用電路板來感應可以使小車車到處走



02.貼一個Arduino應用的影片

2012年11月12日 星期一

期中作品




class Button

{
  PFont font;
  String title;
  color bg,word;
  int posx,posy;
  int butWidth,butHeight;
  boolean pressed=false;
  boolean mouseOver=false;
  Button(String _title, color _bg, color _word)
  {
    setting();
    title=_title;
    word=_word;
    bg=_bg;  
  }    
  Button(String _title, color _bg)
  {
    setting();
    title=_title;
    bg=_bg;  
    word=color(250,250,250);
  }    
  Button(String _title)
  {
    setting();
    title=_title;
    bg=color(100,10,10);
    word=color(250,250,250);
  }    
  void setting()
  {
    butWidth=100;
    butHeight=30;
    font=createFont("Helvetica", 12, true);
    textFont(font);
  }    
  public void Position(int x, int y)
  {
    posx=x;
    posy=y;
  }
  public void Display()
  {
    MouseLeaveWithoutReleasedChecking();
    int fontsize;
    if(!pressed)
    {
      fill(bg);
      fontsize=20;
    }
    else
    {
      fill(50);
      fontsize=15;
    }
    noStroke();
    ellipse(posx,posy,butWidth,butHeight);
    fill(word);
    textAlign(CENTER);
    textSize(fontsize);
    text(title,posx,posy+butHeight/4);      
  }
  public void Pressed()
  {
    pressed=true;
    println(title+" button pressed");
  }
  public void Released()
  {
    pressed=false;
    println(title+" button released");
  }
  public void MouseLeaveWithoutReleasedChecking()
  {
    if(pressed && !mouseOver) Released();  
  }  
  public void CheckArea(int x, int y)
  {
    if(y>posy-butHeight/2 && y<posy+butHeight/2 && x>posx-butWidth/2 && x<posx+butWidth/2)
    {
        mouseOver=true;
        word=color(237,28,36);
    }
    else
    {
      mouseOver=false;
      word=color(0,128,128);
    }
  }    
  public boolean CheckMouseOver()
  {
    return mouseOver;
  }
}
class Card
{
  String cradNum;
  int cardValue;
  int cardWidth,cardHeight;
  int posx,posy;
  color bg=color(255,255,255),fdbg=color(100,50,50);
  color word,shadow=color(0,0,0,50);
  PFont cardFont;
  boolean faceddown=false;    
  Card(String _cradNum, int _cardValue)
  {
    cardWidth=30;
    cardHeight=40;
    cardFont=createFont("Helvetica", 12, true);
    cardValue=_cardValue;
    cradNum=_cradNum;
    CheckWorkColor();
  }    
  void CheckWorkColor()
  {
    if(cradNum.charAt(0)=='?' || cradNum.charAt(0)=='?') word=color(0);
    else word=color(150,10,10);
  }    
  public void Position(int x, int y)
  {
    posx=x;
    posy=y;
  }    
  public void Display()
  {      
    fill(shadow);
    rect(posx+2,posy+2,cardWidth,cardHeight);      
    if(!faceddown)
    {
      fill(bg);
      noStroke();
      rect(posx,posy,cardWidth,cardHeight);        
      textFont(cardFont);
      fill(word);
      textAlign(CENTER);
      text(cradNum,posx+cardWidth/2,posy+cardHeight/2);
    }
    else
    {
      fill(fdbg);
      noStroke();
      rect(posx,posy,cardWidth,cardHeight);
    }      
  }    
  public int GetCardValue()
  {
    return cardValue;
  }    
  public void FaceUp()
  {
    faceddown=false;
  }    
  public void Facedown()
  {
    faceddown=true;
  }
}
class Deck
{
  String[][] pokerDeck;
  ArrayList theDeck;
  ArrayList usedCards;
  boolean deckEmpty;
  int cardValue;    
  Deck()
  {
    StartSetting();
  }    
  public void Test()
  {
    for(int i=0; i<theDeck.size(); i++)
    {
      println(theDeck.get(i));
    }
  }    
  public boolean CheckDeckEmpty()
  {
    return deckEmpty;
  }    
  public String DrawACard()
  {
    if(!deckEmpty)
    {
      int card=(int)random(0,theDeck.size());
      String temp;
      temp=(String)theDeck.get(card);
      theDeck.remove(card);
      usedCards.add(temp);
      StringToValue(temp);
      DeckNumber();
      return temp;
    }
    else return "Out of Cards!!";
  }    
  void StringToValue(String temp)
  {
    char v=temp.charAt(1);
    if(temp.length()==3) cardValue=10;
    else if(v=='J' || v=='Q' || v=='K') cardValue=10;
    else
    {
      switch(v)
      {
        case 'A':
          cardValue=1;
          break;
        case '2':
          cardValue=2;
          break;
        case '3':
          cardValue=3;
          break;
        case '4':
          cardValue=4;
          break;
        case '5':
          cardValue=5;
          break;
        case '6':
          cardValue=6;
          break;
        case '7':
          cardValue=7;
          break;  
        case '8':
          cardValue=8;
          break;  
        case '9':
          cardValue=9;
          break;  
        default:
          println("cardValue in Deck="+v);
          break;
      }
    }      
  }    
  public int GetValue()
  {
    return cardValue;
  }    
  void StartSetting()
  {      
    theDeck=new ArrayList();
    usedCards=new ArrayList();
    theDeck.clear();
    usedCards.clear();
    for(int i=0;i<4;i++)
    {
      for(int j=0;j<13;j++)
      {
        String temp;  
        if(j+1==1) temp="A";
        else if(j+1==11) temp="J";
        else if(j+1==12) temp="Q";
        else if(j+1==13) temp="K";
        else temp=""+(j+1);          
        if(i==0) theDeck.add(" "+temp);
        else if(i==1) theDeck.add(" "+temp);
        else if(i==2) theDeck.add(" "+temp);
        else if(i==3) theDeck.add(" "+temp);
        else
        {
          print("錯誤訊息");
        }
      }
    }
    deckEmpty=false;
  }    
  public void DeckNumber()
  {
    println("Deck remains "+theDeck.size()+" cards");
  }    
}
class TextBox
{
  PFont font;
  String title;
  color word=color(0,0,255);
  int posx,posy;
  TextBox(String _title, int _size)
  {
    font=createFont("Helvetica", _size, true);
    title=_title;
  }    
  TextBox(String _title)
  {
    font=createFont("Helvetica", 18, true);
    title=_title;
  }    
  TextBox()
  {
    font=createFont("Helvetica", 18, true);
    title="";
  }    
  public void ChangeContent(String txt)
  {
    title=txt;
  }    
  public void Position(int x, int y)
  {
    posx=x;
    posy=y;
  }    
  public void Display()
  {
    textFont(font);
    fill(word);
    textAlign(CENTER);
    text(title,posx,posy);
  }
}
Deck myDeck;
Button hitBut, standBut,restartBut, testBut;
TextBox textbox,playerScore,dealerScore,verson;
ArrayList yourCards, dealerCards,buttons;
boolean freeze,lose,win,gameover;
int turns;
int playerx,playery,dealerx,dealery;
int playerSum,dealerSum;  
Card testc;


void setup()
{
  size(500, 400);    
  restartBut=new Button("再一次!!",color(255,255,128));
  hitBut=new Button("再一張",color(255,255,128));
  standBut=new Button("翻牌",color(255,255,128));
  restartBut.Position(width/2,height-restartBut.butHeight);
  hitBut.Position(width/2-hitBut.butWidth/2-3,height-hitBut.butHeight);
  standBut.Position(width/2+standBut.butWidth/2+3,height-standBut.butHeight);
  playerx=width/2-30;
  playery=height*5/6;
  dealerx=width/2-30;
  dealery=height/8;
  reset();    
}  
void draw()
{
  DrawStage();
  Gameset();  
  if(gameover)
  {
    GameOver();
  }
  verson.Display();
}  
void Gameset()
{
  if(turns==1)
  {
    PlayerAddCard(false);
    DealerAddCard(true);
    PlayerAddCard(false);
    DealerAddCard(false);      
    turns++;
  }
  else if(turns==2)
  {      
  }
  else if(turns==3)
  {
    DealerTurn();
    freeze=true;
  }    
  if(lose)
  {      
    textbox.ChangeContent("玩家失敗");
    textbox.Display();
    println("玩家失敗");
    freeze=true;
    gameover=true;
  }
  if(win)
  {
    textbox.ChangeContent("玩家勝利");
    textbox.Display();
    freeze=true;
    gameover=true;
  }
  DisplayCards();    
}  
void reset()
{
  gameover=false;
  win=false;
  lose=false;
  turns=1;
  freeze=false;
  yourCards=new ArrayList();
  dealerCards=new ArrayList();
  yourCards.clear();
  dealerCards.clear();
  myDeck=new Deck();
  dealerSum=0;
  playerSum=0;    
  verson=new TextBox("",9);
  textbox=new TextBox("",30);
  textbox.Position(width/2,height/2-20);
  verson.Position(width-20,height-10);
  playerScore=new TextBox("",15);
  dealerScore=new TextBox("玩家的分數:Unknow",15);
  playerScore.Position(width/2,height*4/5-50);
  dealerScore.Position(width/2,height*1/5+30);
}  
void Test()
{
}  
void mousePressed()
{
  if(!freeze)
  {
    if(hitBut.CheckMouseOver()) hitBut.Pressed();
    if(standBut.CheckMouseOver()) standBut.Pressed();
  }
  else
  {
    restartBut.Pressed();
  }
}  
void mouseReleased()
{
  if(!freeze)
  {
    if(hitBut.CheckMouseOver())
    {
      hitBut.Released();
      PlayerAddCard(false);
    }
    if(standBut.CheckMouseOver())
    {
      standBut.Released();
      turns=3;
    }
  }
  else
  {
    if(restartBut.CheckMouseOver())
    {
      restartBut.Released();
      reset();
    }
  }
}  
void DrawStage()
{
  background(248, 148, 220);
  fill(147,200,255);
  rect(0,height*5/6,width,height/4);
  if(!freeze)
  {
    hitBut.CheckArea(mouseX,mouseY);
    standBut.CheckArea(mouseX,mouseY);
  }
  playerx=width/2-30;
  playery=height*5/6-5;
  dealerx=width/2-30;
  dealery=height/8-3;
  hitBut.Position(width/2-hitBut.butWidth/2-3,height-hitBut.butHeight);
  standBut.Position(width/2+standBut.butWidth/2+3,height-standBut.butHeight);
  playerScore.Display();
  dealerScore.Display();
  standBut.Display();
  hitBut.Display();
}  
void GameOver()
{
  fill(147,200,255);
  rect(0,height*5/6,width,height/4);
  restartBut.Position(width/2,height-restartBut.butHeight);
  restartBut.Display();
  restartBut.CheckArea(mouseX,mouseY);
}  
void PlayerAddCard(boolean facedown)
{
  if(!myDeck.CheckDeckEmpty())
  {
    Card card=new Card(myDeck.DrawACard(),myDeck.GetValue());
    if(facedown)
    {
      card.Facedown();
    }
    else
    {
      card.FaceUp();
    }
    yourCards.add(card);
    AllocateCardPosition();
    playerSum=Scoring(yourCards);
    playerScore.ChangeContent("你的分數:"+playerSum);
    YourStateChecking();
  }    
}  
void DealerAddCard(boolean facedown)
{
  if(!myDeck.CheckDeckEmpty())
  {
    Card card=new Card(myDeck.DrawACard(),myDeck.GetValue());
    if(facedown)
    {
      card.Facedown();
    }
    else
    {
      card.FaceUp();
    }
    dealerCards.add(card);
    AllocateCardPosition();      
  }
}  
void AllocateCardPosition()
{
  for(int i=0; i<yourCards.size();i++)
  {
    Card card=(Card)yourCards.get(i);
    card.Position(playerx+(card.cardWidth+2)*i,playery-card.cardHeight);
  }
  for(int j=0; j<dealerCards.size();j++)
  {
    Card card=(Card)dealerCards.get(j);
    card.Position(dealerx+(card.cardWidth+2)*j,dealery);
  }
}    
void DisplayCards()
{
  for(int i=0; i<yourCards.size();i++)
  {
    Card card=(Card)yourCards.get(i);
    card.Display();
  }
  for(int j=0; j<dealerCards.size();j++)
  {
    Card card=(Card)dealerCards.get(j);
    card.Display();
  }
}  
void YourStateChecking()
{
  if(playerSum<=21) lose=false;
  else lose=true;
}  
void DealerTurn()
{
  dealerSum=Scoring(dealerCards);  
  dealerScore.ChangeContent("對手的分數:"+dealerSum);
  if(dealerSum < 17 && dealerSum<playerSum)
  {
    DealerAddCard(false);
    DealerTurn();
  }
  else
  {
    WinningCondition();
  }
}  
void WinningCondition()
{    
  println(" 你的分數是 "+playerSum);
  println(" 對手的分數是 "+dealerSum);
  if(dealerSum > 21 )
    {
      println("玩家勝利");
      win=true;
    }
    else
    {
      if(dealerSum>=playerSum)
      {
        lose=true;
        println("玩家失敗!");
      }
      else
     {
       println("玩家勝利");
       win=true;
     }
    }
}
 
int Scoring(ArrayList alist)
{
  int sum,ace;
  sum=0;
  ace=0;
  for(int i=0; i<alist.size();i++)
  {
    int value;
    Card card=(Card)alist.get(i);
    card.FaceUp();
    value=card.GetCardValue();
    if(value == 1)
    {
      value=0;
      ace+=1;
    }
    println("value="+value);
    sum+=value;
  }    
  if(ace!=0)
  {
    for(int j=0; j<ace; j++)
    {
      if(sum+11<=21) sum+=11;
      else sum+=1;
    }
  }    
  return sum;
}



心得

拼拼湊湊完成  又加上其中考所以有點趕   所以在不會的時候直接把問題打在google找尋然後問身邊朋友以及哥哥  排版不是很漂亮  但是我們以顏色來吸引玩家  ㄎㄎ

2012年10月30日 星期二

week08,work08


因為我們先前的太鼓達人太難了,所以我們上網找別的益智遊戲,所以我們改變主題了

遇到的問題就是~~不會上網直接google答案就會跑出來慢慢試




心得
        就是還是很難不過差不多都上網google

2012年10月23日 星期二

week7,hw07

 
視訊作業~~~

size(500,300);
PImage bomo;
bomo = loadImage("http://pic4.duowan.com/psp/0807/79716333053/79716615230.jpg");
image(bomo,0,0);
saveFrame("bomo");



主要是把背景先弄出來,之後再搭配音樂,做點擊功能
 
 
心得~~   點擊跟音樂要搭配得恰恰好才可以使遊戲好玩,所以要找一個重節拍的音樂來使用



2012年10月16日 星期二

98160345蔡承芳,HW06,Week6

1.
潘若葳的踩地雷遊戲是每一台電腦都有的遊戲,我覺得版面可以設計可愛一點。

2.
期中作業進度 與楊子儀

太鼓達人

素材:

week06 hw06

1.我覺得游宗穎 跟 潘若葳 的遊戲看起來比較保守也比較好玩
   下樓梯就是挑戰緊張度   但是   踩地雷就是考驗頭腦  那個遊戲有一套公式可以帶入
   所以是在考驗大家的專心度

2.我們是要做太鼓達人
    跟著音樂節奏按

2012年10月9日 星期二

week05,hw05

1.自己動的花
void setup(){
  size(600,600);
}
float rrr=0.1;
void draw(){
  background(255,255,128);
  translate(300,300);
  rotate(rrr);rrr+=0.01;
  fill(250,133,206);
  for(int i=0;i<30;i++){
  rotate( PI/8);
  ellipse(110,10,180,35);

  }
  fill(128,255,128);
  ellipse(0,0,75,75);
}

2.跟自己互動
void setup(){
  size(600,600);
}
float rrr=0.1;
void draw(){
  background(255,255,128);
  translate(mouseX,mouseY);
  rotate(rrr);rrr+=0.01;
  fill(250,133,206);
  for(int i=0;i<30;i++){
  rotate( PI/8);
  ellipse(110,10,180,35);

  }
  fill(128,255,128);
  ellipse(0,0,75,75);
}

3 期中作業初步概念(太鼓達人)

組員:蔡承芳  98160345

2012年10月2日 星期二

week04 , hw04


void setup()
{
size(600,500);
background(255,255,128);

fill(0,128,255);
rect(0,0,50,50);
fill(128,255,64);
rect(0,50,50,50);
fill(255,128,0);
rect(0,100,50,50);
fill(255,128,255);
rect(0,150,50,50);
fill(0,0,0);
rect(0,200,50,50);
fill(255,0,0);
rect(0,250,50,50);

fill(255,255,255);
rect(0,300,50,50);
ellipse(25,325,2.5,2.5);

fill(255,255,255);
rect(0,350,50,50);
ellipse(25,375,5,5);

fill(255,255,255);
rect(0,400,50,50);
ellipse(25,425,10,10);

fill(255,255,255);
rect(0,450,50,50);
rect(20,465,15,15);

fill(255,255,255);
rect(550,200,50,50);

fill(255,0,255);
text("save",570,230);

stroke(170, 155, 50);
strokeWeight(10);
}
void draw()
{
if(mouseX<50 && mouseY&rt;300 && mouseY<350 && mousePressed) 
{ 
strokeWeight(2.5); 
} 
else if(mouseX<50 && mouseY&rt;350 && mouseY<400 && mousePressed) 
{ strokeWeight(5); 
} 
else if(mouseX<50 && mouseY&rt;400 && mouseY<450 && mousePressed) 
{
strokeWeight(10); 
}
else if(mouseX<50 && mouseY<50 && mousePressed) 
{ 
stroke(0,128,255); 
} 
else if(mouseX<50 && mouseY<100 && mousePressed) 
{ 
stroke(128,255,0); 
} 
else if(mouseX<50 && mouseY<150 && mousePressed) 
{ 
stroke(255,128,0); 
} 
else if(mouseX<50 && mouseY<200 && mousePressed) 
{ 
stroke(255,128,255); 
} 
else if(mouseX<50 && mouseY<250 && mousePressed) 
{ 
stroke(0,0,0);
}
else if(mouseX<50 && mouseY<300 && mousePressed) 
{ 
 stroke(255,0,0); 
}
else if(mouseX<50 && mouseY<500 && mousePressed) 
{ 
stroke(255,255,255); 
} 
else if(mouseX&rt;500 && mouseX&rt;200&&mouseY<250 && mousePressed)
{
saveFrame();
}
else if(mousePressed)
{
line(mouseX,mouseY,pmouseX,pmouseY);
}
} 

心得: 小畫家的程式碼好好玩唷 可以自己製作然後繪圖

2012年9月25日 星期二

week 03 hw03

1.
void setup(){
   size(600,600);
}
void draw(){
  fill(255,255,255);
  rect(100,100,100,100);
  
  fill(78,168,250);
  ellipse(mouseX,mouseY,04,20);
}
2.














void setup(){
  size(600,600);   } float x=100,y=100; void draw(){   background(100,150,200);   fill(212,211,78);   ellipse(mouseX,mouseY,100,100);         translate(x,y);   fill(255,255,255);   ellipse(0,0,80,80);   fill(0,0,0);   ellipse(-15,-15,20,20);    fill(0,0,0);    ellipse(15,-15,20,20);    fill(0,0,0);    ellipse(0,+13,15,10);    fill(255,255,255);    ellipse(-15,-15,10,10);    fill(255,255,255);     ellipse(15,-15,10,10);     fill(0,0,0);     ellipse(-30,-45,35,35);     fill(0,0,0);     ellipse(+30,-45,35,35);                        x=x*0.9 + mouseX*0.1;   y=y*0.9 + mouseY*0.1; }
3.心得

就是方向感要很好才能算出什麼位子要畫什麼東西  ㄏㄏ

week 02 hw02

1.50方塊
size(600,600);
for (int i=0;i<50 data-blogger-escaped-i="i" data-blogger-escaped-nbsp="nbsp" data-blogger-escaped-span="span" style="color: #cc6600;">fill
(random(255),random(255),random(255));     rect(random(400),random(300),random(200),random(100)); }
2.


size(500,400);
noStroke();
for (int i=0;i<50 data-blogger-escaped-i="i" data-blogger-escaped-nbsp="nbsp" data-blogger-escaped-span="span" style="color: #cc6600;">for
(int j=0;j<40 data-blogger-escaped-j="j" data-blogger-escaped-nbsp="nbsp" data-blogger-escaped-span="span" style="color: #cc6600;">fill(i*255/50+100,j*200/40+10,180);     ellipse(i*10,j*20,30,40);      } }


3.眼睛


background(20,40,800);
size(400,400);
noStroke();
for( int i=0;i<8 data-blogger-escaped-i="i" data-blogger-escaped-nbsp="nbsp" data-blogger-escaped-span="span" style="color: #cc6600;">for
( int k=0;k<6 data-blogger-escaped-k="k" data-blogger-escaped-span="span" style="color: #cc6600;">fill(i*255/2,k*255/4,0); ellipse(i*100+50,k*100+50,100,100); fill(i*255/7,k*255/8,255); ellipse(i*100+50,k*100+50,100,50); fill(i*255/9,k*255/25,0); ellipse(i*100+50,k*100+50,50,50); }}

4.心得

眼睛的顏色還有大小跟圈圈都要慢慢比對~~~不過好像很好玩一樣只是很麻煩

week 01 hw01

1.processing相關影片


2.

size(1000,1000);
PImage Pluto;
Pluto = loadImage("http://www2.tcgs.tc.edu.tw/~s810303/hw/10/304/dog.jpg");
image(Pluto,20,20);
saveFrame("Pluto");

3.





4.心得
七巧板有點難畫還有顏色要一直換有一丁丁麻煩