Problem with class
in
Programming Questions
•
5 months ago
I am new to Processing and I can't find the reason why my code cannot enter the class....
Here's the whole code:
- float x = 159, y = 158, d1 = 30, d2 = 30;
- boolean enter;
- int i2=0, j2=0;
- void setup() {
- size(700, 700);
- background(255, 255, 255);
- polygon(12, 350, 350, 300);
- polygon(12, 350, 350, 260);
- fill(252, 175, 8);
- ellipse(x, y, d1, d2);
- }
- void polygon(int n, float cx, float cy, float r)
- {
- println("polygon");
- float angle = 360/n;
- beginShape();
- if (r == 300) {
- fill(208);
- }
- else fill(255, 255, 255);
- for (int i = 0; i < n; i++)
- {
- vertex(cx + r * cos(radians(angle * i)),
- cy + r * sin(radians(angle * i)));
- }
- endShape(CLOSE);
- }
- class Sphere
- {
- float x;
- float y;
- int d1;
- int d2;
- Sphere(float x, float y, int d1, int d2) {
- x = 159;
- y = 158;
- d1 = 30;
- d2 = 30;
- }
- void draw() {
- println("draw");
- fill(252, 175, 8);
- ellipse(159, 158, 30, 30);
- move();
- display();
- }
- void move () {
- println("move");
- if (mousePressed) {
- for (int i = i2; i < 12; i++) {
- delay(300);
- i2 = i;
- x = 350 + 280 * cos(radians(30 * i));
- y = 350 + 280 * sin(radians(30 * i));
- for (int j = j2; j < sqrt(pow(x,2)+pow(y,2)); j++) {
- j2 = j;
- x = x+1.5;
- y = y+1;
- }
- }
- }
- }
- void display() {
- println("display");
- fill(252, 175, 8);
- ellipse(x, y, d1, d2);
- }
- }
As you can see I have put a
println after each void so that I can know which void it actually goes to. The problem is that the program does not write draw or move or display.
Any help is appreciated !!!
1