顯示具有 98163021張耀璇 標籤的文章。 顯示所有文章
顯示具有 98163021張耀璇 標籤的文章。 顯示所有文章

2013年1月15日 星期二

98160860黃麒, 98163021張耀璇, Final,



介紹:
我們這組所做的是剪紅線,名字只是個比喻,就好像有五顆炸彈,其中一顆會爆炸,而我們必須猜對那一顆炸彈才能讓贏得遊戲,本來是思考享用很多很多顆假炸彈參雜數顆真炸彈,可是手邊的材料沒有那麼多,所以就縮減成五顆。

程式碼:

import processing.serial.*;
Serial myPort;
import ddf.minim.*;
Minim minim;
AudioPlayer wrong,right;
int com;
int x=0;
int val;
PImage a1,a2,a3,a4,a5,b1,b2,b3,b4,b5,r1,r2;
void setup(){
   myPort = new Serial(this, "COM4", 9600);
  com=int(random(4))+1;
  minim = new Minim(this);
  size(800,600);
  wrong= minim.loadFile("w.mp3");
  right = minim.loadFile("r.mp3");
  a1 = loadImage("a1.png");
  b1 = loadImage("b1.png");
  a2 = loadImage("a2.png");
  b2 = loadImage("b2.png");
  a3 = loadImage("a3.png");
  b3 = loadImage("b3.png");
  a4 = loadImage("a4.png");
  b4 = loadImage("b4.png");
  a5 = loadImage("a5.png");
  b5 = loadImage("b5.png");
  r1 = loadImage("r1.png");
  r2 = loadImage("r2.png");
}
void draw(){
  if(myPort.available()&rt;0){
    val = myPort.read();
 //   println(val);
   }
   if(val=='1'){
     x=1;
   }
   else if(val=='2'){
     x=2;
   }
   else if(val=='3'){
     x=3;
   }
   else if(val=='4'){
     x=4;
   }
   else if(val=='5'){
     x=5;
   }
   else if(val=='R'){
     x=0;
     right.pause();
     right.rewind();
    com=int(random(4))+1;
   }
  background(244,219,142);
  rect (200,0,400,75);
  if(x==1)  image(b1,50,100,200,200);
  else image(a1,50,100,200,200);
  
  if(x==2)  image(b2,300,100,200,200);
  else image(a2,300,100,200,200);
  
  if(x==3)  image(b3,550,100,200,200);
  else image(a3,550,100,200,200);
  
  if(x==4)  image(b4,175,300,200,200);
  else image(a4,175,300,200,200);
  
  if(x==5)  image(b5,425,300,200,200);
  else image(a5,425,300,200,200);
  
  if(x==6)  image(r2,0,510,800,90);
  else image(r1,0,510,800,90);
  
  
 println("com="+com);
//  println(x);
  if (x==com && x!=0)  {fill(183,244,69);
  right.play();
}
  else if (x!=com && val!='H' && x!=0)  {
    wrong.play();
    wrong.rewind();
}
  else
    fill(255,0,0);
  rect (200,0,400,75);  
}
void keyPressed(){
  if(key=='1') x=1;
  if(key=='2') x=2;
  if(key=='3') x=3;
  if(key=='4') x=4;
  if(key=='5') x=5;
  if(key==' '){x=6;
    com=int(random(4))+1;
  }
}

遊戲畫面:




2012年12月4日 星期二

98160860黃麒, 98163021張耀璇, HW11, Week13,

int inpin1=3;
int inpin2=4;
int inpin3=5;
int inpin4=6;
int inpin5=7;

int buttonState1 = 0; // variable for reading the pushbutton status
int buttonState2 = 0;
int buttonState3 = 0;
int buttonState4 = 0;
int buttonState5 = 0;

void setup() {
  pinMode(inpin1, INPUT);
 pinMode(inpin2, INPUT);
 pinMode(inpin3, INPUT);
 pinMode(inpin4, INPUT);
 pinMode(inpin5, INPUT);
}

