if(this.x > otherobject.x){
this.x +/-= set speed;
}
Then repeat for y, although that will get collisions so then maybe use the distance formulae for the other objects, so that if they are within x distance, their speed changes. Or if they do touch, they stop.
Quote from SteyeneYou could just have a function that is called by each of those objects, then in the function have the movement controls.
Edit:
Misread.
Just have then
if(this.x > otherobject.x){
this.x +/-= set speed;
}
Then repeat for y, although that will get collisions so then maybe use the distance formulae for the other objects, so that if they are within x distance, their speed changes. Or if they do touch, they stop.