Graal Forums

Graal Forums (https://forums.graalonline.com/forums/index.php)
-   NPC Scripting (https://forums.graalonline.com/forums/forumdisplay.php?f=8)
-   -   getdir(float, float); (https://forums.graalonline.com/forums/showthread.php?t=134265564)

Gunderak 01-13-2012 07:34 AM

getdir(float, float);
 
I am making a Joystick and am having problems with getdir.
Basically I have this.
PHP Code:

player.dir getdir(Joystick_Controller.35 Joystick_Pointer.10Joystick_Controller.35 Joystick_Pointer.10); 

Joystick_Controller is the joystick background/container.
Joystick_Pointer is a small dot at the cursor.
Is there something I am doing wrong?

DustyPorViva 01-13-2012 07:39 AM

Getdir works off of delta's, but you're not doing a very good job describing what's not actually working.

fowlplay4 01-13-2012 07:40 AM

You have it backwards by the looks of it, switch Controller with Pointer and the modifications you add/subtract.

Here's an example of you can get your direction based on the target (or mouse), and your point of reference (yourself).

I.e: player.dir = getdir(target.x - player.x, target.y - player.y);

Gunderak 01-13-2012 07:56 AM

It now works, but only for the directions 2 and 3....

Skyld 01-13-2012 11:40 AM

Not entirely sure if you need to consider this for the purposes of what you are doing, but you might need to deal with player.x + 1.5 and player.y + 2 to get references from the centre-point of the player, not the top-left corner.

Tolnaftate2004 01-13-2012 07:14 PM

Quote:

Originally Posted by Gunderak (Post 1681612)
It now works, but only for the directions 2 and 3....

Watch your +s and -s

PHP Code:

player.dir getdir((Joystick_Pointer.10) - (Joystick_Controller.35), (Joystick_Pointer.10) - (Joystick_Controller.35)); 

is not the same as

PHP Code:

player.dir getdir(Joystick_Pointer.10 Joystick_Controller.35Joystick_Pointer.10 Joystick_Controller.35); 

is not the same as what you have in the OP.

Gunderak 01-14-2012 12:22 PM

Oh bodmas..... Completly forgot about that.
Darn you high school, why didn't you make me pay attention!

Crow 01-14-2012 04:08 PM

Quote:

Originally Posted by Gunderak (Post 1681654)
Oh bodmas..... Completly forgot about that.
Darn you high school, why didn't you make me pay attention!

:oo:


All times are GMT +2. The time now is 01:59 AM.

Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2026, vBulletin Solutions Inc.
Copyright (C) 1998-2019 Toonslab All Rights Reserved.