Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Particle[] particles = new Particle[10]; // an array of objects from the Particle class
- void setup() {
- size(500, 500);
- for (int i=0; i<particles.length; i++) {
- float x = i*50; // based on your example
- float y = i*20; // I made something up
- particles[i] = new Particle(x,y); // create new objects of the Particle kind
- }
- }
- void draw() {
- background(255);
- for (int i=0; i<particles.length; i++) {
- particles[i].paint(); // draw the Particle objects
- }
- }
- class Particle {
- float x, y;
- float sz = 10;
- Particle(float _x, float _y) {
- x = _x;
- y = _y;
- }
- void paint() {
- ellipse(x, y, sz, sz);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement