顯示具有 08160112_孟慶杰 標籤的文章。 顯示所有文章
顯示具有 08160112_孟慶杰 標籤的文章。 顯示所有文章

2022年1月17日 星期一

期末作業完成week14

 期末作業完成:






Youtube連結:電流急急棒 - YouTube

程式碼:

PImage ball,maze,gem;

int[] rangeX = {0,125};

int[] rangeY = {480,235};


int ballposX = 30,ballposY = 215;

int offsetX = 0,offsetY = 0;


boolean is_over = false;

boolean is_win = false;


void setup()

{

  size(640,480);

  maze=loadImage("maze.png");

  ball=loadImage("ball.png");

  gem=loadImage("gem.png");

}

void draw()

{

  

  

  background(255);

  imageMode(CENTER); 

  image(maze,320,240);

  image(gem,590,415);

  image(ball,ballposX,ballposY);

  

  if(is_over && !is_win)

  {

    GameOver();

  }

  

  if(is_win)

  {

    Win();

  }

}


void mousePressed()

{

  offsetX = ballposX - mouseX;

  offsetY = ballposY - mouseY;

}


void mouseDragged()

{

  if(!is_over)

  {

    ballposX = offsetX + mouseX;

    ballposY = offsetY + mouseY;

  }

  

  detCollision();

  


}


void GameOver()

{

  textAlign(CENTER);

  textSize(100);

  fill(0);

  text("Game Over",320,240);

}


void Win()

{

  textAlign(CENTER);

  textSize(100);

  fill(0);

  text("Victory",320,240);

}


void detCollision()

{

   //左下

  if(ballposX-13 > 0 && ballposX-13 < 125 && ballposY+13 > 235)

  {

    is_over = true;

  }

  if(ballposX-13 > 0 && ballposX-13 < 125 && ballposY-13 > 235)

  {

    is_over = true;

  }

  if(ballposX+13 > 0 && ballposX+13 < 125 && ballposY+13 > 235)

  {

    is_over = true;

  }

  if(ballposX+13 > 0 && ballposX+13 < 125 && ballposY-13 > 235)

  {

    is_over = true;

  }

  

  //左上

  if(ballposX-13 > 0 && ballposX-13 < 125 && ballposY+13 < 195)

  {

    is_over = true;

  }

  if(ballposX-13 > 0 && ballposX-13 < 125 && ballposY-13 < 195)

  {

    is_over = true;

  }

  if(ballposX+13 > 0 && ballposX+13 < 125 && ballposY+13 < 195)

  {

    is_over = true;

  }

  if(ballposX+13 > 0 && ballposX+13 < 125 && ballposY-13 < 195)

  {

    is_over = true;

  }

  

  //右上

  if(ballposX+13 > 515 && ballposX+13 < 640 && ballposY-13 < 395)

  {

    is_over = true;

  }

  if(ballposX+13 > 515 && ballposX+13 < 640 && ballposY+13 < 395)

  {

    is_over = true;

  }

  if(ballposX+13 > 515 && ballposX+13 < 640 && ballposY-13 < 395)

  {

    is_over = true;

  }

  if(ballposX-13 > 515 && ballposX-13 < 640 && ballposY-13 < 395)

  {

    is_over = true;

  }

  

  //中上

  if(ballposX+13 > 125 && ballposX+13 < 515 && ballposY-13 < 45)

  {

    is_over = true;

  }

  if(ballposX-13 > 125 && ballposX-13 < 515 && ballposY-13 < 45)

  {

    is_over = true;

  }

  

  //中下

  if(ballposX+13 > 125 && ballposX+13 < 640 && ballposY+13 > 435)

  {

    is_over = true;

  }

  if(ballposX-13 > 125 && ballposX-13 < 640 && ballposY-13 > 435)

  {

    is_over = true;

  }

  

  //左下2

  if(ballposX+13 > 125 && ballposX+13 < 275 && ballposY+13 > 285)

  {

    is_over = true;

  }

  if(ballposX-13 > 125 && ballposX-13 < 275 && ballposY+13 > 285)

  {

    is_over = true;

  }

  if(ballposX-13 > 125 && ballposX-13 < 275 && ballposY-13 > 285)

  {

    is_over = true;

  }

  

  //右下2

  if(ballposX+13 > 275 && ballposX+13 < 475 && ballposY+13 > 385)

  {

    is_over = true;

  }

  if(ballposX-13 > 275 && ballposX-13 < 475 && ballposY+13 > 385)

  {

    is_over = true;

  }

  if(ballposX-13 > 275 && ballposX-13 < 475 && ballposY-13 > 385)

  {

    is_over = true;

  }

  

  //右下2上面的

  if(ballposX+13 > 416 && ballposX+13 < 475 && ballposY-13 > 235)

  {

    is_over = true;

  }

  if(ballposX+13 > 416 && ballposX+13 < 475 && ballposY+13 > 235)

  {

    is_over = true;

  }

  if(ballposX-13 > 416 && ballposX-13 < 475 && ballposY+13 > 235)

  {

    is_over = true;

  }

  

  //中間

  if(ballposX+13 > 165 && ballposX+13 < 376 && ballposY-13 > 85 && ballposY-13 < 245)

  {

    is_over = true;

  }

  if(ballposX+13 > 165 && ballposX+13 < 376 && ballposY+13 > 85 && ballposY+13 < 245)

  {

    is_over = true;

  }

  if(ballposX-13 > 165 && ballposX-13 < 376 && ballposY+13 > 85 && ballposY+13 < 245)

  {

    is_over = true;

  }

  if(ballposX-13 > 165 && ballposX-13 < 376 && ballposY+13 > 85 && ballposY-13 < 245)

  {

    is_over = true;

  }

  

  //中間右

  if(ballposX+13 > 376 && ballposX+13 < 475 && ballposY-13 > 85 && ballposY-13 < 195)

  {

    is_over = true;

  }

  if(ballposX+13 > 376 && ballposX+13 < 475 && ballposY+13 > 85 && ballposY+13 < 195)

  {

    is_over = true;

  }

  if(ballposX-13 > 376 && ballposX-13 < 475 && ballposY+13 > 85 && ballposY+13 < 195)

  {

    is_over = true;

  }

  if(ballposX-13 > 376 && ballposX-13 < 475 && ballposY+13 > 85 && ballposY-13 < 195)

  {

    is_over = true;

  }

  

  //中間右下

  if(ballposX+13 > 315 && ballposX+13 < 376 && ballposY-13 > 245 && ballposY-13 < 345)

  {

    is_over = true;

  }

  if(ballposX+13 > 315 && ballposX+13 < 376 && ballposY+13 > 245 && ballposY+13 < 345)

  {

    is_over = true;

  }

  if(ballposX-13 > 315 && ballposX-13 < 376 && ballposY+13 > 245 && ballposY+13 < 345)

  {

    is_over = true;

  }

  if(ballposX-13 > 315 && ballposX-13 < 376 && ballposY+13 > 245 && ballposY-13 < 345)

  {

    is_over = true;

  }

  

  //寶石

  if(ballposX > 579 && ballposX < 601 && ballposY > 409 && ballposY < 421)

  {

    is_win = true;

    is_over = true;

  }

  if(ballposX > 579 && ballposX < 601 && ballposY > 409 && ballposY < 421)

  {

    is_win = true;

    is_over = true;

  }

  if(ballposX > 579 && ballposX < 601 && ballposY > 409 && ballposY < 421)

  {

    is_win = true;

    is_over = true;

  }

  if(ballposX > 579 && ballposX < 601 && ballposY > 409 && ballposY < 421)

  {

    is_win = true;

    is_over = true;

  }

  }


