okay im working on a little camera program. i know its sloppy and probably not the bjavascript:%20void(0)est written, but i just need a litle help.
i have everything pretty much how i want it except that i want to make the mouse control the player pan and turn the camera, but i dont want to just pan the camera, i want it to stay behind the character as he pans, just a simple 3rd person camera style. but idk what im doing wrong, if you think you can help me out it would be much appreciated.
heres the code so far...
function main()
{
video_screen = 1;
video_mode = 7;
level_load ("work21.wmb");
wait (2); // wait until the level is loaded
player.pan =0;
mouse_mode = 1; // show the mouse pointer
mouse_map = cursor_pcx; // set the mouse pointer bitmap
camera.z = 150; // choose a convenient height
camera.tilt =-20; // and tilt angle for the camera
while (1)
{
mouse_pos.x = mouse_cursor.x; // allow the mouse pointer to move
mouse_pos.y = mouse_cursor.y; // on the x and y axis
camera.pan -= mouse_force.x;
camera.tilt += mouse_force.y;
wait (1);
}
}
action walking_guard()
{
player = me;
while (1)
{
// move the car using relative_speed
if (key_a)
{
c_move (my, vector(0,20*time_step,0), nullvector, GLIDE);
ent_animate(my,"run",walk_percentage, ANM_CYCLE);
walk_percentage += 10 * time_step;
}
if (key_d)
{
c_move (my, vector(0,-20*time_step,0), nullvector, GLIDE);
ent_animate(my,"run",walk_percentage, ANM_CYCLE);
walk_percentage += 10 * time_step;
}
if (key_w ) // press and hold the "Space" key to move the car
{
c_move (my, vector(20*time_step, 0, 0), nullvector, GLIDE);
ent_animate(my,"run",walk_percentage, ANM_CYCLE);
walk_percentage += 10 * time_step;
}
if (key_s ) // press and hold the "Space" key to move the car
{
c_move (my, vector(-20*time_step, 0, 0), nullvector, GLIDE);
ent_animate(my,"run",walk_percentage, ANM_CYCLE);
walk_percentage += 10 * time_step;
}
camera.x = player.x -125;
camera.y = player.y;
wait (1);
}
}