I want my enemies in my donkey Kong game I'm making to move from left to right(right to left) and continue on a loop but i don't want them to say move off of a platform.
move(direction * speed);
if ((getX()-centerX)*direction >= range) {
direction = -direction;
// change or mirror image if needed
}