Skip to content

Commit 473a340

Browse files
committed
make the oscillation different for each object
Add a range variable to Egg to make the oscillation different for each object Fixes processing#3
1 parent f31275a commit 473a340

File tree

2 files changed

+10
-7
lines changed

2 files changed

+10
-7
lines changed

Basics/Objects/CompositeObjects/CompositeObjects.pde

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,13 +11,13 @@ EggRing er1, er2;
1111

1212
void setup() {
1313
size(640, 360);
14-
er1 = new EggRing(width*0.45, height*0.5, 0.1, 120);
15-
er2 = new EggRing(width*0.65, height*0.8, 0.05, 180);
14+
er1 = new EggRing(width*0.45, height*0.5, 2, 120);
15+
er2 = new EggRing(width*0.65, height*0.8, 10, 180);
1616
}
1717

1818

1919
void draw() {
2020
background(0);
2121
er1.transmit();
2222
er2.transmit();
23-
}
23+
}

Basics/Objects/CompositeObjects/Egg.pde

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,18 +3,21 @@ class Egg {
33
float tilt; // Left and right angle offset
44
float angle; // Used to define the tilt
55
float scalar; // Height of the egg
6+
float range;
67

78
// Constructor
8-
Egg(float xpos, float ypos, float t, float s) {
9+
Egg(float xpos, float ypos, float r, float s) {
910
x = xpos;
1011
y = ypos;
11-
tilt = t;
12+
tilt = 0;
1213
scalar = s / 100.0;
14+
range = r;
1315
}
1416

1517
void wobble() {
16-
tilt = cos(angle) / 8;
18+
tilt = cos(angle) / range;
1719
angle += 0.1;
20+
//print (angle + "-");
1821
}
1922

2023
void display() {
@@ -33,4 +36,4 @@ class Egg {
3336
endShape();
3437
popMatrix();
3538
}
36-
}
39+
}

0 commit comments

Comments
 (0)