【求助】按照Learning Processing上的教程来,但是有错误
processing吧
全部回复
仅看楼主
level 1
祈明行 楼主
2016年03月02日 07点03分 1
level 1
祈明行 楼主
float x =100;
float y =100;
float w =60;
float h =60;
float eyeSize = 16;
void setup () {
size (500,500);
}
void draw () {
background (255);
//color depends on the distance
float d = dist (x,y,mouseX, mouseY);
color c = color (d);
//decide the movement of Zoog
float factor = constrain (mouseX/10, 0,5);//change in 0 to 5
//give the definitions to Zoog, don't put it into draw, or it changes before open the procedure
jiggleZoog (factor);
drawZoog (c);
//define the jiggle and draw
void jiggleZoog (float speed) {
x = x +random (-1,1) * speed;
y = y +random (-1,1) * speed;
x = constrain (x,0,width);
y = constrain (y,0,height);
}
void drawZoog (color eyeColor) {
ellipseMode (CENTER);
rectMode (CENTER);
//arms
for (float i = y-h*3; i<y +h/2; i +=10) {
stroke (0);
line (x -w/4,i,x+w/4,i);
}
//body
stroke (0);
fill(255);
rect(x,y,w/6,h);
//head
stroke(0);
fill(255);
ellipse (x,y-h,w,h);
//eyes
fill (eyeColor);
ellipse (x-w/3,y-h,eyeSize, eyeSize*2);
ellipse (x+w/3,y-h,eyeSize, eyeSize*2);
//legs
stroke (0);
line(x-w/12, y+h/2, x-w/4, y+h/2+10);
line(x+w/12, y+h/2, x+w/4, y+h/2+10);
}
}
2016年03月02日 07点03分 2
不知道为什么总是出现unexpected token:void的提示,请问是什么意思?因为书上的代码就是这样的,所以也不知道哪里错了
2016年03月02日 07点03分
level 5
诸如 void jigglezoog() {
;;;;;;
}
这些void 开头的是函数,都不能放在 void draw() { ;;;;;;}里面, 要放在外面
2016年03月02日 09点03分 4
出现unexpected token:()怎么办啊
2020年09月24日 18点09分
level 3
楼主,请问这本书哪里有,有电子版吗?
2016年03月12日 16点03分 5
1