void loop() {
  buttonState1 = digitalRead(inpin1);
  buttonState2 = digitalRead(inpin2);
  buttonState3 = digitalRead(inpin3);
  buttonState4 = digitalRead(inpin4);
  buttonState5 = digitalRead(inpin5);

  if (buttonState1 == HIGHtone(8, 524,4);
  else if (buttonState2 == HIGHtone(8, 588,4);
  else if (buttonState3 == HIGHtone(8, 660,4);
  else if (buttonState4 == HIGHtone(8, 698,4);
  else if (buttonState5 == HIGHtone(8, 784,4);
  else {
  noTone(8);
  }
}

2012年11月27日 星期二

98160860黃麒, 98163021張耀璇, HW10, Week12,

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 i=0;
void setup() {
  for(int i=13 ; i>=7 ; i--){
    pinMode(i,OUTPUT);
  }
  Serial.begin(9600);
}

void loop() {
  sensorValue = analogRead(sensorPin);    
  Serial.println("Hello World");
  for(i=7 ; i<=13 ; i++){
    digitalWrite(i-2,LOW);
    digitalWrite(i-1,HIGH);
    digitalWrite(i,HIGH);
    digitalWrite(i+1,HIGH);
    digitalWrite(i+2,LOW);
    delay(100);
  }
  for(i=13 ; i>=7 ; i--){
    digitalWrite(i-2,LOW);
    digitalWrite(i-1,HIGH);
    digitalWrite(i,HIGH);
    digitalWrite(i+1,HIGH);
    digitalWrite(i+2,LOW);
    delay(100);
  }
}

2012年11月20日 星期二

98163021,張耀璇

一.
今天老師上的是比較偏硬體的部分,也認識新的程式"arduino"的程式開發軟體,也有一些範例程式,老師說其實就可做出不錯的期末作業,大致上有觸碰按鈕可以做一些節奏音樂的程式,可以設定led燈的發光的時間,也可以搭配按鈕控制發亮。

二.

2012年11月13日 星期二

Midterm 期中作品


我們這組所做的期中作品為"阿寶上樓梯"
也就是所謂的小朋友上樓梯遊戲
這是遊戲剛開始的畫面 玩家要控制空白鍵 讓阿寶能夠跳躍

這是跳躍起來的樣子

  之後越跳越高,一階一階往上跳


以下這是我們的程式碼:

int finnx=0,finny=500;
int dx=5,bgX=0,bgY=0,jump=0,woodx=0,woody=470;
PImage finn1,finn2,jump1,jump2,bg,bg2,wood,wood1,wood2,wood3;
int onboard=0;  
//--------------------------------------------------------------//宣告所有程式所需要用的圖片
void setup(){
  size(600,800);
  finn1 = loadImage("Finn_right.png");
  finn2 = loadImage("Finn_left.png");
  jump1 = loadImage("jump_right.png");
  jump2 = loadImage("jump_left.png");
  bg = loadImage("sky.jpg");
  bg2= loadImage("bg2.jpg");
  wood  = loadImage("wood.png");
  wood1 = loadImage("wood.png");
  wood2 = loadImage("wood.png");
  wood3 = loadImage("wood.png");
}
//----------------------------------------------------------------
void draw(){
  background (239,228,176);
  image(bg2,0,bgY,600,800); //-------------------<初始背景>
  //----------------------------------------------------------------<背景移動:背景會因為主角移動而延伸
 if(bgY>0){
    image(bg,0,bgY-800,600,800);
  }
  if(bgY-800>0){
    image(bg,0,bgY-1600,600,800);
  }
  if(bgY-1600>0)bgY-=800;
  //----------------------------------------------------------------->
  //-----------------------------------------------------------------<宣告階梯
  image(wood ,woodx+340,woody,350,100);
  if ( finnx>woodx+340 && finnx<woodx+600 && finny <= 400){//如果主角在這個範圍內
        finny = 360;                                       //將會把主角的水平位置往上移
        println("up");
        onboard=1;
       }else{
     onboard=0;
     }
  image(wood1,woodx    ,woody-100,350,100);
  if ( finnx>woodx && finnx<woodx+350 && finny <= 200){
        finny = 220;    
        println("up");
        onboard=1;
       }else{
     onboard=0;
     }
  image(wood2,woodx+200,woody-250,350,100);
  image(wood3,woodx+340,woody-400,350,100);
  //-------------------------------<左右移動
  if (finnx>500 || finnx<0) dx=-dx;//使主角會自動左右移動到兩邊盡頭時會轉身
  finnx+=dx;
  //------------------------------->
  //-------------------------------<向右前進.跳耀
  if(dx>0){
    if(jump>0){
        image(jump1,finnx,finny,100,150);
        jump=jump-10;
        finny-=10;
      }
   
    else image(finn1,finnx,finny,100,150);
    if(finny<500 && onboard==0){
        finny+=5;
      }
    }
  //-------------------------------<向左前進.跳耀
  else {
    if(jump>0){
        image(jump2,finnx,finny,100,150);
        jump=jump-10;
        finny-=10;
      }
    else image(finn2,finnx,finny,100,150);
    if(finny<500 && onboard==0){
        finny+=5;
      }
    }
    /*if ( finnx>woodx+340 && finnx<woodx+600 && finny <= 400){
        finny = 360;    
        println("up");
        onboard=1;
       }else{
     onboard=0;
     }*/
  //------------------------------->

  //-------------------------------<跳躍
  }
  void keyPressed()  {
  if (key==' '){
    jump=300;
   }
 
}
  //------------------------------->\

目前還有些許的BUG
也就是無法上了第二階層後繼續跳躍
我們會繼續修改我們的程式 讓他更完整

2012年10月30日 星期二

98163021,張耀璇,HW08,Week08

1.1我們之前完成了人物的左右移動,並且碰到視窗的最邊緣時,會自己更換方向,並且繼續的移動,這是上上禮拜的進度,那上禮拜我們做到的是,利用鍵盤的按鍵可以控制人物往上移動,進行跳躍的動作。


1.2今天的計畫是,如何人物碰到跳躍的板子下方,即會跳不上去,還有場景會一直跑不同的東西,地板會隨機擺放以及地板的數量。


1.3可能會遇到的問題是如地板會隨機,有時候板子距離太遙遠,人物的跳躍可能跳不到,或許要控制在一定的範圍內,還有場景的移動,必須搭配人物的移動以等比例的方式移動,不然背景看起來會非常的不協調,可能要解決的是人物以及背景的位置必須搭配好,否則會很奇怪。
2. 我們目前的進度是把背景的比例用好,然後至於地板的隨機部分,可能會再想解決的方法。
今日進度:

int finnx=0,finny=0;
int dx=5,bgX=0,bgY=0,jump;
PImage finn1,finn2,jump1,jump2,sky,grass;
void setup(){
size(600,800);
finn1 = loadImage("Finn_right.png");
finn2 = loadImage("Finn_left.png");
jump1 = loadImage("jump_right.png");
jump2 = loadImage("jump_left.png");
sky = loadImage("sky.jpg");
grass = loadImage("grass.png");
}
void draw(){
background (239,228,176);
image (sky,0,0,600,630);
image (grass,0,500,600,300);
translate (0,500);

if (finnx>500 || finnx<0) dx=-dx;
finnx+=dx;
if(dx>0) image(finn1,finnx,finny,100,150);
else image(finn2,finnx,finny,100,150);
/*if(jump>0){
jump=jump-10;
finny-=10;
}
if(finny<420){
finny+=5;
}*/
}
/*void keyPressed(){
if(key==' '){
jump=200;
}
}

2012年10月23日 星期二

98160860黃麒, 98163021張耀璇, HW07, Week07,

1.視訊
 


import processing.video.*;
Capture video;
void setup(){
size(640,480,P2D);
video = new Capture(this, width, height);
video.start();
loadPixels();
}
void draw(){
if(video.available()){
video.read();
video.loadPixels();
for(int i=0;i<640*480;i++){
pixels[i]=video.pixels[i];
}
updatePixels();
}
}

2.期中作品:
       今天的進度是讓主角阿寶能夠跳躍,跳躍為上樓梯的方式,除此之外
讓背景圖片能夠一直無限延伸。

2012年10月16日 星期二

HW06 Week06 98163021 張耀璇

1.看了許多同學的其中構思,有些看似很簡單,卻也不簡單,有些看似很難,但好像又還好,但我想可能比較在於運算的東西,會很複雜,所以可能在於判斷都會很難,所以我想應該會雖然複雜,但花時間應該可以做出來。

2012年10月9日 星期二

98163021張耀璇, HW05,Week05

void setup(){
  size(600,600);
}
float rrr=0.01;
void draw(){
  translate(300,300);
  background(0,0,0);
 fill(0,64,0);
ellipse(-2,150,20,250);
pushMatrix();
  rotate(rrr);rrr+=0.5;
  for(int i=0;i<10;i++){
    fill(i*50,255-i,150+i);
    rotate( PI/5);
    ellipse(100,10,200,50);
  }
  fill(255,0,0);
  ellipse(0,0,50,50);
  popMatrix();
  } 
 
 

void setup(){
  size(600,600);
}
float rrr=0.01;
void draw(){
  translate(300,300);
  background(0,0,0);
 fill(0,64,0);
ellipse(-2,150,20,250);
pushMatrix();

  if(mouseX<150||mouseX&rt;450)
  {
  rotate(rrr);
  rrr+=0.5;
  }
  else
  rotate(rrr);
   for(int i=0;i<10;i++){
    fill(i*50,255-i,150+i);
    rotate( PI/5);
    ellipse(100,10,200,50);
  }
  fill(255,0,0);
  ellipse(0,0,50,50);
  popMatrix();
  } 


3.射龍門
一開始電腦為莊家,然後會開出兩張牌,在這個區間中的牌即為獲勝,但是在兩張牌區間之外即為認輸,如果剛好在區間上,是輸雙倍錢。
 

2012年10月2日 星期二

98163021 張耀璇 HW04 week04

void setup(){
  size(500,400);
fill(255,0,0) ; rect(0,0,50,50);
fill(0,255,0);  rect(0,50,50,50);
fill(255);  rect(0,100,50,50);
fill(255,255,255);  rect(0,150,50,50);
fill(125,50,50);  ellipse(470,25,50,50); ellipse(470,80,30,30);
  fill(0,0,200);  rect(0,200,50,50);
  fill(0,255,255);  rect(0,250,50,50);
}
int www=5;
void draw(){
  if(mousePressed && mouseX<50 && mouseY<50) stroke(255,0,0);
  else if(mousePressed && mouseX<50 && mouseY<100) stroke(0,255,0);
  else if(mousePressed && mouseX<50 && mouseY<250) stroke(0,0,200);
  else if(mousePressed && mouseX<50 && mouseY<300) stroke(0,255,255);
  
  else if(mousePressed && mouseX<50 && mouseY<150) save("aaaa.png");
  else if(mousePressed && mouseX<50 && mouseY<200){ 
    PImage file = loadImage("aaaa.png");
    image(file, 0,0,500,400);
  
  }else if(mousePressed && mouseX&rt;450 && mouseY<50){
    strokeWeight(++www);
  }
  else if(mousePressed && mouseX&rt;450 && mouseY<1000){
    strokeWeight(--www);
    if(www<2)www=2;
  }
  else if(mousePressed)  line(mouseX, mouseY, pmouseX, pmouseY);
} 

2012年9月25日 星期二

98163021,張耀璇,HW3



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

void draw(){
  //fill(255,255,255);
 // rect(100,100,100,100);

PImage img;
img = loadImage("456.jpg");
image(img,mouseX ,mouseY);
}

void setup(){
  size(600,600);
  //frameRate(1);
}
float x=100,y=100;
void draw(){
  background(255,255,255);
PImage img;
img = loadImage("456.jpg");



PImage img_dog;
img_dog = loadImage("123.jpg");
image(img_dog,x,y);

image(img,mouseX ,mouseY);
 
  x=x*0.8 + mouseX*0.1;
  y=y*0.8 + mouseY*0.1;
}

剛開始覺得算輕鬆,但感覺越來越複雜了,希望老師能稍微獎的再詳細一點!!

2012年9月18日 星期二

98163021,張耀璇,HW02,week02



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



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



size(500,400);
for(int i=0;i<4;i++){
for(int k=0;k<1;k++){
ellipse(i*110+50,k*110+50,100,100);
fill(i*255/3,k*255/4,0);
ellipse(i*110+50,k*110+50,80,20);
fill(0,0,0);
ellipse(i*110+50,k*140+50,20,20);
fill(255,255,255);
}
}



2012年9月11日 星期二

98163021,張耀璇,hw01



2.




size(800,800);
PImage Kitty;
Kitty = loadImage("http://www.duckykitty.com/hello-kitty-desktop-wallpapers/w_hellokitty020.jpg");
image(Kitty, 20,20);

3.





size(300,300);
background(128,128,128);
fill(255,0,0);
rect(50,30,170,240,7);
fill(249,249,0);
rect(60,45,150,200,7);
fill(255,0,0);
rect(117,235,35,20,7);
fill(255,0,0);
rect(112,40,45,30,7);
fill(255,0,0);
rect(112,55,45,45,7);
fill(0,255,255);
rect(70,125,45,15);
fill(0,255,255);
rect(155,125,45,15);
fill(0,0,0);
rect(95,215,80,1);
line(95,215,90,225);
line(90,225,60,210);
line(175,215,180,225);
line(180,225,210,215);

4.
老師目前上的東西跟上課速度都還能接受,但希望老師能多示範幾個例子,讓我們可以多練習。