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.
IndexDiscussionExhibition › First sketch; Started off on the right foot
Page Index Toggle Pages: 1
First sketch; Started off on the right foot? (Read 873 times)
First sketch; Started off on the right foot?
Oct 17th, 2007, 11:04pm
 
I'm not sure this is the right place to start this topic, so please correct me if it belongs somewhere else.

This here is my first try at some OOP like stuff in processing.
I'm used to actionscript, in which you can assign a onEnterFrame event (like the void draw() function) to each object you've got. Since processing doesn't work that way, I had to think of an other way to tell my objects what to do.

I started with something easy; I've got 5 images which move around the screen, and when they have reached their goal, they will move somewhere else. You can also force new targets by pressing your left mouse button.

I know this isn't much, but I would like some critique on my code; I don't want to start using processing the wrong way.

So please take a look at my code and tell me if I did anything stupid :p

The app itself (along with the code) can be found here:
http://www.jaspervanloenen.com/processing/
Re: First sketch; Started off on the right foot?
Reply #1 - Oct 18th, 2007, 7:39am
 
looks ok.

you are getting to a point where you should think about making a class / object for your moving numbers. this way you could avoid all those loose bits and pieces (variables) floating around in your code.

you mentioned onEnterFrame, another thing that an object would allow is that each object could have it's own drawing function. something like it's personal onEnterFrame ... all you have to do for that is call all these on the objects in draw().

void draw()
{

for ( int i = 0; i < myObjsArray.length; i++ ) {
   myObjsArray[i].drawIt();
}

}

F
Re: First sketch; Started off on the right foot?
Reply #2 - Oct 18th, 2007, 6:07pm
 
Thank you. It worked. That's a lot more efficient Smiley
New try
Reply #3 - Oct 28th, 2007, 1:32pm
 
Thanks again for the help; I learned how classes work :) so I've made a new version of my first try.

This one represents my concentration: I'm always doing a lot of things at the same time, but sometimes I really bite into something and won't let go for a while. And then my concentration slips again and I start doing other things :p

You might have to wait a minute to see what I mean.

And yes... I do know it looks like frog eggs :p

http://www.jaspervanloenen.com/processing/concentration2.html
Page Index Toggle Pages: 1