level 7
proces😍
楼主
1、只运行一次的方法 void setup() {}
2、运行多次的方法 void draw() {}
3、点击键盘运行的方法 void keyPressed(){}
4、点击鼠标的方法 void mousePressed(){}
5、鼠标X的坐标 mouseX
6、鼠标Y的坐标 mouseY
7、鼠标X的上一个坐标 pmouseX
8、鼠标Y的上一个坐标 pmouseY
9、键盘按键字母 key
10、功能键上下左右 keyCode等于(UP/DOWN/LEFT/RIGHT)
11、鼠标的作用键 mouseButton 等于 LEFT\CENTER\RIGHT
12、窗体的宽高 width height
13、条件语句 if(){}
作品跳跳球,一个小球运到窗体,背景边框填充的颜色发生变化。
float x, y, xset, yset;
color bg, fi, st;
void setup() {
size(500, 500);
changColor();
x = width/2;
y = height/2;
xset = random(-5, 5);
yset = random(-5, 5);
}
void changColor(){
bg =color(random(255), random(255), random(255));
fi =color(random(255), random(255), random(255));
st =color(random(255), random(255), random(255));
}
void draw() {
background(bg);
fill(fi);
stroke(st);
ellipse(x, y, 50, 50);
x = x+xset;
y = y+yset;
if (x<0||x>width) {
xset = -xset;
changColor();
}
if (y<0||y>height) {
yset = -yset;
changColor();
}
}
2020年12月21日 15点12分
1
2、运行多次的方法 void draw() {}
3、点击键盘运行的方法 void keyPressed(){}
4、点击鼠标的方法 void mousePressed(){}
5、鼠标X的坐标 mouseX
6、鼠标Y的坐标 mouseY
7、鼠标X的上一个坐标 pmouseX
8、鼠标Y的上一个坐标 pmouseY
9、键盘按键字母 key
10、功能键上下左右 keyCode等于(UP/DOWN/LEFT/RIGHT)
11、鼠标的作用键 mouseButton 等于 LEFT\CENTER\RIGHT
12、窗体的宽高 width height
13、条件语句 if(){}
作品跳跳球,一个小球运到窗体,背景边框填充的颜色发生变化。
float x, y, xset, yset;
color bg, fi, st;
void setup() {
size(500, 500);
changColor();
x = width/2;
y = height/2;
xset = random(-5, 5);
yset = random(-5, 5);
}
void changColor(){
bg =color(random(255), random(255), random(255));
fi =color(random(255), random(255), random(255));
st =color(random(255), random(255), random(255));
}
void draw() {
background(bg);
fill(fi);
stroke(st);
ellipse(x, y, 50, 50);
x = x+xset;
y = y+yset;
if (x<0||x>width) {
xset = -xset;
changColor();
}
if (y<0||y>height) {
yset = -yset;
changColor();
}
}