2020年1月16日 星期四

alanhc 互動技術-week17 [final]

回顧這學期的作品:

 期中作業:LANDING:PLANET




賣點&特點:

  1. 炫麗的特效
  2. 物理(星球重力及降落)及粒子系統(噴射)
  3. 世界地圖可根據視角縮放

困難點:

  • 重寫3次最終改寫成物件導向的CLASS寫法
  • 攝影機的座標
  • 粒子系統噴射

期末作業:drum.io






說明你做了什麼

學javascript es6的語法規則、p5.js與processing的不同,了解socket網路通訊程式原理,
花最多時間在多人連線的部分,需要畫出狀態圖及流程圖,與一般程式思考邏輯不太一樣
分為host與play兩個階段,當某個client在host階段 其他就負責檢查是否有與打一樣,有點像請你跟我這樣做
再花點時間debug
深度學習是否要多層訓練比較好等等

如何操作

1. 將瀏覽器的自動播放功能打開 ,設定 > 進階設定 > 隱私 > 音效 > 允許 {server ip}
2. 進資料夾,在小黑下 node server.js(必須有nodejs在電腦上
3. 接上開發版即可開始玩

賣點是什麼


  • 可以多人遊玩及對戰
  • 深度學習訓練自己的Air drum

困難點是什麼

* 多人連線(寫好協定讓彼此可以跑一樣的視窗及不會打架 使用nodejs socket io
* 深度學習(訓練使準確率提升 ml5 library (base on tensorflow js)
* 互動裝置(Arduino及三軸感測器...
雖然由於serial的原理也是使用nodejs,因此若兩者同時跑會導致我的程式會不同步,若以後可以的話可以再試試用其他的方法解決ex. 直接寫tensorflow.js原生碼之類

2020年1月14日 星期二

06160805的課堂筆記

期末作品

影片:youtube:https://youtu.be/dUTRwbElfHU

說明:透過鍵盤的上、左、右,控制章魚的跳躍,讓章魚可以踩著板子持續向上跳,可以訓練手的靈活度,因為跳躍的幅度較大,所以容易跳離開板子,就會掉下去囉,遊戲就結束了。
     這次增加時間在右上角計時,讓玩家可以知道自己花費多少秒數玩這個遊戲,秒數越多代表生存越久,後面秒數越多板子的間隔距離就越大越不容易跳到。
     怎麼樣玩到後面板子越少,是我們遇到較困難的部分,因為很容易減一個變數讓原本的板子出現問題,這個問題卡了許久。
     因為要隨機加入道具,因此板子跟有彈簧的板子之間的if判斷困擾了許久。

2020年1月10日 星期五

期末作品

06160291溫鎮瑋 06160052林妘鎂

作品:射擊遊戲

連結:https://youtu.be/gQT0Yh68xOU

簡介:本遊戲屬於射擊遊戲,需用搖桿控制幽靈(主角)消滅符咒(怪物)來保護幽靈身後的貓咪,
若符咒觸碰到貓咪即顯示GAME OVER以及分數結束遊戲,若分數達到200分即成功過關。

操作方式:利用搖桿上下左右移動幽靈,往下壓即可射出子彈來攻擊符咒怪物。

賣點:可利用搖桿操作而不是單單只使用鍵盤及滑鼠操作。

困難點:要想辦法讓遊戲結合搖桿控制。

PImage soul;
PImage ememy;
PImage background;
PImage gameover;
PImage first;
PImage cat;
PImage first1;
PImage endgame;
float endgameX=0, endgameY=0;
float first1X=0, first1Y=0;
float catX=0, catY=0;
float soulX=100, soulY=450;
float gameoverX=0, gameoverY=0;
float firstX=0, firstY=0;
float backgroundX=0, backgroundY=0;
float soulVX=0, soulVY=0;
float []bulletX=new float[100];
float []bulletY=new float[100];
float []ememyX=new float[50];
float []ememyY=new float[50];
boolean[]bulletFlying=new boolean[100];
boolean[]ememyAlive=new boolean[50];
int bulletN=0;
int softBrake=0,game=0,score=0;
int m=0, dead=0, point=0;
import processing.serial.*;
Serial serial;
void setup() {
  size(1600, 900);

  serial=new Serial(this, "COM3", 9600);
  soul=loadImage("soul.png");
  cat=loadImage("cat.png");
  ememy=loadImage("ememy.jpg");
  gameover=loadImage("gameover.jpg");
  background=loadImage("background.jpg");
  first=loadImage("first.jpg");
  first1=loadImage("first1.jpg");
  endgame=loadImage("endgame.jpg");
  endgame.loadPixels();
  soul.loadPixels();
  gameover.loadPixels();
  background.loadPixels();
  first.loadPixels();
  first1.loadPixels();
  cat.loadPixels();

  for (int i=0; i<50; i++) {
    ememyX[i]=random(1500)+1300+i*50;
    ememyY[i]=random(750);
    ememyAlive[i]=true;
  }
}
int x=512, y=512, sw=577;
void recycle() {
  for (int i=0; i<bulletN; i++) {
    if (bulletFlying[i]==false) {
      for (int k=i; k<bulletN-1; k++) {
        bulletX[k]=bulletX[k+1]; 
        bulletY[k]=bulletY[k+1]; 
        bulletFlying[k]=bulletFlying[k+1];
      }
      bulletN--;
    }
  }
}
void draw() {
  if(game==0){
    if (serial.available()>0) {
    String now=serial.readString();
    String[] xy=splitTokens(now);
    x=int (xy[0]);
    y=int (xy[1]);
    sw=int (xy[2]);
  }
    image(first, firstX, firstY, 1600, 900);
    if(sw==0&&game==0){
      game++;
    }
    println(game);
  }
  if(game==1){
    if (serial.available()>0) {
    String now=serial.readString();
    String[] xy=splitTokens(now);
    x=int (xy[0]);
    y=int (xy[1]);
    sw=int (xy[2]);
  }
    image(first1, first1X, first1Y, 1600, 900);
    if(sw==0&&game==1){
      game++;
    }
    println(game);
  }
  if(game==2){
  image(background, backgroundX, backgroundY, 1600, 900);
  image(cat, catX, catY, 125, 900);
  for (int i=0; i<50; i++) {
    if (ememyAlive[i]) {
      image(ememy, ememyX[i], ememyY[i], 80, 80);
      ememyX[i]-=10;
    }
  }
  for (int i=0; i<bulletN; i++) {
    if (bulletFlying[i]&&m==0) {
      fill(255, 0, 0);
      ellipse(bulletX[i], bulletY[i], 10, 10);
      bulletX[i]+=50;
      for (int k=0; k<50; k++) {
        if (dist(bulletX[i], bulletY[i], ememyX[k]+40, ememyY[k]+40)<40&&ememyAlive[k]==true) {
          ememyAlive[k]=false;
          bulletFlying[i]=false;
          if (ememyAlive[k]==false&&game==2) {
            point+=10;
          }
          score=point;
        }
      }
      if (bulletX[i]>1600) {
        bulletFlying[i]=false;
      }
    }
    textSize(72);
    text("score:"+point, 150, 100);
  }
  println(point);
  if (sw==0) {
    bulletX[bulletN]=soulX+50;
    bulletY[bulletN]=soulY+50;
    bulletFlying[bulletN]=true;
    bulletN++;
    if (bulletN>=100) bulletN=0;
    m=1;
  } else {
    m=0;
  }
  for (int k=0; k<50; k++) {
    if (ememyX[k]<100) {
      ememyAlive[k]=false;
    }
    if (ememyX[k]<100&& ememyAlive[k]==false) {
      game++;
    }
  }

  if (serial.available()>0) {
    String now=serial.readString();
    String[] xy=splitTokens(now);
    x=int (xy[0]);
    y=int (xy[1]);
    sw=int (xy[2]);
  }
  image(soul, soulX, soulY, 100, 100);
  delay(100);
  if (soulX>1550) {
    soulX=1550;
    soulVX=0;
  }
  if (soulX<100) {
    soulX=100;
    soulVX=0;
  }
  if (soulY>750) {
    soulY=750;
    soulVY=0;
  }
  if (soulY<50) {
    soulY=50;
    soulVY=0;
  }
  if (x==1023) {
    softBrake=1;
  } else if (x==0) {
    softBrake=1;
  }
  if (x==1023) {
    {
      soulX+=10;
      soulVX=10;
    } 
    softBrake=0;
  } else if (x==0) {
    soulX-=50;
    soulVX=-50;
  }
  softBrake=0;
  if (y==1023) {
    {
      soulY+=50;
      soulVY=50;
    } 
    softBrake=0;
  } else if (y==0) {
    soulY-=50;
    soulVY=-50;
  }
  softBrake=0;
  }
  if(game==3){
    image(gameover, gameoverX, gameoverY, 1600, 900);
    textSize(108);
    text("score:"+score, 575, 600);
  }
  if(point>=200){
    game=4;
  }
  if(game==4){
    image(endgame,endgameX,endgameY, 1600, 900);
   fill(#5FDFF7);
   textSize(108);
   text("score:"+score, 550, 750); 
  }
}

期末作業Week17

組員:溫鎮瑋06160291,林妘鎂06160052

作品:射擊遊戲

連結:https://youtu.be/gQT0Yh68xOU

簡介:這是簡單的射擊遊戲搭配著搖桿進行移動以及操作,來擊退符咒保護後面的貓咪。

操作方式:這次想說有新學到搖桿的部分,所以想說讓一定變成用搖桿一定,在加上SW往下壓即可發射子彈的方式讓操作在一個地方上完成

賣點:較為簡單,且在操作重鍵盤滑鼠轉移至搖桿上面

困難點:搖桿的使用以及arduino跟P語言的配合

下面是程式碼的部分
PImage soul;
PImage ememy;
PImage background;
PImage gameover;
PImage first;
PImage cat;
PImage first1;
PImage endgame;
float endgameX=0, endgameY=0;
float first1X=0, first1Y=0;
float catX=0, catY=0;
float soulX=100, soulY=450;
float gameoverX=0, gameoverY=0;
float firstX=0, firstY=0;
float backgroundX=0, backgroundY=0;
float soulVX=0, soulVY=0;
float []bulletX=new float[100];
float []bulletY=new float[100];
float []ememyX=new float[50];
float []ememyY=new float[50];
boolean[]bulletFlying=new boolean[100];
boolean[]ememyAlive=new boolean[50];
int bulletN=0;
int softBrake=0, game=0, score=0;
int m=0, dead=0, point=0;
import processing.serial.*;
Serial serial;
void setup() {
  size(1600, 900);

  serial=new Serial(this, "COM3", 9600);
  soul=loadImage("soul.png");
  cat=loadImage("cat.png");
  ememy=loadImage("ememy.jpg");
  gameover=loadImage("gameover.jpg");
  background=loadImage("background.jpg");
  first=loadImage("first.jpg");
  first1=loadImage("first1.jpg");
  endgame=loadImage("endgame.jpg");
  endgame.loadPixels();
  soul.loadPixels();
  gameover.loadPixels();
  background.loadPixels();
  first.loadPixels();
  first1.loadPixels();
  cat.loadPixels();

  for (int i=0; i<50; i++) {
    ememyX[i]=random(1500)+1300+i*50;
    ememyY[i]=random(750);
    ememyAlive[i]=true;
  }
}
int x=512, y=512, sw=577;
void recycle() {
  for (int i=0; i<bulletN; i++) {
    if (bulletFlying[i]==false) {
      for (int k=i; k<bulletN-1; k++) {
        bulletX[k]=bulletX[k+1];
        bulletY[k]=bulletY[k+1];
        bulletFlying[k]=bulletFlying[k+1];
      }
      bulletN--;
    }
  }
}
void draw() {
  if (game==0) {
    if (serial.available()>0) {
      String now=serial.readString();
      String[] xy=splitTokens(now);
      x=int (xy[0]);
      y=int (xy[1]);
      sw=int (xy[2]);
    }
    image(first, firstX, firstY, 1600, 900);
    if (sw==0&&game==0) {
      game++;
    }
    println(game);
  }
  if (game==1) {
    if (serial.available()>0) {
      String now=serial.readString();
      String[] xy=splitTokens(now);
      x=int (xy[0]);
      y=int (xy[1]);
      sw=int (xy[2]);
    }
    image(first1, first1X, first1Y, 1600, 900);
    if (sw==0&&game==1) {
      game++;
    }
    println(game);
  }
  if (game==2) {
    image(background, backgroundX, backgroundY, 1600, 900);
    image(cat, catX, catY, 125, 900);
    for (int i=0; i<50; i++) {
      if (ememyAlive[i]) {
        image(ememy, ememyX[i], ememyY[i], 80, 80);
        ememyX[i]-=10;
      }
    }
    for (int i=0; i<bulletN; i++) {
      if (bulletFlying[i]&&m==0) {
        fill(255, 0, 0);
        ellipse(bulletX[i], bulletY[i], 10, 10);
        bulletX[i]+=50;
        for (int k=0; k<50; k++) {
          if (dist(bulletX[i], bulletY[i], ememyX[k]+40, ememyY[k]+40)<40&&ememyAlive[k]==true) {
            ememyAlive[k]=false;
            bulletFlying[i]=false;
            if (ememyAlive[k]==false&&game==2) {
              point+=10;
            }
            score=point;
          }
        }
        if (bulletX[i]>1600) {
          bulletFlying[i]=false;
        }
      }
      textSize(72);
      text("score:"+point, 150, 100);
    }
    println(point);
    if (sw==0) {
      bulletX[bulletN]=soulX+50;
      bulletY[bulletN]=soulY+50;
      bulletFlying[bulletN]=true;
      bulletN++;
      if (bulletN>=100) bulletN=0;
      m=1;
    } else {
      m=0;
    }
    for (int k=0; k<50; k++) {
      if (ememyX[k]<100) {
        ememyAlive[k]=false;
      }
      if (ememyX[k]<100&& ememyAlive[k]==false) {
        game++;
      }
    }

    if (serial.available()>0) {
      String now=serial.readString();
      String[] xy=splitTokens(now);
      x=int (xy[0]);
      y=int (xy[1]);
      sw=int (xy[2]);
    }
    image(soul, soulX, soulY, 100, 100);
    delay(100);
    if (soulX>1550) {
      soulX=1550;
      soulVX=0;
    }
    if (soulX<100) {
      soulX=100;
      soulVX=0;
    }
    if (soulY>750) {
      soulY=750;
      soulVY=0;
    }
    if (soulY<50) {
      soulY=50;
      soulVY=0;
    }
    if (x==1023) {
      softBrake=1;
    } else if (x==0) {
      softBrake=1;
    }
    if (x==1023) {
      {
        soulX+=10;
        soulVX=10;
      }
      softBrake=0;
    } else if (x==0) {
      soulX-=50;
      soulVX=-50;
    }
    softBrake=0;
    if (y==1023) {
      {
        soulY+=50;
        soulVY=50;
      }
      softBrake=0;
    } else if (y==0) {
      soulY-=50;
      soulVY=-50;
    }
    softBrake=0;
  }
  if (game==3) {
    image(gameover, gameoverX, gameoverY, 1600, 900);
    textSize(108);
    text("score:"+score, 575, 600);
  }
  if (point>=200) {
    game=4;
  }
  if (game==4) {
    image(endgame, endgameX, endgameY, 1600, 900);
    fill(#5FDFF7);
    textSize(108);
    text("score:"+score, 550, 750);
  }
}

2020年1月8日 星期三

Week_17 期末作品

作品名稱:Sky Challenge

組員:05160035 林欣儀、05160160 黃偉愷




 展示影片: 


 介紹: 

首先,開啟遊戲時,因為載入音樂會需要花點時間,所以製作了loading的畫面。接下來玩家可依照個人的喜好選擇小夥伴,確定小夥伴後就可以進入到遊戲畫面。遊戲主要是讓玩家透過按鍵模組來操控小夥伴的方向,讓小夥伴跳在每朵雲上。每一層的雲朵長度不一致,並且在第五層時雲朵會隨機移動。另外,左右兩側會隨機出現小麻雀飛過,玩家必需閃躲,碰到小麻雀或從雲朵上掉落下來,遊戲就結束了。玩家必需要讓小夥伴安全的跳在每朵雲上和閃躲小麻雀,考驗玩家的技術和反應。




 操作: 

利用arduino按鍵模組上的"上鍵"、"左鍵"、"右鍵",來控制小夥伴的方向。




 特色: 

遊戲的設計上,在越高樓層會提高難度與速度,以及增加隨機飛躍的小麻雀,增加遊戲的困難度,讓玩家可以不斷挑戰。介面的設計上,主要以可愛的角落小夥伴當作遊戲主角,並且搭配輕鬆愉快的音樂,增加遊戲整體的豐富度。另外,因為剛開始載入音樂時,會需要花一點時間等待,為了填補這等待的時間,所以增加loading的畫面。




 困難: 
  1. 在畫面滾動時,需設計好雲與雲之間的間距,才不會讓自動生成的雲交疊在一起或是間距過大導致小恐龍無法跳到雲上。
  2. 要設法讓小恐龍在跳耀到雲上時,可以停留在雲上而非穿透過雲往下掉,當雲往下時小恐龍也要跟著雲一起往下。
  3. 當小恐龍從高處掉到底下的雲時,要避免因重力加速度的關係導致小恐龍穿透過雲。
  4. 加入了重力加速度的計算,讓小恐龍在掉落時可以更符合現實的物理情況。
  5. 加入了PVector計算小恐龍移動的距離,讓小恐龍在移動時可以更加地流暢。
  6. 讓雲朵可以自動的隨機移動並且碰到邊緣要自動反彈。
  7. 由於本程式的物件較多,我們使用了大量的物件導向概念將各個子功能結合在一起,完成程式的整合。
  8. 將arduino按鍵模組與遊戲結合時,發現processing的framerate數值太低時,會讀不到arduino按鍵模組的訊號,framerate數值太高時,會讓畫面動得太快,所以必須在兩者間取中間值。因此,我們設計一套演算法來解決這問題。
  9. 為了同時處理載入音樂和顯示loading畫面,運用多線程的方式來解決這問題。



原始碼

 GitHub 連結: 
https://github.com/Wecan-Huang0602/Sky-Challenge

week17_葉子的上課日記

[ 期末作品 ]



>>簡單的音樂小遊戲<<

隨著箭頭按下相對應的方向鍵就能玩了。
譜面是固定的。

因為調譜很花時間,所以只用完一首歌

[ 遊戲畫面 ]






筆記筆記

期末作品

作品名稱:PACMAN
Youtube連結:https://youtu.be/tt3hGWPoU6k
利用上下左右鍵控制小精靈
小精靈抵達出口會跳到結束畫面

PImage []p=new PImage[2];
PImage Map,money,word,End;
int pX=0, pY=250, pID=0;
int [][]map={
{1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,0,0,0,0,0,0,0,0,0,0},
{1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,0,0,0,0,0,0,0,0,0,0},
{1,1,0,0,0,1,0,0,0,0,0,0,0,0,0,0,1,0,0,0,1,0,0,0,0,0,0,0,1,0,1,0,0,0,0,0,0,0,0,0,0},
{1,1,0,1,0,1,0,1,1,1,1,1,1,1,1,0,1,0,1,0,1,0,1,1,1,0,1,0,1,0,1,0,0,0,0,0,0,0,0,0,0},
{1,1,0,1,0,0,0,1,0,0,0,0,0,0,0,0,0,0,1,0,1,0,0,0,1,0,1,0,0,0,1,0,0,0,0,0,0,0,0,0,0},
{1,1,0,1,1,1,1,1,0,1,1,1,1,1,1,1,1,1,1,0,1,0,1,1,1,0,1,1,1,0,1,0,0,0,0,0,0,0,0,0,0}, 
{1,1,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,1,0,0,0,1,0,0,0,1,0,1,0,1,0,0,0,0,0,0,0,0,0,0},
{1,1,1,1,1,1,0,1,1,1,1,1,1,1,1,1,1,0,1,1,1,0,1,0,1,1,1,0,1,0,1,0,0,0,0,0,0,0,0,0,0},
{1,1,0,0,0,1,0,1,0,0,0,1,0,0,0,0,1,0,0,0,1,0,1,0,0,0,1,0,0,0,1,0,0,0,0,0,0,0,0,0,0},
{1,1,0,1,0,1,1,1,0,1,0,1,0,1,0,0,1,1,1,0,1,0,1,1,1,0,1,1,1,1,1,1,1,1,0,1,1,1,1,1,1},
{1,1,0,1,0,0,0,1,0,1,0,1,0,1,0,0,0,0,0,0,1,0,1,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,1,1},
{1,1,1,1,1,1,0,1,1,1,0,1,0,1,1,1,1,1,1,1,1,0,1,1,1,1,1,1,1,1,1,1,1,1,0,1,0,1,0,1,1},
{1,1,0,0,0,1,0,1,0,0,0,1,0,0,0,0,0,0,0,0,1,0,1,0,0,0,1,0,0,0,0,1,0,0,0,1,0,1,0,1,1},
{1,1,0,1,0,1,0,1,0,1,1,1,1,1,1,1,1,1,1,0,1,0,1,0,1,0,1,0,1,1,1,1,0,1,1,1,0,1,0,1,1},
{1,1,0,1,0,1,0,1,0,0,0,0,0,1,0,0,1,0,0,0,1,0,0,0,1,0,1,0,0,0,0,0,0,1,0,0,0,1,0,1,1},
{1,1,0,1,0,0,0,1,1,1,0,1,0,1,0,0,0,0,1,1,1,1,1,1,1,0,1,1,1,1,1,1,1,1,0,1,1,1,0,1,1},
{1,1,0,1,1,1,0,1,0,0,0,1,0,1,1,1,1,1,1,0,0,0,0,0,1,0,1,0,0,0,0,0,0,0,0,1,0,0,0,1,1},
{1,1,0,1,0,0,0,1,0,1,0,1,0,1,0,0,0,0,0,0,1,0,1,0,0,0,1,0,1,1,1,1,1,1,1,1,0,1,1,1,1},
{1,1,0,1,0,1,1,1,0,1,1,1,0,1,0,0,1,1,1,1,1,0,1,1,1,1,1,0,1,0,0,0,0,0,0,1,0,0,0,1,1},
{1,1,0,1,0,0,0,0,0,1,0,0,0,1,0,0,0,0,0,0,1,0,0,0,0,0,1,0,1,0,1,1,1,0,0,1,0,0,0,1,1},
{1,1,0,1,1,1,1,1,1,1,0,1,1,1,0,0,1,1,1,1,1,1,1,0,1,0,1,0,1,0,0,0,1,0,0,1,1,1,1,1,1},
{0,0,0,0,0,0,0,1,0,1,0,0,0,1,0,0,1,0,0,0,0,0,1,0,1,0,0,0,0,0,0,0,1,0,0,0,0,0,0,1,1},
{0,0,0,0,0,0,0,1,0,1,1,1,0,1,1,1,1,0,1,1,1,0,1,0,1,1,1,1,1,1,1,1,1,1,1,1,0,1,0,1,1},
{0,0,0,0,0,0,0,1,0,0,0,1,0,0,0,0,0,0,1,0,0,0,1,0,1,0,0,0,0,0,0,1,0,0,0,0,0,1,0,1,1},
{0,0,0,0,0,0,0,1,0,1,1,1,1,1,1,1,1,1,1,0,1,1,1,0,1,0,1,0,1,1,1,1,0,1,1,1,1,1,0,1,1},
{0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,1,0,0,0,0,0,0,1,0,0,0,0,0,1,1},
{0,0,0,0,0,0,0,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1},
{1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1}
};
int pacX=2, pacY=19, VX=0, VY=-1;
void pacWalk(){
  if( map[pacY+VY][pacX+VX]==0 ){
    pacX+=VX;
    pacY+=VY;
  }
}
void setup(){
  size(1024, 677);
  p[0]=loadImage("p1.png");
  p[1]=loadImage("p2.png");
  Map=loadImage("Map.png");
  money=loadImage("money.png");
  word=loadImage("word.png");
  End=loadImage("End.png");
}
int stage=0;
float W=24.78,H=23.8,x0=4,y0=6;
void draw(){
  if(stage==0){
    background(0);
    image(word,300,300);
    fill(0);
    rect(50,0,pX,height);
    if(pID==1) image(p[0], pX,pY,250,164);
    else image(p[1], pX,pY,250,164);
    if(frameCount%10==0){
      pID=(pID+1)%2;
      pX+=40;
      if(pX>1000) stage=1;
    }
  }
  if(stage==1){
    background(0);
    image(Map,0,0);//,width,height);
    image(p[0], x0+pacX*W, y0+pacY*H,W,H);
    if(frameCount%10==0){
      pacWalk();
    }
    if( pacX==34 && pacY==7 ){
      stage=3;
    }
  }
  if(stage==3){
    image(End,-20,0);
  }
}
void keyPressed(){
  if(keyCode==UP){ VX=0; VY=-1;}
  if(keyCode==DOWN){ VX=0; VY=+1;}
  if(keyCode==LEFT){ VX=-1; VY=0;}
  if(keyCode==RIGHT){ VX=+1; VY=0;}
}

alanhc 互動技術-week17 [final]

回顧這學期的作品:  期中作業:LANDING:PLANET 賣點&特點: 炫麗的特效 物理(星球重力及降落)及粒子系統(噴射) 世界地圖可根據視角縮放 困難點: 重寫3次最終改寫成物件導向的CLASS寫法...