학생 작품 예제-mouse position
void setup(){
size(900,600);
smooth();
noStroke();
}
int i;
void draw(){
background(121,171,255);
fill(160,186,237);
rect(0,0,900,400);
fill(196,222,255);
rect(0,0,900,350);
fill(214,240,255);
rect(0,0,900,300);
fill(232,255,255);
rect(0,0,900,150);//sky
fill(255,228,0);
ellipse(mouseX,mouseY,70,70);
fill(255,255,54);
ellipse(mouseX,mouseY,50,50);//sun with mouse
fill(120);
rect(75,200,50,500,6,6,0,0);
fill(140);
rect(230,200,50,500,6,6,0,0);
fill(120);
rect(150,250,100,500,6,6,0,0);
rect(275,245,50,500,6,6,0,0);
rect(400,185,50,500,6,6,0,0);
rect(690,500,60,500,6,6,0,0);
fill(130);
rect(325,210,50,500,6,6,0,0);
rect(650,350,50,500,6,6,0,0);//background building
fill(91);
rect(0,350,100,500,9,9,0,0);
rect(105,100,100,500,9,9,0,0);
rect(350,400,100,500,9,9,0,0);
fill(100);
rect(450,150,100,500,9,9,0,0);
fill(98);
rect(550,300,100,500,9,9,0,0);
fill(94);
rect(750,400,100,500,9,9,0,0);//front building
fill(45,0,0);
rect(0,550,900,600);
fill(93,31,0);
rect(0,550,900,5);//ground
fill(225);
rect(i,550,10,10);
rect(i+10,540,15,20);
rect(i+25,550,10,10);//car1
rect(i+60,550,10,10);
rect(i+70,540,15,20);
rect(i+85,550,10,10);//car2
rect(i+120,550,10,10);
rect(i+130,540,15,20);
rect(i+145,550,10,10);//car3
rect(i+180,550,10,10);
rect(i+190,540,15,20);
rect(i+205,550,10,10);//car4
i=i+2;
if(i>width)i=0;//cars speed
}
void mouseMoved(){
fill(255,198,198);
ellipse(mouseX,mouseY,70,70);
fill(255,48,48);
ellipse(mouseX,mouseY,50,50); //if mouse moved sun will change red
}
댓글 없음:
댓글 쓰기