Help with math and absolute-relative mouse coord

For questions about using Classic.

Post » Mon Nov 01, 2010 12:25 pm

I need mouse to be always in maximum 300px range (radius) from object. If distance between mouse and object is greater than 300px then it must be in 300px range, if distance is smaller then do nothing.
Help?
B
19
S
6
G
4
Posts: 171
Reputation: 2,507

Post » Mon Nov 01, 2010 2:53 pm

I solved this by first checking the distance between wherever and mousex/mousey using distance(whateverx, whatevery, mousex, mousey). If it's under 300, set position to mousex/mousey, if it's over 300, set position to the center of the circle and use 'move at angle' 300 pixels towards the mouse using angle(whateverx, whatevery, mousex, mousey)
Moderator
B
87
S
32
G
33
Posts: 3,005
Reputation: 27,397

Post » Mon Nov 01, 2010 4:15 pm

Does "move at angle" use timedelta?
Image Image
B
161
S
48
G
89
Posts: 7,347
Reputation: 66,249

Post » Mon Nov 01, 2010 5:38 pm

No, using move at angle>100 pixels at angle 0 is the same as doing set x to .x+100, so you'd need to move 100*timedelta pixels.
Moderator
B
87
S
32
G
33
Posts: 3,005
Reputation: 27,397

Post » Mon Nov 01, 2010 5:56 pm

It will then be towards mouse in range of 300. That's not what i need.
For ex. i'm moving mouse to the right side of the screen (any resolution, for ex. 1280) - the object will move towards it but only 300px. Then i move mouse to left on 200px - the object still 300px towards mouse pos.
What i need is when i move mouse from right side to left on 200px, the object should do the same - move at 200px. That's why i need to "jail" (?!) mouse in the range, not set object towards it.
B
19
S
6
G
4
Posts: 171
Reputation: 2,507

Post » Mon Nov 01, 2010 6:02 pm

I'm afraid I don't quite understand what you're trying to achieve. Are the "set mouse x/y" actions in mouse/keyboard object what you're looking for?
Moderator
B
87
S
32
G
33
Posts: 3,005
Reputation: 27,397

Post » Mon Nov 01, 2010 6:11 pm

I'm trying to implement Madness Interactive control scheme
http://www.newgrounds.com/portal/view/118826


+ System: distance(Body.X, Body.Y, MouseX, MouseY) Greater than 100
-> MouseKeyboard: Set mouse X to Window.ClientX + Body.X + ( 100 * sin( angle( Body.X, Body.Y, MouseX, MouseY ) ) )
-> MouseKeyboard: Set mouse Y to Window.ClientY + Body.X + ( 100 * cos( angle( Body.X, Body.Y, MouseX, MouseY ) ) )

and that not working correctly

Also why i need this scheme is that i have direct control of hand with weapon and no crosshair at all

ADDED:
Arima sorry i tried your solution without proper understanding, solved but partially - movement seems too jaggy.
B
19
S
6
G
4
Posts: 171
Reputation: 2,507


Return to Help & Support using Construct Classic

Who is online

Users browsing this forum: No registered users and 0 guests