Hi!
I have one problem with my camera in 2D game, my camera look like this: http://www.coubetech.republika.pl/test/main.html camera tarack one obiect but camera can move only when is near game border, and i don't know how i can calculate camera position something obiect allowing of this game border. Now i try do this that:
var value = pos_obj.x - widthGame / 2;
if (value < 0) value = 0;
if (value > widthGame / 2) value = widthGame / 2;
But it's dosen't work very good;
My camera code:
var border = 150;
if (g_CameraX > pos_obj.x - border) g_CameraX = pos_obj.x - border;
if (g_CameraX < pos_obj.x + border - 640) g_CameraX = pos_obj.x + border - 640;
if (g_CameraX < 0) g_CameraX = 0;
if (g_CameraX > 1100 - 640) g_CameraX = 1100 - 640;