2019年9月19日 星期四

week02_


今天要做的是在卡片上面打洞的互動程式

這是隨著滑鼠移動打洞


畫個格子


 │  size(800,300);                                  
    for(int x=0;x<800;x+=16){            
       for(int y=0;y<300;y+=30){         
        rect(x,y,16,30);                           
       }

     }




成品

void setup(){
  size(800,300);
  for(int x=0;x<800;x+=16){
    for(int y=0;y<300;y+=30){
      rect(x,y,16,30);
    }
  }
}
void draw(){
  
  int nowX=mouseX/16*16, nowY=mouseY/30*30;
  if(mousePressed && mouseButton==LEFT){     ///控制滑鼠左鍵填色
  fill(0);
  rect(nowX,nowY,16,30); 
  //rect(mouseX,mouseY, 50,20);
  }
  else if(mousePressed && mouseButton==RIGHT){   ///控制滑鼠右鍵把畫錯的格子恢復顏色
    fill(255);
    rect(nowX,nowY,16,30);
  }
}


放圖片
size(500,500);
PImage img=loadImage("maxresdefault.jpg");
image( img, 0,0,200,200);




PImage img;
void setup(){
  size(500,500);
  img=loadImage("maxresdefault.jpg");
}
void draw(){
  image( img, mouseX,mouseY, 200,200);
}

沒有留言:

張貼留言

alanhc 互動技術-week17 [final]

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