2021年11月29日 星期一

2021年11月22日 星期一

互動概論week07

1.讓球可以向下掉











2.做出兩組球向下掉











3.利用for迴圈,做出很多組











4.撞到下方或上方時,速度會改變,變成另一個方向











5.碰到的話,讓球停下











6.碰到球後,讓球消失











7.熟悉布林變數










8.用陣列增加球的數量










9.隨機製造出球,碰到滑鼠消失










10.同上,但稍微做些改變










11.做出一個簡單的小遊戲




2021年11月15日 星期一

互動概論Week06

 1.寫出Hello











2.用出類似計時器的東西











3.millis()除以1000可知道準確的秒數











4.hour() minute() second() 可以做出簡單的時鐘











5.這行程式碼可以秀出可用的字型











6.打出中文











7.藉由滑鼠點擊切換字體











8.String的函式:nf(),能將小時、分鐘、秒鐘,都用補0的方法變成2位











9.現在時間+下課時間+倒數時間











10.現在時間+下課時間+倒數時間(分:秒)











11.將圖片讀入,用出圖片











12.計時器加上圖片




2021年11月1日 星期一

互動設計week05

 1.安裝video










2.Library-video-movie-loop 讓他跑看看











3.開新檔案打程式,把launbch2.mp4拉過來










4.camera(沒有鏡頭)









5.存檔









6.讀檔










7.用for(迴圈)來改pixels[]裡的值,再利用updatePixels()把pixels[]更新到畫面中










8.改顏色










9.影片暫停



2021年10月25日 星期一

互動概論week04

 1.畫出棋盤的直線











2.用陣列畫出直線










3.用陣列完成棋盤










4.用陣列畫格子










5.用陣列畫出棋子










6.用滑鼠畫出棋子











7.調整棋子,變得準確











8.畫出黑棋和白棋











9.畫出一個圓











10.多重圓圈












11.用滑鼠變色多重圓圈











2021年10月18日 星期一

互動概論week03

 1.讀入圖片











2.改圖大小










3.讀入兩張圖片











4.將小圖去背











5.將圖片對準滑鼠正中心




6.利用imageMode(CENTER)讓圖片置中




7.安裝











8.讀入聲音











9.播放兩個聲音











10.do,re,mi,fa,so