2020年3月27日 星期五

南崁金城武-Week04

今天先寫了按滑鼠會有點點的
PImage BG;
int []x={0,0,0,0,0};
int []y={0,0,0,0,0};
int n=0;
void setup()
{
    size(768,1280);
    BG=loadImage("back.png");
}
void draw()
{
    background(BG);
    for(int i=0;i<5;i++)
    {
        circle( x[i],y[i],40);
    }
}
void mousePressed ()
{
    x[n]=mouseX;
    y[n]=mouseY;
    n=(n+1)%5;
}

後來又寫了個圖像陣列


更新了點點 讓他按著會變大
PImage BG;
int []x={0,0,0,0,0};
int []y={0,0,0,0,0};
int []r={5,5,5,5,5};
int n=0;
void setup()
{
    size(768,1280);
    BG=loadImage("back.png");
}
void draw()
{
    background(BG);
    for(int i=0;i<5;i++)
    {
        circle( x[i],y[i],r[i]);
        if(mousePressed) r[now]++;
    }
    
}
int now=0;
void mousePressed ()
{
    x[n]=mouseX;
    y[n]=mouseY;
    r[n]=5;
    now=n;
    n=(n+1)%5;
}


沒有留言:

張貼留言