int Left=<your left most x coordinate value here>;
int Top=<your up most y coordinate value here>;
int Right=<your right most x coordinate value here>;
int Bottom=<your bottom most y coordinate value here>;
x=max(Left,min(x,Right-width)); //limit the x movement
y=max(Top,min(y,Bottom-height)); //limit the y movement
Users browsing this forum: No registered users and 1 guest