顯示具有 98160345蔡承芳 標籤的文章。 顯示所有文章
顯示具有 98160345蔡承芳 標籤的文章。 顯示所有文章

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

98160345蔡承芳,HW9,Week11

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日 星期二

98160345蔡承芳,HW05,Week5

5-1 轉動



5-2 移動




void setup(){
  size(600,600);
}
float rrr=0.1;
void draw(){
  background(0,0,0);
  translate(mouseX,mouseY);
  rotate(rrr);rrr+=0.01;
  fill(255,174,201);
  for(int i=0;i<30;i++){
  rotate( PI/10);
  ellipse(150,10,200,50);
  }
  fill(153,217,234);
  ellipse(0,0,150,150);
}

5.3 期中作業初步概念(太鼓達人)
組員:楊子儀98160204

98160345蔡承芳,HW04,Week4



void setup()
{
size(500,400);
background(0,0,255);
fill(255,0,0);
rect(0,0,50,50);
fill(255,255,0);
rect(0,50,50,50);
fill(0,0,255);
rect(0,100,50,50);
fill(0,255,0);
rect(0,150,50,50);
fill(255,128,50);
rect(0,200,50,50);
fill(255,255,255);
rect(450,0,50,50);
fill(255,255,255);
ellipse(475, 25, 2,2);
fill(255);
rect(450,50,50,50);
ellipse(475, 75, 6, 6);
rect(450,100,50,50);
ellipse(475, 125, 10,10);
rect(0,250,50,50);
stroke(255,0,0);
strokeWeight(1);
}
void draw()
{
if(mouseX>450 && mouseX<500 && mouseY>0 && mouseY<50 && mousePressed)
{
strokeWeight(3);
}
else if(mouseX>450 && mouseX<500 && mouseY>50 && mouseY<100 && mousePressed)
{
strokeWeight(6);
}
else if(mouseX>450 && mouseX<500 && mouseY>100 && mouseY<150 && mousePressed)
{
strokeWeight(10);
}
else if(mouseX < 50 && mouseY<50 && mousePressed)
{
stroke(255,0,0);
}
else if(mouseX < 50 && mouseY<100 && mousePressed)
{
stroke(255,255,0);
}
else if(mouseX < 50 && mouseY<150 && mousePressed)
{
stroke(0,0,255);
}
else if(mouseX < 50 && mouseY<200 && mousePressed)
{
stroke(0,255,0);
}
else if(mouseX < 50 && mouseY<250 && mousePressed)
{
stroke(255,128,50);
}
else if(mouseX < 50 && mouseY<300 && mousePressed)
{
stroke(255,255,255);
}
else if(mousePressed)
{
line(mouseX,mouseY,pmouseX,pmouseY);
}
}
 

2012年9月25日 星期二

98160345蔡承芳,HW03,Week3

1.



void setup(){
   size(600,600);
}
void draw(){
  fill(255,255,255);
  rect(100,100,100,100);
  
  fill(100,50,250);
  ellipse(mouseX,mouseY,04,10);
}

2.

void setup(){
  size(600,600);
  //frameRate(1);
}
float x=100,y=100;
void draw(){
  background(0,0,0);

  fill(255,255,255);
  ellipse(mouseX,mouseY,100,100);

  translate(x,y);
  fill(145,133,51);
  ellipse(0,0,80,60);
  fill(0,0,0);
  ellipse(-15,-10,15,15);
  fill(0,0,0);
  ellipse(+15,-10,15,15);
  fill(236,60,64);
  ellipse(0,5,20,15);
  fill(236,60,64);
  ellipse(-25,-38,30,30);
  fill(236,60,64);
  ellipse(25,-38,30,30);
  x=x*0.9 + mouseX*0.1;
  y=y*0.9 + mouseY*0.1;
}


3.

課程滿有趣的,但功課有點多了

98160345蔡承芳,HW01,Week1

1.



2.

size(500,500);
PImage kitty;
kitty = loadImage("http://farm6.static.flickr.com/5263/5889286374_803853984b.jpg");
image(kitty, 20,20);



3.





98160345蔡承芳,HW02,Week2

1



size(600,600);
for(int i=0;i<50;i++)
{
fill(random(255),random(255),random(255));
rect(random(255),random(255),random(255),random(255));
}


2



size(400,300);
 for(int i=0;i<40;i++)
 {
  for(int k=0;k<30;k++)
   {
    fill(i*200/40,k*255/30,0);
    triangle(i*20,k*20, i*20+20, k*20, i*20, k*20+20);
    fill(i*200/45,k*200/50,i*200/20);
    triangle(i*10,k*10+10, i*10+10,k*10, i*10+10,k*10+10);
   }
 }




3

size(400,300);
background(600,200,0);
for(int i=0;i<40;i++){
  for(int k=0;k<30;k++){
   
    fill(i*255/4,k*255/3,0);
    ellipse(i*50+10,k*50+10,  50,45);
    fill(0,0,0);
ellipse(i*50+10,k*50+10,10,45);

  }
}