-
Notifications
You must be signed in to change notification settings - Fork 3
/
Butterfly.pde
52 lines (45 loc) · 982 Bytes
/
Butterfly.pde
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
class Butterfly{
float posX;
float posY;
int speed;
int ang;
int flapSpeed = 25;
int flap = 1;
int w = 20;
Butterfly(){
this.posX = width/2+random(0,100);
this.posY = height/2+random(0,100);
this.speed = 5;
this.ang = 0;
}
void move(int moveX, int moveY){
pushMatrix();
posX = sin(radians(ang))*60+moveX;
posY = cos(radians(ang))*30+moveY;
ang++;
translate(posX,posY);
noStroke();
lights();
fill(200,250);
sphere(3);
popMatrix();
flap = flap + flapSpeed;
pushMatrix();
translate(posX,posY,-w/2);
rotateX(radians(90));
rotateY(sin(radians(flap)));
// rect(0,0, w, w);
fill(255,230);
ellipseMode(CORNER);
ellipse(0,0, w, w);
popMatrix();
pushMatrix();
translate(posX,posY,-w/2);
rotateX(radians(90));
rotateY(sin(radians(flap))* -1);
fill(255,230);
ellipseMode(CORNER);
ellipse(-w,0, w, w);
popMatrix();
}
}