Ok, never seen that tag
here a code for a classical RTS camera
with static ISO view and smoothed zooming
Code:
//a simple RTS like ISO camera, like in Warcraft3, without turning the camera.pan
//movement of the camera with cursorkeys, and touching the side of the screen
//zooming with the mouseweel
function tools_camera_RTS_1()
{
var tools_movespeed=50; //movespeed of the camera
var tools_lowest_cam_z=0; //range of the camera for zooming
var tools_highest_cam_z=800;
var tools_zoomhight=600;
var tools_zoomspeed=.6; //value between .99 and .01
var tools_timed_fraction;
var high_tilt=-60; //standard tile of the camera (should be a negative number between -90 and 0)
var low_tilt=-30; //tilt when reching a low position
var tilt_switch_hight=500; //hight when to switch to lower tilt of camera
var tilt_diff;tilt_diff=tilt_switch_hight-tools_lowest_cam_z;
camera.z+=tools_zoomhight; //hight of the camera above ground
camera.pan=90; //to have the same view as in WED
camera.tilt=high_tilt; //ISO looking down
while(1)
{
//re-position camera according to inputdata form mouse-pointer or cursor-keys
if((key_cur)||(mouse_cursor.x>screen_size.x-2)){camera.x+=tools_movespeed*time;}
if((key_cul)||(mouse_cursor.x<2)){camera.x-=tools_movespeed*time;}
if((key_cuu)||(mouse_cursor.y<2)){camera.y+=tools_movespeed*time;}
if((key_cud)||(mouse_cursor.y>screen_size.y-2)){camera.y-=tools_movespeed*time;}
tools_timed_fraction=tools_zoomspeed*time;
tools_zoomhight+=mickey.z*.5;
tools_zoomhight=min(max(tools_lowest_cam_z,tools_zoomhight),tools_highest_cam_z);
camera.z=camera.z*(1-tools_timed_fraction)+tools_zoomhight*tools_timed_fraction;
camera.z=min(max(tools_lowest_cam_z,camera.z),tools_highest_cam_z);
if(camera.z>tilt_switch_hight){camera.tilt=high_tilt;} //use standard tilt above tilt_switch_hight
else{camera.tilt=high_tilt-(((tilt_switch_hight-camera.z)/tilt_diff)*(high_tilt-low_tilt));} //calculate a tilt depending on hight od camera
wait(1);
}
}