# Intuition Test

Hi devs.

I’d like to set you and everyone else a little challenge. It comes from Daniel Shiffman’s “The nature of code” website.

Using VL I would like to see how easily people can mimic the code below (its from processing):

``````float x = 100;
float y = 100;
float xspeed = 1;
float yspeed = 3.3;

void setup() {
size(640,360);
background(255);
}

void draw() {
background(255);

//Move the ball according to its speed.

x = x + xspeed;
y = y + yspeed;

//Check for bouncing.

if [| (x < 0](https://vvvv.org/documentation/x->-width)) {
xspeed = xspeed * -1;
}
if [| (y < 0](https://vvvv.org/documentation/y->-height)) {
yspeed = yspeed * -1;
}

stroke(0);
fill(175);

//Display the ball at the location (x,y).

ellipse(x,y,16,16);
}
``````

The setup and draw stuff isn’t so important but this is or should be a relatively straight forward task:

``````//assign x to to something, perhaps an input. Then
x = x + xspeed
//and then set the xspeed
if [x > width) OR (x < 0](https://vvvv.org/documentation/x->-width)-OR-(x-<-0) xspeed = xspeed * -1
``````

The two parts are able to influence eachother, something, the sort of chaining that is difficult to get from vvvv and one of my the hopes for VL. In vvvv there are are a few hoops to jump through for this example but the code is also fairly simple.

Yet in VL I haven’t identified a straight forward way to do this, by which I mean a way that is as intuitive as make my input (from ‘Update’) mutable and adding it to itself.

The actual node graph at the end looks fairly sort of readable but arriving at the solution is currently suprisingly time-consuming.

One could argue, reasonably, that it is a matter of getting used to the language and that the strangeness of some of its features will become a distant memory, but so far I keep tripping over issues such as above: its very much the norm in my experience of VL. I could do with more examples or more documentation, but examples such as the one above should be pretty easy regardless.

Yours,

Saucy guest

Okay,

After a bit of further testing I return with some contrition. Its a rather beautiful language, especially when we look into types and mutability.

However, I still come across bugs that are causing the sorts of mishaps that made the language difficult to figure out.

This is simple, and its elegant. The trouble I have at the moment stems from the “create” operation. The inputs aren’t showing as pins in my vvvv node so I can’t define how this node starts.

https://vvvv.org/sites/default/files/imagecache/large/images/Bugs.PNG

Its difficult to reproduce this problem. I’ll try again (of course it might be that the ‘Create’ operators shouldn’t show up anyway).

Yours,

Temple rubbing guest

you can create a ‘Reset’ or ‘SetPosition’ operation which does something similar to ‘Create’ and call that to set the fields from the outside.

but it seems that the way you were setting it up is that you directly started to patch in the vvvv node. for the above to work you need to create a new data type ‘Particle’ or so in your .vl document and instantiate that in the vvvv node.

if that does not sound appealing to you, you can do it the vvvv way and use your existing patch and put two SwitchInput nodes before your setters for ‘Velocity’ and ‘Position’ and have a bool input ‘Reset’ to switch to the new values…