Gamestudio Links
Zorro Links
Newest Posts
loading historical data 1st time
by AndrewAMD. 04/14/23 12:54
Trade at bar open
by juanex. 04/13/23 19:43
Bug in Highpass2 filter
by rki. 04/13/23 09:54
Adding Limit Orders For IB
by scatters. 04/11/23 16:16
FisherN
by rki. 04/11/23 08:38
AUM Magazine
Latest Screens
SHADOW (2014)
DEAD TASTE
Tactics of World War I
Hecknex World
Who's Online Now
0 registered members (), 1,012 guests, and 8 spiders.
Key: Admin, Global Mod, Mod
Newest Members
rki, FranzIII, indonesiae, The_Judge, storrealba
18919 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
mouse_pos3d #406105
08/13/12 21:19
08/13/12 21:19
Joined: Dec 2009
Posts: 361
R
rtsgamer706 Offline OP
Senior Member
rtsgamer706  Offline OP
Senior Member
R

Joined: Dec 2009
Posts: 361
I am making a game where an arrow is supposed to point towards the mouse pointer.
I am using the following lines in a while loop:
Code:
vec_to_angle (my.pan,mouse_pos3d);
my.tilt = 0;


the issue is that if the arrow moves it still rotates as if it's in the centre of the screen.
so it's not pointing at the mouse pointer any more.
does anyone know how to make the rotation move with it?
thanks
rtsgamer706

Re: mouse_pos3d [Re: rtsgamer706] #406136
08/14/12 10:52
08/14/12 10:52
Joined: Dec 2011
Posts: 1,823
Netherlands
Reconnoiter Offline
Serious User
Reconnoiter  Offline
Serious User

Joined: Dec 2011
Posts: 1,823
Netherlands
I use this code for letting the player watch mouse_pointer, should do the trick for your arrow:

Code:
VECTOR to;
VECTOR temp_dir;
ANGLE offset_angle;	
...
...
vec_set(to, mouse_dir3d);
vec_normalize(to, 500);
vec_add(to, mouse_pos3d);
vec_diff(temp_dir, to, my.x);
vec_to_angle(offset_angle, temp_dir);
my.pan += ang(offset_angle.pan - my.pan) * 0.2 * time_step; // smooth rotation code




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