Posted By: Xarthor
[FREE] My contribution thread - 01/08/09 20:21
Hi,
so I decided to revamp my blog (link further down + in sig) and open up a thread here where I'll post about contributions that I'll make.
Here is my first:
I wrote a little camera control snippet (you can also find it in Starting with Gamestudio).
It rotates the camera around a specific position and keeps it at a certain distance. Meanwhile the camera always faces this position.
Here my blog article:
http://xarthor.wordpress.com/2009/01/08/lite-c-camera-movement-1/
My blog:
http://xarthor.wordpress.com
And finaly the snippet:
Thanks for reading.
so I decided to revamp my blog (link further down + in sig) and open up a thread here where I'll post about contributions that I'll make.
Here is my first:
I wrote a little camera control snippet (you can also find it in Starting with Gamestudio).
It rotates the camera around a specific position and keeps it at a certain distance. Meanwhile the camera always faces this position.
Here my blog article:
http://xarthor.wordpress.com/2009/01/08/lite-c-camera-movement-1/
My blog:
http://xarthor.wordpress.com
And finaly the snippet:
Code:
VECTOR* cam_center = { x=0; y=0; z=0; } VECTOR* cam_temp = { x=0; y=0; z=0; } var cam_radius = 100; var cam_angle = 0; var cam_speed[2] = { 8, 5 }; // [0]: rotation speed, [1]: speed for changing height function control_Camera() { while(1) { camera.z += cam_speed[1] * (key_cuu - key_cud) * time_step; cam_angle += cam_speed[0] * (key_cur - key_cul) * time_step; cam_angle = ang(cam_angle); camera.x = cam_center.x + cam_radius * sin(cam_angle); camera.y = cam_center.y + cam_radius * cos(cam_angle); vec_set(cam_temp,cam_center); vec_sub(cam_temp,camera.x); vec_to_angle(camera.pan,cam_temp); wait(1); } }
Thanks for reading.