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 › Question on Space Junk.
Page Index Toggle Pages: 1
Question on Space Junk. (Read 396 times)
Question on Space Junk.
Dec 4th, 2007, 1:31am
 
I'm new to processing and I'm trying to understand some of the examples. The one I'm most interested in is Space Junk.

I'm a little confused on how for loops work and what part of the program is working with the mouse.

What's the best way to understand a program like this? Go though it step, by step, looking everything up?

Can someone fill me in on the color coding? How do I tell the difference between a user defined variable and a function.

Re: Question on Space Junk.
Reply #1 - Dec 4th, 2007, 3:10am
 
hi triscuit,

space junk is a somewhat advanced example, since it uses a class and is 3D.

with regard to your questions:
• the for loop in setup() is used to create (or more precisely instantiate) the cubes (as object data in memory only)
• the for loop in draw() draws the cubes
– if I only created one cube, I wouldn't need the for loops, as they are just used to process the multiple cubes.
• in general the color coded stuff is part of the language, not the stuff the user defines.
• the mouse position (only x component) is just used for the z argument in the translate(x, y, z) function call, which zooms in/out as you move left/right.


If you're really new to this stuff, I'd suggest working through the examples in the basics section and spending some time exploring the language reference.  You might also want to pick up one of the/both Processing books, which explain in detail about things such as variables, loops, etc.

have fun.
ira
Page Index Toggle Pages: 1