Gamestudio Links
Zorro Links
Newest Posts
Executing Trades on Next Bar Open
by vicknick. 06/13/24 08:51
Zorro Beta 2.61: PyTorch
by jcl. 06/10/24 14:42
New FXCM FIX Plugin
by flink. 06/04/24 07:30
AlpacaZorroPlugin v1.3.0 Released
by kzhao. 05/22/24 13:41
Free Live Data for Zorro with Paper Trading?
by AbrahamR. 05/18/24 13:28
AUM Magazine
Latest Screens
The Bible Game
A psychological thriller game
SHADOW (2014)
DEAD TASTE
Who's Online Now
1 registered members (henrybane), 1,246 guests, and 8 spiders.
Key: Admin, Global Mod, Mod
Newest Members
AemStones, LucasJoshua, Baklazhan, Hanky27, firatv
19059 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
ROTATING CAMERA (need help) #244016
01/02/09 07:25
01/02/09 07:25
Joined: Dec 2008
Posts: 13
N
noosence Offline OP
Newbie
noosence  Offline OP
Newbie
N

Joined: Dec 2008
Posts: 13

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);
}
}

Re: ROTATING CAMERA (need help) [Re: noosence] #244021
01/02/09 07:45
01/02/09 07:45
Joined: Aug 2008
Posts: 2,838
take me down to the paradise c...
Cowabanga Offline
Expert
Cowabanga  Offline
Expert

Joined: Aug 2008
Posts: 2,838
take me down to the paradise c...
First, If you want to show the mouse:
Code:
mouse_mode = 2; //not =1.


and for the space:
Code:
if (key_space) // not key_s; that's the "S" letter.
{
     c_move (my, vector(-20*time_step, 0, 0), nullvector, GLIDE);
     ent_animate(my,"run",walk_percentage, ANM_CYCLE);
     walk_percentage += 10 * time_step;
}


Re: ROTATING CAMERA (need help) [Re: Cowabanga] #244023
01/02/09 07:49
01/02/09 07:49
Joined: Dec 2008
Posts: 13
N
noosence Offline OP
Newbie
noosence  Offline OP
Newbie
N

Joined: Dec 2008
Posts: 13
im not having trouble with the movement of the player entity or the mouse showing up. i just need to know how to get the camera to stay behind the player entity and rotate along with the player entity's pan.

Re: ROTATING CAMERA (need help) [Re: noosence] #244028
01/02/09 08:15
01/02/09 08:15
Joined: Aug 2008
Posts: 2,838
take me down to the paradise c...
Cowabanga Offline
Expert
Cowabanga  Offline
Expert

Joined: Aug 2008
Posts: 2,838
take me down to the paradise c...
So you're doing everything right.
Anyway. What's you version??

Re: ROTATING CAMERA (need help) [Re: Cowabanga] #244030
01/02/09 08:22
01/02/09 08:22
Joined: Dec 2008
Posts: 13
N
noosence Offline OP
Newbie
noosence  Offline OP
Newbie
N

Joined: Dec 2008
Posts: 13
its just lite c idk what version im pretty sure its the newest one

but right now if i rotate the camera eventually the player is not on screen anymore

and i want it to stay at player.y right on his back

is there some sort of math function i could use to trace a circular path around the character and have the camera follow that path as player.pan increases in either direction with the camera rotating in the proper direction(ie left or right pan)

Re: ROTATING CAMERA (need help) [Re: noosence] #244080
01/02/09 14:51
01/02/09 14:51
Joined: Jul 2008
Posts: 1,178
England
M
MrGuest Offline
Serious User
MrGuest  Offline
Serious User
M

Joined: Jul 2008
Posts: 1,178
England
hey, try something like
Code:
	var camera_dist = 10;
	camera.x = player.x - (cos(camera.pan) * camera_dist);
	camera.y = player.y - (sin(camera.pan) * camera_dist);
	camera.z = player.z;



Moderated by  HeelX, Lukas, rayp, Rei_Ayanami, Superku, Tobias, TWO, VeT 

Gamestudio download | chip programmers | Zorro platform | shop | Data Protection Policy

oP group Germany GmbH | Birkenstr. 25-27 | 63549 Ronneburg / Germany | info (at) opgroup.de

Powered by UBB.threads™ PHP Forum Software 7.7.1