Use an int field to track the current direction ( '1' for moving down and '-1' for moving up). The field can be multiplied by the speed and added to the current y-coordinate to get the new y-coordinate of the actor. If an edge is encountered, multiply the field by '-1' to change its direction of motion.