![]() |
getdir(float, float);
I am making a Joystick and am having problems with getdir.
Basically I have this. PHP Code:
Joystick_Pointer is a small dot at the cursor. Is there something I am doing wrong? |
Getdir works off of delta's, but you're not doing a very good job describing what's not actually working.
|
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); |
It now works, but only for the directions 2 and 3....
|
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.
|
Quote:
PHP Code:
PHP Code:
|
Oh bodmas..... Completly forgot about that.
Darn you high school, why didn't you make me pay attention! |
Quote:
|
| 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.