We are about to switch to a new forum software. Until then we have removed the registration on this forum.
Is there any way to pass a value from setup() to draw() without using global variables? I'm not an expert by any means, I probably wouldn't even pass for an intermediate level programmer, but I've always read that excessive use of global variables was poor programming practice.
Thanks...
Answers
well, setup() and draw() are actually methods in the same class - the preprocessor wraps them in a class definition as part of the compile* - so 'global' variables aren't really global, but class members.
(* export one of your programs and then look in the created directory. there'll be a .java file created from your .pde where you can see the bits that have been added)
Cool- I did what you said and I see how it works, so I guess it's a matter of perspective.
So, looking at the exported source and trying to understand it, what is making the draw() method loop indefinitely?
When a sketch starts, method PApplet.main() is invoked from within main().
When all is set, it invokes our custom setup().
Then keeps calling draw() and other triggered event custom functions indefinitely!
That is called callback functions. >:)