Particle program not detecting mousepress


Hello, I’m trying to implement functionality that makes the particles move away from the mouse when the mouse is pressed. I’ve added the following function directly after the keyPressed() function in the main sketch:

void mousePressed() 
    mouseLoc = ofPoint(ofGetMouseX(), ofGetMouseY(), 0);
    for (std::size_t i = 0; i < particles.size(); i++)
        ofPoint dir = mouseLoc - particles[i].position;
        particles[i].acceleration = dir;
    cout << "mousePressed" << endl;

I’m trying to check it with the cout but that’s not returning anything the console so I don’t think it’s detecting the mousepress. Can someone help me identify what I’m doing wrong?


Think maybe you need to use void mousePressed(int x, int y, int button) {…}


You’re right – thanks for pointing that out to me. Definitely still retaining some tendencies from Processing.