Quantcast
Channel: openFrameworks - Latest posts
Viewing all articles
Browse latest Browse all 40524

Vector init and for loop in C++11

$
0
0

there's not a very specific syntax in c++ for that, ust create a variable and increment it with each iteration:

auto i = 0;
for ( auto & p : particles) {
    float x0 = i * p.x;
    float y0 = i * p.y;
    float x = ofGetWidth() * ofNoise(time * speed + x0);
    float y = ofGetHeight() * ofNoise(time * speed + y0);
    p.update(x, y);
    i++;
}

Viewing all articles
Browse latest Browse all 40524

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>