Two Simple Problems Regarding Expanding on the "Getting Started" Tutorial

Hi, I am just getting started with OF. I decided to expand on the “Getting Started” tutorial by making an array of circles and having one of them change color when my mouse is over that circle. I’m having two super newb problems right now. First, I want 5 circles to be evenly distributed along the y-axis. But I’m only getting one at the top and one at the bottom. I have made sure I’m using correct data types. Also, when my mouse is over one circle, it changes the color for all of the circles instead of just one circle. Here’s my setup code:

#define NUM_OF_PART 5

void ofApp::setup(){


myParticle = new ofMyParticle*[NUM_OF_PART];
for (int i = 0; i < NUM_OF_PART; i++){
    float y_coord_fract = (i*NUM_OF_PART)/(NUM_OF_PART);
    myParticle[i] = new ofMyParticle(512, y_coord_fract*768, 20, 0, 0, false);

Here is my mouseMoved code:

void ofApp::mouseMoved(int x, int y){

for (int i=0; i < NUM_OF_PART; i++){
    if(ofDist(myParticle[i]->particleX, myParticle[i]->particleY, x, y)<myParticle[i]->radius){
        myParticle[i]->colorChange = true;
        myParticle[i]->colorChange = false;


And lastly my colorChange code:

void ofMyParticle::draw(){

if (colorChange == true){
    ofSetColor(ofRandom(255), ofRandom(255), ofRandom(255));

ofCircle(particleX, particleY, radius);


Not sure why all the circles would be changing color, and why during my setup the circle aren’t evenly distributed along the y-axis of the sceen as opposed to only being at the top and bottom. Thanks for any help! Any debugging tips would also be appreciated :smiley:

To distribute your particles evenly you may want to try something like…

int ystore = 0;

void draw(){ 

    for (int i = 0; i < NUM_OF_PART; i++){
          int yincrement = ofGetHeight() / NUM_OF_PART;
          int movetoy = ystore + yincrement;
          myParticle[i] = new ofMyParticle(512, movetoy, 20, 0);
          ystore += yincrement;