plataform

Posted By: Funeral

plataform - 02/17/10 01:14

in a plataform game, when i rotate the camera it moves and i cant see the player anymore, so i wanna know if there's a simple code to keep the player in the center of the scene all the time and the camera rotates around him.
Posted By: Superku

Re: plataform - 02/17/10 01:24

I'm not quite sure if I understand what you're trying to do, but nevertheless:

function center_camera_startup() {
var distance, angle;
VECTOR temp;
distance = 500;
angle = 0;
while(1) {
if(player) {
camera.x = player.x-distance*cos(angle);
camera.y = player.y-distance*sin(angle);
camera.z = player.z+64;

vec_set(temp,player.x);
vec_sub(temp,camera.x);
vec_to_angle(camera.pan,temp);

angle += (key_1-key_2)*10*time_step;
angle %= 360;
}
wait(1);
}
}
© 2023 lite-C Forums