Hey, I want an action to happen only once on MousePressed but I don't want to use void mousePressed() because I want the object (a 3d camera controller) to be more modular so that I can easily re-use it. Is their any way to force an action to only execute once in the if statement? If their is no other way it would be okay for me to just have a void mousePressed() function needed in my main tab although I would prefer the alternative. Thanks for any help!
EDIT: Some extra info just so you know why I really want this to be more modular: I need to get the mouse coordinates right when the mouse goes down so that I can find the difference in position from when it first went down till the present and then stop updating after the mouse is released.
EDIT: EDIT: I'm going to try to use radial velocity to only use the delta in mouse position per frame so that I can cheat out of needing the original position although I would still like to do it the other way if possible.
(The controls, algorithm, etc. are in the description there so I don't see a need to paste it here)
I thought you guys might be interested in this kind of thing (particles YAY :D) and also maybe you guys could offer up some optimizations I could make because it is a bit too slow for my liking. Thanks in advance for any comments or criticisms!
vPoint(float fx, float fy){ // fx is first x and ditto for y
x = fx;
y = fy;
x = oldx = x;
y = oldy = y;
}
void update(){
float tempx = x;
float tempy = y;
x+= x - oldx;
y+= y - oldy;
oldx = tempx;
oldy = tempy;
}
void render(){
stroke(255);
line(x,y,oldx,oldy);
}
}
It is a verlet physics engine and i know the vPoint class is fine because i tested it. I just messed up the Controller class I think can someone help me out cause this error is killing me. I know there may be some unrelated errors in my code but i can't even check them till i fix this darn error. BTW no arrays yet because it's faster to test on on point for now.
As you can see there is no collision checking implemented as of now but I would like to get some help on how I would check that i'm not doing collision calculations on a particle to it's self. How do I check this in an array? Also any help/tips relating to springy collisions would be appreciated as i'm planning to make a pseudo fluid with repulsion and attraction forces.
Thanks!
edit: btw "oloc" was going to be old location but i didn't need that for what i was doing.