Gamestudio Links
Zorro Links
Newest Posts
Newbie Questions
by fairtrader. 12/05/23 14:22
Zorro Trader GPT
by TipmyPip. 12/04/23 11:34
Square root rule
by Smallz. 12/02/23 09:15
RTest not found error
by TipmyPip. 12/01/23 21:43
neural function for Python to [Train]
by TipmyPip. 12/01/23 14:47
Xor Memory Problem.
by TipmyPip. 11/28/23 14:23
Training with command line parameters
by TipmyPip. 11/26/23 08:42
Combine USD & BTC Pairs In Asset Loop
by TipmyPip. 11/26/23 08:30
AUM Magazine
Latest Screens
A psychological thriller game
SHADOW (2014)
DEAD TASTE
Tactics of World War I
Who's Online Now
3 registered members (TedMar, AndrewAMD, fairtrader), 578 guests, and 0 spiders.
Key: Admin, Global Mod, Mod
Newest Members
fairtrader, hus, Vurtis, Harry5, KelvinC
19019 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
Page 1 of 2 1 2
A smooth camera script? #125761
04/23/07 02:51
04/23/07 02:51
Joined: Mar 2007
Posts: 677
0x00000USA
M
MrCode Offline OP
User
MrCode  Offline OP
User
M

Joined: Mar 2007
Posts: 677
0x00000USA
I tried this "experiment" as a code to rotate the camera with the mouse:

Code:

function mouse_look()
{
while(1)
{
if (mouse_left== on)
{
camera.pan= pointer.x * -1 * time_step;
camera.tilt= pointer.y * -1 * time_step;
}
wait(1);
}
}




It works (kind of), but how would I go about making it smoother?

(And, it stops where the invisible cursor stops on the edges of the screen. Can I make it return to the other side somehow?)


Code:
void main()
{
    cout << "I am MrCode,";
    cout << "hear me roar!";
    system("PAUSE");
}
Re: A smooth camera script? [Re: MrCode] #125762
04/23/07 03:18
04/23/07 03:18
Joined: Mar 2007
Posts: 776
Poor village - Poland ;)
tompo Offline
User
tompo  Offline
User

Joined: Mar 2007
Posts: 776
Poor village - Poland ;)
to move camera countinous change camera.pan= to camera.pan+= pointer.x *0.1 *time_step;


Never say never.
Re: A smooth camera script? [Re: tompo] #125763
04/23/07 03:41
04/23/07 03:41
Joined: Mar 2007
Posts: 677
0x00000USA
M
MrCode Offline OP
User
MrCode  Offline OP
User
M

Joined: Mar 2007
Posts: 677
0x00000USA
Smoother, but still jerks. How do you make the invisible cursor "wrap" around the screen (like the spaceship does in Asteroids, but with the invisible cursor), so that the camera isn't fixed to a certain range?




Code:
void main()
{
    cout << "I am MrCode,";
    cout << "hear me roar!";
    system("PAUSE");
}
Re: A smooth camera script? [Re: MrCode] #125764
04/23/07 04:17
04/23/07 04:17
Joined: Mar 2007
Posts: 776
Poor village - Poland ;)
tompo Offline
User
tompo  Offline
User

Joined: Mar 2007
Posts: 776
Poor village - Poland ;)
in main function
Code:
 mouse_mode = 0; 



some vars
Code:
 var mous_hor; var mous_vert;var my_target[3]; 



in camera loop function
Code:
 
MOUSE_POS.X = POINTER.X; MOUSE_POS.Y = POINTER.Y;
mous_hor = (pointer.x - ((screen_size.x )/2)) *-0.01;
mous_vert = (pointer.y - ((screen_size.y )/2)) *-0.01;
temp.x = MOUSE_POS.x;
temp.y = MOUSE_POS.y;
temp.z = 100;
vec_for_screen(temp,CAMERA);
vec_set(my_target.x, temp);
vec_set(temp, my_target.x);
vec_sub(temp,camera.x);
vec_to_angle(camera.pan, temp);



