Forum

OOP in vvvv?

This question leads toward an programming technique I am familiar with it from Java.
Now I want to know if the same thing is possible in vvvv, too.

The thing I want to do is the following:

  1. Create a class (a grafical object).
  2. Create Members(Objects) of the Class and spread them on screen.

You can archieve tis by e.g. having abox (1.) and spreading it on screen (2.)
BUT: I want to have Objects of a class that have some initial parameters INSIDE and that follow its own beat. Example: I want to create a Quad. Every Quad should blink in its own frequency. The frequency is set at generation. Now every quad blinks at its own given frequency. i.e. quad1 = every 20 frames, quad2 = every 30 frames etc…

Is it possible to implement such kind of programming to vvvv?

To illustrate the program. If you are familiar with processing(java):

Blink blink_array;
int num = 0;

void setup() {
size(160,140,P3D);
framerate(40);
background(255);
blink_array = new Blink36;
for (int i = 0; i < 6; i++) {
for (int j = 0; j < 5; j++) {
blink_arraynum = new Blink(i, j);
num++;
}
}
}

void draw() {
for (int i = 0; i < 30; i++) {
blink_arrayi.go();
}
}

class Blink {
int binit = (int)random(32)+5;
int brate = binit;
int x, y;

Blink (int i, int j) {
x = i;
y = j;
println(“X:”+x);
println(“Y:”+y);
}

void go()
{
brate–;
if (brate < 0) {
brate = binit;
fill(0);
} else {
fill(255);
}
rect(x20+20, y20+20, 17, 17);
}
}

should be possible, creat a subpatch which includes all parameters of your class, make input pins for the parameters and send spreads to them …

here a demo patch that does similar patterns like your p5 code …

bug in patch … deleted

bug in the patch, renderer in patch doesn’t initialize, try this:

VVVV_OOP.zip (2.9 kB)

Thinks a lot. Does the work perfectly.

I think I have to re-think patching. In Java all was thinking from “inside-out”. In vvvv all is “outside-in”.