顯示具有 hw06 標籤的文章。 顯示所有文章
顯示具有 hw06 標籤的文章。 顯示所有文章

2014年10月20日 星期一

01160235_謝采玲, HW06, Week06

class teaching:

躲車子


void setup(){
  size(900,500);
  for(int i=0;i<4;i++) car[i]=loadImage("car"+(i+1)+".png");
  for(int i=0; i<3;i++) { carX[i]=int(random(7))*100+100;carY[i]=-random(400);
  }
}

int gameOver=0;
void draw(){
  background(254,235,156);
 
  if(gameOver>0){
    for(int i=0; i<3;i++) { carX[i]=int(random(7))*100+100; carY[i]=random(400);
    fill(255,0,0,20); rect(0,0,900,500); gameOver--; return;
  }
   
  for(int i=1;i<=7;i++){
    if(i%2==1) fill(77);
    else fill(111); rect(i*100,0,100,500);
  }
  for(int i=0;i<3;i++) image(car[i],carX[i],carY[i],100,150);
  imge(car[3],carX[3],carY[3],100,150);
  for(int i=0;i<3;i++){
    carY[i]+=5;
    if(carY[i]>500){carY[i]=-random(100); carX[i]=int(random(7))*100+100}
    if
  }
}

打地鼠


PImage car[]=new PImage[4];
float carX={0,0,0,400}, carY[]={0,0,0,300};
int gopherLife[]={0,0,0,0,0,0,0,0,0};
PImage gopher, gopherPart;
void setup(){
  size(900,600);
  gopher=loadImage("gopher.jpg");
  gopher.resize(150,200);
  gopherPart=createImage(150,200,ARGB);
  imgeMode(CENTER);
}
void draw(){
  background(##FFE40F);
  for(int i=0;i<9;i++){
    ellipse(int (i%3)*300+150, int (i/3)*200+100,150,100);
    gopherLife+=1;
    if(gopherLife[i]>0) gopherLife[i]=-int(random(300));
    gopherPart.copy(gopher,0,0,150,gopherLife[i],0,0,150,gopherLife[i]);
    image(gopher, int(i%3)*300+150, int(1/3)*200+100,150,200);
  }
  image(gopher,0,0);

}

期中作業:


[賽車]

●跑道
●車子不能穿過跑道
●起跑線
●可以設定幾圈
●有計時器
●跑完設定的圈數後,結束遊戲,跳出另一個視窗顯示記錄板

PImage imgBG;
int table[][]= new int [800][510];
void setup() {
  size(800, 510); //700,500
  imgBG=loadImage("background.png");
  background(imgBG);
  loadPixels();
  for(int i=0;i<pixels.length;i++){
      color now= pixels[i];
      if(green(now)>red(now)) pixels[i]=color(255,0,0);//table[i][j]=1;
  }
  /*
  for(int i=0;i<800;i++)
    for(int j=0;j<510;j++){
      color now= pixels[i+j*510];
      if(green(now)>red(now)) pixels[i+j*510]=color(255,0,0);//table[i][j]=1;
      //if(green(now)>=253&&red(now)>=246) pixels[i+j*510]=color(255,0,0);//table[i][j]=1;
      else table[i][j]=0;
    }*/
  rectMode(CENTER);
  updatePixels();
}

float angle=0, carX=200, carY=100, gas=0;

void draw() {
  //background(imgBG);
  translate(carX, carY);
  rotate(angle);
  fill(#0E7C26);
  rect(0, 0, 25, 10);
  fill(#E7F711);
  rect(10, 0, 5, 10);
  carX+=gas*cos(angle);
  carY+=gas*sin(angle);
  if(gas>0) gas-=0.1;
}
void keyPressed() {
  if(keyCode==UP) gas+=2;
  if(keyCode==RIGHT) angle+=0.1;
  if(keyCode==LEFT) angle-=0.1;
  if(keyCode==DOWN) gas-=2;
}
void mouseMoved(){
  if (table[mouseX][mouseY]>0) println("accident");
  else println("safe");
}





Week6_呂季樺_01160306

1. 期中作品進度及展示

Week04 期中作品訂題目/實作示範
Week05 期中作品實作示範
Week06 
Week07
Week08 業界老師授課 (愛迪斯科技)
期中考週
Week10 業界老師授課 (叁式互動)
Week11

2. 實務示範, 以暗棋為例, 讓大家看到它怎麼 "一步步做出來"

目前進度
PImage plane[]=new PImage[3];
int pX[]={25,25,25},pY[]={0,0,0},pVX,pVY;
void setup(){
  size(800,400);  
  for(int i=0;i<3;i++)  plane[i]=loadImage("plane"+int(random(2))+".png");
  for(int i=0;i<3;i++){
    pX[i]=int(random(30))*25;
    pY[i]=int(random(7))*25+25;
  }
}
void draw(){
  background(255);  
  rect(25,25,750,350);
  for(int i=0;i<3;i++){
    image(plane[i],pX[i],pY[i],100,50);
  }
}

第六周課堂作業

期中作業 未完

第六周課堂作業


期中作品



↑遊戲畫面





↑遊戲結束畫面


遊戲分析:
1. 畫背景和洞
2. 槌子打下去後圖片改變
3. 怪獸們隨機從洞中出現
4. 計算時間
5. 計算成績-計算槌子打到的位置及怪獸出現的位置是否一樣



Week06-期中作品

期中作品

            殺螞蟻遊戲

程式Demo↓






int antx=0, anty=0, anty1=0, anty2=0;
int score=0;
int lasttime=60;
PImage imgBG, imgHANT, imgUP, imgSTOP, imgSTART, ant;
void setup(){
  size(380,600);
  ant = loadImage("ant.png");
  imgHANT = loadImage("hant.png");
  imgBG = loadImage("BG.png");
  imgBG.resize(380, 600);
  imgUP = loadImage("up.png");
  imgSTOP = loadImage("stop.png");
  imgSTOP.resize(50, 50);
  imageMode(CENTER);
}
void draw(){
  background(imgBG);
  image(imgHANT, mouseX, mouseY, 120, 60);
  image(imgUP, 190, 20);
  image(imgSTOP, 190, 20);

  anty-=3;
  image(ant,antx+300,anty+600,80,80);
  if(anty+600<0)
  {
    score-=5;
    anty=0;
  }
  anty1-=2;
  image(ant,antx+200,anty1+500,80,80);
  if(anty1+500<0)
  {
    score-=5;
    anty1=0;
  }
  anty2-=3;
  image(ant,antx+100,anty2+700,80,80);
  if(anty2+700<0)
  {
    score-=5;
    anty2=0;
  }
  world();
}
void mousePressed(){
  if (mouseX > antx+300 && mouseX< antx+400 && mouseY<anty+700 && mouseY>anty+600)
   {
     anty=600;
     score+=5;
   }

  if (mouseX > antx+200 && mouseX< antx+300 && mouseY<anty1+600 && mouseY>anty1+500)
   {
   anty1=500;
   score+=5;
   }
  if (mouseX > antx+100 && mouseX< antx+200 && mouseY<anty2+800 && mouseY>anty2+700)
   {
   anty2=700;
   score+=5;
   }
}
void world()
  {
     textFont(createFont("Georgia", 30));
      fill(255);
  text("score:"+score, 25, 30);

  textFont(createFont("Georgia", 30));
      fill(255);
  text("Time:"+lasttime, 250, 30);
  lasttime=60-millis()/1000;

      if(lasttime==0)
      {
      stop();
      textFont(createFont("Georgia", 40));
      background(#FAC17C);
      fill(255,255,255);
      text("Game Over",80,200);
      text("Your score:"+score,40,250);
   
      }

  }

week06


int rocketX=250,rocketY=600, bgY=0,rockX;
PImage imgBG,Rock1;
void setup(){
  size(500,800);
  imgBG=loadImage("space.jpg");
  Rock1=loadImage("rock1.png");
  imgBG.resize(500,800);
}
void draw()
{
  background(imgBG);
  image(imgBG,0,bgY,500,800);
  image(imgBG,0,bgY-800,500,800);
  image(Rock1,50,100,150,150);
  bgY++;
  if(bgY>800) bgY=0;
  rect(rocketX,rocketY,50,100);
  if(rockX>500){rockX=random(100);}
}
void mousePressed() {
  if (mouseButton == LEFT) {
    rocketX-=150;    
  } else if (mouseButton == RIGHT) {
    rocketX+=150;
  }
}

Week 6

期中作品 步驟:
1. 設定砲台 讓他可以左右移動和轉頭
2. 設定飛機 飛機可以從左到右隨機飛出
3. 設定子彈 飛機或是砲台碰觸到子彈時會Gae Over
4. 飛機被子但擊中時會加分

第六周課堂作業

1.先將牌塞進格線裡




2.使牌能打散




3.將牌全數翻面 且 能翻牌


/////////今日進度

期中進度


Week06 葉正聖老師示範

1. 期中作品進度及展示

Week04 期中作品訂題目/實作示範
Week05 期中作品實作示範
Week06 
Week07
Week08 業界老師授課 (愛迪斯科技)
期中考週
Week10 業界老師授課 (叁式互動)
Week11

2. 實務示範, 以暗棋為例, 讓大家看到它怎麼 "一步步做出來"
http://upload.wikimedia.org/wikipedia/commons/d/d7/%E4%BA%94%E5%8D%81%E5%85%AD%E5%AD%90%E8%B1%A1%E6%A3%8B%E9%BA%BB%E5%B0%87.jpg