Loading...
Logo
Processing Forum

3 questions about objects

in General Discussion  •  Other  •  1 year ago  
Hey,

How do I make multiple objects form the same class, if I want to make a million, without having to write the same thing a million times over and over?

How can I get them to not overlap each other?

And how can I get them to bounce off things like, rect() and ellipse()  ?
I'm using a white background with black ellipses and rectangels, maybe this helps..


I'm working with Vec3D, so please keep that in mind ^_^

Thanks in advance!

Replies(2)

You can use an array or arraylist to hold the objects. Then for your code it won't matter if there are 10 or a million objects. Search the forum for arraylist, there are many runnable code examples that use an arraylist to hold multiple objects.

Not overlapping and bouncing can be done through collision detection.

Also check out the examples that come with Processing for example in Topics > Motion.