We closed this forum 18 June 2010. It has served us well since 2005 as the ALPHA forum did before it from 2002 to 2005. New discussions are ongoing at the new URL http://forum.processing.org. You'll need to sign up and get a new user account. We're sorry about that inconvenience, but we think it's better in the long run. The content on this forum will remain online.
IndexProgramming Questions & HelpPrograms › Trouble getting simple program to start
Page Index Toggle Pages: 1
Trouble getting simple program to start (Read 774 times)
Trouble getting simple program to start
Apr 10th, 2010, 9:04pm
 
Hello all. I've gone through this code several times, looking for the slightest typo or syntax mistake, yet come up dry. Any help would be more than appreciated.

Code:

Penguin penguin;
Penguin penguin2;

float thetapenguin = 0;

void setup() {
size(800,600,P3D);
smooth();

penguin = new Penguin(50);
penguin2 = new Penguin(-50);
}

void draw() {
background(255);

penguin.display();
penguin2.display();

penguin.move();
penguin2.move();
}


Class:

Code:

Class Penguin {
float xpos;

Penguin(float xpos_) {
xpos = xpos_;
}

void display() {
fill(0,0,125);

pushMatrix();
translate(width/2,height/2,0);
rotateX(thetapenguin);

ellipse(width/2-xpos,height/2,50,50);
ellipse(width/2+xpos,height/2,50,50);
}

void move() {
thetapenguin+=.02;
popMatrix();
}
}


Re: Trouble getting simple program to start
Reply #1 - Apr 10th, 2010, 9:15pm
 
You have pushMatrix() in the display method...but popMatrix() is in the move method... these should both be in the display method, I think.
Re: Trouble getting simple program to start
Reply #2 - Apr 10th, 2010, 9:31pm
 
That was a good idea, but still no luck. I'm getting an "unexpected token: Penguin" error, while the "error line" consists of my { and } in my void draw() { function.

I mean this (in bold):

Code:

void draw() [b]{[/b]
 background(255);

 penguin.display();
 penguin2.display();

 penguin.move();
 penguin2.move();
[b]}[/b]


Edit: I see bold doesn't work within coding. But at least you're able to see where it leads me to when I try to run my program.
Re: Trouble getting simple program to start
Reply #3 - Apr 11th, 2010, 1:35am
 
That's class, not Class.
(I had to triple check to see it... Smiley)
Re: Trouble getting simple program to start
Reply #4 - Apr 11th, 2010, 10:43am
 
Thanks! It is now running. But when the program starts, I don't see anything, just a white (background is white) screen. My penguin-in-progress isn't printing off screen is it?

And when I go to exit the program, it takes three or four clicks of the 'x'.  Huh
Re: Trouble getting simple program to start
Reply #5 - Apr 11th, 2010, 3:15pm
 
You do a translate, so basically you should draw at 0, 0 since the translate moved that point to the center of the window.
Page Index Toggle Pages: 1