Try something like this... but not tested...

Last edited by tompo; 04/23/07 04:18.

Never say never.
Re: A smooth camera script? [Re: tompo] #125765
04/23/07 04:26
04/23/07 04:26
Joined: Aug 2000
Posts: 7,490
O
Orange Brat Offline

Senior Expert
Orange Brat  Offline

Senior Expert
O

Joined: Aug 2000
Posts: 7,490
Code:

var mouseSensitivity = 15;
var mouseInvert = 1; //1 = normal, -1 = inverted

function mouse_look()
{
while(1)
{
if (mouse_left== on)
{
camera.pan -= mouse_force.x * mouseSensitivity * time_step;
camera.tilt += mouse_force.y * mouseSensitivity * mouseInvert * time_step;
}
wait(1);
}
}




My User Contributions master list - my initial post links are down but scroll down page to find list to active links
Re: A smooth camera script? [Re: Orange Brat] #125766
04/23/07 17:42
04/23/07 17:42
Joined: Mar 2007
Posts: 677
0x00000USA
M
MrCode Offline OP
User
MrCode  Offline OP
User
M

Joined: Mar 2007
Posts: 677
0x00000USA
Thx Orange Brat, it works great now.


Code:
void main()
{
    cout << "I am MrCode,";
    cout << "hear me roar!";
    system("PAUSE");
}
Re: A smooth camera script? [Re: MrCode] #125767
04/23/07 17:48
04/23/07 17:48
Joined: Aug 2000
Posts: 7,490
O
Orange Brat Offline

Senior Expert
Orange Brat  Offline

Senior Expert
O

Joined: Aug 2000
Posts: 7,490
No problem. You don't have to include that mouseInvert part, but I always include it for users who prefer it inverted. It's also good to use the generic mouseSensitivity instead of hardcoding it into the formula. You should always try and use generics. It will make it easier later on when you tie the code into an Options menu provided you allow the end user to change the mouse sensitivity to their preference. If you don't plan on that, you can go ahead and hard code it, but I think it's easier to change the var than to hunt for the formula and change it there in two different places.


My User Contributions master list - my initial post links are down but scroll down page to find list to active links
Re: A smooth camera script? [Re: Orange Brat] #125768
04/23/07 18:33
04/23/07 18:33
Joined: Mar 2007
Posts: 677
0x00000USA
M
MrCode Offline OP
User
MrCode  Offline OP
User
M

Joined: Mar 2007
Posts: 677
0x00000USA
Er, sorry to bother you guys again, but can I make the camera go forward (not along a single axis) with c_move? It keeps giving me fits about "Invalid argument in c_move"

Code:

if(mouse_right== on)
{
c_move (camera,vector(0,10 * time_step,0),nullvector,glide);
}




Code:
void main()
{
    cout << "I am MrCode,";
    cout << "hear me roar!";
    system("PAUSE");
}
Re: A smooth camera script? [Re: MrCode] #125769
04/23/07 18:42
04/23/07 18:42
Joined: Jan 2007
Posts: 1,619
Germany
Scorpion Offline
Serious User
Scorpion  Offline
Serious User

Joined: Jan 2007
Posts: 1,619
Germany
camera is no entity...u need a entity to move

Re: A smooth camera script? [Re: Scorpion] #125770
04/23/07 18:47
04/23/07 18:47
Joined: Mar 2007
Posts: 677
0x00000USA
M
MrCode Offline OP
User
MrCode  Offline OP
User
M

Joined: Mar 2007
Posts: 677
0x00000USA
How do you move the camera around then?

(I really hope you don't need a dummy model, because I can't seem to figure out the whole "Attach camera to entity" business)


Code:
void main()
{
    cout << "I am MrCode,";
    cout << "hear me roar!";
    system("PAUSE");
}
Page 1 of 2 1 2

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