Example #1
0
//--------------------------------------------------------------
void ofApp::update(){
    float mx = ofGetMouseX() - ofGetWindowWidth() / 2;
    float my = -(ofGetMouseY() - ofGetWindowHeight() / 2);

    lights.setPosition(cos(ofGetElapsedTimef() * 10.0f) * 150.0f, 0, sin(ofGetElapsedTimef() * 10.0f) * 150.0f);

    for (int it = 0; it < iterxy; it++) {
        if (cy < rect.getHeight() * 2) {
            if (cx < rect.getWidth()) {
                for (int i = 0; i < polys.size(); i++) {
                    float tx = cx - rect.getWidth() / 2;
                    float ty = cy - (rect.getHeight() * 2) / 2;

                    if (polys[i].inside(tx, ty)) {
                        whips.push_back(whip(tx, ty, 0, 10, 10));
                        break;
                    }
                }
                cx += u;
            } else {
                cy += u;
                cx = -u / 2 * ((cy / u) % 2);
            }
        } else break;
    }

    for (int i = 0; i < whips.size(); i++) {
        float wmd = ofDist(mx, my, whips[i].x, whips[i].y);
        if (wmd < 100.0f) {
            float ga = atan2(whips[i].y - my, whips[i].x - mx) * 180.0f / PI;
            ga += ga > whips[i].r.z ? 0 : 360.0f;
            whips[i].r.z += (ga - whips[i].r.z) / 10.0f;
            whips[i].r.z = fmodf(whips[i].r.z, 360.0f);
        } else {
            whips[i].r.z -= whips[i].r.z / 10.0f;
        }

        float gry = 10.0f * (wmd < 100.0f ? (100.0f - wmd) : 0) / 100.0f;
        whips[i].gr = ofVec3f(0, gry, 0);
    }
}
Example #2
0
void spritz::cipher::shuffle() {
  whip(512); crush();
  whip(512); crush();
  whip(512);
  a = 0;
}