def bound_position(Xmin, Xmax, Ymin, Ymax, x, y, constant): v = PVector(0, 0) if x <= Xmin: v.x = constant elif x >= Xmax: v.x = -constant if y <= Ymin: v.y = constant elif y >= Ymax: v.y = -constant return v.return_as_vector()
def stay_in_border(position): v = PVector(0, 0) Xmin = 13 Xmax = 13 Ymin = 13 Ymax = 13 constant = 100 if position.x <= Xmin: v.x = constant elif position.x >= Xmax: v.x = -constant if position.y <= Ymin: v.y = constant elif position.y >= Ymax: v.y = -constant return v.return_as_vector()